Downloads · 30 days
84
12% of all-time downloads
aidsoid/translategemma-4b-it-4bit_immersive-translate
translategemma-4b-it-4bit_immersive-translate is a text generation model from aidsoid. Use it when you need the model to write or continue text. It is set up for mlx. The card lists the license as gemma.
Mirror of mlx-community/translategemma-4b-it-4bitimmersive-translate at revision 55fe183d, hosted for availability of the Awnsy app. Based on Google's Gemma; use is subject to the Gemma Terms of Use.
Downloads · 30 days
84
12% of all-time downloads
All-time downloads
681
Public
Parameters
3.9B
2.2 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors2.2 GB · 98%
How the weights are stored.
U323.9B · 100%
From the Hugging Face model README
Mirror of mlx-community/translategemma-4b-it-4bit_immersive-translate at revision
55fe183d, hosted for availability of the Awnsy app. Based on Google's Gemma; use is subject to the Gemma Terms of Use.
This repository is an MLX 4-bit build of google/translategemma-4b-it, derived from mlx-community/translategemma-4b-it-4bit and reconfigured for Immersive Translate when you call it through an OpenAI-compatible local server (for example mlx_lm.server). The goal is reliable on-device translation on Apple Silicon: correct stop tokens, and a chat template that understands Immersive Translate’s plain-text placeholders.
EOS / stopping (generation_config.json)
eos_token_id is set to [106, 1] so generation can end on both the Gemma end-of-turn id and the <eos> token. That avoids runaway or awkward truncation when OpenAI-style APIs stream or strip tokens differently than a bare generate() loop.
Chat template (chat_template.jinja)
The template was reformatted for Immersive Translate while staying compatible with TranslateGemma-style messages:
<<<source>>>, it is parsed into source language, target language, and body text, then expanded into the same “professional translator” instruction used in the official template.source_lang_code, target_lang_code, text), that path is unchanged.<start_of_turn>model so servers that always set add_generation_prompt=True still align with how Gemma expects the assistant turn to begin.Together, these updates make the OpenAI-compatible path (chat completions with a single user string) match what Immersive Translate sends, without fighting the tokenizer or EOS handling.
On macOS with Apple Silicon, use uv for a clean Python environment and run the built-in OpenAI-style HTTP server:
uv venv --python 3.12 --seed
source .venv/bin/activate
uv pip install mlx-lm
mlx_lm.server --model mlx-community/translategemma-4b-it-4bit_immersive-translate
Use a custom OpenAI-compatible provider targeting your local server, http://localhost:8080/v1/chat/completions
Leave System prompt empty (blank).
Set Prompt and Multiple prompt to:
<<<source>>>{{from}}<<<target>>>{{to}}<<<text>>>{{text}}
The extension fills {{from}}, {{to}}, and {{text}}; the model’s chat template turns that into the proper TranslateGemma-style user turn.
from mlx_lm import load, generate
model, tokenizer = load("mlx-community/translategemma-4b-it-4bit_immersive-translate")
messages = [
{
"role": "user",
"content": "<<<source>>>English<<<target>>>French<<<text>>>Hello world",
}
]
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
response = generate(model, tokenizer, prompt=prompt, verbose=True)