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
✔ 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)
Follow these steps to run the application:
git clone <repo-link>
cd rag_tutorialsMake sure UV is installed:
pip install uvThen run:
uv syncThis will install all dependencies listed in pyproject.toml.
uv run streamlit run main.pyproject-folder/
│── main.py
│── pyproject.toml
│── README.md
Your pyproject.toml should include dependencies such as:
streamlit
pymupdf
faiss-cpu
sentence-transformers
numpy
ollama
cross-encoder
UV will automatically install them.
Uses PyMuPDF to extract text from each page.
Splits PDF text into overlapping chunks.
Embeds chunks using all-MiniLM-L6-v2.
Stores embeddings in an IndexFlatL2 vector store.
DeepSeek R1 reformulates user queries into variations.
Uses CrossEncoder (MS MARCO MiniLM) to score chunks.
Ollama generates final answer based on top-ranked context.