
RAG-Based Custom Chatbot, AI Document Querying
An end-to-end Retrieval-Augmented Generation application that transforms static PDF documents into an interactive knowledge base, users ask questions in plain English and get accurate, source-grounded answers instantly.
The Challenge
Organizations routinely sit on thousands of pages of PDFs, contracts, technical manuals, research reports, compliance documentation, that are practically impossible to search at any useful depth. Keyword search returns irrelevant results, and employees waste hours manually scanning documents for specific answers. Standard AI chatbots without retrieval produce confident but fabricated responses when asked questions grounded in proprietary documents.
The client needed a solution that would let non-technical users upload their own documents and immediately start asking natural language questions, with answers that are accurate, cited, and grounded exclusively in uploaded content. Support for charts, diagrams, and images embedded inside PDFs was also a hard requirement.
The Solution
TechEmulsion built a production-grade RAG pipeline using OpenAI GPT-4 for generation, OpenAI embeddings for vectorisation, and pgvector as the similarity search layer. Documents are chunked on upload, embedded, and stored. At query time, the user's question is embedded and used to retrieve the top-k most semantically relevant chunks, which are then passed as grounding context to the LLM for answer synthesis.
A separate vision pipeline handles image and chart content found in PDFs, routing those through GPT-4's vision capabilities so users can ask questions about figures and diagrams as naturally as they would about text. The full system runs on FastAPI with a React frontend, deployable as a self-hosted or cloud-hosted service.
Key Features
PDF Upload & Parsing
Users upload one or multiple PDF documents. The system extracts text and identifies graphical content for separate processing.
Vector Embeddings
Document chunks are converted into high-dimensional vector embeddings using OpenAI's embedding models and stored in pgvector for fast similarity search.
Semantic Retrieval
When a user submits a natural language question, the query is embedded and matched against stored vectors to retrieve the most contextually relevant chunks.
LLM Answer Generation
Retrieved chunks are passed to OpenAI GPT-4 as context. The model generates accurate, grounded answers, eliminating hallucinations from context-free prompting.
Image & Graphic Recognition
The system detects charts, diagrams, and images embedded in PDFs and routes them through a vision pipeline so graphical content can be queried alongside text.
Multi-Document Support
Users can maintain separate knowledge bases per project or query across a combined corpus of documents simultaneously.
Tech Stack
Outcomes
~90%
Answer accuracy on in-document queries
<2s
Average retrieval + generation latency
Multi-doc
Simultaneous corpus querying supported
The RAG chatbot eliminated the need for manual document searching across multiple teams. Legal and compliance teams reduced document review time significantly, and the vision pipeline enabled queries against engineering diagrams and financial charts that were previously unsearchable. The architecture is fully extensible, additional document types, chunking strategies, and embedding models can be swapped without rebuilding the pipeline.