Skip to content

Latest commit

ย 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– AI PDF Assistant

Chat with Your PDFs Using Local AI

A modern Retrieval-Augmented Generation (RAG) application that allows users to upload one or more PDF documents and ask questions using a local Large Language Model (LLM) powered by Ollama and Qdrant Vector Database.


Python Streamlit Ollama Qdrant RAG License


๐Ÿš€ Built with Python โ€ข Streamlit โ€ข Ollama โ€ข Qdrant

โญ If you find this project useful, consider giving it a star!


๐Ÿ“– Table of Contents

  • Overview
  • Features
  • System Architecture
  • Project Structure
  • Technology Stack
  • Installation
  • Configuration
  • Usage
  • Screenshots
  • RAG Workflow
  • Future Roadmap
  • Contributing
  • License
  • Author

๐Ÿš€ Overview

AI PDF Assistant is a local Retrieval-Augmented Generation (RAG) application that enables users to interact with PDF documents using natural language.

Instead of manually searching through long PDF files, users can upload one or more documents and ask questions in plain English. The application retrieves the most relevant information using semantic search and generates answers with a local Large Language Model.

Unlike cloud-based AI applications, this project runs entirely on your machine using Ollama and Qdrant, helping keep your documents private while providing fast responses.

The project is designed as a modular, scalable codebase suitable for learning, portfolio projects, and further development.


โœจ Features

๐Ÿ“„ Document Management

  • ๐Ÿ“ค Upload one or multiple PDF documents
  • ๐Ÿ“š Automatic PDF text extraction
  • โœ‚๏ธ Intelligent text chunking
  • ๐Ÿง  Metadata-aware document processing
  • ๐Ÿ—‚๏ธ Document Manager
  • ๐Ÿ—‘๏ธ Delete individual documents
  • ๐Ÿงน Clear the complete knowledge base

๐Ÿค– AI Chat

  • ๐Ÿ’ฌ Interactive chat interface
  • ๐Ÿง  Conversation memory
  • ๐Ÿ“– Context-aware responses
  • ๐Ÿ“š Rich source references
  • ๐Ÿ” Semantic document search
  • โšก Fast local inference using Ollama
  • ๐Ÿ“ Chat history

๐Ÿ” Retrieval-Augmented Generation (RAG)

  • Automatic text chunking
  • Sentence embeddings
  • Vector similarity search
  • Context retrieval
  • Metadata filtering
  • Grounded AI responses
  • Multi-document search

๐Ÿ“Š User Interface

  • ๐ŸŽจ Modern Streamlit interface
  • ๐Ÿ“‚ Sidebar document manager
  • ๐Ÿ“ˆ Knowledge base statistics
  • ๐Ÿ“ค Multiple PDF upload
  • ๐Ÿงน Clear Chat
  • ๐Ÿ—‘๏ธ Clear Database
  • ๐Ÿ“ฑ Simple and responsive layout

๐ŸŒŸ Project Highlights

โœ… 100% Local AI

โœ… No OpenAI API Required

โœ… Privacy Friendly

โœ… Multiple PDF Support

โœ… Conversation Memory

โœ… Rich Source References

โœ… Qdrant Vector Database

โœ… Semantic Search

โœ… Modular Architecture

โœ… Production-Oriented Code Structure


๐Ÿ› ๏ธ Technology Stack

Category Technology
Programming Language Python 3.11+
User Interface Streamlit
Local LLM Ollama (Llama 3.2)
Vector Database Qdrant
Embedding Model all-MiniLM-L6-v2
PDF Processing PyMuPDF
Vector Search Semantic Similarity Search
Version Control Git & GitHub
Dependency Management uv

๐Ÿ“Œ Why This Project?

This project demonstrates the implementation of a complete Retrieval-Augmented Generation (RAG) pipeline using modern AI tools and frameworks.

It combines document processing, semantic search, vector databases, and local large language models into a single application capable of answering questions based on uploaded PDF documents.

The project is designed with a modular architecture, making it easy to extend with additional features such as streaming responses, PDF previews, dashboards, hybrid search, and cloud deployment.


๐ŸŽฏ Use Cases

This application can be used for:

  • ๐Ÿ“š Study Notes
  • ๐Ÿ“– Research Papers
  • ๐Ÿ“‘ Company Documentation
  • ๐Ÿ“„ User Manuals
  • ๐Ÿ“˜ E-books
  • ๐Ÿงพ Technical Documentation
  • ๐ŸŽ“ Educational Material
  • ๐Ÿ“‹ Project Reports

