İçeriğe geç

Gemma 3 1B / 4B / 12B / 27B: Google'ın 256K Vocab + Multimodal (4B+)

Gemma 3 — Google'ın 2025 açık modelleri. 256K vocab (TR-friendly), 4B+ multimodal (SigLIP vision tower), GeGLU activation, RMSNorm, 128K context, ShieldGemma safety classifier. RTX 4090'da Gemma 3 4B/12B QLoRA. system role yok (user'a prepend), Gemma 3 ToS dikkati.

Şükrü Yusuf KAYA
35 dakikalık okuma
İleri
Gemma 3 1B / 4B / 12B / 27B: Google'ın 256K Vocab + Multimodal (4B+)

1. Gemma 3 Mimari Özellikler#

Feature1B4B12B27B
Layers26344862
Hidden1152256038405376
KV heads (GQA)44816
Vocab256,000256,000256,000256,000
Multimodal
Vision encoderSigLIP 400MSigLIP 400MSigLIP 400M
Native context32K128K128K128K
Active params1.0B4.3B12.2B27.0B
Architecture details:
  • GeGLU (Gated GELU) instead of SwiGLU
  • RMSNorm (Llama-like)
  • 256K vocab — Gemma'nın signature: TR token verimi 1.95 (Llama 3.21)
  • system role yok — system prompt user message'a prepend edilir
Chat template:
<start_of_turn>user {system_message}\n\n{user_message}<end_of_turn> <start_of_turn>model {assistant_message}<end_of_turn>

2. RTX 4090 Memory (Gemma 3 4B/12B QLoRA)#

ModelW (NF4)A (batch=2, seq=4096)TotalSığar?
Gemma 3 1B0.5 GB2.0 GB~6 GB✅✅ rahat
Gemma 3 4B2.2 GB3.5 GB~9 GB✅✅ rahat
Gemma 3 12B6.1 GB5.5 GB~15 GB
Gemma 3 27B13.5 GB8.0 GB~25 GB⚠️ batch=1 zorunlu
Avantaj: 256K vocab → embedding 1.05B params (27B'de). Bu W'nin %4'ü — modern büyük vocab tasarımı.
python
# === Gemma 3 12B Türkçe QLoRA Lab ===
from unsloth import FastLanguageModel
from trl import SFTTrainer, SFTConfig
from datasets import load_dataset
 
model, tok = FastLanguageModel.from_pretrained(
"unsloth/gemma-3-12b-it-bnb-4bit",
max_seq_length=4096,
dtype="bfloat16", load_in_4bit=True,
)
model = FastLanguageModel.get_peft_model(
model, r=32, lora_alpha=64, lora_dropout=0.05,
target_modules=["q_proj","k_proj","v_proj","o_proj",
"gate_proj","up_proj","down_proj"],
use_gradient_checkpointing="unsloth",
)
 
# Gemma chat template: system yok — user'a prepend
def to_chat_gemma(ex):
user_msg = ex["instruction"]
if "system" in ex and ex["system"]:
user_msg = ex["system"] + "\n\n" + user_msg
messages = [
{"role": "user", "content": user_msg},
{"role": "assistant", "content": ex["output"]}, # "model" değil "assistant"
]
return {"text": tok.apply_chat_template(messages, tokenize=False)}
 
dataset = load_dataset("malhajar/alpaca-gpt4-tr", split="train").map(to_chat_gemma, num_proc=8)
 
cfg = SFTConfig(
output_dir="gemma-3-12b-tr",
num_train_epochs=1,
per_device_train_batch_size=2,
gradient_accumulation_steps=4,
learning_rate=2e-4,
bf16=True, optim="paged_adamw_8bit",
max_seq_length=4096, packing=True,
dataset_text_field="text",
logging_steps=5, report_to="wandb",
)
 
trainer = SFTTrainer(model=model, tokenizer=tok, train_dataset=dataset, args=cfg)
trainer.train()
Gemma 3 12B Türkçe QLoRA Lab

3. Gemma 3 ToS & Lisans Dikkati#

Gemma 3 Gemma Terms of Use ile yayınlandı — Llama Community License benzeri ama bazı ayrımlar:
  • ✅ Commercial use OK (kısıtsız)
  • ✅ Derivative work OK
  • ✅ Distribution OK (with notice + copy of terms)
  • ❌ "Prohibited Use Policy" ile uyumsuz kullanımlar yasak
  • ⚠️ Gemma derivatives Gemma adını kullanma ve ShieldGemma'yı disable etme kısıtlaması yok ama "responsible use" beklenir
Cookbook'un kuralı: production deploy'da Gemma 3 model card'ını oku, prohibited-use guidance'a uy.
✅ Teslim
  1. Gemma 3 4B veya 12B QLoRA Lab koş. 2) TR-MMLU + MT-Bench-TR ölç. 3) Sonraki ders: 3.7 — Phi-4 + Phi-4-mini (Synthetic-data Centric).

Yorumlar & Soru-Cevap

(0)
Yorum yazmak için giriş yap.
Yorumlar yükleniyor...

İlgili İçerikler