You need to agree to share your Hugging Face information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

OncoLLM-4B-LoRA

DOI

Rapport technique / Technical report : OncoLLM: adapting MedGemma 4B and 27B to oncology tasks, Pierre Antoine, Zenodo, 2026, DOI 10.5281/zenodo.23134374 (PDF FR et EN / PDF in French and English). Jeu d'évaluation / Evaluation set : OncoLLM-Quiz-Onco-v1.

Français

OncoLLM-4B est un modèle de langage médical, ajusté (fine-tuning) à partir de google/medgemma-4b-it pour des tâches d'oncologie en français et en anglais : extraction de biomarqueurs, réponse au traitement, typage TCGA (type, T, N, M), codage CIM-10 et questions à choix de type MediQAl. Auteur : Pierre Antoine.

Dépôt de l'adapter : à appliquer sur google/medgemma-4b-it (voir Utilisation). Le modèle complet est dans OncoLLM-4B.

Usage prévu et limites d'usage

  • Modèle de recherche : il n'est pas un dispositif médical, n'a fait l'objet d'aucune validation clinique et ne doit pas servir à décider seul d'une prise en charge. Son usage doit respecter la politique d'usage interdit et les conditions HAI-DEF (voir Licence).
  • Seule la partie texte a été ajustée et évaluée, la partie vision de MedGemma 4B n'a été ni modifiée ni évaluée.
  • Il sait réciter le serment d'Hippocrate (version du Conseil national de l'Ordre des médecins, 2012) et répondre à des questions sur son contenu.

Entraînement

  • Modèle de base : google/medgemma-4b-it. Méthode : LoRA 16 bits, rang 64, alpha 16 à l'entraînement (configuration publiée : alpha 32, voir Utilisation), taux d'apprentissage 2e-4 décroissant, 2 époques, lot effectif de 16, longueur maximale 4 096 tokens, graine 3407, couches de langage uniquement. Fine-tuning réalisé avec Unsloth. 590 pas d'entraînement.
  • Mélange : 4 718 exemples (jeu d'ajustement du Quiz Onco v1, 4 417 exemples, plus 301 exemples d'identité et de serment, répétés 3 fois et 2 fois).

Données

MediQAl (ANR-MALADES/MediQAl) : questions d'examens médicaux français, tâche Q5 (choix unique, choix multiples). Licence affichée sur la fiche : cc-by-4.0. Splits utilisés : splits officiels train, validation et test, questions d'oncologie uniquement (lexique v2) ; questions ouvertes (oeq) exclues. PARHAF (HealthDataHub/PARHAF, corpus de comptes rendus cliniques fictifs en français) : tâche Q4 (codage CIM-10, pool « General » uniquement). Licences annoncées dans l'article : CC BY 4.0 et Etalab 2.0. PARHAF-biomarkers-annotated et PARHAF-response_to_treatment-annotated (HealthDataHub) : Q1 (biomarqueurs) pour le premier jeu, Q2 (réponse au traitement) pour le second. Licence affichée sur la fiche HF de chacun des deux jeux : cc-by-4.0. PARCOMED (HealthDataHub/PARCOMED) : utilisé pour sonder la couverture oncologique pendant la conception du Quiz (scripts d'exploration) ; non chargé par les scripts qui construisent le Quiz ni par ceux qui entraînent le modèle. Licences affichées sur la fiche : cc-by-4.0 et etalab-2.0. TCGA-Reports (Kefeli et Tatonetti, Patterns 5(3), 2024, doi 10.1016/j.patter.2024.100933 ; dépôt github.com/tatonetti-lab/tcga-path-reports sous licence MIT) : tâche Q3 (type de cancer, T, N, M). Les rapports proviennent du TCGA via le portail GDC, dont les données en accès ouvert sont réutilisables avec mention de la source, sans tentative de réidentification des participants (politique du GDC). Serment d'Hippocrate, version CNOM 2012 : texte tiré du site du Conseil national de l'Ordre des médecins. Quiz Onco v1 : construit par l'auteur à partir des sources ci-dessus.

Évaluation

Quiz Onco v1, jeu d'évaluation de 9 tâches publié sur Hugging Face, sur un sous-ensemble déterministe de 150 éléments au plus par tâche et par division. Précision, sauf Q3 M (F1 macro, la classe majoritaire pèse 94 %). Les effectifs de Q2 (19 et 23) sont trop faibles pour conclure.

