Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Multi-Query + Reranking RAG PDF Chatbot

This project is a Streamlit-based RAG (Retrieval-Augmented Generation) PDF chatbot that uses:

  • UV for dependency management
  • PyMuPDF for PDF extraction
  • Sentence Transformers for embeddings
  • FAISS for vector search
  • Multi-query expansion using DeepSeek
  • Cross-Encoder reranking
  • Ollama for LLM-based answering

🚀 Features

✔ Extracts text from PDF
✔ Splits text into chunks
✔ Creates a FAISS vector index
✔ Performs multi-query retrieval
✔ Re-ranks retrieved chunks
✔ Generates answers using context
✔ Uses DeepSeek-R1 (via Ollama)


📦 Project Setup

Follow these steps to run the application:


1️⃣ Clone the Repository

git clone <repo-link>
cd rag_tutorials

2️⃣ Install Dependencies Using UV

Make sure UV is installed:

pip install uv

Then run:

uv sync

This will install all dependencies listed in pyproject.toml.


3️⃣ Run the Streamlit Application

uv run streamlit run main.py

📁 File Structure

project-folder/
│── main.py
│── pyproject.toml
│── README.md

⚙️ Requirements

Your pyproject.toml should include dependencies such as:

streamlit
pymupdf
faiss-cpu
sentence-transformers
numpy
ollama
cross-encoder

UV will automatically install them.


📝 Description of the Workflow

1. PDF Extraction

Uses PyMuPDF to extract text from each page.

2. Chunking

Splits PDF text into overlapping chunks.

3. Vector Embedding

Embeds chunks using all-MiniLM-L6-v2.

4. FAISS Index

Stores embeddings in an IndexFlatL2 vector store.

5. Multi-Query Retrieval

DeepSeek R1 reformulates user queries into variations.

6. Re-ranking

Uses CrossEncoder (MS MARCO MiniLM) to score chunks.

7. LLM Response

Ollama generates final answer based on top-ranked context.


About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages