🚀 Seed-Coder-8B-Reasoning
Seed-Coder是一個強大、透明且參數高效的8B規模開源代碼模型家族,包含基礎、指令和推理等變體。本項目的Seed-Coder-8B-Reasoning模型在多種編碼任務中表現出色,能有效推動開源代碼模型的發展。
🚀 快速開始
你需要安裝最新版本的 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)
✨ 主要特性
- 以模型為中心:Seed-Coder主要利用大語言模型(LLMs)而非手工規則進行代碼數據過濾,最大限度地減少了預訓練數據構建中的人工工作量。
- 透明性:我們公開分享了以模型為中心的數據管道的詳細信息,包括整理GitHub數據、提交數據和與代碼相關的網絡數據的方法。
- 強大性能:在各種編碼任務中,Seed-Coder在同類規模的開源模型中達到了最先進的性能。
📦 安裝指南
安裝所需的庫:
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)
📚 詳細文檔
模型信息
屬性 |
詳情 |
模型類型 |
因果語言模型 |
訓練階段 |
預訓練和後訓練 |
數據源 |
公共數據集 |
上下文長度 |
65,536 |
模型下載
模型名稱 |
長度 |
下載鏈接 |
備註 |
Seed-Coder-8B-Base |
32K |
🤗 模型 |
在以模型為中心的代碼數據上進行預訓練。 |
Seed-Coder-8B-Instruct |
32K |
🤗 模型 |
進行指令調優以符合用戶意圖。 |
👉 Seed-Coder-8B-Reasoning |
64K |
🤗 模型 |
經過強化學習訓練以提升推理能力。 |
Seed-Coder-8B-Reasoning-bf16 |
64K |
🤗 模型 |
經過強化學習訓練以提升推理能力。 |
評估
Seed-Coder-8B-Reasoning在競賽編程中表現出色,證明了較小的大語言模型也能勝任複雜的推理任務。我們的模型在IOI'2024上超越了QwQ-32B和DeepSeek-R1,並在Codeforces競賽中達到了與o1-mini相當的ELO評級。
如需詳細的基準測試性能,請參考我們的 📑 技術報告。
📄 許可證
本項目採用MIT許可證。有關詳細信息,請參閱 LICENSE文件。