A Python project exploring Retrieval-Augmented Generation (RAG), local LLM inference, and LangChain-based conversational agent workflows using Ollama and ChromaDB.
This repository contains experiments and implementations around two related AI application patterns:
A document question-answering pipeline that:
- loads a PDF document
- extracts and splits its content
- creates embeddings
- stores vectors in ChromaDB
- retrieves relevant context
- generates an answer using a local LLM
The repository also explores conversational AI workflows using LangChain, local model inference, memory, and tool-oriented interactions.
The RAG pipeline is the primary documented implementation in this repository.
This project was built to explore practical concepts behind modern LLM applications, including:
- Retrieval-Augmented Generation
- document ingestion
- text chunking
- embeddings
- vector databases
- semantic retrieval
- prompt-based grounding
- local LLM inference
- conversational AI workflows
- ๐ PDF document loading
- โ๏ธ Recursive text splitting
- ๐ง Embedding generation
- ๐๏ธ ChromaDB vector storage
- ๐ Semantic retrieval
- ๐ค Local LLM inference with Ollama
- ๐ฌ Context-aware question answering
The repository also explores:
- conversational interaction
- multi-turn context
- LangChain-based tool workflows
- local LLM inference
Agent functionality is currently exploratory and is not presented as a production-ready agent platform.
PDF Document
โ
โผ
Document Loader
โ
โผ
Text Splitting
โ
โผ
Embedding Model
โ
โผ
ChromaDB
(Vector Store)
โ
โ
User Question
โ
โผ
Retriever
โ
โผ
Relevant Context
โ
โผ
Local LLM
(Ollama)
โ
โผ
Generated Answer
The application loads the configured PDF document.
Large document content is divided into smaller chunks to make retrieval more effective.
The document chunks are converted into vector representations.
The embeddings are stored in ChromaDB.
When a user asks a question, the system retrieves relevant document chunks based on semantic similarity.
The retrieved context is passed to a local language model through Ollama.
The model generates an answer based on the retrieved context.
The RAG workflow uses a grounding-oriented prompt pattern similar to:
You are an assistant that answers questions using ONLY
the provided context.
If the answer is not in the context, reply:
"I don't know."
The purpose is to reduce unsupported generation when the required information is not present in the retrieved context.
Prompt instructions alone do not guarantee hallucination-free output.
| Area | Technology |
|---|---|
| Language | Python |
| LLM Framework | LangChain |
| LLM Runtime | Ollama |
| Vector Database | ChromaDB |
| Embeddings | Local embedding model |
| Document Processing | PyPDF / LangChain loaders |
LangChain-Rag-Agent/
โ
โโโ rag.py
โ โโโ PDF-based RAG pipeline
โ
โโโ chatbot.py
โ โโโ Conversational workflow
โ
โโโ text_generation.py
โ โโโ LLM interaction utilities
โ
โโโ manual.pdf
โ โโโ Sample document used by the RAG pipeline
โ
โโโ README.md
Install:
- Python 3.x
- Git
- Ollama
git clone https://github.com/abdullahk970/LangChain-Rag-Agent.git
cd LangChain-Rag-Agentpip install langchain langchain-community langchain-ollama chromadb pypdfStart the local Ollama service:
ollama servePull the required models:
ollama pull llama2
ollama pull nomic-embed-textModel names should match the configuration used by the current application.
Run:
python rag.pyThe application will use the configured PDF document as the knowledge source.
The repository also contains an exploratory conversational workflow:
python chatbot.pyThe current public repository should be considered experimental for this part of the project.
A useful next step for this project is to evaluate retrieval quality using a fixed question set.
Potential metrics include:
- Recall@K
- Precision@K
- MRR
- Context relevance
- Answer relevance
- Faithfulness
No numerical benchmark is claimed until a reproducible evaluation dataset and methodology are established.
- The current implementation is primarily an experimental/learning project.
- Retrieval quality depends on chunking and embedding configuration.
- Local model performance depends on available system resources.
- LLM-generated responses may still contain incorrect information.
- The current RAG implementation is centered around a configured PDF knowledge source.
- The conversational agent portion should be considered exploratory rather than production-ready.
- Multi-document RAG
- Web-based interface
- Retrieval evaluation benchmarks
- Better citation support
- Metadata-aware retrieval
- Reranking
- Additional local models
- Structured tool outputs
- More robust agent workflows
- Automated testing
Muhammad Abdullah Khan
- GitHub: abdullahk970
- LinkedIn: Muhammad Abdullah Khan
This project is licensed under the MIT License.