How vietdocmemory/doc-to-atom works
Doc-to-Atom is an audit-first reproduction that turns documents into structured memory atoms, builds a compiled memory bank offline, then answers queries by routing over that bank and injecting composed adapters into a frozen language model. Its separate training path assembles the model, optimizes its components, and records checkpoints and metrics. The graph follows the README’s documented workflow and sampled source references; some subsystem links are documented at a high level because their implementation excerpts were not provided.
Main entry points: query.py Query inference · factory.py System factory · client.py Annotation client · loop.py Training loop
Components 28
Data and annotation
- Atomization CLI
src/doc_to_atom/atomization/cli.py - Annotation client
src/doc_to_atom/atomization/client.py - Annotation prompts
src/doc_to_atom/atomization/prompts.py - XML parser
src/doc_to_atom/atomization/parser.py - Atom records
src/doc_to_atom/atomization/models.py - Record validation
src/doc_to_atom/atomization/validation.py - Dataset preparation
src/doc_to_atom/data/prepare.py - JSONL records
src/doc_to_atom/data/io.py - Semantic audit
src/doc_to_atom/data/semantic_validation.py
Memory construction
- Offline memory build
src/doc_to_atom/inference/build_memory.py - Shared encoder
src/doc_to_atom/encoder/shared.py - Atom compiler
src/doc_to_atom/compiler/model.py - Memory bank
src/doc_to_atom/compiler/memory.py
Query and response
- Query inference
src/doc_to_atom/inference/query.py - Two-stage router
src/doc_to_atom/router/model.py - Frozen BGE reranker
src/doc_to_atom/router/reranker.py - Memory composer
src/doc_to_atom/composer/model.py - Micro-LoRA injection
src/doc_to_atom/injection/lora.py
Training
- System factory
src/doc_to_atom/training/factory.py - Training loop
src/doc_to_atom/training/loop.py - Training objectives
src/doc_to_atom/losses/objectives.py - Checkpoints
src/doc_to_atom/training/checkpoint.py
Evaluation
- Metrics and baselines
src/doc_to_atom/evaluation/metrics.py - Run logging
src/doc_to_atom/evaluation/logging.py
Other components
- Document provider
- Annotation provider
- Query user
- Frozen language model
Connections 38
- Document provider → Atomization CLI: submits documents
README.md - Atomization CLI → Annotation client: requests annotation
src/doc_to_atom/atomization/cli.py - Annotation client → Annotation prompts: uses prompts
src/doc_to_atom/atomization/client.py - Annotation client → Annotation provider: calls provider
README.md - Annotation client → XML parser: parses response
src/doc_to_atom/atomization/client.py - XML parser → Atom records: creates records
src/doc_to_atom/atomization/parser.py - Annotation client → Record validation: validates output
src/doc_to_atom/atomization/client.py - Dataset preparation → JSONL records: writes records
- Atomization CLI → JSONL records: writes atoms
- JSONL records → Atom records: loads records
src/doc_to_atom/data/io.py - Semantic audit → JSONL records: reads records
src/doc_to_atom/data/semantic_validation.py - Atom records → Offline memory build: provides atoms
README.md - Offline memory build → Shared encoder: encodes atoms
src/doc_to_atom/inference/build_memory.py - Offline memory build → Atom compiler: compiles atoms
src/doc_to_atom/inference/build_memory.py - Atom compiler → Memory bank: produces compiled memory
src/doc_to_atom/compiler/model.py - Offline memory build → Memory bank: builds bank
src/doc_to_atom/inference/build_memory.py - Query user → Query inference: submits query
README.md - Query inference → Shared encoder: encodes query
README.md - Query inference → Two-stage router: routes query
src/doc_to_atom/inference/query.py - Query inference → Memory bank: reads bank
src/doc_to_atom/inference/query.py - Two-stage router → Frozen BGE reranker: reranks candidates
src/doc_to_atom/router/model.py - Query inference → Memory composer: composes selection
src/doc_to_atom/inference/query.py - Memory composer → Memory bank: reads selected atoms
src/doc_to_atom/composer/model.py - Query inference → Micro-LoRA injection: injects adapters
src/doc_to_atom/inference/query.py - Micro-LoRA injection → Frozen language model: adapts forward pass
src/doc_to_atom/injection/lora.py - Query inference → Frozen language model: generates response
README.md - System factory → Shared encoder: assembles encoder
src/doc_to_atom/training/factory.py - System factory → Atom compiler: assembles compiler
src/doc_to_atom/training/factory.py - System factory → Two-stage router: assembles router
src/doc_to_atom/training/factory.py - System factory → Memory composer: assembles composer
src/doc_to_atom/training/factory.py - System factory → Micro-LoRA injection: assembles injector
src/doc_to_atom/training/factory.py - System factory → Frozen language model: loads base model
src/doc_to_atom/training/factory.py - Training loop → Training objectives: computes losses
src/doc_to_atom/training/loop.py - Training loop → Checkpoints: saves state
src/doc_to_atom/training/loop.py - Training loop → Run logging: records progress
src/doc_to_atom/training/loop.py - Training loop → System factory: uses system
- Metrics and baselines → Query inference: evaluates predictions
- Metrics and baselines → Run logging: reports metrics