nikhil061307 commited on
Commit
3b5f767
Β·
verified Β·
1 Parent(s): e4d6607

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +145 -12
README.md CHANGED
@@ -1,21 +1,154 @@
1
  ---
2
- base_model: unsloth/gemma-4-e4b-it-unsloth-bnb-4bit
3
- tags:
4
- - text-generation-inference
5
- - transformers
6
- - unsloth
7
- - gemma4
8
  license: apache-2.0
9
  language:
10
  - en
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ---
12
 
13
- # Uploaded finetuned model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- - **Developed by:** nikhil061307
16
- - **License:** apache-2.0
17
- - **Finetuned from model :** unsloth/gemma-4-e4b-it-unsloth-bnb-4bit
18
 
19
- This gemma4 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
1
  ---
 
 
 
 
 
 
2
  license: apache-2.0
3
  language:
4
  - en
5
+ base_model:
6
+ - unsloth/gemma-4-e4b-it-unsloth-bnb-4bit
7
+ tags:
8
+ - transformers
9
+ - safetensors
10
+ - gemma4
11
+ - image-text-to-text
12
+ - text-generation-inference
13
+ - unsloth
14
+ - conversational
15
+ - icd-coding
16
+ - clinical-nlp
17
+ - medical-ai
18
+ pipeline_tag: image-text-to-text
19
  ---
20
 
21
+ # πŸ₯ gemma4-e4b-icd-coding
22
+
23
+ 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.
24
+
25
+ ---
26
+
27
+ ## πŸ“Œ Model Overview
28
+
29
+ | Property | Details |
30
+ |---|---|
31
+ | **Base Model** | `unsloth/gemma-4-e4b-it-unsloth-bnb-4bit` |
32
+ | **Fine-tuned by** | [nikhil061307](https://huggingface.co/nikhil061307) |
33
+ | **Task** | Clinical Note β†’ ICD Code Prediction |
34
+ | **Language** | English |
35
+ | **License** | Apache 2.0 |
36
+ | **Training Framework** | [Unsloth](https://github.com/unslothai/unsloth) + HuggingFace TRL |
37
+
38
+ ---
39
+
40
+ ## πŸš€ What It Does
41
+
42
+ Given a clinical note like:
43
+
44
+ > *"Patient presents with persistent cough, fever, and bilateral infiltrates on chest X-ray. Diagnosed with community-acquired pneumonia."*
45
+
46
+ The model outputs the appropriate ICD-10 code(s), e.g.:
47
+
48
+ ```
49
+ J18.9 - Pneumonia, unspecified organism
50
+ ```
51
+
52
+ ---
53
+
54
+ ## πŸ’» Usage
55
+
56
+ ### Installation
57
+
58
+ ```bash
59
+ pip install unsloth transformers torch
60
+ ```
61
+
62
+ ### Inference
63
+
64
+ ```python
65
+ from transformers import AutoTokenizer, AutoModelForImageTextToText
66
+ import torch
67
 
68
+ model_id = "nikhil061307/gemma4-e4b-icd-coding"
 
 
69
 
70
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
71
+ model = AutoModelForImageTextToText.from_pretrained(
72
+ model_id,
73
+ device_map="auto",
74
+ torch_dtype=torch.bfloat16,
75
+ )
76
+
77
+ clinical_note = """
78
+ Patient is a 65-year-old male with a history of type 2 diabetes presenting
79
+ with polyuria, polydipsia, and HbA1c of 9.2%. Blood glucose fasting at 210 mg/dL.
80
+ """
81
+
82
+ messages = [
83
+ {
84
+ "role": "user",
85
+ "content": f"Predict the ICD-10 codes for the following clinical note:\n\n{clinical_note}"
86
+ }
87
+ ]
88
+
89
+ input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
90
+ inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
91
+
92
+ with torch.no_grad():
93
+ outputs = model.generate(
94
+ **inputs,
95
+ max_new_tokens=256,
96
+ temperature=0.1,
97
+ do_sample=True,
98
+ )
99
+
100
+ response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True)
101
+ print(response)
102
+ ```
103
+
104
+ ---
105
+
106
+ ## πŸ§ͺ Example Input / Output
107
+
108
+ **Input (Clinical Note):**
109
+ ```
110
+ A 52-year-old woman presents with sharp chest pain radiating to the left arm,
111
+ diaphoresis, and shortness of breath. ECG shows ST elevation in leads II, III, aVF.
112
+ Troponin elevated. Impression: Acute inferior STEMI.
113
+ ```
114
+
115
+ **Output (ICD Codes):**
116
+ ```
117
+ I21.19 - ST elevation (STEMI) myocardial infarction involving other coronary artery
118
+ ```
119
+
120
+ ---
121
+
122
+ ## βš™οΈ Training Details
123
+
124
+ - **Base model:** `unsloth/gemma-4-e4b-it-unsloth-bnb-4bit` (4-bit quantized)
125
+ - **Training speedup:** 2x faster training with [Unsloth](https://github.com/unslothai/unsloth)
126
+ - **Library:** HuggingFace TRL (SFTTrainer)
127
+ - **Quantization:** BnB 4-bit (inference efficient)
128
+
129
+ ---
130
+
131
+ ## ⚠️ Limitations & Disclaimer
132
+
133
+ - This model is intended for **research and assistive purposes only**.
134
+ - It is **not a substitute for professional medical coding** by certified coders (CPC/CCS).
135
+ - Always verify predicted ICD codes with qualified clinical staff before use in billing or official documentation.
136
+ - Model performance may vary across specialties, note styles, and rare diagnosis categories.
137
+
138
+ ---
139
+
140
+ ## πŸ“„ License
141
+
142
+ This model is released under the **Apache 2.0** license. See [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) for details.
143
+
144
+ ---
145
+
146
+ ## πŸ™ Acknowledgements
147
+
148
+ - [Unsloth AI](https://github.com/unslothai/unsloth) β€” for the blazing fast fine-tuning framework
149
+ - [Google DeepMind](https://deepmind.google/) β€” for the Gemma model family
150
+ - [HuggingFace TRL](https://github.com/huggingface/trl) β€” for the SFT training utilities
151
+
152
+ ---
153
 
154
+ *Made with ❀️ using [Unsloth](https://github.com/unslothai/unsloth)*