RAG Sales Analysis
Ask business questions about a sales dataset in plain English, fully offline.
Overview
A local question-answering app over the Superstore sales dataset (9,994 orders, 2014–2017). It runs entirely on your machine: sentence-transformer embeddings, ChromaDB and Llama 3 through Ollama, with a FastAPI backend and a Streamlit front end. It's a compact, readable example of a RAG pipeline and of the problems you hit when you point one at tabular data.
How it works
- Two kinds of documents in the vector store: pre-computed summaries (totals, rankings and trends) and one short sentence per order row.
- A keyword classifier routes each question. Analytical questions ("which region is most profitable?") go to the summaries, and lookups ("profit for order CA-2017-115805") go to the rows.
- The retrieved context is passed to Llama 3 running locally in Ollama. No data leaves the machine.
Why the summaries matter
Retrieving individual rows can't answer "what is total profit by region?": the model would see a handful of rows and guess a total. Pre-computing aggregates and retrieving those instead is the main design decision here, and it's the part most worth copying.
Known limitations
- Each question is answered on its own, with no conversation history.
- Unusual combinations of dimensions fall back to row-level chunks and can give inaccurate totals.
- Slow when the model runs on a CPU.
Related projects
FinTax
Retrieval-first research on Finnish tax law: find the right provision before generating anything.
PDF Q&A Chatbot
Chat with your documents, with answers that cite their sources.