DariusTheGeek commited on
Commit
6c93441
·
verified ·
1 Parent(s): d21693c

model card

Browse files
Files changed (1) hide show
  1. README.md +159 -19
README.md CHANGED
@@ -1,27 +1,167 @@
1
- # Generation LoRA adapters (Path B — optional, full regeneration)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- These are the three fine-tuned LoRA adapters whose merged models produce the
4
- generation base `work/submissions/sub_gen_v20.csv`. **The fast reproduction
5
- (`reproduce.sh`) does NOT need them** — it consumes the already-built
6
- gen base. They are only needed to regenerate that base from scratch (Path B: `bash run_full.sh`).
7
 
8
- Merge each adapter onto its base model (downloaded separately — see the README
9
- "What's in the ZIP vs downloaded" section), then sample with `stages/1_generation/gen_samples.py`:
 
10
 
11
- | adapter dir | base model to merge onto | role in the MBR medoid |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  |---|---|---|
13
- | `gen7454/` | `google/gemma-4-31B-it` | primary generator (E1, r64, ckpt-7454, all-8 subsets, 2 ep) |
14
- | `raft_r1/` | `google/gemma-4-31B-it` | RAFT self-distill member (E20) |
15
- | `mg_2226/` | `google/medgemma-27b` | MedGemma member, fine-tuned on Aka_Gha + Eng_Gha (E24) |
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- Merge example (uses the bundled helper):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  ```bash
20
- PY=.envs/venv-serve/bin/python
21
- $PY stages/1_generation/merge_adapter.py --base models/gemma-4-31B-it \
22
- --adapter models/adapters/gen7454 --out models/merged_gen7454
23
- $PY stages/1_generation/merge_adapter.py --base models/gemma-4-31B-it \
24
- --adapter models/adapters/raft_r1 --out models/merged_raft_r1
25
- $PY stages/1_generation/merge_adapter.py --base models/medgemma-27b \
26
- --adapter models/adapters/mg_2226 --out models/merged_mg_2226
 
 
27
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: gemma
3
+ library_name: peft
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - lora
7
+ - peft
8
+ - medical
9
+ - health
10
+ - multilingual
11
+ - africa
12
+ - question-answering
13
+ - zindi
14
+ - mhqa-itu
15
+ language:
16
+ - en
17
+ - sw
18
+ - lg
19
+ - ak
20
+ - am
21
+ base_model:
22
+ - google/gemma-4-31B-it
23
+ - google/medgemma-27b-text-it
24
+ ---
25
 
26
+ # MHQA · ITU · Zindi Challenge — Generation Adapters
 
 
 
27
 
28
+ **`DariusTheGeek/mhqa-itu-adapters`** · the trained-weight component of the winning solution to the
29
+ [Multilingual Health Question Answering in Low-Resource African Languages Challenge (ITU)](https://zindi.africa/competitions/multilingual-health-question-answering-in-low-resource-african-languages-challenge),
30
+ hosted on Zindi. Data by the **HASH** consortium (Hub for AI in Maternal, Sexual & Reproductive Health).
31
 
32
+ This repo hosts **3 LoRA adapters** (the generation members). The full retrieval + generation + judge
33
+ **system**, and one-command reproduction, live in the code repo:
34
+ **[…-ITU-SOLUTION on GitHub](https://github.com/DariusTheGeek/Multilingual-Health-Question-Answering-in-Low-Resource-African-Languages-Challenge-by-ITU-SOLUTION)**.
35
+
36
+ > ⚠️ **Not medical advice.** This is a research artifact built for a benchmark competition. It is **not a
37
+ > medical device**, is **not for clinical use**, and its outputs must not be used to diagnose, treat, or make
38
+ > health decisions. Sexual/reproductive-health content may be inaccurate, incomplete, or unsafe.
39
+
40
+ ---
41
+
42
+ ## Model summary
43
+
44
+ | | |
45
+ |---|---|
46
+ | **Reproduces** | submission `sub_v40` · public LB **0.728509** |
47
+ | **Metric** | `0.37·ROUGE-1 + 0.37·ROUGE-L + 0.26·LLM-judge` (micro-averaged, unicode-aware) |
48
+ | **Languages** | English, Kiswahili, Luganda, Akan/Twi, Amharic (8 country×language subsets) |
49
+ | **What's here** | 3 LoRA adapters (4.7 GB) — the *generation* component |
50
+ | **Adapter type** | PEFT/LoRA on Gemma-4-31B-it and MedGemma-27B-text-it |
51
+
52
+ ### The three adapters
53
+
54
+ | adapter | base model | role | LoRA config | trained on |
55
+ |---|---|---|---|---|
56
+ | **`gen7454`** | `google/gemma-4-31B-it` | primary generator | r64 / α128 / dropout 0 · all linear projections · 2 epochs | all 8 subsets |
57
+ | **`raft_r1`** | *merged `gen7454`* | RAFT self-distillation member | r32 / α64 · lr 5e-5 · 1 epoch | Aka_Gha, Eng_Gha |
58
+ | **`mg_2226`** | `google/medgemma-27b-text-it` | MedGemma member | r64 / α128 · lr 1e-4 · 2 epochs | Aka_Gha, Eng_Gha |
59
+
60
+ > `raft_r1` was trained **on top of the merged `gen7454`** model (RAFT round-1), not on the raw base.
61
+
62
+ ---
63
+
64
+ ## Architecture & approach
65
+
66
+ The competition is scored `0.37·ROUGE-1 + 0.37·ROUGE-L + 0.26·judge`, so ~74 % of the score is lexical
67
+ overlap with a hidden gold answer. The test set splits into two regimes:
68
+
69
+ - **Retrieval subsets** (~60 %: Eng_Uga, Eng_Ken, Eng_Eth, Swa_Ken, Lug_Uga) — the gold answer is almost
70
+ always a **verbatim reuse** of a Train+Val answer-bank entry, already in the candidate pool. The job is
71
+ *selecting the canonical twin*, done by **LightGBM selectors** that use a fine-tuned cross-encoder as a
72
+ feature (not an argmax chooser). These are trained inline and deterministic — **not** weight files.
73
+ - **Generation subsets** (~37 %: Aka_Gha, Eng_Gha) — golds are original/local, so answers are **generated**.
74
+ The **3 LoRA adapters in this repo** each produce a K36 sample pool; a cross-model ROUGE-MBR **medoid**
75
+ picks the consensus answer.
76
+
77
+ A final **LLM-judge pass** (gemma-4-31B-it) reverts off-topic picks (27 cached decisions).
78
+
79
+ **What is a weight vs. deterministic code:**
80
+
81
+ | component | form | where |
82
  |---|---|---|
83
+ | 3 generation adapters | **trained LoRA weights** | this repo |
84
+ | cross-encoder reranker (CE-ft) | trained *inline per fold*, discarded; frozen feature outputs shipped | dataset repo (`mhqa-itu-artifacts`) |
85
+ | 3 LightGBM selectors | trained *inline each run*, deterministic | code (GitHub) |
86
+ | LLM judge | 27 cached revert decisions, replayed | dataset repo |
87
+
88
+ ---
89
+
90
+ ## Intended use
91
+
92
+ - **In scope:** reproducing / validating the competition result; research on retrieval-vs-generation for
93
+ low-resource multilingual health QA; a baseline for the 8 named country×language subsets.
94
+ - **Out of scope:** any clinical, diagnostic, or patient-facing use; generating medical advice; deployment as
95
+ a health chatbot; languages/domains outside the 8 competition subsets (behaviour is untested and unsafe).
96
+
97
+ ## Training data
98
 
99
+ All data is from the Zindi competition (HASH consortium sexual/reproductive-health Q&A across Uganda, Kenya,
100
+ Ghana, Ethiopia). **No external or hand-authored data**; no preprocessing outside the code. Raw `Train.csv` /
101
+ `Val.csv` are Zindi competition data and are **not redistributed** — download them from the competition page.
102
+ The adapters are trained *on* this data but do not *contain* it.
103
+
104
+ ## Evaluation
105
+
106
+ | submission | Public LB | ROUGE-1 | ROUGE-L | Judge |
107
+ |---|---|---|---|---|
108
+ | **`sub_v40`** | **0.728509** | 0.7187 | 0.6514 | 0.8522 |
109
+
110
+ The exact `0.728509` requires the hidden Test gold + Zindi's hosted judge. `common/eval.py` computes the exact
111
+ `0.37/0.37/0.26` blend given a gold file (and per-row judge scores); `reproduce.sh` proves the shipped output
112
+ is byte-identical to the scored `sub_v40`.
113
+
114
+ ## Known limitations
115
+
116
+ - **Coverage:** only the 8 competition subsets/languages; no guarantees elsewhere.
117
+ - **ROUGE-optimized:** the system is tuned to a lexical-overlap metric; high ROUGE ≠ clinical correctness.
118
+ - **Answer-bank reliance:** retrieval subsets depend heavily on verbatim reuse of Train/Val bank answers, so
119
+ generalization to genuinely novel questions is weak.
120
+ - **Amharic:** ROUGE is effectively 0 for Ge'ez script under the metric; Amh_Eth passes through generation.
121
+ - **Generation is stochastic:** the shipped pool uses temperature>0 sampling (reproducible up to sampling; a
122
+ greedy demo path is deterministic). Not a source of clinical reliability.
123
+ - **Health-safety:** outputs may be inaccurate/unsafe; see the disclaimer above.
124
+
125
+ ## How to use
126
+
127
+ The adapters are components of a pipeline — use the GitHub repo, which pulls these weights automatically:
128
 
129
  ```bash
