Goader/gemma-3-4b-it-uk-matt
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)
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.
