Skip to content

TomTolleson/RAG-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAG System with Milvus and LangChain

CI codecov Python 3.12 License: MIT Code style: black security: bandit Ruff

OpenAI License: MIT

A Retrieval-Augmented Generation (RAG) system that combines Milvus vector database with LangChain and OpenAI for intelligent document querying and response generation.

System Overview

This system implements RAG architecture to provide accurate, context-aware responses to questions by:

  1. Storing document embeddings in Milvus vector database
  2. Retrieving relevant context when queried
  3. Generating human-like responses using OpenAI's language models

Components

Vector Store (src/vector_store/milvus_store.py)

  • Uses Milvus for efficient vector similarity search
  • Stores document embeddings using OpenAI's embedding model
  • Handles document addition and retrieval operations
  • Configurable connection settings for Milvus database

RAG Chain (src/rag/rag_chain.py)

  • Implements the core RAG logic
  • Integrates OpenAI's ChatGPT for response generation
  • Manages the retrieval-generation pipeline
  • Configurable temperature and other LLM parameters

Document Processing (main.py)

  • Handles document loading and chunking
  • Configurable chunk size and overlap
  • Supports text documents (expandable to other formats)

Prerequisites

  • Python 3.12+
  • Docker and Docker Compose
  • OpenAI API key

Installation

  1. Clone the repository:
git clone [repository-url]
cd RAG-System
  1. Create a virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables:
# Create .env file with your OpenAI API key
echo "OPENAI_API_KEY=your_key_here" > .env
  1. Start Milvus services:
docker-compose up -d

Usage

  1. Add your documents to the data directory:
mkdir data
echo "Your document content here" > data/test_document.txt
  1. Run the system:
python main.py

Local CI commands

Run tests with coverage:

pytest -q --maxfail=1 --disable-warnings --cov=src --cov-report=term-missing

Run linting:

flake8

Configuration

Milvus Settings

  • Host: localhost (default)
  • Port: 19530 (default)
  • Configurable in src/config/settings.py

Document Processing

  • Chunk size: 1000 (default)
  • Chunk overlap: 0 (default)
  • Configurable in src/config/settings.py

LLM Settings

  • Model: OpenAI ChatGPT
  • Temperature: 0.2 (default)
  • Configurable in src/config/settings.py

Use Cases

This RAG system is ideal for:

  • Document question-answering
  • Knowledge base augmentation
  • Contextual information retrieval
  • Research assistance
  • Technical documentation queries

Docker Services

The system uses several Docker containers:

  • Milvus standalone server
  • Etcd for metadata storage
  • MinIO for object storage

Access MinIO console:

Extending the System

The system can be extended with:

  • Additional document types (PDF, HTML, etc.)
  • Custom embedding models
  • Alternative vector databases
  • Web interface
  • Batch processing
  • Caching mechanisms

Contributing

Contributions are welcome! Please feel free to submit pull requests.

License

[Your license information here]

References

About

A Retrieval-Augmented Generation (RAG) system using Milvus and LangChain

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors