A Retrieval-Augmented Generation (RAG) application that allows you to upload PDF documents and ask questions about their content using local AI models.
- PDF Document Processing: Upload and process PDF files for question-answering
- Local AI Models: Uses Ollama for both embeddings and language generation
- Vector Search: ChromaDB for efficient document retrieval
- Interactive Web Interface: Streamlit-based user interface
- Privacy-First: All processing happens locally - no data sent to external APIs
- Frontend: Streamlit
- Language Model: Llama 3.2:1b (via Ollama)
- Embeddings: nomic-embed-text (via Ollama)
- Vector Database: ChromaDB
- Document Processing: LangChain
- Package Management: uv
Before running this application, make sure you have:
- Python 3.12+ installed
- Ollama installed and running
- uv package manager installed
Download and install Ollama from ollama.ai
# On Windows (PowerShell)
curl -LsSf https://astral.sh/uv/install.ps1 | powershell
# On macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | shgit clone https://github.com/Akash-Dutta07/RAG-Agent-Using-Ollama.git
cd RAG-Agent-Using-Ollama/project# Initialize uv project (if not already done)
uv init
# Install dependencies
uv add -r requirements.txt
# Create lock file and sync
uv lock
uv sync# Download the language model
ollama pull llama3.2:1b
# Download the embedding model
ollama pull nomic-embed-textollama listYou should see both llama3.2:1b and nomic-embed-text in the list.
# Make sure you're in the project directory
streamlit run main.pyThe application will open in your browser at http://localhost:8501
- Upload PDF: Click "Browse files" or drag and drop a PDF file
- Process Document: Click the "Process" button to create embeddings
- Ask Questions: Enter your questions in the text area and click "Get Answer"
- View Context: Expand "Show Context" to see the source text used for the answer
project/
├── main.py # Streamlit application
├── supporting_functions.py # RAG implementation
├── requirements.txt # Python dependencies
├── pyproject.toml # uv project configuration
└── README.md # This file
You can modify the models used by editing supporting_functions.py:
EMBEDDING_MODEL = "nomic-embed-text" # Embedding model
LLM_MODEL = "llama3.2:1b" # Language model- Language Models:
llama3.2:1b,llama3.2:3b,qwen2.5:7b, etc. - Embedding Models:
nomic-embed-text,mxbai-embed-large, etc.
Key dependencies include:
streamlit: Web interfacelangchain: Document processing frameworklangchain-community: Community extensionslangchain-ollama: Ollama integrationlangchain-text-splitters: Text chunkingchromadb: Vector databasepypdf: PDF processingollama: Ollama client
-
Model not found error
# Download the missing model ollama pull <model-name>
-
Ollama connection error
# Check if Ollama is running ollama list # Start Ollama if not running ollama serve
-
Import errors
# Reinstall dependencies uv sync --force -
PDF processing errors
- Ensure PDF is not corrupted
- Check file size (limit: 200MB)
- Try with a different PDF
⭐ If you found this project helpful, please give it a star on GitHub!