kingabzpro commited on
Commit
4c432ec
·
verified ·
1 Parent(s): 080c960

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +327 -90
README.md CHANGED
@@ -1,199 +1,436 @@
1
- ---
2
  library_name: transformers
3
- tags: []
4
- ---
5
-
6
- # Model Card for Model ID
7
-
8
- <!-- Provide a quick summary of what the model is/does. -->
9
-
10
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  ## Model Details
13
 
14
  ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
 
 
 
 
 
 
 
 
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
 
 
29
 
30
- <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
 
36
- ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
 
39
 
40
- ### Direct Use
 
 
 
 
 
 
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
 
43
 
44
- [More Information Needed]
 
45
 
46
- ### Downstream Use [optional]
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
- [More Information Needed]
 
 
 
 
51
 
52
  ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
 
56
- [More Information Needed]
 
 
 
 
 
 
 
57
 
58
  ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
 
62
- [More Information Needed]
 
 
 
 
 
 
63
 
64
  ### Recommendations
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
 
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
 
 
 
 
69
 
70
  ## How to Get Started with the Model
71
 
72
- Use the code below to get started with the model.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  ## Training Details
77
 
78
  ### Training Data
79
 
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
 
82
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  ### Training Procedure
85
 
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
 
88
- #### Preprocessing [optional]
89
 
90
- [More Information Needed]
 
 
 
 
91
 
 
92
 
93
- #### Training Hyperparameters
 
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
 
96
 
97
- #### Speeds, Sizes, Times [optional]
 
98
 
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
 
100
 
101
- [More Information Needed]
102
 
103
- ## Evaluation
 
 
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  ### Testing Data, Factors & Metrics
108
 
109
  #### Testing Data
110
 
111
- <!-- This should link to a Dataset Card if possible. -->
112
 
113
- [More Information Needed]
114
 
115
- #### Factors
 
 
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
 
119
- [More Information Needed]
120
 
121
  #### Metrics
122
 
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
 
125
- [More Information Needed]
 
 
 
 
126
 
127
  ### Results
128
 
129
- [More Information Needed]
 
 
 
 
130
 
131
  #### Summary
132
 
 
133
 
 
134
 
135
- ## Model Examination [optional]
136
 
137
- <!-- Relevant interpretability work for the model goes here -->
138
 
139
- [More Information Needed]
140
 
141
  ## Environmental Impact
142
 
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
 
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
 
153
- ## Technical Specifications [optional]
154
 
155
  ### Model Architecture and Objective
156
 
157
- [More Information Needed]
158
 
159
- ### Compute Infrastructure
160
 
161
- [More Information Needed]
 
 
 
 
 
162
 
163
  #### Hardware
164
 
165
- [More Information Needed]
 
166
 
167
  #### Software
168
 
169
- [More Information Needed]
 
 
 
 
 
 
 
 
 
170
 
171
- ## Citation [optional]
172
 
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
- **BibTeX:**
 
 
 
 
 
 
 
176
 
177
- [More Information Needed]
178
 
179
- **APA:**
 
 
 
 
180
 
181
- [More Information Needed]
182
 
183
- ## Glossary [optional]
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
- [More Information Needed]
 
 
188
 
189
- ## More Information [optional]
190
 
191
- [More Information Needed]
 
 
 
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
196
 
197
  ## Model Card Contact
198
 
199
- [More Information Needed]
 
1
+ ```
2
  library_name: transformers
3
+ tags:
4
+ - medical
5
+ - q&a
6
+ - pubmedqa
7
+ - diffusiongemma
8
+ - lora
9
+ - unsloth
10
+ license: apache-2.0
11
+ datasets:
12
+ - qiaojin/PubMedQA
13
+ language:
14
+ - en
15
+ metrics:
16
+ - accuracy
17
+ base_model:
18
+ - google/diffusiongemma-26B-A4B-it
19
+ pipeline_tag: text-generation
20
+ ```
21
+
22
+ # DiffusionGemma PubMedQA
23
+
24
+ This model is a LoRA fine-tuned version of **DiffusionGemma 26B-A4B IT** for biomedical question answering on **PubMedQA**.
25
+
26
+ The model was fine-tuned to answer biomedical research questions using PubMed abstract context and return one of three labels:
27
+
28
+ ```text
29
+ yes / no / maybe
30
+ ```
31
+
32
+ > This model is intended for experimentation, benchmarking, and educational use. It is **not** intended for clinical decision-making or medical advice.
33
 
34
  ## Model Details
35
 
36
  ### Model Description
37
 
38
+ This model adapts DiffusionGemma to the PubMedQA task. Given a biomedical research question and supporting PubMed abstract context, the model predicts whether the answer is `yes`, `no`, or `maybe`.
39
 
40
+ - **Developed by:** kingabzpro
41
+ - **Shared by:** kingabzpro
42
+ - **Model type:** Diffusion language model with LoRA adapter
43
+ - **Language(s):** English
44
+ - **License:** Apache 2.0
45
+ - **Fine-tuned from:** `google/diffusiongemma-26B-A4B-it`
46
+ - **Training framework:** Unsloth + Transformers
47
+ - **Task:** Biomedical question answering / text generation
48
+ - **Dataset:** `qiaojin/PubMedQA`
49
 
50
+ ### Model Sources
 
 
 
 
 
 
51
 
52
+ - **Repository:** `kingabzpro/diffusiongemma_pubmedqa`
53
+ - **Base model:** `google/diffusiongemma-26B-A4B-it`
54
+ - **Dataset:** `qiaojin/PubMedQA`
55
 
56
+ ## Uses
57
 
58
+ ### Direct Use
 
 
59
 
60
+ This model can be used to answer PubMedQA-style biomedical research questions where the input includes:
61
 
62
+ 1. A biomedical research question
63
+ 2. Relevant abstract/context text
64
+ 3. A request to answer with `yes`, `no`, or `maybe`
65
 
66
+ Example task format:
67
+
68
+ ```text
69
+ Answer the biomedical research question using only the context.
70
+
71
+ Context:
72
+ [PubMed abstract context]
73
 
74
+ Question:
75
+ [Biomedical research question]
76
 
77
+ Answer with only one word: yes, no, or maybe.
78
+ ```
79
 
80
+ ### Downstream Use
81
 
82
+ This model may be useful for:
83
 
84
+ - Biomedical QA experiments
85
+ - PubMedQA-style benchmark testing
86
+ - Fine-tuning tutorials
87
+ - LoRA adapter experiments with DiffusionGemma
88
+ - Educational demos for medical-domain model adaptation
89
 
90
  ### Out-of-Scope Use
91
 
92
+ This model should **not** be used for:
93
 
94
+ - Medical diagnosis
95
+ - Treatment recommendations
96
+ - Emergency medical advice
97
+ - Replacing a doctor, pharmacist, or clinical expert
98
+ - Patient-specific medical decisions
99
+ - High-stakes biomedical or healthcare deployment without further validation
100
+
101
+ The model is trained on a narrow benchmark-style task and may produce incorrect answers.
102
 
103
  ## Bias, Risks, and Limitations
104
 
105
+ This model has several important limitations:
106
 
107
+ - It was fine-tuned on PubMedQA-style examples, not general medical conversations.
108
+ - The model predicts only `yes`, `no`, or `maybe`, so it may oversimplify complex biomedical findings.
109
+ - The evaluation set used in this experiment was small: 50 examples.
110
+ - The model may be sensitive to prompt format.
111
+ - The model may answer incorrectly if the context is incomplete, misleading, or unrelated.
112
+ - The training target was short, so the loss dropped quickly and may not reflect deep medical reasoning.
113
+ - The model should not be treated as medically reliable.
114
 
115
  ### Recommendations
116
 
117
+ Users should:
118
 
119
+ - Use this model only for research and educational experiments.
120
+ - Always verify outputs against trusted biomedical sources.
121
+ - Avoid using the model for real clinical or patient-facing decisions.
122
+ - Run larger evaluations before drawing strong conclusions.
123
+ - Consider training on explanations, not only one-word labels, for a more meaningful medical QA setup.
124
 
125
  ## How to Get Started with the Model
126
 
127
+ ### Install dependencies
128
+
129
+ ```bash
130
+ pip install unsloth
131
+ pip install transformers datasets peft accelerate sentencepiece protobuf
132
+ ```
133
+
134
+ ### Load the model
135
+
136
+ If this repository contains the LoRA adapter, load the base model first and then attach the adapter:
137
+
138
+ ```python
139
+ import copy
140
+ import torch
141
+ from peft import PeftModel
142
+ from unsloth import FastModel
143
+
144
+ base_model_name = "unsloth/diffusiongemma-26B-A4B-it"
145
+ adapter_name = "kingabzpro/diffusiongemma_pubmedqa"
146
+
147
+ model, tokenizer = FastModel.from_pretrained(
148
+ model_name=base_model_name,
149
+ dtype=torch.bfloat16,
150
+ load_in_4bit=False,
151
+ )
152
+
153
+ model = PeftModel.from_pretrained(model, adapter_name)
154
+
155
+ processor = tokenizer
156
+ tok = processor.tokenizer if hasattr(processor, "tokenizer") else processor
157
+
158
+ dev = next(
159
+ (p.device for p in model.parameters() if p.device.type != "meta"),
160
+ torch.device("cuda"),
161
+ )
162
+
163
+ canvas_len = model.config.canvas_length
164
+ ```
165
+
166
+ ### Run inference
167
+
168
+ ```python
169
+ def answer_question(prompt, steps=16):
170
+ input_ids = processor.apply_chat_template(
171
+ [{"role": "user", "content": prompt}],
172
+ tokenize=True,
173
+ add_generation_prompt=True,
174
+ return_tensors="pt",
175
+ ).to(dev)
176
+
177
+ gen_config = copy.deepcopy(model.generation_config)
178
+ gen_config.max_denoising_steps = steps
179
+ gen_config.max_new_tokens = canvas_len
180
+
181
+ model.eval()
182
+
183
+ with torch.no_grad():
184
+ output = model.generate(
185
+ input_ids=input_ids,
186
+ generation_config=gen_config,
187
+ )
188
 
189
+ generated = output.sequences[0, input_ids.shape[1]:]
190
+ text = tok.decode(generated.tolist(), skip_special_tokens=True)
191
+
192
+ return text.strip().lower()
193
+
194
+
195
+ prompt = """Answer the biomedical research question using only the context.
196
+
197
+ Context:
198
+ [Paste PubMed abstract context here]
199
+
200
+ Question:
201
+ [Paste biomedical question here]
202
+
203
+ Answer with only one word: yes, no, or maybe."""
204
+
205
+ print(answer_question(prompt, steps=16))
206
+ ```
207
 
208
  ## Training Details
209
 
210
  ### Training Data
211
 
212
+ The model was fine-tuned on `qiaojin/PubMedQA`.
213
 
214
+ The notebook used:
215
+
216
+ - **Training split:** `pqa_artificial`
217
+ - **Evaluation split:** `pqa_labeled`
218
+ - **Training examples used:** 3,000
219
+ - **Evaluation examples prepared:** 200
220
+ - **Evaluation examples used for reported result:** 50
221
+
222
+ Each training example was converted into a prompt-answer pair:
223
+
224
+ ```text
225
+ Input:
226
+ Biomedical question + PubMed abstract context
227
+
228
+ Target:
229
+ yes / no / maybe
230
+ ```
231
 
232
  ### Training Procedure
233
 
234
+ #### Preprocessing
235
 
236
+ For each PubMedQA row:
237
 
238
+ 1. The abstract contexts were joined into one context block.
239
+ 2. The context was truncated to 2,500 characters.
240
+ 3. The question was inserted below the context.
241
+ 4. The target answer was the `final_decision` field.
242
+ 5. Only examples with `yes`, `no`, or `maybe` labels were used.
243
 
244
+ Prompt format:
245
 
246
+ ```text
247
+ Answer the biomedical research question using only the context.
248
 
249
+ Context:
250
+ {context}
251
 
252
+ Question:
253
+ {question}
254
 
255
+ Answer with only one word: yes, no, or maybe.
256
+ ```
257
 
258
+ Target format:
259
 
260
+ ```text
261
+ {final_decision}
262
+ ```
263
 
264
+ #### Training Hyperparameters
265
+
266
+ - **Training regime:** bf16
267
+ - **LoRA rank:** 64
268
+ - **LoRA alpha:** 128
269
+ - **Trainable parameters:** 149,630,976
270
+ - **Total parameters:** 25,973,409,840
271
+ - **Trainable percentage:** 0.5761%
272
+ - **Training examples:** 3,000
273
+ - **Training steps:** 60
274
+ - **Gradient accumulation:** 4
275
+ - **Learning rate:** 1e-4
276
+ - **Optimizer:** AdamW
277
+ - **Scheduler:** OneCycleLR
278
+ - **Weight decay:** 0.0
279
+ - **Max context characters:** 2,500
280
+ - **Canvas length:** 256
281
+ - **Dataset:** `qiaojin/PubMedQA`
282
+
283
+ #### Speeds, Sizes, Times
284
+
285
+ Training was run on a RunPod H100 notebook.
286
+
287
+ Training logs from the saved notebook:
288
+
289
+ ```text
290
+ step 20/60 | loss 0.0019 | 43s
291
+ step 40/60 | loss 0.0003 | 85s
292
+ step 60/60 | loss 0.0001 | 126s
293
+ ```
294
+
295
+ Approximate training time:
296
+
297
+ ```text
298
+ 126 seconds for 60 steps
299
+ ```
300
+
301
+ ## Evaluation
302
 
303
  ### Testing Data, Factors & Metrics
304
 
305
  #### Testing Data
306
 
307
+ Evaluation used the `pqa_labeled` subset of `qiaojin/PubMedQA`.
308
 
309
+ The reported run used:
310
 
311
+ - **Evaluation examples:** 50
312
+ - **Denoising steps:** 16
313
+ - **Metric:** Accuracy
314
 
