How vinsongqj/42_rag_against_the_machine works
RAG against the machine ingests a corpus, chunks and indexes it, retrieves ranked source locations, and can generate grounded answers or evaluate retrieval recall. Users initiate work through the CLI or optional HTTP API; search supports BM25, semantic, and hybrid retrieval, with query caching. The graph preserves separate ingestion, chunking, indexing, ranking, generation, and evaluation stages. Edges reflect README workflows and shown calls/import references; several CLI and batch details are documented but their implementations were not fully sampled.
Main entry points: retrieve.py Source retrieval · __main__.py CLI commands · api.py HTTP API · index.py Index builder
Components 18
User entry points
- CLI commands
src/__main__.py - HTTP API
src/api.py
Corpus indexing
- File ingestion
src/ingest.py - Chunking
src/chunk.py - Index builder
src/index.py - BM25 index
src/index.py - Semantic index
src/semantic.py
Retrieval and ranking
- Source retrieval
src/retrieve.py - Search ranking
src/rank.py - Query cache
src/cache.py - Index versioning
src/version.py
Answer and evaluation
- Answer generation
src/generate.py - Recall evaluation
src/evaluate.py - Data models
src/models.py
Other components
- CLI user
- HTTP client
- Corpus files
- Ollama model
Connections 24
- CLI user → CLI commands: runs commands
README.md - HTTP client → HTTP API: sends requests
README.md - Corpus files → File ingestion: provides files
src/ingest.py - CLI commands → Index builder: builds indexes
src/__main__.py - Index builder → File ingestion: ingests corpus
src/index.py - File ingestion → Chunking: chunks files
src/ingest.py - Index builder → BM25 index: writes index
src/index.py - Index builder → Semantic index: optionally builds
src/index.py - Semantic index → Semantic index: persists vectors
src/semantic.py - CLI commands → Source retrieval: runs search
README.md - Source retrieval → BM25 index: loads index
src/retrieve.py - Source retrieval → Search ranking: dispatches search
src/retrieve.py - Search ranking → Semantic index: searches vectors
src/rank.py - Source retrieval → Query cache: reads and writes
src/retrieve.py - Source retrieval → Index versioning: checks versions
src/retrieve.py - CLI commands → Answer generation: generates answers
README.md - Answer generation → Ollama model: requests generation
src/generate.py - CLI commands → Recall evaluation: evaluates results
README.md - HTTP API → Source retrieval: retrieves sources
src/api.py - HTTP API → Answer generation: generates answers
src/api.py - CLI commands → HTTP API: starts server
src/__main__.py - File ingestion → Data models: creates chunks
src/ingest.py - Source retrieval → Data models: returns sources
src/retrieve.py - HTTP API → Data models: uses schemas
src/api.py