130
+ git clone https://github.com/DariusTheGeek/Multilingual-Health-Question-Answering-in-Low-Resource-African-Languages-Challenge-by-ITU-SOLUTION.git
131
+ cd Multilingual-Health-…-SOLUTION
132
+ bash env/install.sh
133
+ bash stages/0_setup/fetch_artifacts.sh # ~250 MB data/features (Path A, CPU)
134
+ bash reproduce.sh # -> sub_v40, BYTE-IDENTICAL, minutes, no GPU
135
+
136
+ # Run the actual trained model (GPU ~48 GB):
137
+ bash stages/0_setup/fetch_artifacts.sh --adapters # pulls these 3 adapters (4.7 GB)
138
+ python stages/1_generation/demo_generate.py --adapter models/adapters/gen7454 --base google/gemma-4-31B-it --n 2
139
  ```
140
+
141
+ Standalone load (PEFT):
142
+
143
+ ```python
144
+ from peft import PeftModel
145
+ from transformers import AutoModelForCausalLM
146
+ base = AutoModelForCausalLM.from_pretrained("google/gemma-4-31B-it", torch_dtype="bfloat16", device_map="auto")
147
+ model = PeftModel.from_pretrained(base, "DariusTheGeek/mhqa-itu-adapters", subfolder="gen7454")
148
+ ```
149
+
150
+ ## Dependencies
151
+
152
+ Python 3.11. CPU reproduction: `lightgbm`, `pandas`, `pyarrow`, `regex`, `rouge_score`, `scikit-learn`
153
+ (`requirements.txt`). GPU generation: `unsloth` / `vllm` + `transformers`/`peft`
154
+ (`env/requirements-serve.txt`, `env/requirements-train.txt`).
155
+
156
+ ## License
157
+
158
+ The adapters are LoRA derivatives of gated Google base models; base weights are **referenced, not re-hosted**.
159
+ Use is subject to the base licenses — **`gemma-4-31B-it`: [Gemma Terms of Use](https://ai.google.dev/gemma/terms)**
160
+ and **`medgemma-27b-text-it`: [Health AI Developer Foundations terms](https://developers.google.com/health-ai-developer-foundations/terms)**.
161
+ Accept each on the Hub before downloading the bases. Competition data is governed by the Zindi competition rules.
162
+
163
+ ## Citation
164
+
165
+ Solution to the ITU *Multilingual Health Question Answering in Low-Resource African Languages* challenge
166
+ (Zindi / HASH consortium). Author: DariusTheGeek. Companion dataset repo:
167
+ [`DariusTheGeek/mhqa-itu-artifacts`](https://huggingface.co/datasets/DariusTheGeek/mhqa-itu-artifacts).