How UAT reads a theory paper today
The exact deployed flow (Anant's v3 engine, live since 15 Sept evening) ā from the teacher's upload to an approved answer key. Verified against the running code on the box, 16 Sept 2026.
The one-paragraph version: the teacher's PDF is turned into photos of its pages. A vision AI (Gemini 3.1 Pro) looks at all the pages twice ā once to map the paper's skeleton (sections, question numbers, marks), once to copy out every question's words. The paper is then checked against itself: the total printed on the cover, the sum of the section totals, and the sum of the per-question marks must agree. Then a second AI (Luna, a GPT-class model with "thinking" on) writes a model answer + step-by-step marking scheme for each question, with real textbook passages pasted into its prompt when we have that subject's books. A teacher approves the key before any student sheet is marked. No OCR text engine runs in this flow ā Mathpix is dormant.
1 Ā· The full journey
flowchart TD
T["š©āš« Teacher uploads paper PDF
types name, subject, TOTAL MARKS"] --> G{"Gate checks
(cp-backend)"}
G -->|"AI plan active Ā· quota left
⤠30 pages · budget ok"| S3["PDF saved to S3
test row created (Draft)"]
G -->|any gate fails| RAW["Paper still uploads ā
just no AI answer key
(teacher told why)"]
S3 --> Q["Job queued
(Redis Ā· one paper at a time)"]
Q --> W["Worker picks the job"]
W --> CPAI["cp-ai Ā· /v1/extract
engine = v3"]
CPAI --> IMG["šø Pages ā JPEG photos
150 DPI Ā· no OCR text step"]
IMG --> C1["š§ CALL 1 Ā· STRUCTURE
Gemini 3.1 Pro (vision + thinking)
sees ALL pages at once"]
C1 --> SK["Skeleton: sections, question
numbers, marks, cover total"]
SK --> C2["š§ CALL 2 Ā· CONTENT
Gemini 3.1 Pro Ā· pages re-sent,
15 questions per call
copies every question's words"]
C2 --> REC{"āļø RECONCILE
cover total vs section sum
vs question sum"}
REC -->|two of three agree| OK["confidence OK"]
REC -->|they disagree| DIS["confidence DISAGREE
š“ never auto-approved"]
OK --> DB["Questions stored in Postgres
teacher sees them appear"]
DIS --> DB
DB --> AK["š§ ANSWER KEY Ā· one call per question
Luna (GPT-class) Ā· thinking ON
prompt = question + options + figures
+ marks + š textbook passages (RAG)"]
AK --> J["Judge re-checks each scheme:
steps must add up to the marks"]
J --> REV{"clean?"}
REV -->|yes| AUTO["AUTO-APPROVED"]
REV -->|anything off| NEED["NEEDS REVIEW
with a plain-English reason"]
AUTO --> TEACH["š©āš« Teacher reviews & hits
APPROVE ANSWER KEY"]
NEED --> TEACH
TEACH --> GRADE["Only now do student sheets
get marked against the key"]
2 Ā· Who talks to whom, with what context
sequenceDiagram
participant T as Teacher (browser)
participant BE as cp-backend
participant S3 as S3
participant AI as cp-ai (v3 engine)
participant G as Gemini 3.1 Pro (vision)
participant L as Luna (answers)
participant B as š Textbook store (RAG)
T->>BE: PDF + subject + class + total marks
BE->>S3: store the PDF
BE->>AI: PDF bytes + hints (subject, class, teacher's total)
AI->>AI: render pages ā JPEG photos (150 DPI)
AI->>G: ALL page photos + "map this paper" prompt
G-->>AI: sections Ā· numbering Ā· marks Ā· cover total
AI->>G: same photos + skeleton + "copy out Qs 1ā15"
G-->>AI: full question text (repeat per 15-question chunk)
AI->>AI: reconcile the paper's 3 totals ā confidence
AI-->>BE: questions + sections + marks + verdict
BE-->>T: questions appear on the Answer Key tab
BE->>AI: write the key (per question)
AI->>B: find matching textbook passages
B-->>AI: relevant paragraphs (when the subject has books)
AI->>L: question + options + figure + marks + passages
L-->>AI: model answer + marking scheme (steps sum to marks)
AI->>AI: judge: does the scheme add up?
AI-->>BE: key + AUTO-APPROVED / NEEDS-REVIEW + reason
BE-->>T: "38 of 38 answers written" ā teacher approves
3 Ā· The models, in plain words
| Job | Model | What it's given | What it returns |
| Read the paper's shape (structure call) | gemini-3.1-pro-preview ā a vision LLM, thinking on | Photos of every page + a prompt asking for the paper's map | Sections as printed, each question's number & marks, the cover total |
| Copy the questions out (content calls) | same Gemini, fresh calls | The same page photos again + the map + "transcribe questions NāM" | Every question's exact words, options, passages |
| Split section totals | small text call (its own slot) | "Section Q.2 is 16 marks over 8 questions" | 2 marks each ā flagged as worked out, not printed |
| Write each answer | Luna (GPT-class, via OpenRouter), thinking on, prompt theory_vision_answer@v4 | One question + its options/figure + its marks + textbook passages | Model answer + step marking scheme whose steps add up |
| Check the answer | judge pass | The scheme it just wrote | "adds up" ā auto-approve Ā· anything else ā NEEDS REVIEW + reason |
Is OCR used? Not in this flow. There is no text-extraction engine in the middle ā the vision LLM reads the page photos directly, the way a person reads a printed page. Mathpix (the math-OCR service) is still installed but dormant: it only ever ran on older paths, and the v3 engine takes every paper before Mathpix is reached.
4 Ā· The self-check that guards the total
flowchart LR
A["Cover says
Max. Marks: 80"] --- X{"must
corroborate"}
B["Section totals
16+4+16+18+8+15+3"] --- X
C["Per-question marks
added up"] --- X
X -->|"two of three agree"| OK2["ā
read is trusted"]
X -->|"they disagree"| BAD["š“ DISAGREE ā
key can never auto-approve,
teacher is pointed at it"]
Why this matters (yesterday's lesson): the older pipeline read an 80-mark paper as 60 and nothing shouted, because no two independent totals were compared. v3's whole design bet is that a paper carries its own answer key for "did you read me right?" ā three numbers printed in different places that must agree. Measured on the eval corpus: 91.3% exact totals.
5 Ā· What each piece stores / owns
| Piece | Owns | Layman's role |
| cp-backend | test row, question rows, S3 files, the queue, all gates | The clerk: checks entitlements, files everything, never reads the paper itself |
| cp-ai | the reading + answering brains, model choices, retries | The examiner: reads the paper, writes the key, says how sure it is |
| Gemini 3.1 Pro | ā | The eyes: sees page photos, maps and transcribes |
| Luna | ā | The subject teacher: writes each answer and its step marks |
| Textbook store | book passages per subject/class | The library: real pages quoted into the answer prompt so the key isn't from memory alone |
| Teacher | the final say | Nothing is graded until they press Approve |