Tâche Métrique Modèle de base (val / test) OncoLLM-4B-LoRA (val / test)
Q1 biomarqueurs précision 0,871 / 0,818 0,931 / 0,975
Q2 réponse au traitement (n=19 / 23) précision 0,737 / 0,435 0,842 / 0,652
Q3 TCGA type précision 0,747 / 0,807 0,993 / 0,973
Q3 TCGA T précision 0,700 / 0,760 0,787 / 0,840
Q3 TCGA N précision 0,853 / 0,820 0,900 / 0,913
Q3 TCGA M F1 macro 0,405 / 0,480 0,799 / 0,799
Q4 codage CIM-10, code exact précision 0,097 / 0,047 0,366 / 0,306
Q4 CIM-10, catégorie à 3 caractères précision 0,290 / 0,224 0,774 / 0,776
Q5 MediQAl choix unique précision 0,513 / 0,187 0,633 / 0,227
Q5 MediQAl choix multiples précision 0,178 / 0,067 0,308 / 0,107

Serment et identité (jeu de test interne) : identité 14/14 ; texte complet du serment 4/4 ; questions sur le contenu, formulations non vues 16/24.

Limites connues : la division test de Q5 est nettement plus difficile que la division validation, sans explication établie à ce jour ; les intervalles de confiance et les comparaisons appariées figurent dans le rapport technique publié sur Zenodo (DOI 10.5281/zenodo.23134374).

Utilisation

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel

base = "google/medgemma-4b-it"  # acceptez d'abord les conditions de MedGemma sur Hugging Face
tok = AutoTokenizer.from_pretrained(base)
model = AutoModelForCausalLM.from_pretrained(base, torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(model, "Grujowmi/OncoLLM-4B-LoRA")
messages = [{"role": "user", "content": "Qui es-tu ?"}]
inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True).to(model.device)
out = model.generate(**inputs, max_new_tokens=100, do_sample=False)
print(tok.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))

Échelle du LoRA. Cet adapter a été entraîné et évalué avec Unsloth (lora_alpha 16). D'après nos mesures, il y agit avec une échelle effective environ double de lora_alpha / r : avec Transformers et PEFT, la valeur nominale 16 donne un comportement sensiblement différent (par exemple, la réponse d'identité est tronquée). La configuration publiée dans ce dépôt utilise donc lora_alpha: 32, ce qui reproduit, dans nos vérifications, les réponses mesurées avec Unsloth (questions d'identité, et Quiz via un modèle fusionné à la même échelle). Avec Unsloth, utilisez plutôt la valeur d'origine lora_alpha: 16. Si PEFT signale un torchao incompatible, mettez ce paquet à jour ou désinstallez-le.

Licence

Ce modèle est un dérivé de MedGemma, fourni selon les Health AI Developer Foundations Terms of Use. En l'utilisant ou en le redistribuant, vous acceptez de respecter les restrictions d'usage de la section 3.2 de ces conditions et la politique d'usage interdit, et vous devez les inclure dans tout accord régissant l'usage ou la distribution de ce modèle ou de ses dérivés. Voir aussi le fichier NOTICE. Une autorisation réglementaire de santé peut être requise selon l'usage.

Remerciements : Google (MedGemma), Unsloth, Hugging Face.

English

OncoLLM-4B is a medical language model fine-tuned from google/medgemma-4b-it for oncology tasks in French and English: biomarker extraction, treatment response, TCGA typing (type, T, N, M), ICD-10 coding and MediQAl-style multiple-choice questions. Author: Pierre Antoine.

Repository of the adapter: apply it to google/medgemma-4b-it (see Usage). The full model is OncoLLM-4B.

Intended use and limits

  • Research model: it is not a medical device, has had no clinical validation, and must not be used on its own to decide patient care. Use must comply with the prohibited use policy and the HAI-DEF terms (see License).
  • Only the text part was fine-tuned and evaluated, the vision part of MedGemma 4B was neither modified nor evaluated.
  • It can recite the Hippocratic Oath (version of the French Medical Council, 2012) and answer questions about its content.

Training

  • Base model: google/medgemma-4b-it. Method: 16-bit LoRA, rank 64, alpha 16 at training time (published configuration: alpha 32, see Usage), learning rate 2e-4 with linear decay, 2 epochs, effective batch size 16, maximum length 4,096 tokens, seed 3407, language layers only. Fine-tuned with Unsloth. 590 training steps.
  • Mixture: 4,718 examples (Quiz Onco v1 fine-tuning split, 4,417 examples, plus 301 identity and oath examples, repeated 3 and 2 times).

Data

MediQAl (ANR-MALADES/MediQAl): French medical exam questions, task Q5 (single answer, multiple answers). License shown on the dataset page: cc-by-4.0. Splits used: official train, validation and test splits, oncology questions only (lexicon v2); open-ended questions (oeq) excluded. PARHAF (HealthDataHub/PARHAF, corpus of fictional French clinical reports): task Q4 (ICD-10 coding, "General" pool only). Licenses announced in the paper: CC BY 4.0 and Etalab 2.0. PARHAF-biomarkers-annotated and PARHAF-response_to_treatment-annotated (HealthDataHub): Q1 (biomarkers) for the first dataset, Q2 (treatment response) for the second. License shown on the HF page of each of the two datasets: cc-by-4.0. PARCOMED (HealthDataHub/PARCOMED): used to probe oncology coverage while designing the Quiz (exploration scripts); not loaded by the scripts that build the Quiz nor by those that train the model. Licenses shown on the dataset page: cc-by-4.0 and etalab-2.0. TCGA-Reports (Kefeli and Tatonetti, Patterns 5(3), 2024, doi 10.1016/j.patter.2024.100933; repository github.com/tatonetti-lab/tcga-path-reports under the MIT license): task Q3 (cancer type, T, N, M). The reports come from TCGA through the GDC portal, whose open-access data can be reused with attribution of the source and without attempting to re-identify participants (GDC policy). Hippocratic Oath, CNOM 2012 version: text taken from the website of the French National Medical Council (Conseil national de l'Ordre des médecins). Quiz Onco v1: built by the author from the sources above.

Evaluation

Quiz Onco v1, a 9-task evaluation set published on Hugging Face, on a deterministic subset of at most 150 items per task and split. Accuracy, except Q3 M (macro F1, the majority class is 94%). Q2 sample sizes (19 and 23) are too small to conclude.

Task Metric Base model (val / test) OncoLLM-4B-LoRA (val / test)
Q1 biomarkers accuracy 0.871 / 0.818 0.931 / 0.975
Q2 treatment response (n=19 / 23) accuracy 0.737 / 0.435 0.842 / 0.652
Q3 TCGA type accuracy 0.747 / 0.807 0.993 / 0.973
Q3 TCGA T accuracy 0.700 / 0.760 0.787 / 0.840
Q3 TCGA N accuracy 0.853 / 0.820 0.900 / 0.913
Q3 TCGA M macro F1 0.405 / 0.480 0.799 / 0.799
Q4 ICD-10 coding, exact code accuracy 0.097 / 0.047 0.366 / 0.306
Q4 ICD-10, 3-character category accuracy 0.290 / 0.224 0.774 / 0.776
Q5 MediQAl single answer accuracy 0.513 / 0.187 0.633 / 0.227
Q5 MediQAl multiple answers accuracy 0.178 / 0.067 0.308 / 0.107

Oath and identity (internal test set): identity 14/14; full oath text 4/4; content questions, unseen phrasings 16/24.

Known limitation: the Q5 test split is much harder than the validation split, with no established explanation yet; confidence intervals and paired comparisons are given in the technical report published on Zenodo (DOI 10.5281/zenodo.23134374).

Usage

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel

base = "google/medgemma-4b-it"  # first accept the MedGemma terms on Hugging Face
tok = AutoTokenizer.from_pretrained(base)
model = AutoModelForCausalLM.from_pretrained(base, torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(model, "Grujowmi/OncoLLM-4B-LoRA")
messages = [{"role": "user", "content": "Qui es-tu ?"}]
inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True).to(model.device)
out = model.generate(**inputs, max_new_tokens=100, do_sample=False)
print(tok.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))

LoRA scale. This adapter was trained and evaluated with Unsloth (lora_alpha 16). According to our measurements, it acts there with an effective scale about twice lora_alpha / r: with Transformers and PEFT, the nominal value 16 gives noticeably different behavior (for example, the identity answer is truncated). The configuration published in this repository therefore uses lora_alpha: 32, which reproduces, in our checks, the answers measured with Unsloth (identity questions, and the Quiz through a merged model at the same scale). With Unsloth, use the original value lora_alpha: 16 instead. If PEFT reports an incompatible torchao, update or uninstall that package.

License

This model is a derivative of MedGemma, provided under the Health AI Developer Foundations Terms of Use. By using or redistributing it you agree to comply with the use restrictions in Section 3.2 of those terms and the prohibited use policy, and you must include them in any agreement governing the use or distribution of this model or its derivatives. See also the NOTICE file. Health regulatory authorization may be required depending on the use.

Acknowledgements: Google (MedGemma), Unsloth, Hugging Face.

Citation

@misc{antoine2026oncollm,
  author    = {Antoine, Pierre},
  title     = {OncoLLM: adapting MedGemma 4B and 27B to oncology tasks},
  year      = {2026},
  publisher = {Zenodo},
  doi       = {10.5281/zenodo.23134374},
  url       = {https://zenodo.org/records/23134374}
}
Downloads last month
4
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Grujowmi/OncoLLM-4B-LoRA

Adapter
(125)
this model