Image-Text-to-Text
Transformers
Safetensors
English
gemma4
text-generation-inference
unsloth
conversational
icd-coding
clinical-nlp
medical-ai
Instructions to use nikhil061307/gemma4-e4b-icd-coding with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nikhil061307/gemma4-e4b-icd-coding with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="nikhil061307/gemma4-e4b-icd-coding") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("nikhil061307/gemma4-e4b-icd-coding") model = AutoModelForImageTextToText.from_pretrained("nikhil061307/gemma4-e4b-icd-coding") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use nikhil061307/gemma4-e4b-icd-coding with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nikhil061307/gemma4-e4b-icd-coding" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nikhil061307/gemma4-e4b-icd-coding", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/nikhil061307/gemma4-e4b-icd-coding
- SGLang
How to use nikhil061307/gemma4-e4b-icd-coding with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "nikhil061307/gemma4-e4b-icd-coding" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nikhil061307/gemma4-e4b-icd-coding", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "nikhil061307/gemma4-e4b-icd-coding" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nikhil061307/gemma4-e4b-icd-coding", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Unsloth Studio new
How to use nikhil061307/gemma4-e4b-icd-coding with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for nikhil061307/gemma4-e4b-icd-coding to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for nikhil061307/gemma4-e4b-icd-coding to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for nikhil061307/gemma4-e4b-icd-coding to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="nikhil061307/gemma4-e4b-icd-coding", max_seq_length=2048, ) - Docker Model Runner
How to use nikhil061307/gemma4-e4b-icd-coding with Docker Model Runner:
docker model run hf.co/nikhil061307/gemma4-e4b-icd-coding
| license: apache-2.0 | |
| language: | |
| - en | |
| base_model: | |
| - unsloth/gemma-4-e4b-it-unsloth-bnb-4bit | |
| tags: | |
| - transformers | |
| - safetensors | |
| - gemma4 | |
| - image-text-to-text | |
| - text-generation-inference | |
| - unsloth | |
| - conversational | |
| - icd-coding | |
| - clinical-nlp | |
| - medical-ai | |
| pipeline_tag: image-text-to-text | |
| # π₯ gemma4-e4b-icd-coding | |
| A fine-tuned **Gemma 4 E4B** model for automatic **ICD code prediction** from clinical notes. Given a free-text clinical note, the model outputs the relevant ICD diagnosis codes β streamlining medical billing, documentation, and clinical analytics workflows. | |
| --- | |
| ## π Model Overview | |
| | Property | Details | | |
| |---|---| | |
| | **Base Model** | `unsloth/gemma-4-e4b-it-unsloth-bnb-4bit` | | |
| | **Fine-tuned by** | [nikhil061307](https://huggingface.co/nikhil061307) | | |
| | **Task** | Clinical Note β ICD Code Prediction | | |
| | **Language** | English | | |
| | **License** | Apache 2.0 | | |
| | **Training Framework** | [Unsloth](https://github.com/unslothai/unsloth) + HuggingFace TRL | | |
| --- | |
| ## π What It Does | |
| Given a clinical note like: | |
| > *"Patient presents with persistent cough, fever, and bilateral infiltrates on chest X-ray. Diagnosed with community-acquired pneumonia."* | |
| The model outputs the appropriate ICD-10 code(s), e.g.: | |
| ``` | |
| J18.9 - Pneumonia, unspecified organism | |
| ``` | |
| --- | |
| ## π» Usage | |
| ### Installation | |
| ```bash | |
| pip install unsloth transformers torch | |
| ``` | |
| ### Inference | |
| ```python | |
| from transformers import AutoTokenizer, AutoModelForImageTextToText | |
| import torch | |
| model_id = "nikhil061307/gemma4-e4b-icd-coding" | |
| tokenizer = AutoTokenizer.from_pretrained(model_id) | |
| model = AutoModelForImageTextToText.from_pretrained( | |
| model_id, | |
| device_map="auto", | |
| torch_dtype=torch.bfloat16, | |
| ) | |
| clinical_note = """ | |
| Patient is a 65-year-old male with a history of type 2 diabetes presenting | |
| with polyuria, polydipsia, and HbA1c of 9.2%. Blood glucose fasting at 210 mg/dL. | |
| """ | |
| messages = [ | |
| { | |
| "role": "user", | |
| "content": f"Predict the ICD-10 codes for the following clinical note:\n\n{clinical_note}" | |
| } | |
| ] | |
| input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) | |
| inputs = tokenizer(input_text, return_tensors="pt").to(model.device) | |
| with torch.no_grad(): | |
| outputs = model.generate( | |
| **inputs, | |
| max_new_tokens=256, | |
| temperature=0.1, | |
| do_sample=True, | |
| ) | |
| response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True) | |
| print(response) | |
| ``` | |
| --- | |
| ## π§ͺ Example Input / Output | |
| **Input (Clinical Note):** | |
| ``` | |
| A 52-year-old woman presents with sharp chest pain radiating to the left arm, | |
| diaphoresis, and shortness of breath. ECG shows ST elevation in leads II, III, aVF. | |
| Troponin elevated. Impression: Acute inferior STEMI. | |
| ``` | |
| **Output (ICD Codes):** | |
| ``` | |
| I21.19 - ST elevation (STEMI) myocardial infarction involving other coronary artery | |
| ``` | |
| --- | |
| ## βοΈ Training Details | |
| - **Base model:** `unsloth/gemma-4-e4b-it-unsloth-bnb-4bit` (4-bit quantized) | |
| - **Training speedup:** 2x faster training with [Unsloth](https://github.com/unslothai/unsloth) | |
| - **Library:** HuggingFace TRL (SFTTrainer) | |
| - **Quantization:** BnB 4-bit (inference efficient) | |
| --- | |
| ## β οΈ Limitations & Disclaimer | |
| - This model is intended for **research and assistive purposes only**. | |
| - It is **not a substitute for professional medical coding** by certified coders (CPC/CCS). | |
| - Always verify predicted ICD codes with qualified clinical staff before use in billing or official documentation. | |
| - Model performance may vary across specialties, note styles, and rare diagnosis categories. | |
| --- | |
| ## π License | |
| This model is released under the **Apache 2.0** license. See [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) for details. | |
| --- | |
| ## π Acknowledgements | |
| - [Unsloth AI](https://github.com/unslothai/unsloth) β for the blazing fast fine-tuning framework | |
| - [Google DeepMind](https://deepmind.google/) β for the Gemma model family | |
| - [HuggingFace TRL](https://github.com/huggingface/trl) β for the SFT training utilities | |
| --- | |
| *Made with β€οΈ using [Unsloth](https://github.com/unslothai/unsloth)* |