Model Card for Model ID
Model Details
Model Description
- Developed by: [More Information Needed]
- Funded by [optional]: [More Information Needed]
- Shared by [optional]: [More Information Needed]
- Model type: [More Information Needed]
- Language(s) (NLP): [More Information Needed]
- License: [More Information Needed]
- Finetuned from model [optional]: [More Information Needed]
Model Sources [optional]
- Repository: [More Information Needed]
- Paper [optional]: [More Information Needed]
- Demo [optional]: [More Information Needed]
Uses
Direct Use
[More Information Needed]
Downstream Use [optional]
[More Information Needed]
Out-of-Scope Use
[More Information Needed]
Bias, Risks, and Limitations
[More Information Needed]
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
How to Get Started with the Model
Use the code below to get started with the model.
[More Information Needed]
Training Details
Training Data
[More Information Needed]
Training Procedure
Preprocessing [optional]
[More Information Needed]
Training Hyperparameters
- Training regime: [More Information Needed]
Speeds, Sizes, Times [optional]
[More Information Needed]
Evaluation
Testing Data, Factors & Metrics
Testing Data
[More Information Needed]
Factors
[More Information Needed]
Metrics
[More Information Needed]
Results
[More Information Needed]
Summary
Model Examination [optional]
[More Information Needed]
Environmental Impact
Carbon emissions can be estimated using the
Machine Learning Impact calculator presented in
Lacoste et al. (2019).
- Hardware Type: [More Information Needed]
- Hours used: [More Information Needed]
- Cloud Provider: [More Information Needed]
- Compute Region: [More Information Needed]
- Carbon Emitted: [More Information Needed]
Technical Specifications [optional]
Model Architecture and Objective
[More Information Needed]
Compute Infrastructure
[More Information Needed]
Hardware
[More Information Needed]
Software
[More Information Needed]
Citation [optional]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
Glossary [optional]
[More Information Needed]
More Information [optional]
[More Information Needed]
Model Card Authors [optional]
[More Information Needed]
Model Card Contact
[More Information Needed]
Framework versions
Utilisation avec LoRA
1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
3from peft import PeftModel
4
5# Configuration
6base_model_id = "google/medgemma-4b-it"
7model_id = "Sadou/medgemma-4b-it-medical-report-simplifier"
8device = "cuda" if torch.cuda.is_available() else "cpu"
9
10# Chargement du modèle de base
11base_model = AutoModelForCausalLM.from_pretrained(
12 base_model_id,
13 quantization_config=BitsAndBytesConfig(load_in_4bit=True),
14 device_map="auto",
15 torch_dtype=torch.bfloat16,
16)
17
18# Chargement des adaptateurs LoRA fine-tunés
19model = PeftModel.from_pretrained(base_model, model_id)
20
21# Chargement du tokenizer
22tokenizer = AutoTokenizer.from_pretrained(base_model_id)
23
24def simplify_medical_report(medical_text, max_length=300, temperature=0.3):
25 """
26 Simplifie un rapport médical pour un patient
27
28 Args:
29 medical_text (str): Texte médical à simplifier
30 max_length (int): Longueur maximale de la réponse
31 temperature (float): Créativité (0.1 = conservateur, 0.7 = créatif)
32
33 Returns:
34 str: Explication simplifiée et rassurante
35 """
36
37 prompt = f"""<start_of_turn>user
38{medical_text}<end_of_turn>
39<start_of_turn>model
40"""
41
42 inputs = tokenizer(prompt, return_tensors="pt").to(device)
43
44 with torch.inference_mode():
45 outputs = model.generate(
46 **inputs,
47 max_new_tokens=max_length,
48 do_sample=True,
49 temperature=temperature,
50 pad_token_id=tokenizer.eos_token_id,
51
52 )
53
54 response = tokenizer.decode(outputs[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True)
55 return response.strip()
56
57# Exemple d'utilisation
58medical_text = "Bilan thyroïdien : 'TSH : 8.5 mUI/L (N: 0.4-4.0), T4 libre : 10 pmol/L (N: 10-25). Hypothyroïdie fruste.'"
59simplified = simplify_medical_report(medical_text)
60print(f"📋 Rapport médical:\n{medical_text}\n")
61print(f"💬 Explication patient:\n{simplified}\n")