🚀 Seed-Coder-8B-Base
Seed-Coder-8B-Base 是一个 8B 规模的开源代码模型,具有强大、透明和参数高效的特点。它有基础、指令和推理等多种变体,能在多种编码任务中展现出色性能。
✨ 主要特性
- 以模型为中心:Seed-Coder 主要利用大语言模型(LLMs)而非手工规则进行代码数据过滤,减少了预训练数据构建中的人工工作量。
- 透明性:我们公开分享了以模型为中心的数据管道的详细信息,包括整理 GitHub 数据、提交数据和与代码相关的网络数据的方法。
- 强大性能:在各种编码任务中,Seed-Coder 在同类规模的开源模型中达到了最先进的性能。
本仓库包含的 Seed-Coder-8B-Base 模型,具有以下特点:
属性 |
详情 |
模型类型 |
因果语言模型 |
训练阶段 |
预训练 |
数据源 |
GitHub 数据、与代码相关的网络数据 |
训练令牌数 |
6 万亿 |
支持任务 |
代码补全、代码填充(中间填充) |
上下文长度 |
32,768 |
📦 安装指南
你需要安装最新版本的 transformers
和 accelerate
:
pip install -U transformers accelerate
🚀 快速开始
以下是一个简单的示例,展示了如何使用 Hugging Face 的 pipeline
API 加载模型并进行代码生成:
import transformers
import torch
model_id = "ByteDance-Seed/Seed-Coder-8B-Base"
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device_map="auto",
)
output = pipeline("def say_hello_world():", max_new_tokens=100)
print(output[0]["generated_text"])
💻 使用示例
基础用法
import transformers
import torch
model_id = "ByteDance-Seed/Seed-Coder-8B-Base"
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device_map="auto",
)
output = pipeline("def say_hello_world():", max_new_tokens=100)
print(output[0]["generated_text"])
高级用法
Seed-Coder-8B-Base 原生支持 中间填充(Fill-in-the-Middle,FIM) 任务,即给定前缀和后缀,模型预测缺失的中间内容。这适用于代码填充场景,如完成函数体或在两段代码之间插入缺失的逻辑。
import transformers
import torch
model_id = "ByteDance-Seed/Seed-Coder-8B-Base"
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device_map="auto",
)
prefix = "def add_numbers(a, b):\n "
suffix = "\n return result"
fim_input = '<[fim-suffix]>' + suffix + '<[fim-prefix]>' + prefix + '<[fim-middle]>'
output = pipeline(fim_input, max_new_tokens=512)
print(output[0]["generated_text"])
📚 详细文档
Seed-Coder-8B-Base 已在代码生成、代码补全和代码推理基准测试中进行了评估,在约 8B 的开源模型中达到了最先进的性能。
基准测试 |
DeepSeek-Coder-6.7B-Base |
OpenCoder-8B-Base |
Qwen2.5-Coder-7B |
Seed-Coder-8B-Base |
HumanEval |
47.6 |
66.5 |
72.0 |
77.4 |
MBPP |
70.2 |
79.9 |
79.4 |
82.0 |
MultiPL-E |
44.7 |
61.0 |
58.8 |
67.6 |
cruxeval-O |
41.0 |
43.9 |
56.0 |
54.8 |
有关详细的基准测试性能,请参考我们的 📑 技术报告。
📄 许可证
本项目采用 MIT 许可证。有关详细信息,请参阅 LICENSE 文件。