TranslateGemma Technical Report
Paper • 2601.09012 • Published • 22
How to use bRadu/translategemma-4b-it-novision with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="bRadu/translategemma-4b-it-novision")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("bRadu/translategemma-4b-it-novision")
model = AutoModelForCausalLM.from_pretrained("bRadu/translategemma-4b-it-novision")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use bRadu/translategemma-4b-it-novision with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "bRadu/translategemma-4b-it-novision"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "bRadu/translategemma-4b-it-novision",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/bRadu/translategemma-4b-it-novision
How to use bRadu/translategemma-4b-it-novision with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "bRadu/translategemma-4b-it-novision" \
--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": "bRadu/translategemma-4b-it-novision",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "bRadu/translategemma-4b-it-novision" \
--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": "bRadu/translategemma-4b-it-novision",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use bRadu/translategemma-4b-it-novision with Docker Model Runner:
docker model run hf.co/bRadu/translategemma-4b-it-novision
Text-only (no-vision) conversion of google/translategemma-4b-it, saved in FP16 (safetensors).
The tokenizer is set from google/gemma-3-1b-it.
This repo contains a converted Gemma3ForCausalLM checkpoint extracted from the language component of the original multimodal model:
google/translategemma-4b-itGemma3ForCausalLM (text-only)float16 weightsSYSTEM_PROMPT = """You are a professional {source_lang} ({src_lang_code}) to {target_lang}
({tgt_lang_code}) translator. Your goal is to accurately convey the meaning and
nuances of the original {source_lang} text while adhering to {target_lang} grammar,
vocabulary, and cultural sensitivities. Produce only the {target_lang}
translation, without any additional explanations or commentary. Please translate
the following {source_lang} text into {target_lang}:\n"""
google/translategemma-4b-it page, similar to google/gemma-3-1b-it)
messages = [
{
"role" : "system",
"content": SYSTEM_PROMPT
},
{
"role": "user",
"content": <TEXT_TO_BE_TRANSLATED>
}
]
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(model)
tokenizer.apply_chat_template(messages)