Downloads · 30 days
0
TachyHealthResearch/medgemma-4b-medical-coding
medgemma-4b-medical-coding is a text generation model from TachyHealthResearch. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
This is a LoRA adapter fine-tuned on medGemma4B for medical coding tasks. The model is specifically designed to:
Downloads · 30 days
0
Access
Public
Updated Sep 1, 2025
Repo size
165 MB
Likes
2
Public
Click a slice to open those files.
.safetensors197 MB · 66%
From the Hugging Face model README
This is a LoRA adapter fine-tuned on medGemma4B for medical coding tasks. The model is specifically designed to:
Base Model: medGemma4B
Fine-tuning Method: LoRA (Low-Rank Adaptation)
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained("TachyHealthResearch/medgemma-4b-medical-coding")
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
"medGemma4B",
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True
)
# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "TachyHealthResearch/medgemma-4b-medical-coding")
# Define the system prompt for medical coding
system_prompt = """You are an expert medical coding specialist.
Analyze the discharge summary to extract diseases, procedures, and assign appropriate medical codes.
Return the response in JSON format with this structure:
{"diseases": ["disease1", "disease2"], "icd10_codes": ["code1", "code2"],
"procedures": ["procedure1", "procedure2"], "cpt_codes": ["code1", "code2"],
"hcpcs_codes": ["code1", "code2"]}"""
# Example discharge summary
discharge_summary = """
Patient admitted with chest pain and shortness of breath.
Diagnosed with acute myocardial infarction and congestive heart failure.
Underwent percutaneous coronary intervention with stent placement.
"""
# Prepare the conversation
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": f"Please analyze this discharge summary:\n\n{discharge_summary}"}
]
# Apply chat template and generate
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.1,
do_sample=True,
pad_token_id=tokenizer.eos_token_id,
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
generated_response = response[len(text):].strip()
print("Generated Medical Codes:")
print(generated_response)
This model has been specifically fine-tuned for medical coding tasks and demonstrates strong performance in:
This model is released under the Apache 2.0 License.
If you use this model in your research or applications, please cite:
@misc{TachyHealthResearch_medgemma_4b_medical_coding_2024},
title = {medgemma-4b-medical-coding: Medical Coding Model},
author = {TachyHealthResearch},
year = {2024},
publisher = {Hugging Face},
url = {https://huggingface.co/TachyHealthResearch/medgemma-4b-medical-coding}
}
Important: This model is intended for research and healthcare applications. Always ensure proper validation and human oversight when using AI models in medical contexts.