Text Generation
Transformers
Safetensors
cohere2_moe
conversational
chat
code
agent
8-bit precision
compressed-tensors
Instructions to use CohereLabs/North-Mini-Code-1.0-w4a16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CohereLabs/North-Mini-Code-1.0-w4a16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="CohereLabs/North-Mini-Code-1.0-w4a16") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("CohereLabs/North-Mini-Code-1.0-w4a16") model = AutoModelForCausalLM.from_pretrained("CohereLabs/North-Mini-Code-1.0-w4a16", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use CohereLabs/North-Mini-Code-1.0-w4a16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CohereLabs/North-Mini-Code-1.0-w4a16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CohereLabs/North-Mini-Code-1.0-w4a16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/CohereLabs/North-Mini-Code-1.0-w4a16
- SGLang
How to use CohereLabs/North-Mini-Code-1.0-w4a16 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "CohereLabs/North-Mini-Code-1.0-w4a16" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CohereLabs/North-Mini-Code-1.0-w4a16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "CohereLabs/North-Mini-Code-1.0-w4a16" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CohereLabs/North-Mini-Code-1.0-w4a16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use CohereLabs/North-Mini-Code-1.0-w4a16 with Docker Model Runner:
docker model run hf.co/CohereLabs/North-Mini-Code-1.0-w4a16
Add files using upload-large-folder tool
Browse files- config.json +2 -1
- tokenizer_config.json +6 -0
config.json
CHANGED
|
@@ -112,7 +112,8 @@
|
|
| 112 |
"observer_kwargs": {}
|
| 113 |
},
|
| 114 |
"input_activations": null,
|
| 115 |
-
"output_activations": null
|
|
|
|
| 116 |
}
|
| 117 |
},
|
| 118 |
"kv_cache_scheme": null,
|
|
|
|
| 112 |
"observer_kwargs": {}
|
| 113 |
},
|
| 114 |
"input_activations": null,
|
| 115 |
+
"output_activations": null,
|
| 116 |
+
"format": null
|
| 117 |
}
|
| 118 |
},
|
| 119 |
"kv_cache_scheme": null,
|
tokenizer_config.json
CHANGED
|
@@ -13,6 +13,12 @@
|
|
| 13 |
"tokenizer_class": "TokenizersBackend",
|
| 14 |
"model_max_length": 1000000000000000019884624838656,
|
| 15 |
"sp_model_kwargs": {},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
"added_tokens_decoder": {
|
| 17 |
"0": {
|
| 18 |
"content": "<PAD>",
|
|
|
|
| 13 |
"tokenizer_class": "TokenizersBackend",
|
| 14 |
"model_max_length": 1000000000000000019884624838656,
|
| 15 |
"sp_model_kwargs": {},
|
| 16 |
+
"chat_template": [
|
| 17 |
+
{
|
| 18 |
+
"name": "default",
|
| 19 |
+
"template": "{{ bos_token }}\n{%- macro document_turn(documents) -%}\n<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_THINKING|>I will look through the document to address the users needs.<|END_THINKING|><|START_ACTION|>[\n {\"tool_call_id\": \"0\", \"tool_name\": \"direct-injected-document\", \"parameters\": {}}\n]<|END_ACTION|><|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[\n {\n \"tool_call_id\": \"0\",\n \"results\": {\n{% for doc in documents %}\n \"{{ loop.index0 }}\": {{doc|tojson}}{% if not loop.last %},\n {% endif %}\n{% endfor %}\n\n },\n \"is_error\": null\n }\n]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>\n{%- endmacro -%}\n{%- macro render_content(content) -%}\n{%- if content is string -%}\n{{ content }}\n{%- elif content is none -%}\n{%- elif content is mapping -%}\n{%- if content.text is defined -%}{{ content.text }}{%- endif -%}\n{%- else -%}\n{%- set _parts = namespace(first=true) -%}\n{%- for item in content -%}\n{%- if item is string -%}\n{%- if not _parts.first -%}{{ \"\\n\" }}{%- endif -%}\n{{ item }}\n{%- set _parts.first = false -%}\n{%- elif item is mapping and (item.type|default(\"text\"))|lower == \"text\" and item.text is defined -%}\n{%- if not _parts.first -%}{{ \"\\n\" }}{%- endif -%}\n{{ item.text }}\n{%- set _parts.first = false -%}\n{%- endif -%}\n{%- endfor -%}\n{%- endif -%}\n{%- endmacro -%}\n{%- macro tool_call_id_to_int(messages, tool_call_id) %}\n{%- set counter = namespace(value=0) %}\n{%- set tool_call_id_seen = namespace(value=false) %}\n{%- for msg in messages %}\n {%- if msg.tool_calls %}\n {%- for tool_call in msg.tool_calls %}\n {%- if tool_call.id == tool_call_id and not tool_call_id_seen.value -%}\n {{ counter.value }}\n {%- set tool_call_id_seen.value = true %}\n {%- endif %}\n {%- set counter.value = counter.value + 1 %}\n {%- endfor %}\n {%- endif %}\n{%- endfor %}\n{%- endmacro %}\n{%- macro format_tool_message(messages, tool_msg) -%}\n {\n \"tool_call_id\": \"{{ tool_call_id_to_int(messages, tool_msg.tool_call_id) }}\",\n \"results\": {\n \"0\": {{ render_content(tool_msg.content)|tojson }}\n },\n \"is_error\": null\n }\n{%- endmacro -%}\n{%- if messages and messages[0]['role']|lower == 'system' %}{%- set developer_preamble = messages[0]['content'] %}{% endif %}\n{%- set tool_idx = namespace(value=0) %}\n{%- set tool_ids_seen = namespace(value=[]) %}\n{%- set sent_documents = namespace(value=false) -%}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TEXT|># Available Tools\n```json\n[\n{% if documents or tools %}\n{%- if documents %}\n {\"name\": \"direct-injected-document\", \"description\": \"This is a special tool to directly inject user-uploaded documents into the chat as additional context. DO NOT use this tool by yourself!\", \"parameters\": {\"type\": \"object\", \"properties\": {}, \"required\": []}, \"responses\": {\"200\": {\"description\": \"Successfully returned a list of chunked text snippets from the directly uploaded documents.\", \"content\": {\"application/json\": {\"schema\": {\"type\": \"array\", \"items\": {\"type\": \"object\", \"required\": [\"url\", \"snippet\"], \"properties\": {\"url\": {\"type\": \"string\", \"description\": \"The url of the uploaded document.\"}, \"snippet\": {\"type\": \"string\", \"description\": \"The text snippet for the returned document chunk.\"}}}}}}}}}{%- if tools %},{% endif %}\n{%- endif %}\n{%- if tools %}\n{%- for tool in tools %}\n {\"name\": \"{{ tool['function']['name'] }}\", \"description\": \"{{tool['function']['description']}}\", \"parameters\": {{ tool['function']['parameters']|tojson }}, \"responses\": null}{%- if not loop.last %},{% endif %}\n{%- endfor %}\n{%- endif %}\n{% else %}\n\n{% endif %}\n]\n```<|END_TEXT|><|END_OF_TURN_TOKEN|>\n{%- if developer_preamble %}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TEXT|>{{ render_content(developer_preamble) }}<|END_TEXT|><|END_OF_TURN_TOKEN|>\n{%- endif %}\n{%- for message in messages %}\n {%- if message.role|lower == 'system' and not (loop.first and developer_preamble) %}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TEXT|>{{ render_content(message.content) }}<|END_TEXT|><|END_OF_TURN_TOKEN|>\n {%- elif message.role|lower == 'user' %}\n<|START_OF_TURN_TOKEN|><|USER_TOKEN|><|START_TEXT|>{{ render_content(message.content) }}<|END_TEXT|><|END_OF_TURN_TOKEN|>{%- if documents and not sent_documents.value %}{%- set sent_documents.value = true %}{% set tool_idx.value = tool_idx.value + 1 %}{{ document_turn(documents) }}{% endif %}\n {%- elif message.role|lower == 'assistant' or message.role|lower == 'chatbot' %}\n<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>{% if message.tool_calls %}<|START_THINKING|>{{message.tool_plan}}<|END_THINKING|><|START_ACTION|>[\n {% for tc in message.tool_calls %}\n {\"tool_call_id\": \"{{ tool_idx.value }}\", \"tool_name\": \"{{ tc['function']['name'] }}\", \"parameters\": {{ tc['function']['arguments']|tojson }}}{% if not loop.last %},{% endif %}\n\n {% set tool_idx.value = tool_idx.value + 1 %}\n {% endfor %}\n]<|END_ACTION|><|END_OF_TURN_TOKEN|>{% else %}<|START_TEXT|>{{ render_content(message.content) }}<|END_TEXT|><|END_OF_TURN_TOKEN|>{% endif %}\n {% elif message.role|lower == 'tool' and message.tool_call_id not in tool_ids_seen.value %}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[\n{{ format_tool_message(messages, message) }}\n {%- for msg in messages[loop.index0 + 1:] %}\n {%- if msg.role|lower == 'tool' %},\n{{ format_tool_message(messages, msg) }}\n {%- set tool_ids_seen.value = tool_ids_seen.value + [msg.tool_call_id] %}\n {%- else %}\n {%- break %}\n {%- endif %}\n {%- endfor %}\n\n]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>\n {%- endif %}\n{%- endfor %}<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_THINKING|>\n"
|
| 20 |
+
}
|
| 21 |
+
],
|
| 22 |
"added_tokens_decoder": {
|
| 23 |
"0": {
|
| 24 |
"content": "<PAD>",
|