๐Ÿ“ˆ Current Version

Version: v1.0

Included Features

  • โœ… Multiple PDF Upload
  • โœ… Local LLM (Ollama)
  • โœ… Semantic Search
  • โœ… Qdrant Vector Database
  • โœ… Conversation Memory
  • โœ… Rich Source References
  • โœ… Document Manager
  • โœ… Sidebar Statistics
  • โœ… Clear Database
  • โœ… Modular Service Architecture

๐Ÿ† Project Goals

The primary goals of this project are:

  • Build a complete local RAG application
  • Learn vector databases and semantic search
  • Explore local LLM deployment with Ollama
  • Develop a modular and scalable architecture
  • Create a portfolio-ready AI application
  • Demonstrate modern AI engineering practices

๐Ÿ—๏ธ System Architecture

The AI PDF Assistant follows a modular Retrieval-Augmented Generation (RAG) architecture.

                    +----------------------+
                    |    Upload PDF(s)     |
                    +----------+-----------+
                               |
                               โ–ผ
                    +----------------------+
                    |   PDF Text Loader    |
                    +----------+-----------+
                               |
                               โ–ผ
                    +----------------------+
                    |    Text Chunking     |
                    +----------+-----------+
                               |
                               โ–ผ
                    +----------------------+
                    | Sentence Embeddings  |
                    +----------+-----------+
                               |
                               โ–ผ
                    +----------------------+
                    |  Qdrant Vector DB    |
                    +----------+-----------+
                               โ–ฒ
                               |
                    User Question
                               |
                               โ–ผ
                    +----------------------+
                    | Semantic Retrieval   |
                    +----------+-----------+
                               |
                               โ–ผ
                    +----------------------+
                    |     Ollama LLM       |
                    +----------+-----------+
                               |
                               โ–ผ
                    AI Answer + Sources

๐Ÿ”„ RAG Pipeline

The application follows the Retrieval-Augmented Generation workflow.

Step 1 โ€” Upload PDF

The user uploads one or more PDF documents using the Streamlit interface.

โ†“

Step 2 โ€” Extract Text

The application extracts readable text from every page of the uploaded PDF.

โ†“

Step 3 โ€” Chunking

Large documents are divided into smaller chunks so they can be embedded efficiently.

โ†“

Step 4 โ€” Generate Embeddings

Each text chunk is converted into a high-dimensional vector using the embedding model.

โ†“

Step 5 โ€” Store in Qdrant

The generated vectors are stored inside Qdrant together with useful metadata.

Example metadata:

{
  "document_id": "...",
  "filename": "AI.pdf",
  "chunk_index": 12,
  "text": "Artificial Intelligence..."
}

โ†“

Step 6 โ€” User Question

The user asks a question in natural language.

โ†“

Step 7 โ€” Semantic Search

The question is embedded and compared against all stored vectors.

The most relevant chunks are retrieved.

โ†“

Step 8 โ€” Context Building

Retrieved chunks are combined into a prompt.

Conversation history is also included.

โ†“

Step 9 โ€” Ollama

The prompt is sent to the local Llama model.

โ†“

Step 10 โ€” Response

The assistant generates an answer together with supporting source references.


๐Ÿ“‚ Project Structure

AI PDF Assistant
โ”‚
โ”œโ”€โ”€ app
โ”‚   โ”œโ”€โ”€ api
โ”‚   โ”‚   โ””โ”€โ”€ upload.py
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ core
โ”‚   โ”‚   โ”œโ”€โ”€ config.py
โ”‚   โ”‚   โ”œโ”€โ”€ constants.py
โ”‚   โ”‚   โ””โ”€โ”€ logger.py
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ services
โ”‚   โ”‚   โ”œโ”€โ”€ chunker.py
โ”‚   โ”‚   โ”œโ”€โ”€ database_service.py
โ”‚   โ”‚   โ”œโ”€โ”€ document_service.py
โ”‚   โ”‚   โ”œโ”€โ”€ embedding_service.py
โ”‚   โ”‚   โ”œโ”€โ”€ ingestion_service.py
โ”‚   โ”‚   โ”œโ”€โ”€ llm_service.py
โ”‚   โ”‚   โ”œโ”€โ”€ pdf_loader.py
โ”‚   โ”‚   โ”œโ”€โ”€ search_service.py
โ”‚   โ”‚   โ””โ”€โ”€ vector_service.py
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ main.py
โ”‚
โ”œโ”€โ”€ frontend
โ”‚   โ”œโ”€โ”€ chat_page.py
โ”‚   โ”œโ”€โ”€ sidebar.py
โ”‚   โ”œโ”€โ”€ streamlit_app.py
โ”‚   โ””โ”€โ”€ upload_page.py
โ”‚
โ”œโ”€โ”€ tests
โ”‚
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ uv.lock
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ LICENSE

