https://github.com/emredeveloper/rag-with-cache
A comprehensive study and implementation of best practices for Retrieval-Augmented Generation (RAG) systems. This project includes advanced features like model caching, multilingual support, and evaluation metrics to enhance the performance and usability of RAG systems.
https://github.com/emredeveloper/rag-with-cache
artificial-intelligence documentation llm python rag
Last synced: about 1 month ago
JSON representation
A comprehensive study and implementation of best practices for Retrieval-Augmented Generation (RAG) systems. This project includes advanced features like model caching, multilingual support, and evaluation metrics to enhance the performance and usability of RAG systems.
- Host: GitHub
- URL: https://github.com/emredeveloper/rag-with-cache
- Owner: emredeveloper
- Created: 2025-01-20T21:21:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-10-03T15:48:45.000Z (9 months ago)
- Last Synced: 2025-10-13T22:43:49.752Z (8 months ago)
- Topics: artificial-intelligence, documentation, llm, python, rag
- Language: Python
- Homepage:
- Size: 15.7 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# ๐ RAG-With-Cache
A compact reference implementation of **Retrieval-Augmented Generation (RAG)**
that focuses on the core building blocks: PDF ingestion, vector search, and
language model generation. The codebase has been simplified so the main RAG
pipeline lives in a dedicated `rag/` package with minimal dependencies and a
clean entry point.
---
## ๐ Features
- **Modular package layout** โ Embedding, language, data-loading, and
retriever utilities are organised under `rag/` for easier reuse.
- **FAISS and HyDE retrievers** โ Switch between traditional dense retrieval
and HyDE-style hypothetical document retrieval from the command line.
- **Model caching** โ Embedding and language models are cached locally to
avoid repeated downloads.
- **PDF utilities** โ Lightweight helpers for loading and chunking documents.
- **Test coverage** โ Pytest suite that exercises each major component with
fast stubs.
---
## ๐ Quick Start
1. **Install dependencies**
```bash
pip install -r requirements.txt
```
2. **Prepare your documents**
Place PDFs inside `data/pdfs/`. The directory is created automatically when
running the CLI, but adding files ahead of time lets you test retrieval
immediately.
3. **Run the demo CLI**
```bash
python main.py
```
Choose between FAISS or HyDE retrieval when prompted and start asking
questions about your documents.
---
## ๐ Project Structure
```text
โโโ rag/
โ โโโ config.py # Configuration dataclass
โ โโโ data/ # PDF loading utilities
โ โโโ embeddings.py # SentenceTransformer wrapper with caching
โ โโโ language.py # HuggingFace causal LM wrapper with caching
โ โโโ retrievers/ # FAISS and HyDE retrievers
โ โโโ system.py # High-level RAG orchestration
โโโ data/pdfs/ # PDF documents for retrieval
โโโ tests/ # Pytest suite
โโโ main.py # Command-line entry point
โโโ requirements.txt # Minimal dependency set
โโโ setup.py # Package metadata
```
---
## ๐งช Running the Tests
```bash
pytest
```
The HyDE tests rely on stubbed models so they run quickly without downloading
large checkpoints.