Skip to main content
←All work

RAG Document Chatbot

Role
Generative AI / RAG Project
Timeline
Academic Project (PDC)
Status
Completed - deployed
Category
Generative AI / RAG

A Streamlit-based retrieval-augmented generation chatbot that answers questions using context retrieved from an indexed PDF source document.

This Streamlit application implements a retrieval-augmented generation (RAG) pipeline that allows users to ask natural-language questions about a source PDF document. The system chunks and indexes the document using LangChain, retrieves relevant passages for each query using HuggingFace embeddings and a vector index, then passes the retrieved context to Groq's LLM to generate a grounded answer.

01

The problem

Large language models answer questions from parametric memory, which means they can hallucinate information and cannot answer questions about documents they have never seen. RAG addresses this by retrieving the relevant passages first and conditioning the model's response on those passages, keeping answers grounded in the actual document content.

02

Approach

  1. Document ingestion

    The source document (reflexion.pdf) is loaded using LangChain's PyPDFLoader. The document is split into overlapping chunks using RecursiveCharacterTextSplitter to preserve context across chunk boundaries.

  2. Embedding and indexing

    Chunks are embedded using HuggingFace Embeddings (via LangChain's HuggingFaceEmbeddings). VectorstoreIndexCreator builds an in-memory vector index from these embeddings.

  3. Retrieval and generation

    At query time, a RetrievalQA chain retrieves the most relevant document chunks and passes them as context to ChatGroq, the LangChain integration for Groq's LLM API. The model generates an answer grounded in the retrieved passages. Answers are constrained to what is recoverable from the document, reducing unsupported claims.

  4. Interface

    The application is built with Streamlit and styled with a dark custom CSS theme and a branded logo. It is deployed on Vercel.

03

Stack

Framework

PythonStreamlit

RAG Pipeline

LangChainRetrievalQAVectorstoreIndexCreatorRecursiveCharacterTextSplitter

LLM

Groq (ChatGroq)

Embeddings

HuggingFace Embeddings (LangChain)

Document Processing

PyPDFLoader (LangChain)reflexion.pdf

Deployment

Vercel
04

What it changes

  • End-to-end RAG pipeline: PDF ingestion → chunking → embedding → retrieval → grounded generation.
  • Answers grounded in the indexed source document rather than parametric model memory.
  • Deployed and publicly accessible at pdc-rag-chatbot.vercel.app.
  • Dark-themed Streamlit interface with branded presentation.

The LLM and answer quality depend on the content of the indexed PDF (reflexion.pdf) and the Groq model in use. Questions outside the scope of the document may produce incomplete or inaccurate answers.

05

About the author

I'm Aaqib Shaikh, a software engineer based in Karachi, Pakistan. I build full-stack web applications, AI systems, and machine-learning tools, from architecture to deployment, and studied Computer Science at Iqra University. The resume has the full background, more work is on the projects page, and the contact page is the way to reach me. Code lives on GitHub.