Downloads ยท 30 days
45
17% of all-time downloads
RayyanAhmed9477/med-coding
med-coding is a text classification model from RayyanAhmed9477. Use it when you need a label for a piece of text. The card lists the license as mit.
Downloads ยท 30 days
45
17% of all-time downloads
All-time downloads
266
Public
Parameters
3.8B
7.6 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors7.6 GB ยท 100%
From the Hugging Face model README
๐ฅ Advanced AI-Powered Medical Coding Model
Transforming Clinical Documentation into Accurate Medical Codes
The Rayyan Medical Coding Model is a state-of-the-art AI model designed for accurate medical code extraction from clinical documentation. Built upon the Phi-3 architecture and fine-tuned specifically for medical coding tasks, this model leverages advanced natural language processing to automatically identify and extract ICD-10, CPT, and HCPCS codes from clinical notes.
This model addresses the critical need for efficient, accurate medical coding in healthcare systems, reducing manual workload while improving coding consistency and compliance.
# Install transformers and dependencies
pip install transformers safetensors torch accelerate
# For GPU support (optional)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
# Load the model
model_name = "RayyanAhmed9477/med-coding"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="auto" # Uses GPU if available
)
# Example clinical text
clinical_text = """
Patient presents with Type 2 diabetes mellitus without complications.
Elevated HbA1c at 8.2%. Started on metformin 1000mg BID.
"""
# Prepare input
prompt = f"""
Extract medical codes from this clinical text:
{clinical_text}
Return results in JSON format:
{{
"codes": [
{{
"code": "...",
"type": "ICD-10|CPT|HCPCS",
"description": "...",
"confidence": 0.0-1.0,
"rationale": "..."
}}
]
}}
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
# Generate response
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=500,
temperature=0.3,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
# Decode and extract codes
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(response)
from transformers import pipeline
# Create a medical coding pipeline
medical_coder = pipeline(
"text-generation",
model="RayyanAhmed9477/med-coding",
torch_dtype=torch.bfloat16,
device_map="auto"
)
# Process clinical text
result = medical_coder(
"Patient diagnosed with acute bronchitis, prescribed azithromycin 500mg.",
max_new_tokens=300,
temperature=0.3
)
print(result[0]['generated_text'])
โโโ rayyan-med-coding-model.safetensors # Combined model weights
โโโ model.safetensors.index.json # Model index
โโโ config.json # Model configuration
โโโ tokenizer.json # Tokenizer data
โโโ tokenizer.model # SentencePiece model
โโโ tokenizer_config.json # Tokenizer settings
โโโ added_tokens.json # Medical domain tokens
โโโ special_tokens_map.json # Special token mappings
โโโ generation_config.json # Generation parameters
This model is licensed under the MIT License. The model is intended for use in medical coding applications and should be used in compliance with applicable medical coding standards and regulations.
If you use this model in your research, please cite:
@model{rayyan_medical_coding_2025,
title={Rayyan Medical Coding Model: AI-Powered Medical Code Extraction},
author={Rayyan Ahmed},
year={2025},
publisher={Hugging Face},
url={https://huggingface.co/RayyanAhmed9477/med-coding}
}
Get started today with the Rayyan Medical Coding Model!
โญ Star this repository if you find it useful!
</div>