MINI PROJECT
PROGRAMMING IN PYTHON
Subject Code:- CIE-332P
Project title:- Document Intelligence System
Problem Statement :-
The growth of digital documents makes information retrieval
difficult. Traditional search lacks context, and LLMs hallucinate. A
system is needed to retrieve relevant data and generate accurate,
context-based answers efficiently.
SUBMITTED To:- Ms. Balvinder Kaur
INTRODUCTION:-
The rapid growth of digital documents has made
information extraction increasingly challenging
across domains. Traditional approaches such as
manual search and keyword-based search are
inefficient and fail to capture semantic meaning.
While Large Language Models (LLMs) can generate
human-like responses, they suffer from
hallucination, lack of domain-specific knowledge,
and limited access to user-provided data. To
overcome these issues, this project implements a
Retrieval-Augmented Generation (RAG) system that
integrates semantic search, embeddings, and a
vector database. This approach ensures context-
aware, accurate, and reliable answers, significantly
improving information retrieval efficiency and
overall user experience.
TECH STACK USED :-
1. Chainlit (Frontend Interface):- Chat interface with file upload and streaming responses
2. LangChain (Framework):- Chat interface with file upload and streaming responses
3. LangGraph :- Chat interface with file upload and streaming responses
4. Groq LLM :- Generates accurate answers from retrieved document context
5. Generative AI Embeddings :- Converts text into vectors for semantic similarity search
6. InMemoryVectorStore :- Stores embeddings and enables fast document retrieval
7. PyPDFLoader & TextLoader:- Extract text from PDF and text files
8. RecursiveCharacterTextSplitter:- Breaks documents into manageable overlapping chunks
9. python-dotenv:- Securely manages API keys and environment variables
Frontend & Interactivity:-
1. File Upload Interaction:-
The system begins with an interactive file upload feature
implemented using Chainlit’s AskFileMessage. Users are required
to upload a PDF or text file before asking any questions, ensuring
that the system always has relevant data to process. It supports
file type validation and size limits (up to 50MB), along with a
timeout mechanism to handle delays. This controlled entry point
prevents invalid usage and ensures that the question-answering
process is always grounded in the uploaded document.
2. Real-Time Feedback:-
The frontend provides real-time feedback during document
processing through dynamic messages such as “Processing file”
or indicating the number of text chunks being handled. These
updates are displayed using Chainlit’s messaging system, which
keeps the user informed about system activity. This improves
user experience by reducing uncertainty and preventing the
perception that the system has become unresponsive during
longer operations
3. Chat-Based Query System
Once the document is processed, users interact with the
system through a conversational chat interface. Instead of
using traditional forms or search bars, users can ask
questions in natural language, making the system intuitive
and easy to use. Each query is sent to the backend for
processing, and responses are returned in the same chat
format, creating a seamless conversational flow similar to
modern AI assistants.
4. Streaming Responses
The system enhances interactivity by streaming responses in
real time, displaying the answer token-by-token as it is
generated. This is achieved using the agent’s streaming
functionality, which allows partial outputs to be shown
immediately rather than waiting for the complete response.
This approach significantly improves perceived performance
and keeps users engaged, as they can start reading the
answer while it is still being generated.
5. Session-Based Interaction
The frontend uses session management to store user-specific
data such as the processed document (vector store) and the
initialized agent. This ensures that each user interacts with
their own dataset without interference from other sessions. It
enables personalized and isolated interactions, maintaining
data consistency throughout the conversation. However, the
session is temporary, and data is lost once the session ends
or the application restarts.
Backend & Interactivity:-
1. Document Processing & Vector Storage
2. Semantic Search (Retrieval Logic)
2. Semantic Search (Retrieval Logic)
3. Agent-Based Response Generation & Streaming