๐Ÿงฉ Service Layer

The application is divided into reusable service modules.

Service Responsibility
PDF Loader Extract text from PDF files
Chunker Split documents into chunks
Embedding Service Generate vector embeddings
Vector Service Store and search vectors in Qdrant
Search Service Retrieve relevant chunks
LLM Service Communicate with Ollama
Database Service Clear and manage the knowledge base
Document Service Manage uploaded documents

๐Ÿ” Metadata Stored with Every Chunk

Each document chunk is stored with metadata to support advanced features.

Current metadata includes:

  • Document ID
  • Filename
  • Source Path
  • Chunk Index
  • Chunk Text

This metadata enables:

  • Individual document deletion
  • Rich source references
  • Document statistics
  • Future page-aware citations

๐Ÿ“Š Data Flow

PDF
 โ”‚
 โ–ผ
Text Extraction
 โ”‚
 โ–ผ
Chunking
 โ”‚
 โ–ผ
Embeddings
 โ”‚
 โ–ผ
Qdrant
 โ”‚
 โ–ผ
Semantic Search
 โ”‚
 โ–ผ
Context
 โ”‚
 โ–ผ
Ollama
 โ”‚
 โ–ผ
Answer + Sources

๐Ÿ’ก Design Principles

The project follows several software engineering principles:

  • Modular architecture
  • Separation of concerns
  • Service-oriented design
  • Reusable components
  • Scalable project structure
  • Easy future extensibility
  • Clean and maintainable code

โš™๏ธ Installation

Follow these steps to set up the project on your local machine.


๐Ÿ“‹ Prerequisites

Before running the project, make sure you have the following installed:

  • Python 3.11 or later
  • Git
  • Ollama
  • Docker (for Qdrant)
  • uv (Python package manager)

๐Ÿ“ฅ Clone the Repository

git clone https://github.com/sagarsoni7254-eng/ai-pdf-assistant.git

Move into the project directory:

cd ai-pdf-assistant

๐Ÿ Create a Virtual Environment

Windows

python -m venv .venv

Activate:

.venv\Scripts\activate

macOS / Linux

python3 -m venv .venv

Activate:

source .venv/bin/activate

๐Ÿ“ฆ Install Dependencies

This project uses uv for dependency management.

Install all required packages:

uv sync

This command installs all dependencies defined in:

  • pyproject.toml
  • uv.lock

๐Ÿค– Install Ollama

Download Ollama from:

https://ollama.com/download

Verify installation:

ollama --version

Download the required model:

ollama pull llama3.2

Start the Ollama server:

ollama serve

๐Ÿ—„๏ธ Start Qdrant

Run Qdrant locally using Docker:

docker run -p 6333:6333 qdrant/qdrant

Verify Qdrant is running:

Open your browser:

http://localhost:6333/dashboard

๐Ÿš€ Run the Application

Launch Streamlit:

streamlit run frontend/streamlit_app.py

Open:

http://localhost:8501

The application should now be running successfully.


๐Ÿ“‚ Configuration

Current default configuration:

Setting Value
LLM llama3.2
Embedding Model all-MiniLM-L6-v2
Vector Database Qdrant
Frontend Streamlit
Language Python

๐Ÿ’ป Using the Application

Step 1

Upload one or more PDF documents.


Step 2

The application automatically:

  • Extracts text
  • Splits documents into chunks
  • Generates embeddings
  • Stores vectors in Qdrant

Step 3

Ask questions using natural language.

Examples:

What is Artificial Intelligence?

Explain Machine Learning.

Summarize Chapter 5.

Compare CNN and RNN.

List important interview questions.

Explain this topic for beginners.

Step 4

The assistant:

  • Retrieves relevant document chunks
  • Builds context
  • Sends the prompt to Ollama
  • Generates an answer
  • Displays source references

๐Ÿ›  Troubleshooting

Ollama not running

Start Ollama:

ollama serve

Model not found

Download the model:

ollama pull llama3.2

