Sulaiman Shariff

personal

Notes Generator

Turns a physics chapter into notes you can actually revise from, with diagrams a vision model has checked.

Role
Engineer, Cognivo OPC
When
2026
Built with
Python, Gemini, Typst, Manim
Result
3attempts before a section ships without its diagram
Page one of generated notes on Current Electricity, with a chapter summary panel, a definition callout and the formula I equals Q over t set in its own panel.
The head of page one of a generated chapter. Typeset with Typst from a structured document, not rendered from markdown.

Summarising a chapter is easy and produces something useless: a shorter version of the textbook you already could not face reading. The target here was different, a page a student can revise from the night before an exam.

That target drove almost every decision. Content is written as typed blocks rather than continuous prose: definitions, comparison tables, worked examples, warnings, connections to things the student already knows. No more than two paragraphs may run consecutively. Key terms are emphasised so the page can be skimmed. Equations are set large and on their own. A page of unbroken text has failed, however accurate it is.

A generated page on resistivity, with a definition callout, a worked comparison to copper and nichrome, and a table contrasting metals and semiconductors.
One page, six block types. The table is doing the work a paragraph about metals and semiconductors would have done badly, and the copper-versus-nichrome comparison is there to attach the definition to something a student has seen.

The diagram loop

Roughly a third of sections carry a diagram, and diagrams are where generated material usually falls apart. Labels overlap. Arrows point at nothing. The figure restates the caption instead of adding to it.

So generated figure code is statically checked, rendered, and then shown to a vision model that judges it against the section it belongs to. If it is rejected, the feedback goes back into a regeneration, up to three times.

An accepted diagram showing a series circuit and a parallel circuit side by side, each with two resistors, a cell, and the equivalent-resistance formula beneath it.
Accepted on the first pass. Two circuits, drawn to the same scale so they can be compared, with the rule for each written underneath.

The more interesting outcome is the other one. After three attempts the document ships without that figure rather than with a bad one, and in the physics chapter that is exactly what happened to section one: four sections planned a diagram, three got one, and the opening section gave up.

A rejected diagram of electron drift in a conductor, with electron markers colliding with the positive ion markers behind them and a subscript that failed to typeset.
The best of the three attempts at that section, and still rejected. Electrons collide with the ions they are drifting past, and the drift velocity is labelled v_d because the subscript never typeset. The other two attempts crashed before rendering anything at all.

Half price, and safe to resume

Generating thirty chapters one at a time is slow and costs full price. The Gemini Batch API is half price, so chapters are processed in waves, outline, then sections, then classification, then code generation and gating, which turns thirty end-to-end pipelines into four or five provider round trips.

Batching introduces a nastier failure mode than it removes. Batch creation is not idempotent, and a batch is billable the moment it is created, so a retry after a timeout can quietly bill twice. The fix is that every job gets a deterministic name and an intent row written before creation, duplicates are cancelled on discovery, and a budget cap is enforced before submission rather than after.

Anything the batch does not return falls back to synchronous full-price generation, so no document ships with holes in it.

$0.03
per chapter$0.06 with diagrams, measured from traces
27
diagram attempts across five runs23 of them rendered
2
chapters carried end to endphysics and history

Why Typst

Markdown to PDF gives you a web page printed on A4. Typst is a real typesetting system, so the output has proper measure, hanging punctuation, and equations set at a size you can read across a desk. Content is stored as a structured document with stable section and block identifiers, which means a review pass can address one field of one block, and re-rendering costs nothing because the generation is already paid for.