chhaya / writeup /HF_BLOG.md
Manjunathan R
Link the published HF blog post in README
e2ebf1f
|
Raw
History Blame Contribute Delete
11 kB

A newer version of the Gradio SDK is available: 6.20.0

Upgrade
metadata
title: 'Chhaya: teaching a 4B model to be the eyes, not the doctor'
thumbnail: >-
  https://huggingface.co/spaces/build-small-hackathon/chhaya/resolve/main/assets/hero-scene.jpg
authors:
  - user: YOUR_HF_USERNAME

Chhaya: teaching a 4B model to be the eyes, not the doctor

Field notes from the Hugging Face Build Small Hackathon — Backyard AI track.

Chhaya — shade for those who work in the sun

The auto driver whose right arm bakes in the window sun for ten hours. The delivery rider whose neck burns under the helmet line. The construction worker on a site that doesn't reschedule for a heat wave. They get the most sun exposure of anyone and the fewest skin checks — and heat waves are making the exposure worse every year. Around 75% of India's workforce — roughly 380 million people — work in heat-exposed outdoor jobs, against about 9.5 dermatologists per million people, with 80% of the population rural and far from one.

The phone is the one tool they all already have. So the question was narrow: what can a small model do with one photo and thirty seconds, for someone who will never see a dermatologist?

That's Chhaya (छाया — "shade").

See it in 90 seconds

(Prefer the full story? Here's the 4.5-minute walkthrough.)

What Chhaya does

  1. Skin check — snap a photo of any spot. MedGemma-1.5-4B describes what it sees (type, colour, borders, symmetry, texture) and flags how concerning it looks: looks ordinary / worth watching / show a doctor.
  2. A plan built around your work day — tell Chhaya your occupation, hours in direct sun, and water access, and it builds a hydration schedule and protection plan that fits: window-side UV for drivers, helmet-line burns for riders, NDMA work-hour guidance for construction.
  3. Heat symptom triage — first-aid for heat cramps / exhaustion / heatstroke. Deliberately zero AI: pure deterministic logic from NDMA / WHO guidance, because an emergency is not the place for sampling.
  4. Read it aloud — every verdict can be spoken with one tap (Kokoro-82M, on CPU), in English or Hindi, so the plan reaches workers who don't read English easily.

You can try the live app right here:

The one design decision everything else followed

Early on it would have been easy to let the model do everything — look at the photo and tell the person what to drink, when to rest, whether to worry. That's also how you build something that confidently hallucinates a hydration schedule.

So we drew a hard line: the model is the eyes, the guidelines are the medicine.

  • MedGemma-1.5-4B looks at the photo and returns a structured description — type, colour, borders, symmetry, texture, a concern level. That's all it's trusted with.
  • Every medical number and action — litres per shift, ORS timing, the 12–3 pm shade window, when to call an ambulance — is curated, deterministic content from NDMA India heat guidance, WHO heat-health advice, and the Cancer Council ABCDE criteria.

The model never invents medicine. When it's wrong, it's wrong about what a spot looks like — recoverable — not about what you should do — dangerous.

The fine-tune: from "describes skin" to "knows when to worry"

Sunny — the MedGemma skin tracker that inspired this — fine-tuned on Gemini's opinion of each image. We wanted the one medically-loaded field, concern, anchored to something harder.

So the training set joins two sources:

  • ISIC-2024 lesion photos, with concern mapped from biopsy ground truth (malignant → see a doctor).
  • Google SCIN — real consumer phone photos with dermatologist labels, spanning Monk skin tones 1–7 (dermoscopy datasets skew light-skinned; our users don't).

1,406 examples, low deliberately downsampled so the model can't learn to default to "safe" — the one mistake a screening tool must never make. A low spot whose description shows the full ABCDE high-risk combo gets bumped to watch regardless of label. Cautious by construction.

The headline metric isn't accuracy — it's malignant recall: of the spots that truly need a doctor, how few did the model wave through as ordinary.

The numbers (141-image held-out test set)

metric base MedGemma Chhaya-tuned (v2)
Valid JSON 99.3% 100%
Concern accuracy 33.3% 69.5%
Malignant recall 0.94 0.83
Output tokens / answer 770 156

The fine-tune doubled accuracy and cut output to a fifth — the chain-of-thought preamble is gone, which is the 5× speed-up you feel live. One honest caveat: base's 0.94 recall looks higher, but it's hollow — base reaches it by dumping ~60% of all cases into "watch" (hence 33% accuracy). It's a hedge machine, not a safer tool. The tuned model commits to a real triage; we oversampled the "see-a-doctor" class to lift recall from 0.77 (v1) to 0.83 (v2), and the deterministic ABCDE backstop plus the always-on "see a doctor if…" card carry the residual risk.

(Training: QLoRA on a frozen vision tower, 2 epochs, ~$6 of Modal credits total across v1 + v2.)

Three things that broke, and what they taught us

1. The model thinks out loud. First live test on ZeroGPU: the app fell back to demo mode. MedGemma-1.5 is a reasoning model — it emits a long Thought: … trace before the JSON, and our token budget ran out mid-thought. Fix was two-part: raise the budget, and parse the last balanced {…} block carrying a concern key rather than the first. The reasoning trace often contains a draft JSON; you want the conclusion, not the scratch work.

2. Cold starts time out into demo mode. On ZeroGPU the GPU only exists inside the @spaces.GPU window. The very first inference after the Space wakes from sleep had to download ~8 GB of weights inside that window — it timed out, threw, and silently degraded to a heuristic "demo reading." The fix: prewarm the model and adapter into the local disk cache at startup (on CPU, no GPU needed), so the first real inference just loads from disk and finishes in time. Lazy loading is elegant until the lazy path is also the slow path.

3. Pretty isn't tasteful. The first UI was a generic clinical dashboard. Wrong audience. The rebuild — a warm sand-and-dusk palette, a hand-drawn sun-under-an-umbrella mascot, plain-language result cards, a dawn-to-dusk sun slider — isn't decoration; it's the difference between something a tired worker actually opens and something that feels like a hospital form.

What it is, and isn't

Chhaya is not a medical device and never diagnoses. It describes, it explains in plain words, and it points people toward care earlier than they'd have gone on their own. For someone who works in the sun and has never had a skin check, "this is worth showing a doctor" — arriving for free, in thirty seconds, on the phone already in their pocket — is the whole point.


Try it & watch

Build artifacts

References & further reading

The problem

The guidelines (the deterministic "medicine")

Models & data

Chhaya is not a medical device and provides no diagnosis. Built for the Hugging Face Build Small Hackathon — Backyard AI track.