How baejoseph/cis-retriever works
Project type and purpose
• RAG-Lite is a full-stack document Q&A application built in Python with a Streamlit front-end. It implements Retrieval-Augmented Generation (RAG) over user-uploaded DOCX files, performing hierarchical chunking, semantic retrieval, and evidence-based response generation via OpenAI (or local LLMs).
File structure
• Top-level files:
• config.yaml, env.template – configuration and environment variables
• pyproject.toml, uv.lock – dependency & lock files
• README.md, rag_prompt.md – documentation
• src/ directory:
• app.py – Streamlit UI → orchestrates uploads, slider controls, chat interface
• parser.py & ingester.py – document ingestion, hierarchical chunking, duplicate detection
• rag_pipeline.py – core RAG workflow: retrieve chunks → call LLM → assemble evidence citations
• openai_services.py – abstraction over external LLM & embedding APIs (OpenAI, Ollama)
• logger.py & log_time.py – centralized logging and timing decorators
• helpers.py – utility functions
• tests/ directory: YAML-driven retrieval tests and sample DOCX files
• images/ – UI assets
Key architecture insights from README
• Three logical layers: UI (Streamlit), Business Logic (RAG pipeline & parser), External Services (LLM & embeddings)
• Caching layer for processed documents and embeddings
• Dependency injection for testability
• Configurable retrieval parameters (top-K, similarity threshold)
Main components
a. Frontend (Streamlit UI)
b. Backend Application Layer
• Document Ingestion & Chunking Service
• Retrieval & Ranking Service (vector store + cosine similarity)
• RAG Orchestrator (rag_pipeline)
• OpenAI Services (LLM & embeddings)
c. Caching / Storage
• Processed documents cache
• Embedding / vector index store
d. External Dependencies
• OpenAI API or Local LLM (Ollama)
• AWS or other persistence if used (S3, Redis, etc.)
e. Configuration & Logging
• config.yaml / .env
• logger service
Relationships and data flow
1. User uploads DOCX via Streamlit → Streamlit UI
2. UI invokes Document Ingestion service → parser/ingester
3. Ingestion produces hierarchical chunks → stored in cache & vector store
4. User asks a question → UI passes query to RAG Orchestrator
5. RAG Orchestrator retrieves top-K chunks from vector store (cosine sim)
6. Orchestrator calls OpenAI Services for answer generation + citations
7. Response returned to UI
Architectural patterns & design principles
• Layered architecture: clear separation UI / Application / External Services
• Modular, testable services with dependency injection
• Caching for idempotent ingestion & vector lookups
• Config-driven parameters (chunk size, thresholds)
Final reminders
• Don’t omit the caching layer—it’s central to performance.
• Both ingestion and query time data flows.
• Keep labels concise but unambiguous; avoid generic terms like “Module.”