A clean Python project for building a Retrieval-Augmented Generation assistant over local PDF files.
This project lets you:
- Load one or more PDF files from a local folder
- Split the extracted text into searchable chunks
- Create an OpenAI embedding index using FAISS
- Ask questions against the indexed PDF content
- Optionally rerank retrieved chunks with Cohere
- Run a simple evaluation against your own test questions
pdf-rag-assistant/
├── data/ # Place your PDF files here
├── vector_store/ # FAISS index is saved here
├── src/
│ └── rag_pdf_assistant/
│ ├── __init__.py
│ ├── chat.py
│ ├── config.py
│ ├── evaluation.py
│ ├── indexer.py
│ ├── pdf_loader.py
│ └── prompts.py
├── main.py
├── requirements.txt
├── .env.example
└── .gitignore
python -m venv .venvWindows:
.venv\Scripts\activateMac/Linux:
source .venv/bin/activatepip install -r requirements.txtCreate a .env file in the project root:
OPENAI_API_KEY=your_openai_api_key_here
COHERE_API_KEY=optional_cohere_api_key_hereCohere is optional. If you do not add a Cohere key, the project will use normal FAISS similarity retrieval.
Place your PDFs inside the data/ folder.
python main.py buildpython main.py ask "What is this document about?"python main.py chatpython main.py evaluateDo not upload your .env file, API keys, or private PDFs. The .gitignore file already excludes common sensitive/local files.