Ask your business data questions in plain English and get back the answer, the SQL, and a chart in seconds. Everything runs on your own machine, so no data ever leaves your computer.
This is an agentic AI system that converts natural language into SQL, runs it against a local database, fixes its own failed queries, and visualizes the result, all powered by a local LLM through Ollama.
In most companies, business teams cannot get answers from their own data without help. Every question, such as "which region is losing money", goes into a queue to a data analyst and comes back days later. The obvious shortcut of pasting data into ChatGPT or Claude is often not allowed, because sensitive financial and customer data cannot be sent to a third party cloud AI. The result is that the people who need answers are stuck waiting, while the data team drowns in repetitive ad hoc requests.
I built a self hosted analyst that anyone on the team can use, with no SQL knowledge required.
- The user asks a question in plain English.
- A local LLM (qwen2.5-coder:7b) receives the database schema and writes a SQL query.
- The query runs against a local SQLite database.
- If the SQL fails, the system feeds the error back to the model and retries automatically. This is the agentic self correction step.
- The result is shown as both a table and an interactive chart.
Because the model runs locally through Ollama and the database stays on the machine, no business data ever leaves the device. That directly removes the privacy blocker that stops teams from using cloud AI.
Architecture:
User question (English)
|
v
Local LLM (Ollama, qwen2.5-coder:7b) generates SQL from schema
|
v
SQLite (superstore.db) executes query
| | on error
| v
| feed error back, LLM rewrites the SQL (auto retry)
v
Table plus interactive Plotly chart
- Questions that would normally sit in an analyst queue for days are now answered in seconds, directly by the person who needs them.
- The whole system runs fully offline, so it works in exactly the environments where cloud AI is banned for compliance reasons.
- A failed query no longer blocks the user, because the agent rewrites broken SQL on its own before the user ever sees an error.
- The project is open sourced under MIT, so any team can clone it, point it at their own database, and run it without sending data anywhere. It is tested on the Sample Superstore dataset (9,994 rows).
| Layer | Tool |
|---|---|
| LLM (local) | Ollama, qwen2.5-coder:7b |
| Data | SQLite (Sample Superstore, 9,994 rows) |
| App and UI | Streamlit with custom CSS |
| Charts | Plotly |
Prerequisites: Python 3.11 or newer, and Ollama installed (https://ollama.com/download).
# 1. Clone
git clone https://github.com/FaizarM/Local-AI-Data-Analyst.git
cd Local-AI-Data-Analyst
# 2. Install dependencies
pip install -r requirements.txt
# 3. Pull the local model
ollama pull qwen2.5-coder:7b
# 4. Build the database from the CSV
python load_data.py
# 5. Run the app
streamlit run app.py
Open the URL that Streamlit prints, usually http://localhost:8501.
I am a data science student, and I keep seeing the same gap. Companies sit on data they cannot easily query, and the privacy rules around cloud AI make the easy shortcuts off limits. I wanted to prove that you can give a team a real, useful AI analyst without handing their data to anyone. This is my take on what an AI system that actually ships should look like: local, private, and solving a problem that someone actually has.
MIT