A production-ready Retrieval-Augmented Generation (RAG) application built using Python, Groq API, Llama 3.3, LangChain, ChromaDB, and HuggingFace Embeddings.
The application converts PDF documents into a searchable vector database and enables users to ask natural language questions grounded in the document content using semantic retrieval and LLM-powered answer generation.
This project demonstrates the complete RAG pipeline used in modern AI applications, including document ingestion, chunking, embeddings, vector search, retrieval, prompt engineering, and LLM inference.
- π Load one or multiple PDF documents
- βοΈ Intelligent document chunking
- π§ Local HuggingFace Embeddings
- ποΈ ChromaDB Vector Database
- π Semantic Similarity Search
- π Retrieval-Augmented Generation (RAG)
- π€ Groq Llama 3.3 Integration
- π¬ Interactive CLI Chat Interface
- β‘ Fast Vector Retrieval
- π§© Modular Project Architecture
- π Secure API Key Management using Environment Variables
PDF Documents
β
βΌ
PyMuPDF Document Loader
β
βΌ
Recursive Character Text Splitter
β
βΌ
HuggingFace Embedding Model
β
βΌ
Chroma Vector Database
β
User Question
β
βΌ
Embed User Question
β
βΌ
Semantic Similarity Search
β
βΌ
Retrieve Top-K Chunks
β
βΌ
Prompt Engineering with Context
β
βΌ
Groq (Llama 3.3 70B)
β
βΌ
Grounded AI Answer
local-pdf-rag/
β
βββ data/ # PDF documents
βββ chroma_db/ # Vector database (generated)
β
βββ utils/
β βββ loader.py # PDF loading
β βββ splitter.py # Document chunking
β βββ embeddings.py # Embedding model
β
βββ ingest.py # Creates ChromaDB
βββ rag.py # Retrieval pipeline
βββ app.py # CLI interface
βββ config.py # Configuration
β
βββ requirements.txt
βββ .env.example
βββ .gitignore
βββ README.md
| Component | Technology |
|---|---|
| Language | Python |
| LLM Provider | Groq API |
| Model | Llama 3.3 70B Versatile |
| Framework | LangChain |
| Vector Database | ChromaDB |
| Embeddings | HuggingFace Sentence Transformers |
| PDF Loader | PyMuPDF |
| Text Splitting | RecursiveCharacterTextSplitter |
| Environment Variables | python-dotenv |
git clone https://github.com/your-username/local-pdf-rag.git
cd local-pdf-ragpython -m venv venvvenv\Scripts\activatesource venv/bin/activatepip install -r requirements.txtCreate a .env file.
GROQ_API_KEY=your_groq_api_keyPlace your PDF files inside:
data/
Run:
python ingest.pyThis will:
- Load PDFs
- Split text into chunks
- Generate embeddings
- Store vectors inside ChromaDB
python app.pyExample:
You:
What is Retrieval Augmented Generation?
Assistant:
Retrieval-Augmented Generation (RAG) is...
- Load PDF documents.
- Extract text using PyMuPDF.
- Split documents into overlapping chunks.
- Generate embeddings using HuggingFace.
- Store embeddings in ChromaDB.
- User asks a question.
- The question is embedded.
- ChromaDB retrieves the most relevant chunks.
- Retrieved context is inserted into a prompt.
- Groq's Llama 3.3 generates a grounded response.
Extracting structured text from PDF documents.
Breaking large documents into overlapping chunks for better retrieval.
Converting text into dense vector representations for semantic similarity.
Efficient storage and retrieval of document embeddings using ChromaDB.
Finding relevant information based on meaning instead of keyword matching.
Combining retrieval with LLM inference to generate grounded answers.
Using Groq's ultra-fast inference API with Llama 3.3.
Injecting retrieved context into prompts to reduce hallucinations.
Separating ingestion, retrieval, embeddings, and inference into reusable components.
- π Source citations (PDF & page numbers)
- π― Metadata filtering
- π Hybrid Search (Keyword + Semantic)
- π MMR Retrieval
- π¬ Conversation Memory
- π Streamlit Web Interface
- β‘ FastAPI REST API
- π³ Docker Support
- βοΈ Cloud Deployment
- π Multi-user document collections
- Supports PDF documents only.
- Requires rebuilding the vector database when documents change.
- Responses depend on retrieval quality.
- Internet connection required for Groq API inference.
After building this project, you understand:
- Retrieval-Augmented Generation (RAG)
- Vector databases
- Semantic search
- Embeddings
- ChromaDB
- LangChain
- HuggingFace Embeddings
- Prompt Engineering
- Groq API integration
- LLM application architecture
- Document Question Answering
- Modular AI system design
Contributions are welcome!
Possible improvements:
- Better retrieval strategies
- Improved prompt templates
- UI development
- Additional document formats
- Multi-model support
- Performance optimization
- Groq for ultra-fast LLM inference
- Meta for the Llama models
- LangChain for orchestration
- ChromaDB for vector storage
- HuggingFace for embedding models
- PyMuPDF for PDF parsing
Built as a hands-on learning project while exploring Retrieval-Augmented Generation (RAG), Large Language Models (LLMs), Vector Databases, Semantic Search, Prompt Engineering, and Production-Ready AI Systems.