Skip to content
Nelson D’SouzaEmail me

Self-hosted chess tutor

Chess Tutor

A chess tutor where the engine establishes every fact, lessons are pitched to how players at your rating really play, and a local model only puts the engine’s facts into words.

what it does

  • The engine decides every fact

    Moves, evaluations and tactics come from Stockfish and python-chess.

  • Graded without a model

    Every answer is a square, a move or a count, checked exactly.

  • Pitched to how people at your rating play

    Maia2 predicts the moves a player at your level picks; Stockfish says which of them hold.

  • The model only phrases engine facts

    A sentence that names anything the engine did not establish is dropped. Token containment only; facts still have to carry their relations.

the engine’s facts

Board after 5...Nxd5 in the Fried Liver: White’s knight on g5 can take on f7RBQKBRNNNBRNBQKR
Stockfish
5…Nxd5 costs about 8% of expected score, under the inaccuracy line. White’s point now is Nxf7 or d4, not the model’s O-O.
Maia2 + Stockfish, a student at 1100
Few players at this level survive the line. After the book move 5…Na5, most do.
Redrawn from the design notes and the fact tests
Engraving of the Turk chess automaton: a turbaned figure in a fur-trimmed robe sits behind a cabinet with a chessboard on top, its doors and drawer open to show gears, levers and a tray of chessmen inside
Its ancestor: The Turk, chess automaton, Racknitz plate, 1789. Joseph Friedrich zu Racknitz, Public domain

The problem

I asked a capable local model three questions about a well-known opening position. It got all three wrong, including a capture of a pawn that was no longer there and the opponent’s threat given as the position’s tactic, and it sounded sure each time. A beginner cannot catch that.

How it fits together

Where each chess fact comes fromArchitecture diagram with 9 nodes, 8 connections. Each step is listed as text below.Phones andbrowsers, over atailnetPython app, a localserviceStockfish +python-chessMaia2Local model viallama.cppNames onlyengine facts?Commentary on theboardGlicko + FSRSPostgresa move or an answerpositionposition + ratingfacts onlya sentenceyesexact graderating, schedule
  1. Phones and browsers, over a tailnet to Python app, a local service: “a move or an answer”
  2. Python app, a local service to Stockfish + python-chess: “position”
  3. Python app, a local service to Maia2: “position + rating”
  4. Stockfish + python-chess to Local model via llama.cpp: “facts only”
  5. Local model via llama.cpp to Names only engine facts?: “a sentence”
  6. Names only engine facts? to Commentary on the board: “yes”
  7. Python app, a local service to Glicko + FSRS: “exact grade”
  8. Glicko + FSRS to Postgres: “rating, schedule”
Where each chess fact comes from A sentence that names anything outside the facts it was given is dropped. With the model offline, the board shows the bare facts. Token containment does not verify relations between licensed facts.

What I built

Stockfish and python-chess produce the facts: legal moves, evaluations, what a move leaves hanging, and which of the tutor’s chess concepts a position shows. I build questions from templates over those facts, and every answer a student gives is a square, a move or a count, so grading is exact and needs no model. A test makes sure no question gives away its own answer.

I gave the language model one job: turning the engine’s findings into a sentence of commentary while you watch a game. It runs locally through llama.cpp, so no hosted model API is involved.

I measure difficulty against the student. Maia2 predicts which moves a player at a given rating will actually choose, Stockfish decides which of those hold, and together they estimate whether you survive the position a move creates. An engine calls some moves playable that an 1100 player loses almost every time.

A Glicko rating over puzzles sets the level, and FSRS spaced repetition schedules concepts rather than positions, so a weakness comes back in a new position instead of one you have memorised. Puzzles come from the Lichess corpus. Each student’s history lives in Postgres. I run the app as a service on my own machine, reached from phones over a private tailnet, with a server-held clock for games between two phones.

How it turned out

Running and in use, with a puzzle ladder, coached games against Maia, historical chapters and two-phone play. Aggregate Watch drop-rate and student learning-outcome measurements are not yet collected.

710 → 2.1 ms
to find puzzles near a rating, after cutting the Lichess corpus from 3.6 million puzzles to 242,537 in 64 MB.

Written about it

Built with

  • Python
  • Stockfish
  • python-chess
  • Maia2
  • llama.cpp
  • PostgreSQL
  • FSRS