danielhanchen commited on
Commit
fc2c3d2
·
verified ·
1 Parent(s): af821d3

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +297 -0
README.md ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - CohereLabs/North-Mini-Code-1.0
4
+ inference: false
5
+ library_name: transformers
6
+ license: apache-2.0
7
+ tags:
8
+ - conversational
9
+ - unsloth
10
+ - chat
11
+ - code
12
+ - agent
13
+ ---
14
+ <div>
15
+ <p style="margin-top: 0;margin-bottom: 0;">
16
+ <em><a href="https://docs.unsloth.ai/basics/unsloth-dynamic-v2.0-gguf">Unsloth Dynamic 2.0</a> achieves superior accuracy & outperforms other leading quants.</em>
17
+ </p>
18
+ <div style="display: flex; gap: 5px; align-items: center; ">
19
+ <a href="https://github.com/unslothai/unsloth/">
20
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png" width="133">
21
+ </a>
22
+ <a href="https://discord.gg/unsloth">
23
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
24
+ </a>
25
+ <a href="https://docs.unsloth.ai/">
26
+ <img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
27
+ </a>
28
+ </div>
29
+ </div>
30
+
31
+
32
+ # **Model Card for North Mini Code**
33
+
34
+ ## **Model Summary**
35
+
36
+ North Mini Code is an open weights research release of a 30B-A3B parameter model optimized for code generation, agentic software engineering, and terminal tasks.
37
+
38
+ Developed by: [Cohere](https://cohere.com/) and [Cohere Labs](https://cohere.com/research)
39
+
40
+ * Point of Contact: [**Cohere Labs**](https://cohere.com/research)
41
+ * License: Apache 2.0
42
+ * Model: North Mini Code
43
+ * Model Size: 30B total; 3B active
44
+ * Context length: 256K & 64K max output
45
+
46
+ For more details about this model, please check out our [blog post](https://huggingface.co/blog/CohereLabs/introducing-north-mini-code).
47
+
48
+ **Try North Mini Code**
49
+
50
+ You can try out North Mini Code before downloading the weights in OpenCode and our hosted [Hugging Face Space](https://huggingface.co/spaces/CohereLabs/North-Mini-Code-1.0).
51
+
52
+ **Evaluation**
53
+
54
+ ![image1](https://cdn-uploads.huggingface.co/production/uploads/62668f725fb8d521d94d8451/xR7kZ3X9RKEZrbgD6hpG1.png)
55
+
56
+ <details>
57
+ <summary><span style="font-size: 80%;"><b>Benchmarking Methodology [CLICK TO EXPAND]</span></b></summary>
58
+
59
+ - <span style="font-size: 80%;">We used SWE-Bench Verified, SWE-Bench Pro, Terminal-Bench v2, and Terminal-Bench Hard to benchmark North Mini Code's agentic coding capabilities. For evaluation harnesses, we used the Swe-Agent harness v1.1.0 for SWE-Bench, and a simple ReAct harness employing a single terminal-use tool based on Harbor's Tmux session implementation for Terminal-Bench v2. For Terminal Bench Hard, we directly used Terminus-2, following the same methodology as the Artificial Analysis Intelligence Index to compare North-Mini-Code-1.0 with the other models. Additionally, we used SciCode and LiveCodeBench v6 as complex code-generation benchmarks outside of tool use.</span>
60
+ - <span style="font-size: 80%;">We run each benchmark with 3 different seeds and report the average benchmark performance, using temperature=1.0 and top\_p=0.95. We used publicly reported scores for competitor models, either from original reports or the Artificial Analysis Intelligence Index, where available. Additionally, Gemma4’s scores for agentic coding tasks were reported by [Qwen team](https://qwen.ai/blog?id=qwen3.6-35b-a3b). For benchmark results that any public report is missing, denoted by (\*) in the figure, we run them internally using the recommended model configuration.</span>
61
+ </details>
62
+
63
+ **Usage**
64
+
65
+ Please install transformers from the source repository that includes the necessary changes for this model. We recommend using the following set of sampling parameters for generation: \`temperature=1.0\`, \`top\_p=0.95\`.
66
+
67
+ ```py
68
+ # pip install transformers
69
+ from transformers import AutoTokenizer, AutoModelForCausalLM
70
+
71
+ model_id = "CohereLabs/North-Mini-Code-1.0"
72
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
73
+ model = AutoModelForCausalLM.from_pretrained(model_id)
74
+
75
+ prompt = "Write a python program to check if a string is a palindrome or not."
76
+
77
+ # Format message with the North-Mini-Code-1.0 chat template
78
+ messages = [{"role": "user", "content": prompt}]
79
+ input_ids = tokenizer.apply_chat_template(
80
+ messages,
81
+ tokenize=True,
82
+ add_generation_prompt=True,
83
+ return_tensors="pt",
84
+ )
85
+
86
+ gen_tokens = model.generate(
87
+ **input_ids,
88
+ max_new_tokens=1024,
89
+ do_sample=True,
90
+ temperature=1.0,
91
+ top_p=0.95
92
+ )
93
+
94
+ gen_text = tokenizer.decode(gen_tokens[0])
95
+ print(gen_text)
96
+ ```
97
+
98
+ You can also use the model directly using transformers `pipeline` abstraction:
99
+
100
+ ```py
101
+ from transformers import pipeline
102
+ import torch
103
+
104
+ model_id = "CohereLabs/North-Mini-Code-1.0"
105
+
106
+ prompt = """Given a list of unique words each of size k and an n sized word, w, where n is a multiple of k,
107
+ 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.
108
+ """
109
+
110
+ pipe = pipeline(
111
+ "text-generation",
112
+ model=model_id,
113
+ torch_dtype="auto",
114
+ device_map="auto",
115
+ )
116
+
117
+ messages = [
118
+ {"role": "user", "content": f"{prompt}"},
119
+ ]
120
+
121
+ text = tokenizer.apply_chat_template(
122
+ messages,
123
+ tokenize=False,
124
+ add_generation_prompt=True,
125
+ )
126
+
127
+
128
+ outputs = pipe(
129
+ messages,
130
+ max_new_tokens=1024,
131
+ do_sample=True,
132
+ temperature=1.0,
133
+ top_p=0.95
134
+
135
+ )
136
+
137
+ print(outputs[0]["generated_text"][-1])
138
+
139
+ ```
140
+
141
+ ## **Model Details**
142
+
143
+ **Input**: Text only.
144
+
145
+ **Output**: Model generates text.
146
+
147
+ **Model Architecture**: North-Mini-Code-1.0 is a decoder-only Transformer-based sparse Mixture-of-Experts model. It uses an efficient attention implementation, interleaved between sliding-window attention with RoPE and global attention with no positional embeddings, in a 3:1 ratio. The feed-forward block is an MoE block with 128 experts, of which 8 are activated per token. Each expert block is an FFN block with SwiGLU activation. The router applies a sigmoid activation function to the logits before the top-k selection. We also use a single dense layer before the sparse layers. North-Mini-Code-1.0 was post-trained using a two-stage cascaded supervised fine-tuning (SFT) followed by reinforcement learning with verifiable rewards (RLVR), focusing on agentic coding. For more technical details, please check out our [blog post](https://huggingface.co/blog/CohereLabs/introducing-north-mini-code).
148
+
149
+ **Context Length:** North-Mini-Code-1.0 supports a context length of 256K & 64K output length.
150
+
151
+ ### **Tool Use Capabilities:**
152
+
153
+ North-Mini-Code-1.0 has been specifically trained with tool-use capabilities for agentic coding.
154
+
155
+ Tool use with North-Mini-Code-1.0 is supported through [chat templates](https://huggingface.co/docs/transformers/main/en/chat_templating#advanced-tool-use--function-calling) in Transformers. We recommend providing tool descriptions using JSON schema.
156
+
157
+ **Tool Use Example \[CLICK TO EXPAND\]**
158
+
159
+ ```py
160
+ # Define tools
161
+ tools = [{
162
+ "type": "function",
163
+ "function": {
164
+ "name": "bash",
165
+ "description": "Execute a bash command in the terminal.",
166
+ "parameters": {
167
+ "type": "object",
168
+ "properties": {
169
+ "command": {
170
+ "description": "The bash command to execute.",
171
+ "type": "string"
172
+ }
173
+ },
174
+ "required": ["command"]
175
+ },
176
+ }
177
+ }]
178
+
179
+ # Define conversation input
180
+ conversation = [{"role": "user", "content": "Find out if there is any json file in this folder"}]
181
+
182
+
183
+ # Get the Tool Use prompt
184
+ input_prompt = tokenizer.apply_chat_template(conversation=conversation, tools=tools, tokenize=False, add_generation_prompt=True, return_tensors="pt")
185
+
186
+ # Tokenize the prompt
187
+ input_ids = tokenizer(input_prompt, return_tensors="pt")
188
+ ```
189
+
190
+ You can then generate from this input as normal.
191
+
192
+ North Mini Code, similarly as all the other Cohere agent models released to date, supports [interleaved thinking](https://docs.vllm.ai/en/latest/features/interleaved_thinking/) and works best when turned on. You’re strongly encouraged to pass on all the model-generated thinking contents to future agentic steps, and chat turns for the best model performance. Please refer to the linked vllm doc and see how it’s done.
193
+
194
+ If the model generates thinking content and tool calls, you should add both of them to the chat history like so:
195
+
196
+ ```py
197
+ # Pass on the tool_call and thinking
198
+ tool_call = {"name": "bash", "arguments": {"command": "ls -al"}}
199
+ reasoning = "The user wants to find if there are any JSON files in the current folder. I should use the `ls` command to list files and then check if there are any JSON files (files ending with .json). Let me first list the files in the current directory."
200
+
201
+ conversation.append({"role": "assistant", "tool_calls": [{"id": "0", "type": "function", "function": tool_call}], "reasoning": reasoning})
202
+ ```
203
+
204
+ and then call the tool and append the result, as a dictionary, with the tool role, like so:
205
+
206
+ ```py
207
+ # This needs to be a dictionary
208
+ tool_result = {"stdout": "test.json\ntest.py", "return_code": "0"}
209
+
210
+ # Append tool results
211
+ conversation.append({"role": "tool", "tool_call_id": "0", "content": tool_result})
212
+ ```
213
+
214
+ After that, you can `generate()` again to let the model use the tool result in the chat.
215
+
216
+ Note that this was a very brief introduction to tool calling \- for more information the Transformers [tool use documentation](https://huggingface.co/docs/transformers/main/chat_templating#advanced-tool-use--function-calling).
217
+
218
+ ### **vLLM**
219
+
220
+ You can also run the model in vLLM. Please use vLLM main for North Mini Code until a new release is available, and accurate response parsing also requires installing Cohere’s melody library.
221
+
222
+ ```shell
223
+ uv pip install "git+https://github.com/vllm-project/vllm.git"
224
+ uv pip install cohere_melody>=0.9.0
225
+ ```
226
+
227
+ Then the vllm server can be started with the following command:
228
+
229
+ ```shell
230
+ vllm serve CohereLabs/North-Mini-Code-1.0 \
231
+ -tp 2 \
232
+ --max-model-len 320000 \
233
+ --tool-call-parser cohere_command4 \
234
+ --reasoning-parser cohere_command4 \
235
+ --enable-auto-tool-choice
236
+ ```
237
+
238
+ **Use locally deployed North Mini Code in OpenCode:**
239
+
240
+ Please use OpenCode main branch until a new release is available.
241
+
242
+ ```shell
243
+ # Example commands to install on linux
244
+ git clone https://github.com/anomalyco/opencode.git cd opencode
245
+
246
+ # Install Bun
247
+ curl -fsSL https://bun.sh/install | bash
248
+ export BUN_INSTALL="$HOME/.bun"
249
+ export PATH="$BUN_INSTALL/bin:$PATH"
250
+
251
+ # node-gyp was needed by a dependency
252
+ bun add -g node-gyp
253
+
254
+ # Install dependencies
255
+ bun install
256
+
257
+ # Build CLI
258
+ bun run --cwd packages/opencode build /usr/bin/install -m 755 \
259
+ ./opencode/packages/opencode/dist/opencode-linux-x64/bin/opencode \
260
+ /root/.local/bin/opencode
261
+ ```
262
+
263
+ To use locally deployed North Mini Code in Opencode, please use this config which enables interleaved reasoning:
264
+
265
+ ```json
266
+ {
267
+ "$schema": "https://opencode.ai/config.json",
268
+ "model": "vllm/CohereLabs/North-Mini-Code-1.0",
269
+ "provider": {
270
+ "vllm": {
271
+ "npm": "@ai-sdk/openai-compatible",
272
+ "name": "Local vLLM server",
273
+ "options": {
274
+ "baseURL": "http://127.0.0.1:8000/v1",
275
+ "apiKey": "EMPTY"
276
+ },
277
+ "models": {
278
+ "North-Mini-Code-1.0": {
279
+ "name": "North-Mini-Code-1.0",
280
+ "interleaved": {
281
+ "field": "reasoning"
282
+ },
283
+ "limit": {
284
+ "context": 256000,
285
+ "output": 64000
286
+ }
287
+ }
288
+ }
289
+ }
290
+ }
291
+ }
292
+
293
+ ```
294
+
295
+ ## **Model Card Contact**
296
+
297
+ For errors or additional questions about details in this model card, contact \[labs@cohere.com\].