The problem
AI grading is easy to demo and hard to trust. Models award more marks than a question allows, totals that do not add up, and confident feedback about sentences the student never wrote. A teacher needs to see what was written, where the problem is and exactly how many marks were lost.
How a paper gets marked
- Extract: the PDF becomes text with a bounding box for every run of characters, plus offsets into the flat text. Those offsets are the join key for everything after.
- Grade: the rubric, the model answer, the text and the PDF itself go to the model, which returns marks, evidence quotes and annotations against a strict JSON schema.
- Reconcile: the model's judgements are kept; its arithmetic is not. Totals are recomputed, marks are clamped, skipped rubric points are filled in, and every adjustment is recorded.
- Anchor: each quote is located in the paper (exactly, then by fuzzy word-window search, then by a distinctive-word fallback) and turned into per-line rectangles.
- Annotate: boxes are drawn over a copy of the paper with the correction in the margin. Annotations stay editable without re-marking.
The guarantees
- A mark never exceeds its rubric maximum and is never negative.
- Totals always equal the sum of their parts. This is asserted on the way out, and a breach throws instead of returning a wrong number.
- Marks awarded without a quote raise a flag. Quotes that cannot be located lower confidence instead of disappearing.
- The uploaded original is stored byte for byte and only ever read.
When things go wrong
A blank paper short-circuits before any model call. A model that is down, rate-limited or slow falls back to a deterministic offline grader and the result is labelled degraded. Malformed output gets a tolerant parse, one repair round-trip, then the offline grader. On Groq, which cannot see images, the two diagram questions are flagged for human review instead of guessed at.
Proof
The test answer paper is generated from code, so it and its error key can never drift apart. It contains 23 planted mistakes with an intended mark of 6 / 15, and the suite asserts that exact breakdown: a regression shows up as a failing test, not a plausible-looking wrong number.