gemma-3-4b-it-uk-matt
google/gemma-3-4b-it transferred to the Ukrainian-centric Lapa tokenizer with MATT (Model-Aware Tokenizer Transfer). The tokenizer keeps the original Gemma vocabulary and adds Ukrainian tokens, cutting the token count on Ukrainian text by roughly a third. Only the input embeddings differ from the original model; the chat template, special tokens and generation config are unchanged.
Base-model counterpart: Goader/gemma-3-4b-uk-matt.
Recipe
- Embeddings initialized with FOCUS from
gemma-3-4b-it, with every token present in the original vocabulary copied exactly from the original model, then trained with the AIM objective against the frozen original model: layers 1–16 of 34,all_words_last_tokenalignment, MSE loss, lr 1e-4, original-vocabulary embeddings frozen. - One pass over 1.03M Ukrainian documents (Kobza corpus, 256-token windows), ~6 h on one H100.
- Weights stored in bfloat16 with the full 262,208-row embedding table.
Results (Ukrainian, 3-shot, greedy, base-model prompts without chat template)
| metric | gemma-3-4b-it (original tokenizer) | FOCUS init | this model |
|---|---|---|---|
| Belebele uk (acc) | 77.7 | 38.0 | 64.0 |
| Global MMLU uk (acc) | 49.8 | 31.4 | 41.5 |
| FLORES en→uk (BLEU / chrF) | 26.3 / 57.5 | 24.3 / 55.2 | 25.4 / 56.8 |
| FLORES uk→en (BLEU / chrF) | 39.6 / 66.9 | 15.1 / 42.0 | 33.7 / 60.8 |
| WMT en→uk (BLEU) | 7.2 | 6.1 | 9.4 |
| XLSum uk (ROUGE-1) | 6.9 | 5.5 | 5.6 |
Generation into Ukrainian is essentially fully recovered (97–99 % on FLORES en→uk). Understanding-heavy tasks recover ~82–91 %, less than the base-model transfer (94–98 %), so this model trades some accuracy on Ukrainian comprehension for ~35 % shorter Ukrainian sequences.
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("Goader/gemma-3-4b-it-uk-matt")
model = AutoModelForCausalLM.from_pretrained("Goader/gemma-3-4b-it-uk-matt", torch_dtype="bfloat16", device_map="auto")
messages = [{"role": "user", "content": "Поясни простими словами, що таке фотосинтез."}]
ids = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
out = model.generate(ids, max_new_tokens=256)
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
Text-only: the vision tower is inherited unchanged but the image path was not evaluated.