Skip to content

RAG Service

peter-olai edited this page May 7, 2025 · 4 revisions

RAG (Retrieval Augmented Generation) Service

The rag_service/ directory and its modules implement the Retrieval Augmented Generation functionality. RAG enhances the responses of LLMs by providing them with relevant information retrieved from a knowledge base. This is a key part of the overall Chat Service Pipeline.

Uploading documents

For step by step instructions on how to upload documents to the RAG-Database please click here

Functionality

  • Document Ingestion/Indexing: Processes and stores documents (e.g., text files, PDFs, database records) in a way that allows for efficient searching (e.g., vector embeddings). The context_upload.py script is primarily responsible for this.
  • Retrieval: Given a user query, searches the indexed knowledge base to find the most relevant document snippets or pieces of information.
  • Context Augmentation: Provides the retrieved information as additional context to the LLM when generating a response.

Components

  • Vector Database: Often, a vector database (e.g., Pinecone, FAISS, ChromaDB) is used to store embeddings of the documents for similarity search.
  • Embedding Model: A model used to convert text into numerical vectors (embeddings).
  • Search/Retrieval Logic: Algorithms to find the most relevant documents based on query embeddings.

Usage

When a user query is received:

  1. The query may be embedded.
  2. The RAG service searches the knowledge base for relevant information using the query or its embedding.
  3. The retrieved information is combined with the original query and system prompts.
  4. This augmented prompt is then sent to the LLM (see LLM Integration and LLM.py) to generate a more informed and contextually accurate response.

(Information on the specific vector database used, the embedding models, and the structure of the knowledge base should be detailed here.)

Clone this wiki locally