DEV Community

Cover image for I Made Gemma Grade Its Own Homework (So I Don't Have to Trust It Blindly)
Javier Tan
Javier Tan

Posted on AI-assisted

I Made Gemma Grade Its Own Homework (So I Don't Have to Trust It Blindly)

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission πŸ’Έ

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle

What I Built

A worksheet generator for private tutors in Singapore, covering PSLE and O-Level subjects (Math, Science, English, A-Math, Physics, Chemistry, Biology β€” 8 subjects, ~90 syllabus topics).

Private tutors spend hours every week writing or hunting for practice questions, writing answer keys, and figuring out what each student should practise next. This tool does all three: it generates multiple-choice, short-answer and structured questions (with examiner-style mark schemes) against a real syllabus style guide, cross-checks its own answers before showing them to you, tracks each student's weak topics locally, and exports straight to Word or printable HTML.

Who'd pay: an independent tutor or small tuition centre. They already charge by the hour β€” saving even one hour a week on worksheet prep covers a small flat monthly fee. Because inference is local and free per call, the business model can be a flat price with no usage cost, which isn't possible if every generation hits a metered API.

It also has an optional hosted student portal for tutors who want to assign work digitally: students get a private link, answers come back to an Inbox, multiple-choice is marked instantly, and the tutor marks the rest against their own mark scheme β€” all while answer keys and worked solutions never leave the tutor's laptop.

Demo

Shows: generating a worksheet, a flagged question getting caught and replaced, exporting to Word, and the use of the student-tutor portal that runs directly from the tutor's laptop.

Code

Worksheet Generator for Tutors

License: MIT Python 3.12 Model: Gemma 3 4B Tests: 96 passing Hacktoberfest 2026

Hacktoberfest Open-Source AI Challenge: Week 2 (theme: Side Hustle) Tags: #devchallenge #hf26challenge Primary category: Best Use of Gemma

A local-first practice worksheet generator for Singapore private tutors, covering PSLE and O-Level. It runs an open-weight model (Gemma) through Ollama, so the whole thing works on a tutor's laptop with no internet, no API key and no per-worksheet cost. Student names and weak topics never leave the machine, unless you choose to connect the optional portal (section 5a), in which case only first names, the worksheets you assign and the students' answers pass through it.


Demo

worksheet-gen-demo.mp4

Shows: generating a worksheet, a flagged question getting caught and replaced, exporting to Word, and the use of the student-tutor portal that runs directly from the tutor's laptop.


1. The problem and who would pay

Private tutors spend hours each week writing or hunting for syllabus-style practice questions, writing…

How I Built It

The stack is a Streamlit UI calling into an engine.py that talks to Gemma, running locally through Ollama β€” no internet, no API key, no per-worksheet cost. Everything else (syllabus data, rendering, SQLite storage, the optional Flask portal) is plain Python around that core loop.

Gemma isn't just "call an LLM and print the output" here β€” it's used four specific ways that only make sense because it's local, open-weight and free per call:

  • Grammar-constrained generation. Every call passes a Pydantic model's JSON schema straight into Ollama's format= parameter, so Gemma decodes under a grammar constraint rather than just being asked nicely for JSON. A 5-option MCQ or a missing mark scheme is close to structurally impossible instead of something I catch after the fact.
  • Gemma grading Gemma. For every checkable question, a second independent call strips out the answer and asks Gemma to solve it blind, then compares that fresh answer against the original. Doubling inference per question to self-verify only works because the model is free and on the same machine β€” on a metered API this would double the cost of every worksheet.
  • Task-tuned temperature. 0.7 for most questions (variety), 0.3 for structured/mark-scheme questions (consistency matters more when marks are on the line), and temperature 0 for the blind cross-check re-solve, so a disagreement is a real signal and not sampling noise.
  • A closed generate β†’ verify β†’ fix loop, entirely on-device. Flagged questions get regenerated and re-checked against Gemma up to three times before being handed back labelled "please review" instead of silently passed off as correct.

I benchmarked this properly instead of eyeballing it: eval.py runs Gemma (gemma3:4b) across 8 real syllabus topics in a plain-prompt baseline versus the full schema-constrained pipeline.

Mode Valid schema Self-consistent Near-duplicates Avg secs/run
Baseline 8/8 16/40 (40%) 1 170.1s

Why Does Open Innovation Matter?

Concern Closed API This project (open weights, local)
Student privacy Names and weak topics go to a third-party server Nothing leaves the laptop
Unit economics Cost per worksheet, scales with usage ~Zero marginal cost β€” flat pricing works
Offline use Needs internet Works anywhere the tutor teaches
Vendor lock-in Pricing/model changes out of your hands Swap the model with one env var

The open model is what makes the business model (flat price, no usage cost) and the privacy promise possible at the same time. The per-student weak-topic profile feature specifically is only reasonable to build because the data never has to leave the machine β€” I wouldn't build that feature on top of a closed API handling minors' data.

Direct answer to the question itself, if you want it as plain prose instead of the table: open weights made two things possible that a closed API would have blocked. First, the privacy promise β€” a closed API means student names and their weak topics travel to a third party, which is a real problem when your users are minors; running Gemma locally means that data never leaves the tutor's laptop at all. Second, the unit economics β€” the blind cross-check doubles the number of model calls per question (generate, then verify), and the auto-fix loop can triple it again for flagged questions. That's 2-4x the inference per worksheet, which would meaningfully inflate a per-call API bill but costs nothing extra when the model is local and open-weight. The business model (flat price, zero marginal cost) and the trust feature (self-verification) both only exist because it's open weights running locally β€” on a closed API you'd have to choose between affording the verification step or affording the privacy.

My First User

No real-user pilot has been completed before this submission. I've tested the generator end-to-end myself across PSLE Math and A-Math, all three question types, both export formats, and the weak-topic targeting loop. A pilot with an independent tutor is the immediate next step after submitting.

Prize Categories

  • Best Use of Gemma β€” the entire generation, verification and auto-fix pipeline runs on Gemma locally via Ollama; see "How I Built It" above for specifics.

Top comments (0)