unsloth/North-Mini-Code-1.0-GGUF · Hugging Face

Reddit r/LocalLLaMA 模型

摘要

此页面托管了Cohere的North-Mini-Code-1.0模型的GGUF量化版本,这是一个30B-A3B MoE模型,针对代码生成和代理任务进行了优化。提供了从特定PR构建llama.cpp以支持cohere2moe架构的说明。

这是为新的Cohere 30B A3B模型准备的GGUF。我还没有机会测试它,但我认为它与[https://github.com/ggml-org/llama.cpp/pull/24260](https://github.com/ggml-org/llama.cpp/pull/24260)相关。
查看原文
查看缓存全文

缓存时间: 2026/06/10 05:42

unsloth/North-Mini-Code-1.0-GGUF · Hugging Face

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

https://huggingface.co/unsloth/North-Mini-Code-1.0-GGUF#run-these-ggufs-with-llamacpp用 llama.cpp 运行这些 GGUF 文件

这些是 North-Mini-Code-1.0 的 GGUF 量化版本。该模型使用 cohere2moe 架构,该架构尚未被标准的 llama.cpp 发布版本支持。在 llama.cpp 的 PR #24260 (https://github.com/ggml-org/llama.cpp/pull/24260) 合并之前,请从该 PR 分支构建 llama.cpp 以加载这些文件。一旦该 PR 进入正式版本,这些 GGUF 文件将无需重新下载即可在标准 llama.cpp 上运行,因为它们已经声明了 general.architecture = cohere2moe

https://huggingface.co/unsloth/North-Mini-Code-1.0-GGUF#1-build-llamacpp-from-pr-242601. 从 PR #24260 构建 llama.cpp

`` git clone https://github.com/ggml-org/llama.cpp cd llama.cpp git fetch origin pull/24260/head:cohere2-moe git checkout cohere2-moe

CUDA 编译。去掉 -DGGML_CUDA=ON 则仅 CPU 编译。

cmake -B build -DGGML_CUDA=ON cmake –build build –config Release -j ``

编译生成的二进制文件位于 build/bin/ 目录下(包括 llama-clillama-serverllama-quantize)。

https://huggingface.co/unsloth/North-Mini-Code-1.0-GGUF#2-download-a-quant2. 下载一个量化版本

`` pip install huggingface_hub

hf download unsloth/North-Mini-Code-1.0-GGUF
–include “North-Mini-Code-1.0-UD-Q4_K_XL.gguf”
–local-dir North-Mini-Code-1.0-GGUF ``

这里每个量化版本都是单个文件,但 BF16/ 目录除外,它被拆分成两个分片。要使用拆分的集合,请下载整个文件夹,然后将 llama.cpp 指向第一个分片(...-00001-of-00002.gguf);它会自动加载其余部分。

https://huggingface.co/unsloth/North-Mini-Code-1.0-GGUF#3-run3. 运行

使用 llama-cli 进行交互式聊天:

./build/bin/llama-cli \ --model North-Mini-Code-1.0-GGUF/North-Mini-Code-1.0-UD-Q4_K_XL.gguf \ --jinja \ --n-gpu-layers 99 \ --ctx-size 16384 \ --temp 1.0 --top-p 0.95 \ -p "编写一个 Python 程序,检查一个字符串是否是回文。"

使用 llama-server 启动与 OpenAI 兼容的服务器:

./build/bin/llama-server \ --model North-Mini-Code-1.0-GGUF/North-Mini-Code-1.0-UD-Q4_K_XL.gguf \ --jinja \ --n-gpu-layers 99 \ --ctx-size 16384 \ --host 0.0.0.0 --port 8080

然后查询它:

curl http://localhost:8080/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "messages": [{"role": "user", "content": "编写一个 Python 程序,检查一个字符串是否是回文。"}], "temperature": 1.0, "top_p": 0.95 }'

注意:

  • 传递 --jinja 以应用模型聊天模板,包括工具调用。
  • 推荐的采样参数为 temperature=1.0top_p=0.95
  • 设置 --n-gpu-layers 99 将所有层卸载到 GPU,或者降低该值以适配你的显存。使用 --ctx-size 设置上下文窗口(该模型支持高达 256K)。
  • imatrix_unsloth.gguf_file 是用于构建这些量化版本的重要性矩阵。它不是一个模型,运行时不会加载。

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

https://huggingface.co/unsloth/North-Mini-Code-1.0-GGUF#model-summary模型摘要

North Mini Code 是一个开放权重的研究成果发布,拥有 30B 总参数、3B 活跃参数,针对代码生成、智能体软件工程和终端任务进行了优化。

由以下机构开发: 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-Agent 工具 v1.1.0 进行 SWE-Bench,使用一个简单的 ReAct 工具(基于 Harbor 的 Tmux session 实现,使用单个终端使用工具)进行 Terminal-Bench v2。对于 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 = “编写一个 Python 程序,检查一个字符串是否是回文。”

使用 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 = “”“给定一个大小为 k 的唯一单词列表和一个大小为 n 的单词 w,其中 n 是 k 的倍数, 编写一个 Python 程序,确定列表中可连接形成单词 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/unsloth/North-Mini-Code-1.0-GGUF#model-details模型详情

输入: 仅文本。

输出: 模型生成文本。

模型架构: North-Mini-Code-1.0 是一个仅解码器、基于 Transformer 的稀疏混合专家模型。它使用高效的注意力实现,在滑动窗口注意力(带 RoPE)和全局注意力(无位置嵌入)之间以 3:1 的比例交错。前馈块是一个包含 128 个专家的 MoE 块,每个 token 激活其中 8 个。每个专家块是一个使用 SwiGLU 激活函数的 FFN 块。路由器在 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/unsloth/North-Mini-Code-1.0-GGUF#tool-use-capabilities工具使用能力:

North-Mini-Code-1.0 专门针对智能体编码训练了工具使用能力。

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

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

``

定义工具

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 agent 模型类似,支持交错思考 (https://docs.vllm.ai/en/latest/features/interleaved_thinking/),并且在开启时效果最佳。强烈建议你将模型生成的所有思考内容传递到后续的 agent 步骤和对话轮次中,以获得最佳模型性能。请参考链接的 vllm 文档了解具体操作。

如果模型生成了思考内容和工具调用,你应该将它们都添加到聊天历史中,如下所示:

``

传递 tool_call 和 thinking

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/unsloth/North-Mini-Code-1.0-GGUF#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": "本地 vLLM 服务器", "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/unsloth/North-Mini-Code-1.0-GGUF#model-card-contact模型卡联系方式

如果关于本模型卡中的细节有错误或其他疑问,请联系 [[email protected]]。

相似文章

CohereLabs/North-Mini-Code-1.0

Hugging Face Models Trending

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

GnLOLot/MiniCPM5-1B-Claude-Opus-Fable5-V2-Thinking-GGUF

Hugging Face Models Trending

GnLOLot 发布了 MiniCPM5-1B-Claude-Opus-Fable5-V2-Thinking 模型的 GGUF 量化版本。该模型是一个 10 亿参数的思考模型,基于 Fable 5 数据微调,相比 V1 版本在工具调用/函数调用方面有所改进,旨在通过 llama.cpp 及兼容运行时进行本地部署。

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

Reddit r/LocalLLaMA

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