- code_3.py – Main Python script for running the RAG chatbot.
- lsb.pdf – Sample PDF document used for testing question-answering.
- .gitignore – Configuration file to exclude large model and installer files.
This project implements an offline Retrieval-Augmented Generation (RAG) chatbot that can answer questions based on the contents of PDF documents.
The chatbot works completely offline, ensuring data privacy, security, and independence from external APIs.
Workflow:
- Extract text from PDFs using
pdfplumber. - Split text into chunks and generate embeddings using
SentenceTransformers. - Store embeddings in DuckDB for efficient vector search.
- Retrieve the most relevant chunks for a given query.
- Use LangChain to pass the retrieved context into a locally run LLM (LLaMA 3).
- Generate accurate, context-aware responses.
- Python 3.10+
- LangChain – for building RAG pipelines
- pdfplumber – for extracting text from PDFs
- DuckDB – lightweight embedded database
- SentenceTransformers – for semantic vector embeddings
- Torch – backend for deep learning
- Ollama (or other LLaMA runtime) – for running the LLaMA model locally
Install dependencies manually with pip, or just copy-paste the below block into your terminal:
pip install langchain
pip install pdfplumber
pip install duckdb
pip install sentence-transformers
pip install torch