How rararapi/rag-galirage works
Main Components
• Input/Query Module: Representing where queries are fed (e.g., using sample_query.txt or other user input).
• Preprocessing Module: Where PDF ingestion occurs, text normalization happens (using normalize_text functions), and document splitting is handled (dynamic chunk_size and chunk_overlap settings).
• BM25 Scoring Module: The first-stage screening that quickly estimates document relevance.
• Embedding and Vector Search Module: Implements the secondary screening using embeddings stored in a Chroma vector store for precise retrieval.
• Few-shot Prompting/Answer Generation Module: Uses domain-specific Q&A examples and step-by-step thinking to produce a coherent final answer.
• Logging/Warning Control: Handling deprecation warnings and log levels for operational stability.
• (Optional) Data Refresh Module: The part that re-generates the embedding vector store to ensure the latest data is always in use.
Relationships and Interactions
• Flow starts with the Input/Query Module where a query is read.
• This query is passed to the Preprocessing Module to ensure that the input documents are properly ingested and normalized.
• The processed data goes into the BM25 Scoring Module to filter the top relevant documents.
• The documents from BM25 are forwarded to the Embedding and Vector Search Module, which refines the selection based on high-quality vector representations.
• The results are then delivered to the Answer Generation Module that utilizes few-shot prompts to produce the final answer.
• Throughout processing, Logging/Warning Control monitors the process, and the Data Refresh Module ensures the embedding store is up-to-date.
Architectural Patterns and Design Principles
• Two-stage retrieval architecture (quick coarse filtering with BM25 followed by fine-grained vector search).
• Modular design allowing each component (query processing, text preprocessing, BM25 search, vector search, and answer generation) to be developed and maintained independently.
• Emphasis on extensibility (such as easily updating prompt examples or dynamically adjusting document chunk sizes).
• Error handling and robustness, especially in components that deal with PDF processing and text normalization.
Relevant Technologies and Frameworks
• Python (as indicated by main.py and requirements.txt)
• BM25 algorithms for initial search ranking
• Chroma vector store and embedding libraries for the precision vector search
• Few-shot prompting techniques likely related to language model integrations
• Logging frameworks and custom error handling for PDF processing