Build a natural-language analytics assistant that grounds a local open-weight model in governed definitions, checks every generated SQL statement before it runs, lets the database enforce each reader's access, and measures answers by comparing query results.
Generative AI Engineer. Advanced.
For developers who write Python and SQL with joins and use Docker Compose, and want to let people ask a data warehouse questions in plain English with a local model, without letting the model decide what anyone may see.
This project builds an assistant that answers questions about a retailer's sales in plain English, by writing SQL with a model that runs on your own computer. You do not need any background in language models, model serving or database security: the lessons teach those. You do need a few skills and a computer that can hold the model. This page says exactly which, and how to check each one before you start.
"Which North stores had the largest drop in net sales last month?" sounds like one query. Answering it safely needs four decisions the question does not state: what net sales means, which dates last month covers, which stores this person may see, and whether the SQL a model writes is safe to run. This page shows where each of those decisions is made, follows one question from the browser to the answer, and then covers how the system is changed, operated and recovered.
"Text-to-SQL" means turning a question in ordinary language into a SQL query and running it. Modern code models are good at it: give one a table definition and "total sales by region last month" and you will usually get a sensible query. The word "usually" is the subject of this lesson. Before building anything, it helps to list the specific ways an assistant like this goes wrong, because each part of the design exists to catch one of them, and the evaluation is built to meas
Ask three people at Harbourline Outfitters for "sales last month" and you can get three numbers. The store manager means what went through the tills. Finance means revenue after discounts and refunds, on completed orders only. Someone else is thinking of the fiscal month, which at Harbourline does not line up with the calendar month. None of them is wrong; they are using different definitions.
The assistant needs a model that reads a question and the semantic layer and writes one PostgreSQL query. This project runs that model on your own computer, on the CPU, with no API key and no data leaving the machine. This lesson explains what is actually running when the llm container starts, how a request becomes tokens and tokens become JSON, and what the JSON schema in each request does and does not promise.
The semantic layer tells the model what the data means. That is often not enough for a 7B model to write the SQL Harbourline expects: which join to use for "fiscal quarter", how to compare two months side by side, how to name the output columns. People learn those conventions from examples, and so do models. This lesson builds the full prompt the assistant sends for one question: the instructions, the definitions, a handful of reviewed examples found for this question, and th
The model has returned a well-formed decision with "action": "query" and a SQL string. That string came from a language model that read untrusted text. It may be exactly right, subtly wrong, or something nobody asked for: a second statement after a semicolon, a DELETE, a call to pg_sleep(30), a query against the customer table. This lesson builds the check that every statement passes before the database sees it, and explains why it parses the SQL instead of searching the text
The North manager asks, "What were Coast net sales last month?" The checker passes the model's SQL: it reads sales_lines, an allowed view, with allowed functions. Should the assistant answer?
An assistant that always produces a number is dangerous: some questions are ambiguous, some cannot be answered from this data, and some first attempts are simply wrong. This lesson follows a question through the decision loop in nlq/pipeline.py and explains each way it can end: an answer, a clarifying question, a decline, a permission refusal, a bounded repair, or a failure that says so. The point is that every ending is distinct, so the reader, the logs and the evaluation ca
A table of numbers answers the question, but readers like a sentence: "North had the highest net sales in July, 182,410.55." The same model that wrote the SQL can write that sentence from the result. It can also write "North's sales doubled", when the result says nothing about the previous month, or round 182,410.55 to "about 190,000". The sentence would be the first thing the reader reads and the least checked thing on the page.
You change one line of the semantic layer, or swap the model for a newer one, or add ten curated examples. Is the assistant better or worse? Trying a few questions by hand tells you how it did on those questions, today, as you remembered to check them. This lesson builds the measurement the project relies on instead: versioned sets of questions with known answers, run through the real assistant, compared by result, with gates that a change must pass.
The earlier lessons follow one question through the assistant. Running it for real readers adds the questions an operator asks: who is calling, what is safe to write in a log, how answers are reviewed and how good ones improve later answers, how many readers one machine can serve, and how to change the model or the definitions without finding out in production that answers got worse. This lesson covers each, as this project implements it, and says where a production deploymen
Starting point: nothing yet. End point: you know your computer has the cores, memory, disk, tools and free port the lab needs.
Starting point: a checked computer and the source folder. End point: the assistant image exists and its unit tests and linters pass, with networking turned off.
Starting point: the image. End point: state/ holds the passwords and reader tokens, data/ the synthetic warehouse, and models/ the verified model file.
Starting point: state, data, model and image. End point: PostgreSQL, the model server and the assistant are running and healthy on one Compose network, with only the assistant published on your loopback interface.
Starting point: a healthy stack. End point: you have seen the same question answered with different rows for different readers, and questions that end in a clarification, a decline or a refusal.
Starting point: a healthy stack. End point: the stack tests have shown, against the real database, that access is enforced whatever SQL arrives.
Starting point: a healthy stack. End point: reports that say how often the assistant is right, by category, for this model and these definitions, and whether it passes its gates.
Starting point: answered requests in the database. End point: one answer you have checked is in the example library, where later similar questions retrieve it.
Starting point: a working stack and a report for each split. End point: you have added a metric, measured it on the dev and held-out splits, and either kept it or gone back.
Starting point: the lab, finished. End point: nothing of this project remains on your computer except the source folder.
Learning Access: INR 199 plus 18% GST. Source Pack: INR 399 plus 18% GST. 90 days of online access. No auto-renewal.
Runs entirely on your computer with Docker Compose: about 6 GB of downloads (a 4.7 GB model file and three container images) and a synthetic warehouse generated locally. No cloud account, API key, payment method or hosted lab is used or included. The model runs on your CPU; the timings quoted in the lessons were measured on an 8-vCPU Graviton cloud virtual machine, and reproducing them on similar hardware is optional and at your own cost.
Vectametric Project Source Licence (2026-09-27): lawfully obtained source may be copied, modified and deployed for personal learning and interview preparation, including personal portfolio demonstrations with attribution. These permissions continue after online access expires. Do not resell or redistribute the Source Pack or its original source files, unchanged or modified. Commercial or client production use requires separate written permission. The model file, container images and Python packages downloaded when building or running, such as Qwen2.5-Coder, llama.cpp, PostgreSQL, FastAPI, psycopg and sqlglot, retain their own licences. See LICENSE.txt and the Project Source Licence section of the site Terms for the full rules.
You can read the project material without deploying it. Running a cloud build requires the accounts, permissions and tools listed in that project's prerequisites. Deployment runs in your environment, not in a hosted Vectametric lab.
Yes. Learning Access includes the online source-file browser and explanations. The Source Pack adds the downloadable reference repository where available. The project's licence governs use of the source.
No. Cloud and CI usage are separate. Read the project's cost notice, set a budget and stop deadline, and follow its destruction and leftover-resource checks.
The project curriculum lists the available scenarios and interview topics. These focus on understanding the architecture and explaining decisions; they are not a promise of particular interview questions or a job.
The project page and checkout show the online access period for your selected plan. Access does not auto-renew. Downloaded source remains subject to its licence; future releases are not automatically included.
Review the Terms and No-Refund Policy before confirming access. All sales are final; Vectametric does not offer refunds.
Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy