Skip to content

yusuf6/ask-your-pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📄 Modular RAG Application: PDF Chat with Gemma:2b

A professional-grade Retrieval-Augmented Generation (RAG) application that leverages LangChain, Streamlit, and Ollama. This tool allows you to upload PDF documents and interact with their content locally using the Gemma:2b model.

🏗️ Project Architecture

The application is built using a modular design to ensure scalability and ease of maintenance.

  • Frontend: Streamlit (Responsive web interface)
  • Orchestration: LangChain (Managing the RAG pipeline)
  • Local LLM: Ollama (Running Gemma:2b)
  • Vector Database: Chroma (Storing and retrieving document embeddings)

📁 File Structure

├── app.py                   # Main Streamlit UI and session management
├── data_loaders/
│   └── DataLoader.py        # logic for PDF extraction and temp file handling
├── transform/
│   ├── Splitter.py          # Document chunking logic
│   └── Embeddings.py        # Logic for creating and storing vectors
├── retriever/
│   └── Retrieval.py         # RAG chain construction and prompt templates
└── requirements.txt         # Project dependencies

Module Details:

DataLoader.py: Handles raw file bytes, saves them to a temporary file, and converts them into LangChain Document objects.

Splitter.py: Breaks large text into smaller segments (chunks). This is vital so the LLM context window isn't overwhelmed.

Embeddings.py: Uses Ollama to transform text chunks into mathematical vectors and stores them in a local Chroma database.

Retrieval.py: Defines how the system searches the database and structures the final prompt for the Gemma model.

🛠 Prerequisites

Before running the app, ensure you have the following installed:

Python 3.9+

Ollama

Gemma Model: Pull the model locally by running:

ollama pull gemma:2b

🚀 How to Execute

Install Dependencies:

pip install -r requirements.txt

Run the App:

streamlit run app.py

Usage:

Upload a PDF in the sidebar.

Wait for the "Finished!" or "Document indexed" success message.

Type your question in the main chat input.

Future Design Enhancements

Chat History: Implement StreamlitChatMessageHistory so the model remembers your previous questions in the same session.

Persistent Storage: Currently, the VectorDB is deleted when the session ends. You could update Embeddings.py to save the Chroma database to a local directory for permanent access.

About

This is an interactive LLM Based chat application for PDF inputs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages