CoolFace
Modelpublic

Goader/gemma-3-4b-it-uk-matt

sourceHugging Facegemmaupdated 7d agoView on Hugging Face
0likes119downloads
Model Card

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_token alignment, 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)

metricgemma-3-4b-it (original tokenizer)FOCUS init**this model**
Belebele uk (acc)77.738.064.0
Global MMLU uk (acc)49.831.441.5
FLORES en→uk (BLEU / chrF)26.3 / 57.524.3 / 55.225.4 / 56.8
FLORES uk→en (BLEU / chrF)39.6 / 66.915.1 / 42.033.7 / 60.8
WMT en→uk (BLEU)7.26.19.4
XLSum uk (ROUGE-1)6.95.55.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

python
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.