An interactive PDF chatbot that lets you upload multiple PDF documents and query their content using a local LLM (TinyLlama via Ollama). Built with Gradio for the UI and LangChain for retrieval and embeddings.
- Upload and parse multiple PDFs
- Semantic search over PDF contents
- Summarize documents
- Streaming responses from a local LLM (TinyLlama)
- Local-only architecture (no cloud APIs required)
- Beautiful Gradio interface with custom styling
- Dynamic updates when PDFs are removed from the upload list
project/
│
├── gradio_UI.py # Main Gradio user interface
├── pdf_loader.py # Load and parse PDFs into LangChain documents
├── text_splitter.py # Split documents into chunks for embedding
├── vector_store.py # Build and manage FAISS vector store
├── chatbot.py # Semantic search over vector store
├── ollama_stream.py # Streaming integration with Ollama LLM
├── README.md # Project documentation
-
Upload PDFs
- Each PDF is split into smaller text chunks.
- Chunks are embedded using sentence-transformers (MiniLM).
- All embeddings are stored in a local FAISS vector database.
-
Ask Questions
- User queries are converted to embeddings.
- FAISS retrieves the most relevant chunks.
- Context is passed to TinyLlama via Ollama’s local API.
-
Get Streaming Answers
- Responses from TinyLlama stream back into the UI in real-time.
- The UI shows sources and page numbers used for the answer.
- Clone the repository
git https://github.com/l-amarante-99/code_challenge.git
cd code_challenge- Create a virtual environment
Recommended: Conda:
conda create -n pdfbot python=3.10
conda activate pdfbot- Install dependencies
pip install -r requirements.txtDependencies include:
- gradio
- langchain
- sentence-transformers
- langchain_community
- httpx
- PyMuPDF
- faiss-cpu
- Install and run Ollama
See Ollama installation guide.
Start Ollama:
ollama servePull TinyLlama:
ollama run tinyllamapython gradio_UI.pyVisit http://localhost:7860 in your browser.
All processing is entirely local:
- No PDFs are uploaded to external servers.
- LLM runs locally via Ollama.
- “Summarize the text.”
- “What are the key findings in the paper?”
- “What methods did the authors use?”
- “What are the conclusions of the paper?”