Financial Document RAG Assistant is a local, multi-document RAG application for uploading and persistently indexing financial PDF reports. It uses BGE-M3 for multilingual semantic retrieval, ChromaDB for persistent vector storage, and Ollama for local LLM answer generation. The project includes a FastAPI backend, a Streamlit interface, and CLI tools. Every answer is returned with system-managed source file, page, and chunk metadata.
- PDF upload and persistent indexing
- Multi-document registry
- Document-specific Chroma retrieval
- BGE-M3 multilingual embeddings
- Local Ollama LLM support
- Focused answer context
- System-managed sources
- FastAPI document API
- Streamlit UI
- CLI tools
- Retrieval evaluation
- Cross-document leakage checks
Streamlit UI / CLI
↓
FastAPI
↓
Document Registry
↓
PDF Processing and Chunking
↓
BGE-M3 Embeddings
↓
Persistent ChromaDB
↓
document_id Filtered Retrieval
↓
Focused Context
↓
Ollama LLM
↓
Answer + System Sources
app/ Core backend application and orchestration
api/ FastAPI routes and request/response schemas
documents/ JSON-backed document registry
loaders/ PDF text extraction with page metadata
processing/ Text cleaning, chunking, and ingestion
rag/ Retrieval, context, prompts, and answer generation
services/ Document indexing and RAG service orchestration
vectorstore/ BGE-M3 embeddings, ChromaDB, and local vector utilities
ui/ Streamlit frontend and FastAPI HTTP client
scripts/ CLI, indexing, evaluation, and manual smoke tools
eval/ Retrieval evaluation questions
tests/ Unit, API, isolation, and UI smoke tests
learning_notes/ Development notes and engineering decisions
python -m venv venvWindows:
.\venv\Scripts\activatepip install -r requirements.txtPull the default local model:
ollama pull gemma3:4bThe Ollama application must be running before using the Ollama provider.
uvicorn app.main:app --reloadSwagger:
http://127.0.0.1:8000/docs
In a separate terminal:
streamlit run ui/app.pyOpen:
http://localhost:8501
- Upload a PDF.
- Index the document in ChromaDB.
- Select an indexed document.
- Ask a question.
- Review the answer and its source metadata.
GET /healthPOST /askPOST /documents/uploadGET /documentsPOST /documents/{document_id}/ask
Index a document:
python -m scripts.index_document --pdf-path data/raw/KPC_2026.05.pdfList indexed documents:
python -m scripts.index_document --list-documentsAsk a question:
python -m scripts.ask_pdf --question "Fonun yönetim ücreti nedir?" --llm-provider ollama --llm-model gemma3:4bPDF files are local runtime data and are not committed. Place the evaluation PDF under data/raw/ before running the command.
Single-document evaluation:
python -m scripts.evaluate_rag --pdf-path data/raw/KPC_2026.05.pdf --eval-path eval/rag_eval_questions.json --start-page 1 --end-page 3 --top-k 3 --use-cacheVerified result:
Pass rate: 100.00%
Average Precision@3: 0.7500
Average Recall@3: 1.0000
Average MRR@3: 1.0000
Average NDCG@3: 0.9599
Cross-document isolation is covered by automated document_id metadata-filter tests. A dedicated multi-document evaluation script and dataset are planned but are not included yet. The intended future command is:
python -m scripts.evaluate_multi_document_rag --eval-path eval/multi_document_eval.json --top-k 3 --relevance-mode strictNo multi-document leakage rate is reported because this evaluation has not been implemented and verified yet.
Question:
Fonun yönetim ücreti nedir?
Answer:
Fonun yönetim ücreti 7.125.856,54 TL'dir.
Sources:
- KPC_2026.05.pdf, page 3
- BGE-M3 embeddings are supplied directly instead of using Chroma's default embedding model.
- Document isolation is enforced with
document_idmetadata filters. - Only the most relevant chunks are included in the answer context.
- Source metadata is generated by the system rather than the LLM.
- Retrieval quality is evaluated independently from answer generation.
- Streamlit is implemented as a thin HTTP client over FastAPI.
- Table-heavy PDF extraction can still be noisy.
- The evaluation dataset is currently small.
- Local LLM answer quality depends on model capacity.
- Authentication and multi-user support are not included.
- The application is not financial advice.

