November 2026 · Project write-up
Building FastBreak an NBA stats assistant that shows its work
FastBreak answers plain-English questions about the NBA, like "What was the Warriors' regular season record in 2015-16?" or "Who has the most 20-point games off the bench?", from a database of every game since 2015-16 that updates every night. Under every answer it shows the SQL query it ran and the rows that query returned, so you never have to take its word for anything.
I wanted to build something where I couldn't hide behind a reply that sounds right. A stats question has one correct answer, so every claim the system makes can be checked, and that meant I had to measure it properly instead of trying it a few times and deciding it worked.
How it works
The data comes from NBA.com through the nba_api library. Loading every season's game log took about 100 seconds: 14,128 games and 300,879 player rows. Who started each game is only in the box scores, though, and that is about 14,000 separate requests, so that part ran overnight and had to survive NBA.com blocking me partway through. Each game is recorded as it loads, so a crash or a block just means the next run picks up where the last one stopped. A nightly job at 9am adds the new games and reloads the current season, because the NBA corrects stats after the fact.
The assistant itself is deliberately simple. A language model, qwen3:14b running on Ollama on my home PC with two graphics cards, writes a SQL query for the question. The query runs on a read-only connection with a 10 second limit. Then the model writes the answer from the rows, and a check holds the answer back if any number in it isn't in those rows. The web app is Next.js on Vercel, talking to an API on my PC through a Tailscale tunnel.
What I found
Score the rows, not the reply
Before building the assistant, I wrote 50 test questions with the SQL that answers them, and saved the rows each one returns. An answer only counts when the assistant's query returns the same rows. Reading replies and judging them would have been faster, and it would have hidden most of what I found below. I drafted the questions with Claude Code. I checked 12 of the answers against outside sources myself, and approved the other 38 on Claude Code's source checks, with each link written down next to the question.
Half the wrong answers had the right numbers
The first version got 20 of 50 right. When I went through the 25 wrong answers, 13 of them had the right values with the wrong labels: a team ID instead of the team, seconds instead of minutes, a game ID instead of the date. I added rules for how a result should look, which a real app needs anyway to display an answer, and the score went to 31 of 50. Comparing question by question, 12 got fixed and 1 broke, which is very unlikely to be luck.
Some wrong answers were my fault
Two of the answers I'd marked wrong were fair readings of my own questions. "The most points scored off the bench in a single game" can mean one player or a whole team's bench, and the model picked the team. I reworded both questions instead of pretending the model was wrong.
A setting was quietly deleting my prompt
Thinking mode, where the model reasons before it answers, roughly doubled the score on hard questions, from 5 of 15 to 11 of 15. But its replies ran past 9,000 tokens, and Ollama was using its default 4,096-token context. Past that limit it silently drops the oldest text, which was the database schema at the top of my prompt. Nothing errored. I fixed the context size, capped how long a reply can be, and re-ran everything. The score came out the same, 44 of 50, but until that re-run I couldn't have said so.
Accuracy costs time, and you have to choose
Thinking on gets 44 of 50 right but takes about 55 seconds a question. Thinking off gets 36 of 50 in about 6 seconds. I built a router where a quick call decides whether a question is hard, which got 40 of 50 at about 11 seconds. I also tried a small open model to make the simple questions faster, and it got 1 of 50.
Then the site went live, and the first hard question I asked on it took 83 seconds. The page sat on its first step the whole time, and from the outside it looked broken. So the live site switched to thinking off. It is right less often, but nobody waits a minute and a half wondering if it crashed. That was a product decision, not a technical one, and I wrote down why in the repo.
The check can't catch the wrong question
One of the first questions on the live site was "Who scored the most points in a game last season?", and it answered "Shai Gilgeous-Alexander, with 2531 points." That is his whole season. The query added up every game instead of taking the best one, and my number check passed, because 2531 really was in the rows. The check proves every number came from the data. It can't tell you the query answered a different question. That is exactly why the query and the rows are always on screen, and the miss is now in my test set. When I asked it again, it got it right (Bam Adebayo's 83), which is its own lesson: the model doesn't make the same mistake every time.
50 questions is a small test
36 of 50 sounds precise, but with 50 questions the true rate is anywhere from about 58% to 82%. One question moves the score by 2 points, and a re-run of the same setup flipped 3 questions each way. So I compare runs question by question instead of by the headline number, and the site gives its score as a count ("Right on 37 of 50 test questions" today, which means somewhere between 60% and 84%) rather than a percentage that sounds more certain than it is.
The data fails in ways you only see live
On the first night of the season, the nightly job recorded a game as failed because it was still in the first quarter. A week later the job crashed, because my PC had been off at 9am, so it ran in the evening while games were being played and NBA.com sent back a box score with no team stats yet. Each of these is written up in the repo with what happened, why, the fix, and the test that now catches it.
What I learnt
The main lesson was the same one cellar taught me, but sharper: decide how you'll measure something before you build it, and make the measure strict. Scoring by rows instead of by how a reply reads is what found the label problems, my own bad questions, and the context bug. The second lesson was to be honest about what a check can and can't do. "Every number is checked" is true, and it still let a confidently wrong answer through. The third was that accuracy, speed and how something feels to use pull against each other, and choosing between them is part of the job, not something the numbers decide for you.
I built this with Claude Code again, including the redesign of the web app, where every answer is laid out like a newspaper box score. The useful part wasn't the speed. It was asking it to show me the evidence for a result, and then checking that evidence myself before I believed it.
Adding a semantic layer
After launch, I added a semantic layer, built with dbt. It is a set of tested tables where the definitions an answer depends on are worked out once: minutes, home and away, wins, off the bench, double- and triple-doubles, per-game averages, and shooting percentages as total makes over total attempts. The model now queries those tables, and its prompt describes them with dbt's own descriptions, so each definition lives in one place.
The pitch for semantic layers is that they make models better at SQL. On the same 50 questions with thinking off, the raw tables scored 36. The first version of the layer also scored 36, and after two fixes to it, 38 and then 37. That is flat. FastBreak is four small tables, though, and my prompt already defined most terms. The big gains people report come from huge, messy schemas.
It moved the mistakes
The definition errors went away. It used to say the Celtics averaged 8 points a game, because it averaged over players instead of games. Now it says 120.6. But a new kind of mistake showed up. One table has a row for each team in a game, so every game appears twice, and the model counted rows instead of games: 118 overtime games in a season that had 59. Adding a table with one row per game fixed counting games, but tables like these still trip it up. Even after that fix, it told me the 2015-16 Warriors went 146-18. A semantic layer tells a model what a number means. It doesn't tell it what a row is.
What it did improve
Each right answer takes about a third less of the model's time, and queries that fail to run went from six in a run to one, because the model writes shorter queries when a definition is already a column. The live site answers from it now, and under the box score it prints a key: the tables the query read, what one row means in each, and the definitions it used.
Where it stands
FastBreak is live and answers from my PC whenever it's on. It gets 37 of 50 test questions right with thinking off, answering from the semantic layer in about 4 seconds. Next I want to grow the test set to 150 or 200 questions, mostly from what real people ask, so the score means more, and run each setup more than once. I also want to stop the double counting, and see whether fine-tuning a small model on this database can match the big one on simple questions, the way it did for cellar.
You can try it while my machine is on, and the code, the test set and every run's results are on GitHub.