RAG PDF Chatbot
A Professional, Enterprise-Grade Retrieval-Augmented Generation System for PDF Documents
🎯 Problem Statement
Organizations struggle with extracting actionable insights from large collections of PDF documents. Traditional search methods fail to provide contextual, accurate answers to complex questions. RAG PDF Chatbot solves this by combining:
- Document Retrieval: Find relevant information from PDF collections
- Contextual Understanding: Use LLM to understand and synthesize information
- Natural Language Interface: Ask questions in plain English and get precise answers
🏗️ Architecture
graph TD
A[PDF Documents] --> B[Document Processor]
B --> C[Vector Store]
C --> D[Retriever]
D --> E[RAG Chain]
E --> F[LLM]
F --> G[Answer]
G --> H[User]
H -->|Question| E
Key Components
- Document Processor: Loads and chunks PDF documents
- Vector Store: Stores document embeddings for efficient retrieval
- Retriever: Finds relevant documents for a given question
- RAG Chain: Combines retrieved context with LLM for answer generation
- LLM Interface: Uses Ollama to run local language models
🛠️ Tech Stack
- Core: Python 3.8+
- Document Processing: LangChain, PyMuPDF
- Embeddings: Ollama (nomic-embed-text)
- Vector Store: FAISS
- LLM: Ollama (llama3.2:3b)
- Configuration: Python dataclasses + environment variables
- Testing: pytest
🚀 Quick Start
Prerequisites
- Python 3.8+
- Ollama running locally with required models
- PDF documents in the
rag-dataset/directory
Installation
# Clone the repository
git clone https://github.com/your-org/rag-pdf-chatbot.git
cd rag-pdf-chatbot
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Set up environment variables
cp .env.example .env
# Edit .env with your configuration
Running the Application
# Basic usage
python -m src.main --help
# Ask a specific question
python -m src.main --question "What are the benefits of BCAA supplements?"
# Interactive mode
python -m src.main --interactive
# Rebuild vector store
python -m src.main --rebuild --interactive
📂 Project Structure
rag-pdf-chatbot/
├── src/ # Core application code
│ ├── __init__.py # Package initialization
│ ├── config.py # Configuration management
│ ├── document_processor.py # Document loading and processing
│ ├── vector_store.py # Vector storage and retrieval
│ ├── rag_chain.py # RAG pipeline implementation
│ └── main.py # Main application entry point
├── tests/ # Unit and integration tests
├── docs/ # Architecture and design documentation
├── config/ # Configuration files
├── scripts/ # Automation and utility scripts
├── .env.example # Environment variable template
├── .gitignore # Git ignore patterns
├── README.md # This file
└── requirements.txt # Python dependencies
🔧 Configuration
The application uses environment variables for configuration. See .env.example for all available options:
# Ollama Configuration
OLLAMA_BASE_URL=http://localhost:11434
EMBEDDING_MODEL=nomic-embed-text
LLM_MODEL=llama3.2:3b
# Document Processing
DATASET_PATH=rag-dataset
CHUNK_SIZE=1000
CHUNK_OVERLAP=100
# Vector Store
VECTOR_STORE_PATH=health_supplements
SAVE_VECTOR_STORE=true
# Retrieval
RETRIEVAL_TYPE=mmr
RETRIEVAL_K=3
RETRIEVAL_FETCH_K=100
RETRIEVAL_LAMBDA=1.0
🧪 Testing
# Run all tests
pytest tests/
# Run specific test
pytest tests/test_document_processor.py
# Run with coverage
pytest --cov=src tests/
📖 Documentation
🤝 Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
🎯 Value Proposition
For Developers:
- Clean, modular architecture following SOLID principles
- Easy to extend and customize
- Comprehensive documentation and examples
For Organizations:
- Extract insights from PDF documents efficiently
- Reduce manual document review time
- Improve knowledge discovery and decision making
For Recruiters:
- Professional, enterprise-grade codebase
- Follows best practices for security and maintainability
- Demonstrates advanced Python and AI/ML skills
🔒 Security
This project follows GitGuardian security standards:
- No hardcoded secrets
- Environment variable configuration
- Secure dependency management
- Regular security audits
📞 Support
For issues, questions, or feature requests, please open an issue on GitHub.
Built with ❤️ for developers, by developers.
Metadata
Release files for rag-pdf-chatbot 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rag_pdf_chatbot-1.0.0.tar.gz | 14.5 kB | Without provenance | Details for rag_pdf_chatbot-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rag_pdf_chatbot-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for rag_pdf_chatbot-1.0.0-py3-none-any.whl |
Total release size: 26.5 kB
Release files / rag_pdf_chatbot-1.0.0.tar.gz
| Download URL | rag_pdf_chatbot-1.0.0.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec21cdcfc628e4ad3d7dd9d92acd454d4742f347bf043ba84ed0afce5701c7de
|
|
BLAKE2b-256 checksum How to use checksums |
645077544a49ef7ab074ee0d0d170167bbc57c786122fb6317ea3ad5360accad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / rag_pdf_chatbot-1.0.0-py3-none-any.whl
| Download URL | rag_pdf_chatbot-1.0.0-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f369157fa4f95aacd5ffee17d377543a8405f134e27cd1a0ce8d120e72634918
|
|
BLAKE2b-256 checksum How to use checksums |
001b3866a15ea453fc84d72b8a05ced3370aa12b4a1d4d19db01d745ba13899d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for rag-pdf-chatbot 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.