315
+ #### Factors
316
 
317
+ The evaluation was not disaggregated by biomedical topic, article type, answer class, or question type. Results should be treated as a small sanity-check evaluation, not a full benchmark.
318
 
319
  #### Metrics
320
 
321
+ Accuracy was used because PubMedQA final decisions are discrete labels:
322
 
323
+ ```text
324
+ yes / no / maybe
325
+ ```
326
+
327
+ A prediction was counted as correct if the cleaned model output matched the gold `final_decision`.
328
 
329
  ### Results
330
 
331
+ | Setting | Accuracy | Correct / Total |
332
+ | --- | --- | --- |
333
+ | Before fine-tuning | 0.60 | 30 / 50 |
334
+ | After fine-tuning | 0.80 | 40 / 50 |
335
+ | Improvement | +0.20 | +10 / 50 |
336
 
337
  #### Summary
338
 
339
+ In the saved RunPod H100 notebook run, the model improved from **60% accuracy before fine-tuning** to **80% accuracy after fine-tuning** on a 50-example PubMedQA evaluation sample.
340
 
341
+ This is a **+20 percentage point improvement**.
342
 
343
+ The result shows that the model can quickly adapt to the PubMedQA answer format. However, this is a small evaluation and should not be interpreted as a clinically meaningful benchmark.
344
 
345
+ ## Model Examination
346
 
347
+ No detailed interpretability or model examination was performed.
348
 
349
  ## Environmental Impact
350
 
351
+ Carbon emissions were not measured for this run.
 
 
352
 
353
+ - **Hardware Type:** NVIDIA H100 80GB HBM3
354
+ - **Hours used:** Approximately 0.04 hours for the 60-step training loop, excluding setup, model loading, and evaluation
355
+ - **Cloud Provider:** RunPod
356
+ - **Compute Region:** Not recorded
357
+ - **Carbon Emitted:** Not measured
358
 
359
+ ## Technical Specifications
360
 
361
  ### Model Architecture and Objective
362
 
363
+ The base model is DiffusionGemma 26B-A4B IT, a diffusion-style language model. The fine-tuning used LoRA adapters.
364
 
365
+ The training objective followed a block-diffusion setup:
366
 
367
+ 1. Encode the target answer into the model canvas.
368
+ 2. Randomly corrupt answer tokens.
369
+ 3. Train the model to reconstruct the clean answer.
370
+ 4. Apply loss only over the target answer tokens.
371
+
372
+ ### Compute Infrastructure
373
 
374
  #### Hardware
375
 
376
+ - NVIDIA H100 80GB HBM3
377
+ - Reported GPU memory: approximately 85 GB total
378
 
379
  #### Software
380
 
381
+ - Python
382
+ - PyTorch 2.10.0+cu128
383
+ - Transformers
384
+ - Unsloth
385
+ - Unsloth Zoo
386
+ - PEFT
387
+ - Datasets
388
+ - RunPod Jupyter Notebook
389
+
390
+ ## Citation
391
 
392
+ If you use this model, please cite the original PubMedQA dataset and DiffusionGemma base model.
393
 
394
+ **PubMedQA:**
395
 
396
+ ```bibtex
397
+ @inproceedings{jin2019pubmedqa,
398
+ title={PubMedQA: A Dataset for Biomedical Research Question Answering},
399
+ author={Jin, Qiao and Dhingra, Bhuwan and Liu, Zhengping and Cohen, William W. and Lu, Xinghua},
400
+ booktitle={Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing},
401
+ year={2019}
402
+ }
403
+ ```
404
 
405
+ ## Glossary
406
 
407
+ - **PubMedQA:** A biomedical question-answering dataset based on PubMed abstracts.
408
+ - **LoRA:** Low-Rank Adaptation, a parameter-efficient fine-tuning method.
409
+ - **DiffusionGemma:** A diffusion-style language model.
410
+ - **Denoising steps:** Iterative generation steps used by diffusion models.
411
+ - **Accuracy:** Percentage of predictions matching the gold label.
412
 
413
+ ## More Information
414
 
415
+ This model was created as a simple fine-tuning experiment for adapting DiffusionGemma to a medical QA dataset.
416
 
417
+ The task is intentionally simple:
418
 
419
+ ```text
420
+ Biomedical context + question → yes / no / maybe
421
+ ```
422
 
423
+ For a stronger medical QA model, future versions should train on both:
424
 
425
+ ```text
426
+ Decision: yes/no/maybe
427
+ Explanation: short evidence-based explanation
428
+ ```
429
 
430
+ ## Model Card Authors
431
 
432
+ - kingabzpro
433
 
434
  ## Model Card Contact
435
 
436
+ For questions, contact the model repository owner on Hugging Face.