A newer version of the Streamlit SDK is available:
1.54.0
RAG System
A modular Retrieval-Augmented Generation (RAG) system for document-based question answering.
Features
- Document Processing: Extract and chunk text from PDF, DOCX, and TXT files
- Semantic Search: Embed and search documents based on meaning, not just keywords
- Flexible Architecture: Support for multiple embedding models and vector databases
- REST API: API for integrating with other applications
- Web UI: User-friendly Streamlit interface for document upload and querying
Architecture
The system consists of the following components:
- Embedding Model: Converts text to vector embeddings
- Vector Database: Stores and searches document embeddings
- Document Processor: Extracts and chunks text from documents
- RAG Engine: Combines retrieval and generation for question answering
- API: Exposes functionality through a RESTful API
- UI: Provides a user interface for interacting with the system
Installation
Prerequisites
- Python 3.8+
- pip
Setup
Clone the repository:
git clone https://github.com/yourusername/rag-system.git cd rag-systemInstall dependencies:
pip install -r requirements.txtSet up environment variables (optional):
cp .env.example .env # Edit .env with your settings
Usage
API Server
Run the API server:
python app.py
The API will be available at http://localhost:8000
Streamlit UI
Run the Streamlit UI:
streamlit run ui/app.py
The UI will be available at http://localhost:8501
API Endpoints
POST /documents: Add documentsPOST /upload: Upload and process document filesPOST /query: Query the RAG systemGET /search: Search for documentsDELETE /documents: Clear all documentsGET /health: Check system health
Configuration
The system can be configured through environment variables or the config.py file:
EMBEDDING_MODEL_NAME: Name of the embedding modelVECTOR_DB_TYPE: Type of vector database to useCHUNK_SIZE: Size of document chunksCHUNK_OVERLAP: Overlap between chunksTOP_K: Number of documents to retrieveSEARCH_TYPE: Type of search (semantic, keyword, hybrid)LLM_MODEL_NAME: Name of the language model for generationLLM_API_KEY: API key for the language model
Extending
The modular architecture makes it easy to extend the system:
- Add new embedding models in
embedding/model.py - Add new vector databases in
storage/vector_db.py - Add support for new document types in
document/processor.py - Add new LLM integrations in
llm/model.py