How gefolgwar/rag_42ber works
RAG Against the Machine indexes a vLLM corpus, retrieves relevant code or documentation spans, and can generate grounded answers or score retrieval quality. The main flow is corpus scan → chunk → lexical/dense index → retrieval → source-span resolution and answer generation; CLI commands and a FastAPI API expose it. Dataset evaluation is a separate capability. Edges use the supplied excerpts, SOURCE INDEX references, or README; unsampled wiring is not inferred.
Main entry points: retrieval.py Retrieval Service · index_cmd.py Index Command · cli.py CLI Dispatcher · eval_cmd.py Evaluation Command
Components 25
Ingestion and Chunking
- Corpus Ingestion
src/ingest.py - File Filtering
src/file_filter.py - Chunking Facade
src/chunking.py - Python AST Chunks
src/chunk_python.py - Markdown Chunks
src/chunk_markdown.py - Window Splitting
src/chunk_window.py - Chunk Spans
src/chunk_types.py
Search Indexes
- Incremental Hashes
src/hash.py - BM25 Knowledge Base
src/index.py - Query Tokenizer
src/tokenizer.py - Dense and RRF Search
src/dense.py
Retrieval and Sources
- Retrieval Service
src/retrieval.py - Query Cache
src/cache.py - Request and Result Models
src/models.py
User Interfaces
- CLI Dispatcher
src/cli.py - HTTP API
api/app.py - Index Command
src/commands/index_cmd.py - Search Command
src/commands/search_cmd.py - Answer Command
src/commands/answer_cmd.py - Evaluation Command
src/commands/eval_cmd.py
Answers and Evaluation
- Grounded Generator
src/generator.py - Recall Evaluator
src/evaluator.py
Other components
- User
- vLLM Corpus
- Question Dataset
Connections 34
- User → CLI Dispatcher: runs commands
README.md - User → HTTP API: sends requests
README.md - CLI Dispatcher → Index Command: dispatches
src/cli.py - CLI Dispatcher → Search Command: dispatches
src/cli.py - CLI Dispatcher → Answer Command: dispatches
src/cli.py - CLI Dispatcher → Evaluation Command: dispatches
src/cli.py - vLLM Corpus → Corpus Ingestion: provides files
README.md - Index Command → Corpus Ingestion: collects files
src/commands/index_cmd.py - Corpus Ingestion → File Filtering: filters paths
src/ingest.py - Index Command → Chunking Facade: chunks files
src/commands/index_cmd.py - Chunking Facade → Python AST Chunks: routes Python
src/chunking.py - Chunking Facade → Markdown Chunks: routes documents
src/chunking.py - Python AST Chunks → Window Splitting: splits oversized spans
src/chunk_python.py - Markdown Chunks → Window Splitting: splits oversized spans
src/chunk_markdown.py - Chunking Facade → Chunk Spans: returns spans
src/chunking.py - Index Command → Incremental Hashes: checks changes
src/commands/index_cmd.py - Index Command → BM25 Knowledge Base: builds and saves
src/commands/index_cmd.py - BM25 Knowledge Base → Query Tokenizer: tokenizes text
src/index.py - Index Command → Dense and RRF Search: optionally builds
src/commands/index_cmd.py - Search Command → Retrieval Service: searches cached
src/commands/search_cmd.py - Answer Command → Retrieval Service: loads and searches
src/commands/answer_cmd.py - HTTP API → Retrieval Service: routes search
api/app.py - Retrieval Service → BM25 Knowledge Base: runs lexical search
src/retrieval.py - Retrieval Service → Query Cache: checks and stores
src/retrieval.py - Retrieval Service → Dense and RRF Search: optionally fuses results
src/retrieval.py - Retrieval Service → File Filtering: filters result types
- Retrieval Service → Request and Result Models: creates source spans
src/retrieval.py - Answer Command → Grounded Generator: generates answers
src/commands/answer_cmd.py - HTTP API → Grounded Generator: routes answers
api/app.py - Answer Command → Retrieval Service: resolves source chunks
src/commands/answer_cmd.py - Question Dataset → Evaluation Command: supplies questions
README.md - Evaluation Command → Retrieval Service: loads search results
src/commands/eval_cmd.py - Evaluation Command → Recall Evaluator: scores recall
src/commands/eval_cmd.py - Evaluation Command → Request and Result Models: validates data
src/commands/eval_cmd.py