CohereLabs/North-Mini-Code-1.0

Hugging Face Models Trending 模型

摘要

Cohere Labs 发布了 North Mini Code,一个拥有 30B 参数(3B 活跃)的开放权重模型,针对代码生成、智能体软件工程和终端任务进行了优化,基于 Apache 2.0 许可。

任务:文本生成 标签:transformers, safetensors, cohere2_moe, 文本生成, 对话, 聊天, 代码, 智能体, 许可:apache-2.0, 区域:us
查看原文
查看缓存全文

缓存时间: 2026/06/10 00:16

CohereLabs/North-Mini-Code-1.0 · Hugging Face

来源:https://huggingface.co/CohereLabs/North-Mini-Code-1.0

https://huggingface.co/CohereLabs/North-Mini-Code-1.0#model-card-for-north-mini-codeNorth Mini Code 模型卡片

https://huggingface.co/CohereLabs/North-Mini-Code-1.0#model-summary模型概要

North Mini Code 是一个开放权重的研究版本,拥有 30B-A3B 参数,专为代码生成、自主软件工程和终端任务优化。

开发方:Cohere (https://cohere.com/) 和 Cohere Labs (https://cohere.com/research)

  • 联系人:Cohere Labs (https://cohere.com/research)
  • 许可协议:Apache 2.0
  • 模型:North Mini Code
  • 模型大小:总计 30B;激活参数 3B
  • 上下文长度:256K 输入 & 64K 最大输出

有关该模型的更多详情,请查看我们的博文 (https://huggingface.co/blog/CohereLabs/introducing-north-mini-code)。

试用 North Mini Code

您可以在下载权重之前,通过 OpenCode 和我们的托管版 Hugging Face Space (https://huggingface.co/spaces/CohereLabs/North-Mini-Code-1.0) 试用 North Mini Code。

评估

image1 (https://cdn-uploads.huggingface.co/production/uploads/62668f725fb8d521d94d8451/xR7kZ3X9RKEZrbgD6hpG1.png)

基准测试方法 [点击展开]- 我们使用 SWE-Bench Verified、SWE-Bench Pro、Terminal-Bench v2 和 Terminal-Bench Hard 来评估 North Mini Code 的自主编码能力。评估工具方面,SWE-Bench 使用了 Swe-Agent 工具链 v1.1.0;Terminal-Bench v2 使用了一个简单的 ReAct 工具链,该工具链基于 Harbor 的 Tmux 会话实现,只使用一个终端工具。对于 Terminal Bench Hard,我们直接使用 Terminus-2,并遵循 Artificial Analysis Intelligence Index 的相同方法,将 North-Mini-Code-1.0 与其他模型进行比较。此外,我们还使用 SciCode 和 LiveCodeBench v6 作为外部工具使用场景下的复杂代码生成基准。

  • 每个基准测试我们使用 3 个不同的随机种子运行,并报告平均基准性能,使用 temperature=1.0 和 top_p=0.95。对于竞争对手模型,我们使用公开报告的分数,来源为原始报告或 Artificial Analysis Intelligence Index。此外,Gemma4 在自主编码任务上的分数由 Qwen 团队 (https://qwen.ai/blog?id=qwen3.6-35b-a3b) 报告。对于图中标记为 (*) 且缺少公开报告的基准结果,我们内部使用推荐的模型配置进行运行。

使用方式

请从包含该模型必要更改的源仓库安装 transformers。我们建议使用以下采样参数进行生成:temperature=1.0top\_p=0.95

``

pip install transformers

from transformers import AutoTokenizer, AutoModelForCausalLM

model_id = “CohereLabs/North-Mini-Code-1.0” tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id)

prompt = “Write a python program to check if a string is a palindrome or not.”

使用 North-Mini-Code-1.0 聊天模板格式化消息

messages = [{“role”: “user”, “content”: prompt}] input_ids = tokenizer.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, return_tensors=“pt”, )

gen_tokens = model.generate( **input_ids, max_new_tokens=1024, do_sample=True, temperature=1.0, top_p=0.95 )

gen_text = tokenizer.decode(gen_tokens[0]) print(gen_text) ``

您也可以直接使用 transformers 的 pipeline 抽象来使用该模型:

`` from transformers import pipeline import torch

model_id = “CohereLabs/North-Mini-Code-1.0”

prompt = “”“Given a list of unique words each of size k and an n sized word, w, where n is a multiple of k, Write a program in python to determine the number of unique combinations of words in the list that can be concatenated to form an anagram of the word w. “”“

pipe = pipeline( “text-generation”, model=model_id, torch_dtype=“auto”, device_map=“auto”, )

messages = [ {“role”: “user”, “content”: f“{prompt}“}, ]

text = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True, )

outputs = pipe( messages, max_new_tokens=1024, do_sample=True, temperature=1.0, top_p=0.95 )

print(outputs[0][“generated_text”][-1]) ``

https://huggingface.co/CohereLabs/North-Mini-Code-1.0#model-details模型详情

输入:仅文本。

输出:模型生成文本。

模型架构:North-Mini-Code-1.0 是一个仅解码器的、基于 Transformer 的稀疏混合专家(MoE)模型。它采用了高效的注意力实现,在滑动窗口注意力(使用 RoPE)和全局注意力(无位置嵌入)之间以 3:1 的比例交错。前馈块是一个包含 128 个专家的 MoE 块,每个 token 激活其中 8 个。每个专家块是一个使用 SwiGLU 激活的前馈网络块。路由器在 top-k 选择之前对 logits 应用 sigmoid 激活函数。我们还在稀疏层之前使用了一个密集层。North-Mini-Code-1.0 经过两个阶段的级联监督微调(SFT)以及后续的可验证奖励强化学习(RLVR)进行后训练,重点聚焦自主编码。更多技术细节请查看我们的博文 (https://huggingface.co/blog/CohereLabs/introducing-north-mini-code)。

上下文长度:North-Mini-Code-1.0 支持 256K 上下文长度和 64K 输出长度。

https://huggingface.co/CohereLabs/North-Mini-Code-1.0#tool-use-capabilities工具使用能力:

North-Mini-Code-1.0 专门针对自主编码的工具使用能力进行了训练。

通过在 Transformers 中使用聊天模板 (https://huggingface.co/docs/transformers/main/en/chat_templating#advanced-tool-use–function-calling) 来支持工具使用。我们建议使用 JSON schema 提供工具描述。

工具使用示例 [点击展开]

``

定义工具

tools = [{ “type”: “function”, “function”: { “name”: “bash”, “description”: “在终端中执行 bash 命令。”, “parameters”: { “type”: “object”, “properties”: { “command”: { “description”: “要执行的 bash 命令。”, “type”: “string” } }, “required”: [“command”] }, } }]

定义对话输入

conversation = [{“role”: “user”, “content”: “查看此文件夹中是否有 json 文件”}]

获取工具使用提示

input_prompt = tokenizer.apply_chat_template(conversation=conversation, tools=tools, tokenize=False, add_generation_prompt=True, return_tensors=“pt”)

对提示进行分词

input_ids = tokenizer(input_prompt, return_tensors=“pt”) ``

然后您可以像平常一样从此输入进行生成。

North Mini Code 与迄今发布的所有其他 Cohere 自主模型一样,支持交错思考 (https://docs.vllm.ai/en/latest/features/interleaved_thinking/),并且在开启时效果最佳。强烈建议您将所有模型生成的思考内容传递给后续的自主步骤和对话轮次,以获得最佳模型性能。请参考链接的 vllm 文档,了解具体操作方法。

如果模型生成了思考内容和工具调用,您应该将两者都添加到对话历史中,如下所示:

``

传递 tool_call 和思考

tool_call = {“name”: “bash”, “arguments”: {“command”: “ls -al”}} reasoning = “用户想知道当前文件夹中是否有任何 JSON 文件。我应该使用 ls 命令列出文件,然后检查是否有 JSON 文件(以 .json 结尾的文件)。让我先列出当前目录中的文件。”

conversation.append({“role”: “assistant”, “tool_calls”: [{“id”: “0”, “type”: “function”, “function”: tool_call}], “reasoning”: reasoning}) ``

然后调用工具并将结果以字典形式追加,角色为 tool:

``

这需要是一个字典

tool_result = {“stdout”: “test.json\ntest.py”, “return_code”: “0”}

追加工具结果

conversation.append({“role”: “tool”, “tool_call_id”: “0”, “content”: tool_result}) ``

之后,您可以再次调用 generate() 让模型在对话中使用工具结果。

请注意,这只是对工具调用的简要介绍——更多信息请参阅 Transformers 的工具使用文档 (https://huggingface.co/docs/transformers/main/chat_templating#advanced-tool-use–function-calling)。

https://huggingface.co/CohereLabs/North-Mini-Code-1.0#vllmvLLM

您也可以在 vLLM 中运行该模型。在新版本发布之前,请使用 vLLM 主线版本运行 North Mini Code,并且正确的响应解析还需要安装 Cohere 的 melody 库。

uv pip install "git+https://github.com/vllm-project/vllm.git" uv pip install cohere_melody>=0.9.0

然后可以使用以下命令启动 vllm 服务器:

vllm serve CohereLabs/North-Mini-Code-1.0 \ -tp 2 \ --max-model-len 320000 \ --tool-call-parser cohere_command4 \ --reasoning-parser cohere_command4 \ --enable-auto-tool-choice

在 OpenCode 中使用本地部署的 North Mini Code:

在新版本发布之前,请使用 OpenCode 主线分支。

``

在 Linux 上安装的示例命令

git clone https://github.com/anomalyco/opencode.git cd opencode

安装 Bun

curl -fsSL https://bun.sh/install | bash export BUN_INSTALL=“HOME/.bun" export PATH="BUN_INSTALL/bin:$PATH”

需要 node-gyp(依赖项需要)

bun add -g node-gyp

安装依赖

bun install

构建 CLI

bun run –cwd packages/opencode build /usr/bin/install -m 755
./opencode/packages/opencode/dist/opencode-linux-x64/bin/opencode
/root/.local/bin/opencode ``

要在 OpenCode 中使用本地部署的 North Mini Code,请使用以下配置(启用交错推理):

{ "$schema": "https://opencode.ai/config.json", "model": "vllm/CohereLabs/North-Mini-Code-1.0", "provider": { "vllm": { "npm": "@ai-sdk/openai-compatible", "name": "Local vLLM server", "options": { "baseURL": "http://127.0.0.1:8000/v1", "apiKey": "EMPTY" }, "models": { "North-Mini-Code-1.0": { "name": "North-Mini-Code-1.0", "interleaved": { "field": "reasoning" }, "limit": { "context": 256000, "output": 64000 } } } } } }

https://huggingface.co/CohereLabs/North-Mini-Code-1.0#model-card-contact模型卡片联系方式

如果本模型卡片中存在错误或对细节有疑问,请联系 [email protected]

相似文章

推出 North Mini Code:Cohere 首款面向开发者的模型

Hugging Face Blog

Cohere 发布了 North Mini Code,这是一款 30B 参数的混合专家(MoE)模型,在 Apache 2.0 许可下拥有 3B 激活参数,专为智能体软件工程任务优化,在编程基准测试中性能优于同类尺寸模型。

CohereLabs/North-Mini-Code-1.0-eagle · Hugging Face

Reddit r/LocalLLaMA

Cohere Labs发布North-Mini-Code-1.0-eagle,这是一个用于推测解码的草稿模型,以加速代码生成。它采用三个密集transformer层,带有滑动窗口注意力机制,并兼容fp8/w4a4目标模型。

发布 Cohere North Mini Code

Reddit r/LocalLLaMA

Cohere正式发布North Mini Code编程模型,权重可在Hugging Face上获取,并支持vLLM和MLX部署。