Inspiration

In Nigeria the 2024/25 school census puts the average at about 50 or more learners per classroom, and many public-school teachers mark for classes of 100 or more. One continuous-assessment test can take a whole weekend to mark, so pupils get their feedback weeks late, if at all.

AI marking tools exist, but they upload children's work to a server. They also need a steady connection and cost money per page, and teachers in staff rooms on patchy networks often have none of those.

The laptop on the teacher's desk is exactly where Chrome's Gemini Nano runs.

What it does

  1. Rubric (cloud, once per test). The teacher types the question and model answer, or attaches a photo or PDF of the marking scheme. Gemini in the cloud turns it into one-point checks that must add up to the max mark. The teacher can edit any of them. No pupil data is involved.

  2. Marking (on this laptop, every script). The teacher photographs each answer (file upload or webcam). Gemini Nano reads the handwriting and then ticks every check yes/no with a short quote as evidence. RedBiro adds up the ticks itself, so the small model never does arithmetic.

  3. Review. Low-confidence scripts and contradictory reasons are flagged as "Needs your check." The teacher clicks any ✓/✗ to override a tick, and the total updates. Changes are tracked and exported. Each card also shows what Nano read from the photo.

  4. Re-teach report (cloud, once per class). Only anonymised per-check counts leave the laptop, plus optional generic mistake tags. The teacher sees the exact JSON before it is sent. Gemini returns the most common mistakes, a 10-minute re-teach plan and practice questions.

Every result carries a badge read from inferenceSource: "On this laptop" or "Cloud." A footer counts the KB of pupil work uploaded, which is 0 while the privacy lock is on.

The demo video (https://www.youtube.com/watch?v=VV8ALToC-tY) is a real Gemini Nano run of the eight synthetic sample scripts on a laptop CPU. It shows on-device marking (Amaka 6/6, "On this laptop"), the class report totals, mark distribution, per-check bars, mistake tags, and the anonymised JSON payload. It does not show a finished cloud re-teach report: recording stopped before that button was used.

How we built it

Firebase AI Logic hybrid inference (firebase/ai): getAI(app, { backend: new GoogleAIBackend() }) and one getGenerativeModel per task, because mode and schema are per instance.

  • Marking models use InferenceMode.ONLY_ON_DEVICE (privacy lock, the default) or PREFER_ON_DEVICE (the teacher opts in to cloud fallback).
  • Rubric and report models use PREFER_IN_CLOUD. When the laptop is offline they fall back to Nano, so the whole app still works with no internet.
  • Structured JSON on both sides: onDeviceParams.promptOptions.responseConstraint for Nano and inCloudParams.generationConfig.responseSchema for the cloud.
  • initializeDeviceModel() runs from a click, with download progress. response.inferenceSource drives the badges and the upload counter.
  • Multimodal on-device input: JPEG photos, downscaled to 768 px on the long edge to stay inside Nano's per-request token limit.

App Check, which AI Logic requires: reCAPTCHA Enterprise (Firebase console: Fraud Defense) for the hosted app, with a Classic v3 fallback if only that key is set, and the debug provider on localhost only.

Remote Config sets the cloud model (default gemini-4-hydrogen) and the review threshold.

Gemini Developer API on the free Spark plan. No billing account.

Vanilla JS + Vite. IndexedDB for tests, photos and marks. A service worker for offline use.

A ?mock=1 test double for window.LanguageModel lets the full Firebase AI Logic path run in headless Chrome. There are unit tests (vitest) and an end-to-end Playwright test.

Challenges we ran into

Small models and sums. Asking Nano for a total mark was unreliable. Splitting the rubric into one-point checks, asking only yes/no for each, and adding up the ticks in code was the method that worked best in our go/no-go test.

Broken JSON. Even with a response constraint, CPU Nano occasionally returns malformed JSON. RedBiro parses forgivingly and retries once.

A privacy gap in hybrid mode. In a browser without the Prompt API, the SDK has no on-device adapter and sends requests to the cloud even in ONLY_ON_DEVICE. We added an explicit availability guard so a locked script is never uploaded.

Speed on CPU. On a CPU-only laptop, a 27 Nov 2026 run of real Gemini Nano took about 113 seconds of model time per script (two calls: transcribe the photo, then tick every check against that text). After tightening the prompt, later runs on the same laptop were still about two minutes of model time (Amaka was 115.9 s in the demo video). End-to-end wall time on a laptop CPU is typically about two to four minutes per script. RedBiro marks in a queue the teacher can leave running and stop, and the timer counts only active model time.

Contradictory ticks. On that 27 Nov run, one synthetic script that wrote "Solid - ice" was marked 5/6: Nano called ice a correct solid example and then said it was "not listed in the answer." The check prompt now states that lists in parentheses are acceptable answers, not text the student must copy, and a contradictory reason is flagged as "Needs your check" instead of being accepted silently. After that change, a re-run on the same laptop marked Amaka 6/6 (the expected mark), including in the demo video. Other scripts in that 8-script synthetic run did not all match the expected marks, which is why the teacher-review flags matter. We have not measured accuracy on real pupils' handwriting.

Honest testing without real pupils. We used only synthetic, computer-drawn scripts so that no child's work appears anywhere.

Accomplishments that we're proud of

The hybrid split is the product design, not just a fallback: per-pupil work stays on the device, and once-per-test planning goes to the cloud.

A teacher can see exactly what leaves the laptop, including the anonymised JSON payload before a re-teach report is sent.

It works fully offline, including the rubric and report (on Nano) when there's no connection.

The demo video is a real on-device run: eight synthetic scripts marked on the laptop, with 0 marked in the cloud and 0 KB of student work uploaded.

What we learned

Single-turn, schema-constrained, one-decision-per-check prompts get far more out of an on-device model than one big "mark this" prompt.

inferenceSource is what makes hybrid behaviour visible and trustworthy to users.

On a laptop CPU, Gemini Nano is usable for this job, but each script takes on the order of two minutes of model time (about two to four minutes of wall time), so the queue and the "what Nano read" review panel matter as much as the ticks.

What's next for Redbiro

A pilot with real teachers and real (consented, anonymised) scripts to measure agreement with teacher marks and time saved.

Multi-question papers: page detection and one rubric per question.

Printable feedback slips per pupil, and a roster import.

Android (Gemini Nano via ML Kit) for teachers who only have a phone.

Built With

  • chrome-prompt-api
  • firebase-ai-logic
  • firebase-app-check
  • firebase-remote-config
  • gemini-api
  • gemini-nano
  • indexeddb
  • javascript
  • playwright
  • recaptcha-enterprise
  • vite
  • vitest
Share this project:

Updates

Submission history