This repository contains my solution for the Kalpit Pvt Ltd AI Intern Hiring Assignment (Phase 1). It implements a local, command-line Q&A system using a Retrieval-Augmented Generation (RAG) pipeline. The system answers questions solely from the provided speech.txt (an excerpt from Dr. B. R. Ambedkar’s writing) — no internet or external APIs are used.
Build a simple CLI-based Q&A system that:
- Loads the provided
speech.txt. - Splits text into manageable chunks.
- Creates local embeddings and stores them in a local vector database.
- Retrieves relevant chunks for a user’s question.
- Generates an answer using the retrieved context and a local LLM.
Constraints and choices required by the brief:
- Language: Python 3.8+
- Orchestration: LangChain
- Vector store: ChromaDB (local)
- Embeddings: HuggingFace
sentence-transformers/all-MiniLM-L6-v2(local; no keys) - LLM: Ollama with Mistral 7B (local; no accounts/keys)
- Deliverables: code (
main.py),requirements.txt,README.md, andspeech.txtin a public repo
- Language: Python 3.8+
- Framework: LangChain (1.x module split)
- LLM: Ollama with Mistral 7B (local)
- Embeddings:
sentence-transformers/all-MiniLM-L6-v2(local) - Vector store: ChromaDB (local)
- Document loading:
TextLoaderreadsspeech.txt. - Chunking:
CharacterTextSplittercreates overlapping chunks. - Embedding: HuggingFace model produces vector representations locally.
- Indexing: Chroma persists embeddings to
./chroma_db. - Retrieval + Generation: Top matches are concatenated into context and passed to Ollama (Mistral) with a compact prompt to produce an answer.
main.py— end-to-end RAG pipeline and CLI loopspeech.txt— the source document used for answeringrequirements.txt— Python dependencieschroma_db/— persisted local vector store (auto-created)
Below are Windows-focused steps (PowerShell).
- Windows: download and install from https://ollama.ai/ (launch the app so the service runs)
- Pull the model:
ollama pull mistralOptional, to run the server explicitly:
ollama serveUse the bundled virtual environment (gptintern) or create your own.
- Activate the existing venv:
& "D:Path/Ambedkar_GPT Intern Task/gptintern/Scripts/Activate.ps1"- Or create a fresh one:
python -m venv .venv
& ".\.venv\Scripts\Activate.ps1"- Install dependencies:
python -m pip install -r requirements.txtWith your environment active and Ollama running:
python main.pyThen type your question at the prompt, or type exit to quit.
- ModuleNotFoundError for
langchain.document_loadersorlangchain.text_splitters:- LangChain 1.x split modules. This project uses:
langchain_community.document_loaderslangchain_text_splitterslangchain_community.embeddings/vectorstores/llms
- Ensure dependencies are installed:
- LangChain 1.x split modules. This project uses:
python -m pip install langchain langchain-community langchain-text-splitters chromadb sentence-transformers-
Ollama connection issues:
- Make sure the service is running and
mistralis pulled. - Try
ollama run mistralonce to confirm the model executes.
- Make sure the service is running and
-
First run is slow:
- Embedding the corpus and creating the Chroma index happens only once and is cached under
./chroma_db.
- Embedding the corpus and creating the Chroma index happens only once and is cached under
- The classic
RetrievalQAchain referenced in the brief isn’t present in recent LangChain 1.x. This repo composes the chain usinglangchain_corerunnables (ChatPromptTemplate→Ollama→StrOutputParser) with a retriever from Chroma. - Everything runs fully offline once models are pulled (Ollama + HF embeddings).
- Public repository with:
main.py(well-commented)requirements.txtREADME.md(this file)speech.txt
For hiring evaluation purposes only.