Instructions to use google/translategemma-4b-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/translategemma-4b-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="google/translategemma-4b-it") 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("google/translategemma-4b-it") model = AutoModelForMultimodalLM.from_pretrained("google/translategemma-4b-it", 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 google/translategemma-4b-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/translategemma-4b-it" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/translategemma-4b-it", "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/google/translategemma-4b-it
- SGLang
How to use google/translategemma-4b-it 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 "google/translategemma-4b-it" \ --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": "google/translategemma-4b-it", "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 "google/translategemma-4b-it" \ --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": "google/translategemma-4b-it", "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 google/translategemma-4b-it with Docker Model Runner:
docker model run hf.co/google/translategemma-4b-it
Cannot load processor with `AutoProcessor` from transformers ≥ 5.4.0
#20 opened about 1 month ago
by
haukelicht
Handling Unknown Source Languages in Translation Templates
5
#19 opened 2 months ago
by
sandeep1401
Add missing fil language code
#18 opened 3 months ago
by
mjpohja
TranslateGemma Terminology Control and Context Support for Scientific Translation
1
#17 opened 3 months ago
by
EliasKim
Passing context to the model
1
#16 opened 3 months ago
by
Mahendranath
After llama.cpp rework of template parsing, can no longer load this model
👍 1
2
#15 opened 4 months ago
by
quasoft2
Support for Mossi (mos) language code in TranslateGemma chat template
5
#14 opened 6 months ago
by
madoss
Significant Performance Regression and Content Omission after 8-bit Quantization
1
#13 opened 6 months ago
by
Emily901017
finetune
3
#11 opened 6 months ago
by
Dehsahk-AI
new discuss
3
#10 opened 6 months ago
by
tegal12
how to use vllm to serve google/translategemma-4b-it & how to use it?
7
#9 opened 6 months ago
by
ggmarks
zh-CH looks like a typo of zh-CN?
2
#8 opened 6 months ago
by
lirc571
Performance?
4
#6 opened 6 months ago
by
Budenloui
Are there plans to provide task or litertlm versions for the litt-literature community?
👍 2
4
#5 opened 6 months ago
by
willopcbeta
Example script for fine-tuning on a new destination language
4
#4 opened 6 months ago
by
gmallen
Extremely slow inference (~130s) on RTX 3080 - "slow image processor" warning
👀 10
3
#3 opened 6 months ago
by
simpple28
input context -2k
1
#2 opened 6 months ago
by
LittleTaro
Installation Video and Testing - Step by Step
3
#1 opened 6 months ago
by
fahdmirzac