Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Hybrid RAG Assistant

A production-inspired Hybrid Retrieval-Augmented Generation (Hybrid RAG) application built with TypeScript, Node.js, ChromaDB, Elasticsearch, Cohere Rerank, and Google Gemini.

The application allows users to upload PDF documents, indexes them using both semantic search and keyword search, and provides an AI-powered chat interface capable of answering questions grounded in the uploaded documents.


✨ Features

  • 📄 Upload and index PDF documents
  • ✂️ Automatic document chunking
  • 🧠 Generate embeddings using Google Gemini
  • 🔍 Semantic search using ChromaDB
  • 🔎 Keyword search using Elasticsearch (BM25)
  • ⚡ Hybrid retrieval using Reciprocal Rank Fusion (RRF)
  • 🎯 Context re-ranking using Cohere Rerank v3.5
  • 🤖 AI-generated responses using Gemini 2.5 Flash
  • 💬 Interactive chat interface
  • 🌙 Modern dark-themed frontend

🏗️ System Architecture

Talk-PDF_system-design

📸 Application

Dashboard

  • Upload PDF documents
  • Browse indexed documents
  • Ask questions grounded in the uploaded knowledge base

⚙️ Tech Stack

Backend

  • Node.js
  • TypeScript
  • Express.js

AI & Retrieval

  • Google Gemini Embeddings
  • Gemini 2.5 Flash
  • Cohere Rerank v3.5
  • ChromaDB
  • Elasticsearch

Document Processing

  • LangChain
  • PDF Loader
  • Recursive Character Text Splitter

Frontend

  • React
  • TypeScript
  • Tailwind CSS

🔄 Retrieval Pipeline

For every user query:

  1. Convert the query into an embedding using Gemini.
  2. Perform semantic search in ChromaDB.
  3. Perform keyword search in Elasticsearch (BM25).
  4. Merge both result sets using Reciprocal Rank Fusion (RRF).
  5. Re-rank the merged results with Cohere Rerank.
  6. Build a context-aware prompt.
  7. Generate the final answer with Gemini 2.5 Flash.

📑 Document Ingestion Pipeline

When a PDF is uploaded:

  1. Load the PDF.
  2. Extract text.
  3. Split the document into chunks.
  4. Generate embeddings for each chunk.
  5. Store embeddings in ChromaDB.
  6. Store document text and metadata in Elasticsearch.
  7. Make the document available for querying.

🧩 Key Concepts Demonstrated

This project showcases practical implementations of modern RAG techniques, including:

  • Retrieval-Augmented Generation (RAG)
  • Hybrid Search
  • Vector Search
  • BM25 Keyword Search
  • Reciprocal Rank Fusion (RRF)
  • Semantic Re-ranking
  • Embedding Generation
  • PDF Parsing
  • Document Chunking
  • Prompt Engineering
  • AI-powered Question Answering

🚀 Getting Started

Clone the repository

git clone https://github.com/RohitVerma2003/Talk-PDF.git
cd Talk-PDF

Install dependencies

cd client
npm install

cd..
cd server
npm install

Configure environment variables

Create a .env file in server folder:

CHROMA_API_KEY
CHROMA_TENANT
CHROMA_DATABASE

ELASTIC_CLOUD_ID=
ELASTIC_CLOUD_URL=
ELASTIC_API_KEY=

GEMINI_API_KEY
COHERE_API_KEY

Start the application

server

npm run start

client

npm run dev

💡 Future Improvements

  • User authentication
  • Conversation history
  • Streaming AI responses
  • Citation highlighting
  • Hybrid search filters
  • OCR support for scanned PDFs
  • Document collections
  • Docker deployment
  • Kubernetes deployment
  • Evaluation pipeline using RAGAS

🎯 Learning Outcomes

This project was built to explore how modern production-style RAG systems work by combining:

  • Semantic Retrieval
  • Keyword Retrieval
  • Retrieval Fusion
  • Re-ranking
  • Large Language Models

It demonstrates how these components work together to improve retrieval quality and generate grounded, context-aware AI responses.

⭐ If you found this project interesting, consider giving it a star!

About

A production-inspired Hybrid Retrieval-Augmented Generation (Hybrid RAG) application built with TypeScript, Node.js, ChromaDB, Elasticsearch, Cohere Rerank, and Google Gemini.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages