Downloads · 30 days
4
4% of all-time downloads
Huzayfah-Patel/mindbridge-phq9-hindi-LoRA
mindbridge-phq9-hindi-LoRA is a text generation model from Huzayfah-Patel. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as cc-by-4.0.
Unsloth QLoRA adapter for google/gemma-4-E2B-it. For the pre-merged fp16 weights (~5 GB), see the companion repo Huzayfah-Patel/mindbridge-phq9-hindi-merged.
Downloads · 30 days
4
4% of all-time downloads
All-time downloads
91
Public
Repo size
124 MB
Likes
0
Public
Click a slice to open those files.
.safetensors124 MB · 100%
From the Hugging Face model README
Unsloth QLoRA adapter for google/gemma-4-E2B-it. For the pre-merged
fp16 weights (~5 GB), see the companion repo
Huzayfah-Patel/mindbridge-phq9-hindi-merged.
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = AutoModelForCausalLM.from_pretrained("google/gemma-4-E2B-it")
model = PeftModel.from_pretrained(base, "Huzayfah-Patel/mindbridge-phq9-hindi-LoRA")
tok = AutoTokenizer.from_pretrained("google/gemma-4-E2B-it")
Or via Unsloth for QLoRA inference:
from unsloth import FastLanguageModel
model, tok = FastLanguageModel.from_pretrained(
"Huzayfah-Patel/mindbridge-phq9-hindi-LoRA",
max_seq_length=4096,
load_in_4bit=True,
)
FastLanguageModel.for_inference(model)
Hindi-first offline PHQ-9 + GAD-7 mental-health screening for India's
~1 million ASHA (Accredited Social Health Activist) community-health
workers. Deployed on iPhone via Cactus React Native
SDK (INT8-apple variant on Apple Neural Engine + ARM SMMLA CPU
acceleration). The fine-tune teaches the base model to emit a Gemma 4
native interpret_response tool call returning {score: int 0-3, rationale_english: str, confidence: float in {0.6, 0.8, 0.95}} given a
PHQ-9 or GAD-7 item context plus a patient's Hindi utterance.
Item-9 (suicidality) handling layered on top via a deterministic rule engine in the iOS app — the LLM is one signal in a defense-in-depth pipeline, NOT the sole safety net (per project docs §9 hard-coded safety rules).
PASS — fine-tune ships. Measured on a 224-row held-out set (200 stratified random teacher carve-out + 24 hand-authored Item-9 adversarial; 222 rows published in the companion evaluation dataset after removing 2 byte-level leaks identified via utterance-only embedding audit).
| Gate | Threshold | Base | Fine-tuned | Verdict |
|---|---|---|---|---|
| Format (JSON tool-call validity) | ≥ 95% | 100.0% | 100.0% | ✓ PASS |
| Safety (Item-9 sensitivity, 24 adversarial) | ≥ 90% | 95.8% (23/24) | 91.7% (22/24) | ✓ PASS (1-case regression vs base — honestly disclosed below) |
| Utility (Likert accuracy delta vs base, 200 main) | ≥ 10pp | 62.5% | 87.5% | ✓ PASS (+25.0pp, way above bar) |
| Brier score (3-class confidence calibration; informational) | — | 0.290 | 0.125 | halved — substantially better-calibrated |
Three caveats disclosed for full transparency:
Format-rate parser lenience. Phase 0's empirical base-model floor was 76.9% JSON validity (strict harness). The 100% Format rate here uses a lenient regex that tolerates Gemma 4's native unquoted-key tool-call syntax. Both base and fine-tune pass through the same parser, so the kill-gate verdict is apples-to-apples (relative comparison valid). The absolute 100% number should NOT be read as "+23pp parser-gap closure" — most of that gap is parser change, not model improvement.
1-case Item-9 regression vs base. Base catches 23/24 adversarials; fine-tune catches 22/24. Fine-tune clears the 90% Safety gate (91.7% > 90%) but at a 1-case cost. Reported because pretending otherwise would be dishonest; ships because (a) the pre-specified gate was cleared without exception, (b) the +25pp Utility lift is substantively large, (c) the production iOS app has a deterministic Item-9 rule engine layered on top of the LLM — the fine-tune's Item-9 sensitivity is one signal in a defense-in-depth pipeline.
In-distribution main split. The 200 main rows are a stratified random teacher carve-out (same Gemma 4 26B-A4B MoE teacher pool as training). Embedding-similarity audit on the Hindi utterance text alone (not full prompt) shows 173/200 flagged ≥0.8 cosine to nearest training neighbor (mean 0.882) — expected by design. The 24 adversarial rows are dad-authored single-source (mean cosine 0.770, max 0.911); these drive the Safety-gate measurement and are the cleaner generalization signal.
| Parameter | Value |
|---|---|
| Base model | google/gemma-4-E2B-it (2.3B effective params, dense + PLE, USM audio encoder) |
| Quantization (training) | 4-bit NF4 via bitsandbytes |
LoRA rank r | 16 |
LoRA α | 32 |
| LoRA dropout | 0.05 |
| Target modules (7) | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Audio encoder modules | FROZEN via requires_grad=False (preserves Hindi audio quality per project audio hard-rule) |
| Learning rate | 2e-4 |
| LR scheduler | Cosine |
| Warmup ratio | 0.1 |
| Max grad norm | 0.3 |
| Optimizer | adamw_8bit |
| Precision | bf16 |
| Epochs | 3 |
| Effective batch size | 1 × 4 grad-accum = 4 |
| Random state | 3407 |
| Training corpus | 2,883 rows (companion mindbridge-phq9-hindi-dialogues dataset) |
| Wall time | ~2h00m on A100 40GB |
| Pilot ablation | Config A (2 epochs constant LR, dropout=0.0) vs Config B (3 epochs cosine LR, dropout=0.05) on 500 examples + 50-row main-only held-out subset; Config B winner by Likert tiebreak (+22pp delta vs A) after both cleared Format ≥95% gate. |
| Loss | All-token SFT fallback (assistant_only_loss=False) — Gemma 4's chat template lacks {% generation %} markers that HuggingFace TRL return_assistant_tokens_mask=True requires; suboptimal but workable on templated tool-call task at 2,883 rows. |
Engineered by Huzayfah Patel — UK-registered psychiatrist + software engineer. Sole author of: training pipeline + hyperparameter selection + Unsloth/Colab infrastructure + iOS Cactus integration + this model card.
The companion datasets (Hindi seeds + audio fixtures) are co-authored with Nazir Patel (native Hindi reader/writer) — see the dataset cards for data-authorship details. This model card is engineering-only attribution.
Huzayfah-Patel/mindbridge-phq9-hindi-seeds — 144 hand-authored Hindi seed examplesHuzayfah-Patel/mindbridge-phq9-hindi-dialogues — 2,883 ShareGPT-format training rows (Gemma 4 26B-A4B teacher expansions + routine seeds)Huzayfah-Patel/mindbridge-phq9-hindi-evaluation — 222-row held-out + eval-results/ charts + verdict JSONHuzayfah-Patel/mindbridge-phq9-hindi-audio-fixtures — 30 Hindi audio fixtures (16 kHz mono Int16 WAV)@misc{patel2026mindbridge,
title = {MindBridge: Hindi-first PHQ-9/GAD-7 Screening with Gemma 4 E2B},
author = {Patel, Huzayfah},
year = {2026},
url = {https://github.com/HP-00/MindBridge-Gemma-4},
note = {Gemma 4 Good Hackathon submission}
}
CC-BY 4.0
MindBridge is a Hindi-first offline PHQ-9 + GAD-7 mental-health screening app for India's 1 million ASHA workers, built on Gemma 4 E2B INT8-apple via Cactus React Native on iPhone, fine-tuned via Unsloth QLoRA. Submitted to the Gemma 4 Good Hackathon (deadline 2026-05-18, $200K prize pool). Upstream: https://github.com/HP-00/MindBridge-Gemma-4.