当前位置: 首页 > news >正文

【字节拥抱开源】字节豆包团队开源首发 Seed-Coder 大模型

我们非常高兴地向大家介绍 Seed-Coder,它是一个功能强大、透明、参数高效的 8B 级开源代码模型系列,包括基础变体、指导变体和推理变体。Seed-Coder 通过以下亮点促进开放代码模型的发展。

  • 以模型为中心: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 torchmodel_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"])

填充中间部分(FIM)示例
Seed-Coder-8B-Base 原生支持 填充中间部分(FIM) 任务,即模型被提供一个前缀和一个后缀,并要求预测缺失的中间内容。这使得在代码填充场景中,如完成函数体或在两段代码之间插入缺失的逻辑成为可能。

import transformers
import torchmodel_id = "ByteDance-Seed/Seed-Coder-8B-Base"pipeline = transformers.pipeline("text-generation",model=model_id,model_kwargs={"torch_dtype": torch.bfloat16},device_map="auto",
)# You can concatenate a prefix, a special FIM separator token, and a suffix
prefix = "def add_numbers(a, b):\n    "
suffix = "\n    return result"# Combine prefix and suffix following the FIM format
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-BaseOpenCoder-8B-BaseQwen2.5-Coder-7BSeed-Coder-8B-Base
HumanEval47.666.572.077.4
MBPP70.279.979.482.0
MultiPL-E44.761.058.867.6
cruxeval-O41.043.956.048.4

Seed-Coder-8B-Instruct 模型,具有以下特点:

  • 类型:因果语言模型
  • 训练阶段:预训练与后训练
  • 数据来源:公共数据集、合成数据
  • 上下文长度:32,768

代码示例
您需要安装最新版本的 transformers accelerate

pip install -U transformers accelerate

这是一个简单的示例,展示了如何使用 Hugging Face 的 pipeline API 加载模型并执行代码生成:

from transformers import AutoTokenizer, AutoModelForCausalLM
import torchmodel_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-Instruct 在广泛的编码任务中进行了评估,包括代码生成、代码推理、代码编辑和软件工程,在约 8B 的开源模型中实现了最先进的性能。

ModelHumanEvalMBPPMHPPBigCodeBench (Full)BigCodeBench (Hard)LiveCodeBench (2410 – 2502)
CodeLlama-7B-Instruct40.954.06.721.93.43.6
DeepSeek-Coder-6.7B-Instruct74.474.920.035.510.19.6
CodeQwen1.5-7B-Chat83.577.717.639.618.93.0
Yi-Coder-9B-Chat82.382.026.738.111.517.5
Llama-3.1-8B-Instruct68.370.117.136.613.511.5
OpenCoder-8B-Instruct83.579.130.540.316.917.1
Qwen2.5-Coder-7B-Instruct88.482.026.741.018.217.3
Qwen3-8B84.877.032.851.723.023.5
Seed-Coder-8B-Instruct84.885.236.253.320.524.7

Seed-Coder-8B-Reasoning 模型,具有以下特点:

  • 类型:因果语言模型
  • 训练阶段:预训练与后训练
  • 数据来源:公共数据集
  • 上下文长度:32,768

代码示例
您需要安装最新版本的 transformers accelerate

pip install -U transformers accelerate

这是一个简单的示例,展示了如何使用 Hugging Face 的 pipeline API 加载模型并执行代码生成:

from transformers import AutoTokenizer, AutoModelForCausalLM
import torchmodel_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-8B-Reasoning 在竞争性编程中表现出色,表明较小的语言模型也能在复杂推理任务中胜任。我们的模型在 IOI’2024 上超越了 QwQ-32B 和 DeepSeek-R1,并在 Codeforces 竞赛中取得了与 o1-mini 相当的 ELO 评分。

在这里插入图片描述
在这里插入图片描述
有关详细的基准性能,请参阅我们的📑 技术报告.

相关文章:

  • 04 mysql 修改端口和重置root密码
  • 软件测试——用例篇(3)
  • Web3 初学者学习路线图
  • 20250510-查看 Anaconda 配置的镜像源
  • navicat112_premium_cs_x64.exe PatchNavicat.exe
  • BeanPostProcessor和AOP
  • 前端SSE技术详解:从入门到实战的完整指南
  • Anaconda的简单使用
  • Java 中的数据类型误导点!!!
  • [Spring AOP 7] 动态通知调用
  • OSCP - Proving Grounds - EvilBox-One
  • 《深入理解Linux网络》笔记
  • 基于语言模型的依存关系分句 和 主题变换检测(基于词频和句段得分)的 意思
  • JavaScript基础-全局作用域
  • 内存、磁盘、CPU区别,Hadoop/Spark与哪个联系密切
  • Hadoop 2.x设计理念解析
  • hot100-子串-JS
  • 17.Excel:实用的 VBA 自动化程序
  • 嵌入式Web服务器lighttpd交叉编译详解
  • 8.2.CICD自动化
  • 种罂粟喂鸡防病?四川广元一村民非法种植毒品原植物被罚​
  • 巴防空系统击落印度无人机,印称巴方违反停火协议
  • 巴军事行动致印度70%电网瘫痪
  • 中非民间对话在赞比亚举行
  • 上海国际电影节推出三大官方推荐单元,精选十部优秀影片
  • 吉林市马拉松5月18日开赛,奖牌、参赛服公布