Data and AI

PDF Q&A Bot (RAG System)

Upload a PDF to a Streamlit app, ask questions in plain English, and get answers with the pages they came from, retrieved from a FAISS index of sentence-transformers embeddings. It tries OpenAI, then a local Ollama server, and with no LLM configured it still answers with the retrieved passages verbatim.

Stack
Python, FAISS, sentence-transformers, Streamlit
Code
github.com/ADM1SH/pdf-qa-rag-bot

Overview

Install

  1. Install the dependencies.
pip install -r requirements.txt
  1. Write the sample PDF to sample_docs/handbook.pdf.
python generate_sample_pdf.py
  1. Run the smoke test to ingest the PDF and retrieve the right page.
python test_ingest.py
  1. Start the Streamlit app.
streamlit run app.py

To get LLM-composed (rather than extractive) answers, set OPENAI_API_KEY or run Ollama locally (ollama serve + ollama pull llama3) before asking questions.

Docs

The full documentation covers how it works, configuration and results.