This project is a local API that allows you to upload a PDF, automatically index its content using FAISS and SentenceTransformers, and ask semantic questions answered by a local LLM (Mistral 7B Instruct via llama-cpp-python
).
- Upload and validate PDF files
- Extract and chunk text from PDF
- Create vector index (FAISS +
all-MiniLM-L6-v2
) - Ask semantic questions using a local Mistral model
- No internet required — works fully offline after model download
pdf_qa_api/
├── app/
│ ├── main.py
│ ├── pdf_utils.py
│ ├── vector_store.py
│ ├── llm_interface.py
│ └── config.py
├── models/
├── uploads/
├── requirements.txt
└── README.md
- Clone this repo
- Download a
.gguf
model (e.g. Mistral 7B Instruct) intomodels/
- Install dependencies:
pip install -r requirements.txt
- Run the API:
uvicorn app.main:app --reload
- Open the docs: http://localhost:8000/docs
POST /upload_pdf
: Upload a PDF (max 10MB) → triggers indexingGET /answer?question=...
: Ask a semantic question about the PDF
- FastAPI
- PyMuPDF
- sentence-transformers
- faiss-cpu
- llama-cpp-python
- Validates MIME type and size
- Refuses non-PDF files
This project is licensed under the MIT License - see the LICENSE file for details.