How kalvium23/sw81_autorag_champs works
Purpose and Entry Points
This is a Python retrieval-augmented generation (RAG) pipeline repository. It ingests source documents, prepares searchable chunks, indexes them for hybrid retrieval, and sends retrieved context to an LLM. There is no declared application CLI or service entry point in the supplied README; the callable boundaries are the package modules under src/.
1. Document Ingestion Pipeline
The ingestion layer converts raw files into validated, cleaned, and chunked content suitable for indexing. Its stages are separated so input handling and content normalization can evolve independently.
• src/ingestion/loaders.py
• src/ingestion/validator.py
• src/ingestion/cleaner.py
• src/ingestion/chunker.py
Primary flow: source material from data/ → loader → validation → cleaning → chunking → retrieval/indexing layer.
2. Retrieval Corpus Boundary
data/ is the raw-document boundary, while outputs/ is the intended boundary for generated artifacts or run results. The repository keeps these directories present but does not commit their contents.
• data/.gitkeep
• outputs/.gitkeep
• src/ingestion/__init__.py
This separation implies ingestion should not depend on generated RAG responses, and retrieval/index artifacts should be treated independently from source inputs.
3. Embedding and Vector Indexing
The retrieval subsystem turns document chunks into vector representations and persists or accesses them through a vector-store abstraction.
• src/retrieval/embedder.py
• src/retrieval/vector_store.py
• src/retrieval/__init__.py
The key boundary is between embedding generation and storage/query mechanics: callers should pass normalized chunks and metadata into this layer rather than coupling ingestion directly to a specific vector database implementation.
4. Hybrid Search
Query-time retrieval combines vector similarity with another retrieval signal, likely keyword or lexical search, behind a dedicated hybrid-search component.
• src/retrieval/hybrid_search.py
• src/retrieval/embedder.py
• src/retrieval/vector_store.py
Primary control flow: user/query text → query embedding and lexical retrieval → hybrid ranking → selected context chunks. This module is the central ranking boundary before LLM invocation.
5. RAG Orchestration and LLM Boundary
The RAG package defines prompt construction, request/response structures, token constraints, and the external LLM client integration.
• src/rag/llm_client.py
• src/rag/prompts.py
• src/rag/schema.py
• src/rag/token_budget.py
The expected flow is ranked retrieval context → token-budget enforcement → prompt assembly → LLM client → structured response. schema.py should be the contract boundary for data exchanged among retrieval, prompting, and model invocation code.
6. Prompt Assets and Model Configuration
Prompt text is partly maintained as a repository asset, distinct from Python prompt assembly logic.
• prompts/diagnostic_system.md
• src/rag/prompts.py
• .env.example
prompts/diagnostic_system.md suggests a diagnostic-oriented system instruction. .env.example indicates runtime configuration or credentials are externalized, likely including LLM and/or vector-store service settings. External services are not named in the provided tree, so their concrete providers should remain implementation-configurable.
7. Runtime and Validation
The project is Python-based, with dependencies declared in requirements.txt. Focused test modules exercise the two major pipeline boundaries.
• requirements.txt
• src/test_ingestion.py
• src/test_retrieval.py
• src/rag/test_llm.py
The architecture’s critical integration path is ingestion → vector indexing → hybrid retrieval → budgeted prompt generation → external LLM response.
Main entry points: llm_client.py LLM client · hybrid_search.py Hybrid search · embedder.py Embedder · schema.py RAG schema
Components 17
Ingestion
Transforms raw documents into indexable chunks.
Retrieval
Indexes chunks and produces hybrid-ranked context.
- Embedder · Creates document and query vectors.
src/retrieval/embedder.py - Vector store · Decouples indexing and similarity queries from a provider.
src/retrieval/vector_store.py - Hybrid search · Combines vector and lexical retrieval signals.
src/retrieval/hybrid_search.py
RAG Orchestration
Builds budgeted prompts and invokes the model.
- RAG schema · Contract between retrieval, prompting, and model invocation.
src/rag/schema.py - Token budget
src/rag/token_budget.py - Prompt assembly
src/rag/prompts.py - LLM client · Provider-configurable external-model boundary.
src/rag/llm_client.py
Other components
- Raw documents · Uncommitted source-document boundary.
data/.gitkeep - User query
- Diagnostic system prompt
prompts/diagnostic_system.md - External LLM
- Generated outputs · Uncommitted run-result boundary.
outputs/.gitkeep - Runtime configuration · Externalizes model and store settings or credentials.
.env.example
Connections 19
- Raw documents → Loaders: load files
- Loaders → Validator: validate
- Validator → Cleaner: clean
- Cleaner → Chunker: chunk
- Chunker → Embedder: normalized chunks
- Embedder → Vector store: index vectors
- User query → Hybrid search: retrieve
- Hybrid search → Embedder: embed query
- Hybrid search → Vector store: vector and lexical lookup
- Hybrid search → RAG schema: ranked context
- RAG schema → Token budget: context contract
- Token budget → Prompt assembly: selected context
- Diagnostic system prompt → Prompt assembly: system instruction
- Prompt assembly → LLM client: assembled request
- LLM client → External LLM: model request
- LLM client → RAG schema: structured response
- LLM client → Generated outputs: generated result
- Runtime configuration → Vector store: store settings
- Runtime configuration → LLM client: model settings