Qdrant connection failed

Make sure Docker is running.

Restart Qdrant:

docker run -p 6333:6333 qdrant/qdrant

Streamlit not found

Activate the virtual environment:

source .venv/bin/activate

Then install dependencies again:

uv sync

๐Ÿ“Œ Supported Features

  • โœ… Multiple PDF Upload
  • โœ… Semantic Search
  • โœ… Conversation Memory
  • โœ… Rich Source References
  • โœ… Local LLM
  • โœ… Qdrant Vector Database
  • โœ… Modular Architecture
  • โœ… Modern UI
  • โœ… Easy Installation

๐Ÿ“ธ Application Screenshots

Screenshots will be updated as the project evolves.

๐Ÿ  Home Page

The main interface where users can upload documents and interact with the AI assistant.

screenshots/home.png

๐Ÿ“ค Upload PDF

Upload one or multiple PDF documents.

screenshots/upload.png

๐Ÿ’ฌ AI Chat

Ask questions about uploaded documents using natural language.

screenshots/chat.png

๐Ÿ“š Rich Source References

Every response includes supporting document references.

screenshots/sources.png

๐Ÿ“‚ Document Manager

Manage uploaded documents and maintain your knowledge base.

screenshots/sidebar.png

๐Ÿ”ฎ Future Roadmap

The following features are planned for future releases.

๐Ÿš€ Version 1.1

  • โšก Streaming AI Responses
  • ๐Ÿ“„ Page-aware Source References
  • ๐Ÿ“Š Knowledge Base Dashboard
  • ๐Ÿ“ˆ Similarity Score Display

๐Ÿš€ Version 1.2

  • ๐Ÿ“‘ PDF Preview
  • ๐Ÿ“ค Export Chat (PDF & Markdown)
  • ๐ŸŽจ Improved User Interface
  • ๐ŸŒ™ Dark / Light Theme

๐Ÿš€ Version 2.0

  • ๐ŸŒ Multi-user Authentication
  • โ˜ Cloud Deployment
  • ๐Ÿณ Docker Compose Support
  • ๐Ÿ” Hybrid Search (Semantic + Keyword)
  • ๐Ÿ“‚ DOCX & TXT Support
  • ๐ŸŽ™ Voice Input
  • ๐Ÿ”Š Text-to-Speech Responses

๐Ÿค Contributing

Contributions are welcome!

If you'd like to improve this project:

  1. Fork the repository.
  2. Create a new branch.
git checkout -b feature/my-feature
  1. Commit your changes.
git commit -m "Add my feature"
  1. Push your branch.
git push origin feature/my-feature
  1. Open a Pull Request.

๐Ÿž Reporting Issues

If you find a bug or want to request a feature, please create a GitHub Issue.

Please include:

  • Operating System
  • Python Version
  • Error Message
  • Steps to Reproduce

๐Ÿ“š Learning Outcomes

This project demonstrates practical experience with:

  • Python Development
  • Streamlit Applications
  • Retrieval-Augmented Generation (RAG)
  • Semantic Search
  • Vector Databases
  • Local Large Language Models
  • Software Architecture
  • Git & GitHub
  • AI Application Development

๐Ÿ“œ License

This project is licensed under the MIT License.

See the LICENSE file for details.


๐Ÿ‘จโ€๐Ÿ’ป Author

Sagar Soni

AI & Machine Learning Enthusiast

Interested in:

  • ๐Ÿค– Artificial Intelligence
  • ๐Ÿง  Machine Learning
  • ๐Ÿ“„ Retrieval-Augmented Generation (RAG)
  • ๐Ÿ’ฌ Large Language Models
  • ๐Ÿ Python Development

GitHub:

https://github.com/sagarsoni7254-eng


๐Ÿ™ Acknowledgements

This project would not have been possible without the amazing open-source community.

Special thanks to:

  • Python
  • Streamlit
  • Ollama
  • Qdrant
  • Sentence Transformers
  • PyMuPDF
  • GitHub

โญ Support

If you found this project useful:

โญ Star this repository

๐Ÿด Fork the project

๐Ÿ’ฌ Share your feedback

Your support motivates future improvements.


๐Ÿค– AI PDF Assistant

Built with โค๏ธ using Python, Streamlit, Ollama and Qdrant


Thank you for visiting this repository!

โญ If you like this project, please consider giving it a star.

About

A Local AI PDF Assistant built using Streamlit, Ollama, Qdrant and RAG.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages