#๐ Advanced PDF Assistant with GPU Acceleration Using llama cpp (for multiple pdfs)
A powerful AI-powered PDF assistant that leverages GPU acceleration for fast document processing, summarization, question-answering, and comparison. Built with Gradio for an intuitive web interface and powered by local LLMs via llama-cpp-python.
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install -y tesseract-ocr tesseract-ocr-eng poppler-utils
macOS:
brew install tesseract poppler
Windows:
git clone https://github.com/M-e-h-18/Offline-pdf-chatbot-and-analyser.git
cd Offline-pdf-chatbot-and-analyser
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
For NVIDIA GPU acceleration:
pip install torch>=2.0.0+cu118 --index-url https://download.pytorch.org/whl/cu118
CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python --upgrade --force-reinstall --no-cache-dir
python app.py
The application will:
http://localhost:7860The application can be configured by modifying the Config class in app.py:
class Config:
MAX_TOKENS_CHUNK = 1000 # Chunk size for processing
OCR_DPI = 200 # OCR resolution
OCR_LANG = 'eng' # Tesseract language
EMBED_BATCH_SIZE = 4 # Embedding batch size
LLM_N_CTX = 2048 # Context window size
CACHE_SIZE = 5 # Number of PDFs to cache
GPU_LAYERS = -1 # GPU layers (-1 = all)
N_THREADS = 4 # CPU threads
The application automatically downloads these models on first run:
Models are stored in the models/ directory and only downloaded once.
Models not downloading:
models/ directory permissionsOCR not working:
tesseract --versionGPU not detected:
nvidia-smiOut of memory errors:
EMBED_BATCH_SIZE in configLLM_N_CTX sizeThe application logs to both console and pdf_assistant.log file. Check logs for debugging information.
This project is licensed under the MIT License - see the LICENSE file for details.
Gradio for the web interface
llama-cpp-python for LLM inference
PyMuPDF for PDF processing
Tesseract for OCR capabilities
Hugging Face for model hosting
https://www.kaggle.com/code/liv0oid/notebook848a56a6fb/edit(kaggle notebook link)
Note: This application processes PDFs locally on your machine. No data is sent to external servers, ensuring your document privacy and security.
#๐ Advanced PDF Assistant with GPU Acceleration Using llama cpp (for multiple pdfs)
A powerful AI-powered PDF assistant that leverages GPU acceleration for fast document processing, summarization, question-answering, and comparison. Built with Gradio for an intuitive web interface and powered by local LLMs via llama-cpp-python.
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install -y tesseract-ocr tesseract-ocr-eng poppler-utils
macOS:
brew install tesseract poppler
Windows:
git clone https://github.com/M-e-h-18/Offline-pdf-chatbot-and-analyser.git
cd Offline-pdf-chatbot-and-analyser
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
For NVIDIA GPU acceleration:
pip install torch>=2.0.0+cu118 --index-url https://download.pytorch.org/whl/cu118
CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python --upgrade --force-reinstall --no-cache-dir
python app.py
The application will:
http://localhost:7860The application can be configured by modifying the Config class in app.py:
class Config:
MAX_TOKENS_CHUNK = 1000 # Chunk size for processing
OCR_DPI = 200 # OCR resolution
OCR_LANG = 'eng' # Tesseract language
EMBED_BATCH_SIZE = 4 # Embedding batch size
LLM_N_CTX = 2048 # Context window size
CACHE_SIZE = 5 # Number of PDFs to cache
GPU_LAYERS = -1 # GPU layers (-1 = all)
N_THREADS = 4 # CPU threads
The application automatically downloads these models on first run:
Models are stored in the models/ directory and only downloaded once.
Models not downloading:
models/ directory permissionsOCR not working:
tesseract --versionGPU not detected:
nvidia-smiOut of memory errors:
EMBED_BATCH_SIZE in configLLM_N_CTX sizeThe application logs to both console and pdf_assistant.log file. Check logs for debugging information.
This project is licensed under the MIT License - see the LICENSE file for details.
Gradio for the web interface
llama-cpp-python for LLM inference
PyMuPDF for PDF processing
Tesseract for OCR capabilities
Hugging Face for model hosting
https://www.kaggle.com/code/liv0oid/notebook848a56a6fb/edit(kaggle notebook link)
Note: This application processes PDFs locally on your machine. No data is sent to external servers, ensuring your document privacy and security.