🚀 Seed-Coder-8B-Instruct
Seed-Coder是一个强大、透明且参数高效的8B规模开源代码模型家族,包含基础、指令和推理等多种变体。它通过以模型为中心的数据处理方式、透明的数据管道和出色的性能,推动了开源代码模型的发展。本仓库中的Seed-Coder-8B-Instruct模型具有特定的类型、训练阶段、数据源和上下文长度等特点。
🚀 快速开始
你需要安装最新版本的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-Instruct"
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=512)
response = tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True)
print(response)
✨ 主要特性
- 以模型为中心:Seed-Coder主要利用大语言模型(LLMs)而非手工规则进行代码数据过滤,最大限度地减少了预训练数据构建中的人工工作量。
- 透明:我们公开分享了以模型为中心的数据管道的详细信息,包括整理GitHub数据、提交数据和与代码相关的网络数据的方法。
- 强大:在各种编码任务中,Seed-Coder在同类规模的开源模型中达到了最先进的性能。
📦 安装指南
你需要安装最新版本的transformers
和accelerate
:
pip install -U transformers accelerate
💻 使用示例
基础用法
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "ByteDance-Seed/Seed-Coder-8B-Instruct"
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=512)
response = tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True)
print(response)
📚 详细文档
模型下载
模型名称 |
长度 |
下载地址 |
备注 |
Seed-Coder-8B-Base |
32K |
🌐 模型 |
在以模型为中心的代码数据上进行预训练。 |
👉 Seed-Coder-8B-Instruct |
32K |
🌐 模型 |
经过指令微调,以符合用户意图。 |
Seed-Coder-8B-Reasoning |
64K |
🌐 模型 |
经过强化学习训练,以提升推理能力。 |
Seed-Coder-8B-Reasoning-bf16 |
64K |
🌐 模型 |
经过强化学习训练,以提升推理能力。 |
评估
Seed-Coder-8B-Instruct在广泛的编码任务中进行了评估,包括代码生成、代码推理、代码编辑和软件工程,在约8B的开源模型中达到了最先进的性能。
模型 |
HumanEval |
MBPP |
MHPP |
BigCodeBench (Full) |
BigCodeBench (Hard) |
LiveCodeBench (2410 – 2502) |
CodeLlama-7B-Instruct |
40.9 |
54.0 |
6.7 |
25.7 |
4.1 |
3.6 |
DeepSeek-Coder-6.7B-Instruct |
74.4 |
74.9 |
20.0 |
43.8 |
15.5 |
9.6 |
CodeQwen1.5-7B-Chat |
83.5 |
77.7 |
17.6 |
43.6 |
15.5 |
3.0 |
Yi-Coder-9B-Chat |
82.3 |
82.0 |
26.7 |
49.0 |
17.6 |
17.5 |
Llama-3.1-8B-Instruct |
68.3 |
70.1 |
17.1 |
40.5 |
13.5 |
11.5 |
OpenCoder-8B-Instruct |
83.5 |
79.1 |
30.5 |
50.9 |
18.9 |
17.1 |
Qwen2.5-Coder-7B-Instruct |
88.4 |
83.5 |
26.7 |
48.8 |
20.3 |
17.3 |
Qwen3-8B |
84.8 |
77.0 |
32.8 |
51.7 |
23.0 |
23.5 |
Seed-Coder-8B-Instruct |
84.8 |
85.2 |
36.2 |
53.3 |
26.4 |
24.7 |
有关详细的基准测试性能,请参考我们的📑 技术报告。
模型信息
属性 |
详情 |
模型类型 |
因果语言模型 |
训练阶段 |
预训练和后训练 |
数据源 |
公共数据集、合成数据 |
上下文长度 |
32,768 |
📄 许可证
本项目采用MIT许可证。有关详细信息,请参阅许可证文件。