🚀 Seed-Coder-8B-Reasoning GGUFモデル
Seed-Coder-8B-Reasoning GGUFモデルは、コード生成タスクに特化したモデルです。このモデルは、特定の手法を用いて生成され、様々な量子化形式が用意されており、ハードウェアやメモリの制約に応じた最適な使用が可能です。
🚀 クイックスタート
必要なライブラリのインストール
最新バージョンのtransformers
とaccelerate
をインストールする必要があります。
pip install -U transformers accelerate
モデルのロードとコード生成の実行
以下は、Hugging Faceのpipeline
APIを使用してモデルをロードし、コード生成を行う簡単な例です。
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "ByteDance-Seed/Seed-Coder-8B-Reasoning"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True)
messages = [
{"role": "user", "content": "Write a quick sort algorithm."},
]
input_ids = tokenizer.apply_chat_template(
messages,
tokenize=True,
return_tensors="pt",
add_generation_prompt=True,
).to(model.device)
outputs = model.generate(input_ids, max_new_tokens=16384)
response = tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True)
print(response)
✨ 主な機能
- モデル中心のアプローチ:コードデータのフィルタリングに主にLLMを利用し、手作業による事前学習データの構築を最小限に抑えます。
- 透明性:モデル中心のデータパイプラインの詳細を公開しています。
- 高性能:同等のサイズのオープンソースモデルの中で、様々なコーディングタスクで最先端の性能を達成します。
📦 インストール
必要なライブラリのインストールは、以下のコマンドで行います。
pip install -U transformers accelerate
💻 使用例
基本的な使用法
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "ByteDance-Seed/Seed-Coder-8B-Reasoning"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True)
messages = [
{"role": "user", "content": "Write a quick sort algorithm."},
]
input_ids = tokenizer.apply_chat_template(
messages,
tokenize=True,
return_tensors="pt",
add_generation_prompt=True,
).to(model.device)
outputs = model.generate(input_ids, max_new_tokens=16384)
response = tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True)
print(response)
📚 ドキュメント
モデル生成の詳細
このモデルは、llama.cpp のコミット 5787b5da
を使用して生成されました。
量子化方法
標準のIMatrixでは低ビット量子化やMOEモデルでの性能が十分ではないため、新しい量子化方法をテストしています。llama.cpp --tensor-type
を使用して選択したレイヤーを強化しています。詳細は Layer bumping with llama.cpp を参照してください。
モデル形式の選択
モデル形式の選択は、ハードウェアの能力とメモリの制約に依存します。以下に、各モデル形式の特徴と適用ケースをまとめた表を示します。
モデル形式 |
精度 |
メモリ使用量 |
デバイス要件 |
最適な使用ケース |
BF16 |
非常に高い |
高い |
BF16対応のGPU/CPU |
メモリを削減した高速推論 |
F16 |
高い |
高い |
FP16対応のGPU/CPU |
BF16が利用できない場合の推論 |
Q4_K |
中 - 低 |
低い |
CPUまたは低VRAMデバイス |
メモリ制約のある推論 |
Q6_K |
中 |
中程度 |
メモリの多いCPU |
量子化による精度向上 |
Q8_0 |
高い |
中程度 |
中程度のVRAMを持つGPU/CPU |
量子化モデルの中で最も高い精度 |
IQ3_XS |
低い |
非常に低い |
超低メモリデバイス |
最大限のメモリ効率、低精度 |
IQ3_S |
低い |
非常に低い |
低メモリデバイス |
IQ3_XSよりも少し使いやすい |
IQ3_M |
低 - 中 |
低い |
低メモリデバイス |
IQ3_Sよりも精度が高い |
Q4_0 |
低い |
低い |
ARMベース/組み込みデバイス |
Llama.cppがARM推論用に自動的に最適化 |
Ultra Low-Bit (IQ1/2_*) |
非常に低い |
極めて低い |
小型のエッジ/組み込みデバイス |
非常に制限されたメモリにモデルを収める |
Hybrid (e.g., bf16_q8_0 ) |
中 - 高 |
中程度 |
混合精度推論に対応したハードウェア |
パフォーマンスとメモリのバランス、重要なレイヤーでのFPに近い精度 |
🔧 技術詳細
- モデルの種類:因果言語モデル
- 学習段階:事前学習と事後学習
- データソース:公開データセット
- コンテキスト長:65,536
📄 ライセンス
このプロジェクトはMITライセンスの下で公開されています。詳細は LICENSEファイル を参照してください。
引用
もしこの研究が役に立った場合は、以下のように引用してください。
@misc{seed2025seedcoderletcodemodel,
title={{Seed-Coder}: Let the Code Model Curate Data for Itself},
author={{ByteDance Seed} and Yuyu Zhang and Jing Su and Yifan Sun and Chenguang Xi and Xia Xiao and Shen Zheng and Anxiang Zhang and Kaibo Liu and Daoguang Zan and Tao Sun and Jinhua Zhu and Shulin Xin and Dong Huang and Yetao Bai and Lixin Dong and Chao Li and Jianchong Chen and Hanzhi Zhou and Yifan Huang and Guanghan Ning and Xierui Song and Jiaze Chen and Siyao Liu and Kai Shen and Liang Xiang and Yonghui Wu},
year={2025},
eprint={2506.03524},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2506.03524},
}