A modular Retrieval-Augmented Generation (RAG) framework built with Python. The project is designed with clean architecture principles, making each component independent and easily replaceable. It supports document ingestion, text chunking, embedding generation, FAISS vector storage, retrieval, prompt construction, and answer generation using a Large Language Model.
- Modular RAG pipeline
- PDF document ingestion
- Configurable text chunking
- Embedding generation
- FAISS vector database
- Similarity-based document retrieval
- Prompt template builder
- LLM-based answer generation
- YAML-based configuration
- Logging support
- Unit tests for individual modules
.
├── configs/
│ └── config.yaml # Project configuration
├── data/
│ ├── doc.index # FAISS index
│ └── doc.pkl # Stored metadata
├── docs/ # Input PDF documents
├── logs/
│ └── rag-llm.log
├── src/ # Source code
├── test/ # Unit tests
├── main.py # Entry point
└── README.md
The project follows a modular RAG pipeline:
PDF Documents
│
▼
Data Ingestion
│
▼
Chunking
│
▼
Embedding
│
▼
FAISS Vector Store
│
▼
Retriever
│
▼
Prompt Builder
│
▼
LLM Generator
│
▼
Final Answer
Each stage is implemented as an independent module, allowing different implementations to be plugged into the pipeline with minimal changes.
Clone the repository
git clone https://github.com/Abolmw4/RAG-LLM.git
cd rag-llmCreate a virtual environment
python -m venv <your-env>Activate it
Linux/macOS
source <your-env>/bin/activateWindows
<your-env>\Scripts\activateInstall dependencies
pip install -r requirements.txtProject settings are stored in
configs/config.yaml
Typical configurable parameters include
- Embedding model
- Chunk size
- Chunk overlap
- Vector database path
- LLM model
- Prompt template
- Retrieval parameters
Run the project
python main.pyThe pipeline performs the following steps:
- Load PDF documents.
- Split documents into chunks.
- Generate embeddings.
- Store embeddings in FAISS.
- Retrieve relevant chunks.
- Build a prompt.
- Generate the final response using the LLM.
Run all unit tests
python -m unittest discover testor
pytest- Python
- LangChain
- FAISS
- Ollama
- Sentence Transformers
- PyYAML
- unittest
- Hybrid Retrieval (BM25 + Dense Retrieval)
- Re-ranking
- Metadata filtering
- Multi-query retrieval
- Streaming responses
- Web interface
- REST API
- Support for additional document formats
- Evaluation pipeline
- Docker deployment