Downloads · 30 days
11
11% of all-time downloads
aixsatoshi/gemma-4-26b-a4b-cosine-slerp
gemma-4-26b-a4b-cosine-slerp is a image-text-to-text model from aixsatoshi. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as apache-2.0.
google/gemma-4-26B-A4B (base) と google/gemma-4-26B-A4B-it (IT) を、層ごとのコサイングラデーションSLERPで統合したモデルです。
Downloads · 30 days
11
11% of all-time downloads
All-time downloads
101
Public
Parameters
25.8B
51.6 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors51.6 GB · 100%
From the Hugging Face model README
google/gemma-4-26B-A4B (base) と google/gemma-4-26B-A4B-it (IT) を、層ごとのコサイングラデーションSLERPで統合したモデルです。
マージ前に両モデルの重みを比較した結果:
| パーツ | Cosine類似度 | 差の大きさ |
|---|---|---|
| Attention (layer 0) | 0.78 | 大きく異なる |
| Attention (layer 15) | 0.76 | 大きく異なる |
| Attention (layer 29) | 0.66 | 最も異なる |
| Dense MLP (layer 0) | 0.79-0.87 | かなり異なる |
| LayerNorm | 0.9999 | ほぼ同じ |
| Router proj | 0.9999 | ほぼ同じ |
| Router scale | 1.0 (identical) | 完全一致 |
| Expert weights | ~1.0 | ほぼ同じ |
| Embeddings | ~1.0 | ほぼ同じ |
ITの fine-tuning は Attention と Dense MLP だけ を大きく変更しており、Expert 重みはほぼ変えていない。後半層ほど Attention の乖離が大きい(layer 29: cos=0.66)。つまり IT fine-tuning は主に出力に近い層の Attention パターンを調整して指示追従能力を獲得している。
この分析を踏まえ、浅い層ほど base 寄り(探索的)、深い層ほど IT 寄り(指示追従)のコサイングラデーションを適用。
Attention と Dense MLP にコサインカーブでなめらかに t を変化させます:
t(layer) = 0.5 + 0.5 × (1 - cos(π × layer / 29)) / 2
| Layer | SLERP t | 意味 |
|---|---|---|
| 0 | 0.500 | base 50% / IT 50% (広い視野) |
| 5 | 0.536 | |
| 10 | 0.633 | |
| 15 | 0.764 | 中間 |
| 20 | 0.890 | |
| 25 | 0.977 | |
| 29 | 1.000 | IT 100% (出力直前は完全IT) |
Expert, Router, LayerNorm, Embeddings, Vision encoder は IT モデルをそのまま使用(差がほぼないため)。
Layer 0-4 (sliding attn) : Attn=SLERP(~0.5) MLP=SLERP(~0.5) Expert=IT Router=IT
Layer 5 (full attn) : Attn=SLERP(0.54) MLP=SLERP(0.54) Expert=IT Router=IT
Layer 6-10 (sliding attn) : Attn=SLERP(~0.6) MLP=SLERP(~0.6) Expert=IT Router=IT
Layer 11 (full attn) : Attn=SLERP(0.67) MLP=SLERP(0.67) Expert=IT Router=IT
...グラデーションがなめらかに上昇...
Layer 24-28 (sliding attn) : Attn=SLERP(~0.98) MLP=SLERP(~0.98) Expert=IT Router=IT
Layer 29 (full attn) : Attn=IT(1.0) MLP=IT(1.0) Expert=IT Router=IT
| google/gemma-4-26B-A4B-it | 本モデル | |
|---|---|---|
| アーキテクチャ | Gemma-4 MoE | Gemma-4 MoE |
| 総パラメータ | ~26B | ~26B |
| アクティブパラメータ | ~4B | ~4B |
| エキスパート数 | 128 | 128 |
| top-k | 8 | 8 |
| Hidden size | 2816 | 2816 |
| レイヤー数 | 30 | 30 |
| Attention | 25 sliding + 5 full | 同一構造 |
| Vision encoder | あり | あり |
| マルチモーダル | 対応 | 対応 |
vllm serve aixsatoshi/gemma-4-26b-a4b-cosine-slerp \
--tensor-parallel-size 4 \
--max-model-len 4096 \
--gpu-memory-utilization 0.95 \
--trust-remote-code
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "aixsatoshi/gemma-4-26b-a4b-cosine-slerp"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype="bfloat16",
device_map="auto",
)
messages = [{"role": "user", "content": "日本の首都はどこですか?"}]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
inputs = inputs.to(model.device)
outputs = model.generate(inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))