Run this model with HF Jobs

Run OussamaEL/medgemma-ECG-C on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/OussamaEL/medgemma-ECG-C. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/OussamaEL/medgemma-ECG-C on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/OussamaEL/medgemma-ECG-C. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/OussamaEL/medgemma-ECG-C. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.

MedGemma-4B ECG Report Generator

This is a fully merged, standalone model fine-tuned from unsloth/medgemma-4b-pt for ECG interpretation and clinical report generation. It was trained using the Unsloth library for high-efficiency, memory-optimized fine-tuning.

This model is designed to take structured output from a primary ML classifier (which provides findings like "Atrial Fibrillation: 82% confidence, Present") and synthesize it into a coherent, human-readable clinical report, complete with an impression, detailed analysis, and clinical recommendations.

Model Details

  • Base Model: unsloth/medgemma-4b-pt
  • Fine-tuning Method: Unsloth + LoRA (merged into base model)
  • Training Data: 500 curated ECG interpretation examples.
  • Evaluation Score: The model achieved an average structural correctness score of Not available / 1.0 on a hold-out set.

Usage

This model follows a standard instruction format. Provide the instruction and the structured input to get a clinical report.

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_name = "OussamaEL/medgemma-ECG-C"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)

# Alpaca prompt format is required
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction:
{}
### Input:
{}
### Response:
{}"""

instruction = "You are a medical AI assistant specializing in ECG interpretation. Analyze the ECG findings and patient context to generate a clinical report."

input_text = """ECG FINDINGS:
- Atrial Fibrillation (AFIB): 95% confidence, Present
- Sinus Tachycardia (STACH): 88% confidence, Present

PATIENT CONTEXT:
68-year-old male with diabetes and hypertension presents with 2 days of worsening shortness of breath and leg swelling."""

inputs = tokenizer(
    alpaca_prompt.format(instruction, input_text, ""),
    return_tensors="pt"
).to("cuda")

outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True).split("### Response:")[1].strip())

This model is intended for research and development purposes and is not a substitute for professional medical advice.

Downloads last month
36
Safetensors
Model size
4B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for OussamaEL/medgemma-ECG-C

Finetuned
(8)
this model