← Back to Projects

RAG Financial Accounting

Retrieval-Augmented Study Chatbot

This project started as a way to help my brother study for his Financial Accounting course. Instead of searching through dozens of slides for every doubt, he can ask a question in plain language and get an answer grounded in his own course notes.

It is a small RAG (Retrieval-Augmented Generation) system with a web chatbot: the most relevant passages from the notes are retrieved, and an AI model answers using only those passages, citing the source PDF and page so every answer can be checked against the original material.

How It Works

documents/*.txt ──► rag_creator.py ──► chroma_db/  (vector database)
                     split into chunks,
                     compute embeddings
                                            │
question ──► chatbot.py ──► top 4 chunks ───┘
                  │
                  └──► AI API (question + chunks) ──► answer with sources

Pipeline

1. Chunking
The course notes are split at every label line, so each chunk is one slide or page of the course. The source and page are stored as metadata and kept in the chunk text so the model can cite them.
[TEMA: Financial Accounting, FONTE: 4. Inventories.pdf, página 3]
# Slide title
- content...
2. Embeddings
Each chunk is turned into a vector with intfloat/multilingual-e5-small, a small multilingual model that works well for both Portuguese and English. It runs locally on CPU, for free.
3. Storage
Vectors are stored in a local ChromaDB vector database.
4. Answering
The question is embedded, the 4 closest chunks are retrieved and sent to the AI model with instructions to answer only from that context. The retrieved sources are shown under each answer.

Tech Stack

Language:
Python 3.10+
Embedding Model:
multilingual-e5-small (local)
Vector Database:
ChromaDB
Interface:
Gradio web chatbot
LLM:
gpt-4.1-mini (default)
Providers:
Any OpenAI-compatible API (Groq, OpenRouter, Gemini)

Known Limitations

  • Some topics, such as Taxes and Leases, only have a one-page summary in the notes, so answers on those topics are less detailed.
  • Retrieval uses only the current question, so vague follow-ups like "and the other one?" may retrieve the wrong passages. Complete questions work best.