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
|
@@ -26,6 +26,19 @@ import re
|
|
| 26 |
|
| 27 |
from transformers import pipeline
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
def extract_entities(text):
|
| 31 |
"""
|
|
@@ -55,19 +68,6 @@ def extract_entities(text):
|
|
| 55 |
return extracted_data
|
| 56 |
|
| 57 |
|
| 58 |
-
prefix = """Extract SDTM domain entities from: """
|
| 59 |
-
|
| 60 |
-
unstructured_text = """<ENTER YOUR TEXT HERE>"""
|
| 61 |
-
|
| 62 |
-
generator = pipeline(
|
| 63 |
-
"text-generation", model="ClinicalIntelligence/saama_gemma", device="cuda"
|
| 64 |
-
)
|
| 65 |
-
output = generator(
|
| 66 |
-
[{"role": "user", "content": prefix + unstructured_text}],
|
| 67 |
-
max_new_tokens=16000,
|
| 68 |
-
return_full_text=False,
|
| 69 |
-
)[0]
|
| 70 |
-
llm_output = output["generated_text"]
|
| 71 |
extracted_entities_list = extract_entities(llm_output)
|
| 72 |
|
| 73 |
for extracted_entity in extracted_entities_list:
|
|
|
|
| 26 |
|
| 27 |
from transformers import pipeline
|
| 28 |
|
| 29 |
+
prefix = """Extract SDTM domain entities from: """
|
| 30 |
+
|
| 31 |
+
unstructured_text = """<ENTER YOUR TEXT HERE>"""
|
| 32 |
+
|
| 33 |
+
generator = pipeline(
|
| 34 |
+
"text-generation", model="ClinicalIntelligence/saama_gemma", device="cuda"
|
| 35 |
+
)
|
| 36 |
+
output = generator(
|
| 37 |
+
[{"role": "user", "content": prefix + unstructured_text}],
|
| 38 |
+
return_full_text=False,
|
| 39 |
+
)[0]
|
| 40 |
+
llm_output = output["generated_text"]
|
| 41 |
+
|
| 42 |
|
| 43 |
def extract_entities(text):
|
| 44 |
"""
|
|
|
|
| 68 |
return extracted_data
|
| 69 |
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
extracted_entities_list = extract_entities(llm_output)
|
| 72 |
|
| 73 |
for extracted_entity in extracted_entities_list:
|