Image-Text-to-Text
Transformers
Safetensors
gemma3
Generated from Trainer
trl
sft
conversational
text-generation-inference
Instructions to use ClinicalIntelligence/saama_gemma with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ClinicalIntelligence/saama_gemma with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ClinicalIntelligence/saama_gemma") 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, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("ClinicalIntelligence/saama_gemma") model = AutoModelForMultimodalLM.from_pretrained("ClinicalIntelligence/saama_gemma", device_map="auto") 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 Settings
- vLLM
How to use ClinicalIntelligence/saama_gemma with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ClinicalIntelligence/saama_gemma" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ClinicalIntelligence/saama_gemma", "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/ClinicalIntelligence/saama_gemma
- SGLang
How to use ClinicalIntelligence/saama_gemma 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 "ClinicalIntelligence/saama_gemma" \ --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": "ClinicalIntelligence/saama_gemma", "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 "ClinicalIntelligence/saama_gemma" \ --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": "ClinicalIntelligence/saama_gemma", "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" } } ] } ] }' - Docker Model Runner
How to use ClinicalIntelligence/saama_gemma with Docker Model Runner:
docker model run hf.co/ClinicalIntelligence/saama_gemma
Update README.md
Browse files
README.md
CHANGED
|
@@ -14,12 +14,17 @@ licence: license
|
|
| 14 |
This model is a fine-tuned version of [google/medgemma-4b-it](https://huggingface.co/google/medgemma-4b-it).
|
| 15 |
It has been trained using [TRL](https://github.com/huggingface/trl).
|
| 16 |
|
| 17 |
-
The ClinicalIntelligence/saama_gemma is a fine-tuned MedGemma model designed to transform unstructured clinical narratives—such as discharge notes—into structured, SDTM-aligned datasets (e.g., Adverse Events, Medical History, Procedures). Trained on an SME-curated dataset derived from MIMIC-III, the model treats clinical data extraction as a complex reasoning task, explicitly evaluating assertion, temporality, and causality to generate accurate, traceable JSON outputs. By learning regulatory semantics directly, it significantly outperforms base models in domain grounding and schema consistency. Users should note current limitations regarding context window constraints for lengthy notes, rare abbreviation handling, and the resolution of multi-domain entities.
|
| 18 |
|
| 19 |
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
## Quick start
|
|
|
|
| 23 |
|
| 24 |
```python
|
| 25 |
import re
|
|
@@ -36,6 +41,7 @@ generator = pipeline(
|
|
| 36 |
output = generator(
|
| 37 |
[{"role": "user", "content": prefix + unstructured_text}],
|
| 38 |
return_full_text=False,
|
|
|
|
| 39 |
)[0]
|
| 40 |
llm_output = output["generated_text"]
|
| 41 |
|
|
|
|
| 14 |
This model is a fine-tuned version of [google/medgemma-4b-it](https://huggingface.co/google/medgemma-4b-it).
|
| 15 |
It has been trained using [TRL](https://github.com/huggingface/trl).
|
| 16 |
|
| 17 |
+
The [ClinicalIntelligence/saama_gemma](https://huggingface.co/ClinicalIntelligence/saama_gemma) is a fine-tuned MedGemma model designed to transform unstructured clinical narratives—such as discharge notes—into structured, SDTM-aligned datasets (e.g., Adverse Events, Medical History, Procedures). Trained on an SME-curated dataset derived from MIMIC-III, the model treats clinical data extraction as a complex reasoning task, explicitly evaluating assertion, temporality, and causality to generate accurate, traceable JSON outputs. By learning regulatory semantics directly, it significantly outperforms base models in domain grounding and schema consistency. Users should note current limitations regarding context window constraints for lengthy notes, rare abbreviation handling, and the resolution of multi-domain entities.
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
+
## INSTALLATION
|
| 22 |
+
```
|
| 23 |
+
pip install -U transformers
|
| 24 |
+
```
|
| 25 |
|
| 26 |
## Quick start
|
| 27 |
+
**NOTE** - Adjust the **max_new_tokens** parameter as needed; it is set to 3000 by default.
|
| 28 |
|
| 29 |
```python
|
| 30 |
import re
|
|
|
|
| 41 |
output = generator(
|
| 42 |
[{"role": "user", "content": prefix + unstructured_text}],
|
| 43 |
return_full_text=False,
|
| 44 |
+
max_new_tokens=3000
|
| 45 |
)[0]
|
| 46 |
llm_output = output["generated_text"]
|
| 47 |
|