Text Generation
Transformers
Safetensors
Ukrainian
English
gemma3
image-text-to-text
conversational
text-generation-inference
Instructions to use Goader/gemma-3-4b-uk-matt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Goader/gemma-3-4b-uk-matt with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Goader/gemma-3-4b-uk-matt") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Goader/gemma-3-4b-uk-matt") model = AutoModelForMultimodalLM.from_pretrained("Goader/gemma-3-4b-uk-matt", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Goader/gemma-3-4b-uk-matt with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Goader/gemma-3-4b-uk-matt" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Goader/gemma-3-4b-uk-matt", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Goader/gemma-3-4b-uk-matt
- SGLang
How to use Goader/gemma-3-4b-uk-matt with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Goader/gemma-3-4b-uk-matt" \ --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": "Goader/gemma-3-4b-uk-matt", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
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 "Goader/gemma-3-4b-uk-matt" \ --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": "Goader/gemma-3-4b-uk-matt", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Goader/gemma-3-4b-uk-matt with Docker Model Runner:
docker model run hf.co/Goader/gemma-3-4b-uk-matt
gemma-3-4b-uk-matt
google/gemma-3-4b-pt 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.
Recipe
- Embeddings initialized with FOCUS (Goader/gemma-3-4b-pt-focus),
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)
| metric | gemma-3-4b-pt (original tokenizer) | FOCUS init | this model |
|---|---|---|---|
| Belebele uk (acc) | 72.6 | 34.6 | 68.2 |
| Global MMLU uk (acc) | 51.0 | 28.7 | 47.8 |
| FLORES en→uk (BLEU / chrF) | 26.8 / 57.2 | 9.1 / 32.0 | 25.7 / 56.2 |
| FLORES uk→en (BLEU / chrF) | 42.0 / 67.9 | 5.1 / 27.0 | 40.3 / 66.6 |
| WMT en→uk (BLEU) | 5.1 | 1.6 | 4.8 |
| XLSum uk (ROUGE-1) | 6.5 | 1.5 | 5.8 |
The model recovers 94–98 % of the original on every task while reading Ukrainian with ~35 % fewer tokens.
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("Goader/gemma-3-4b-uk-matt")
model = AutoModelForCausalLM.from_pretrained("Goader/gemma-3-4b-uk-matt", torch_dtype="bfloat16")
This is a base (pretrained) model, not instruction-tuned.
- Downloads last month
- 262
Model tree for Goader/gemma-3-4b-uk-matt
Base model
google/gemma-3-4b-pt