Text Generation
MLX
Safetensors
Mixture of Experts
edge-inference
prerouter
lora
ssd-offload
conversational
custom_code
4-bit precision
Instructions to use Edge0/Edge0-8B-A1B-preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use Edge0/Edge0-8B-A1B-preview with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("Edge0/Edge0-8B-A1B-preview") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use Edge0/Edge0-8B-A1B-preview with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Edge0/Edge0-8B-A1B-preview"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Edge0/Edge0-8B-A1B-preview" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use Edge0/Edge0-8B-A1B-preview with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "Edge0/Edge0-8B-A1B-preview"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "Edge0/Edge0-8B-A1B-preview" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Edge0/Edge0-8B-A1B-preview", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use Edge0/Edge0-8B-A1B-preview with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Edge0/Edge0-8B-A1B-preview"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default Edge0/Edge0-8B-A1B-preview
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Edge0/Edge0-8B-A1B-preview with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Edge0/Edge0-8B-A1B-preview"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "Edge0/Edge0-8B-A1B-preview" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Upload chat_template.jinja with huggingface_hub
Browse files- chat_template.jinja +130 -0
chat_template.jinja
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{#- Bailing V3 chat template -#}
|
| 2 |
+
{#- Supports: thinking option, tool calling -#}
|
| 3 |
+
|
| 4 |
+
{#- ==================== thinking option normalization ==================== -#}
|
| 5 |
+
{%- if enable_thinking is defined %}
|
| 6 |
+
{%- if enable_thinking %}
|
| 7 |
+
{%- set thinking_option = 'on' %}
|
| 8 |
+
{%- else %}
|
| 9 |
+
{%- set thinking_option = 'off' %}
|
| 10 |
+
{%- endif %}
|
| 11 |
+
{%- elif thinking_option is not defined %}
|
| 12 |
+
{%- set thinking_option = 'on' %}
|
| 13 |
+
{%- endif %}
|
| 14 |
+
|
| 15 |
+
{#- ==================== preserved thinking ==================== -#}
|
| 16 |
+
{% set preserved_thinking = true %}
|
| 17 |
+
|
| 18 |
+
{#- ==================== system message ==================== -#}
|
| 19 |
+
{{- '<role>SYSTEM</role>' }}
|
| 20 |
+
{%- if tools %}
|
| 21 |
+
{%- if messages[0].role == 'system' %}
|
| 22 |
+
{{- messages[0].content + '\n' }}
|
| 23 |
+
{%- endif %}
|
| 24 |
+
{{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
|
| 25 |
+
{%- for tool in tools %}
|
| 26 |
+
{{- "\n" }}
|
| 27 |
+
{{- tool | tojson }}
|
| 28 |
+
{%- endfor %}
|
| 29 |
+
{{- "\n</tools>\n\nIf none of the functions can be used, point it out. If the given question lacks the parameters required by the function, also point it out.\nIf you need to use a function, for each function call, output the function name and arguments within the following XML format:\n<tool_call>{function-name}\n<arg_key>{arg-key-1}</arg_key>\n<arg_value>{arg-value-1}</arg_value>\n<arg_key>{arg-key-2}</arg_key>\n<arg_value>{arg-value-2}</arg_value>\n...\n</tool_call>\n" }}
|
| 30 |
+
{%- if messages[0].role == 'system' and messages[0].content is string and ('detailed thinking on' in messages[0].content or 'detailed thinking off' in messages[0].content) %}
|
| 31 |
+
{{- '<|role_end|>' }}
|
| 32 |
+
{%- else %}
|
| 33 |
+
{{- 'detailed thinking ' + thinking_option + '<|role_end|>' }}
|
| 34 |
+
{%- endif %}
|
| 35 |
+
{%- else %}
|
| 36 |
+
{%- if messages[0].role == 'system' %}
|
| 37 |
+
{%- if 'detailed thinking on' in messages[0].content or 'detailed thinking off' in messages[0].content %}
|
| 38 |
+
{{- messages[0].content + '<|role_end|>' }}
|
| 39 |
+
{%- else %}
|
| 40 |
+
{{- messages[0].content + '\n' }}
|
| 41 |
+
{{- 'detailed thinking ' + thinking_option + '<|role_end|>' }}
|
| 42 |
+
{%- endif %}
|
| 43 |
+
{% else %}
|
| 44 |
+
{{- 'detailed thinking ' + thinking_option + '<|role_end|>' }}
|
| 45 |
+
{%- endif %}
|
| 46 |
+
{%- endif %}
|
| 47 |
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 48 |
+
{%- for message in messages[::-1] %}
|
| 49 |
+
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 50 |
+
{%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
|
| 51 |
+
{%- set ns.multi_step_tool = false %}
|
| 52 |
+
{%- set ns.last_query_index = index %}
|
| 53 |
+
{%- endif %}
|
| 54 |
+
{%- endfor %}
|
| 55 |
+
{%- for message in messages %}
|
| 56 |
+
{%- if message.content is string %}
|
| 57 |
+
{%- set content = message.content %}
|
| 58 |
+
{%- else %}
|
| 59 |
+
{%- set content = '' %}
|
| 60 |
+
{%- endif %}
|
| 61 |
+
{%- if message.role == "user" %}
|
| 62 |
+
{{- '<role>HUMAN</role>' + message.content + '<|role_end|>' }}
|
| 63 |
+
{%- elif message.role == "system" and not loop.first %}
|
| 64 |
+
{{- '<role>SYSTEM</role>' + message.content + '<|role_end|>' }}
|
| 65 |
+
{%- elif message.role == "assistant" %}
|
| 66 |
+
{%- set reasoning_content = '' %}
|
| 67 |
+
{%- if message.reasoning_content is string and message.reasoning_content != '' %}
|
| 68 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 69 |
+
{%- else %}
|
| 70 |
+
{%- if '</think>' in content %}
|
| 71 |
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
| 72 |
+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 73 |
+
{%- endif %}
|
| 74 |
+
{%- endif %}
|
| 75 |
+
{%- if preserved_thinking or loop.index0 > ns.last_query_index %}
|
| 76 |
+
{%- if reasoning_content != '' %}
|
| 77 |
+
{{- '<role>ASSISTANT</role>' + '\n<think>' + reasoning_content.strip('\n') + '</think>' + content.lstrip('\n') }}
|
| 78 |
+
{%- else %}
|
| 79 |
+
{{- '<role>ASSISTANT</role>\n<think></think>' + content }}
|
| 80 |
+
{%- endif %}
|
| 81 |
+
{%- else %}
|
| 82 |
+
{{- '<role>ASSISTANT</role>\n<think></think>' + content }}
|
| 83 |
+
{%- endif %}
|
| 84 |
+
{%- if message.tool_calls %}
|
| 85 |
+
{%- for tool_call in message.tool_calls %}
|
| 86 |
+
{%- if (loop.first and content) or (not loop.first) %}
|
| 87 |
+
{{- '\n' }}
|
| 88 |
+
{%- endif %}
|
| 89 |
+
{%- set tc = tool_call %}
|
| 90 |
+
{%- if tool_call.function %}
|
| 91 |
+
{%- set tc = tool_call.function %}
|
| 92 |
+
{%- endif %}
|
| 93 |
+
{{- '<tool_call>' + tc.name }}
|
| 94 |
+
{% set _args = tc.arguments %}
|
| 95 |
+
{%- for k, v in _args.items() %}
|
| 96 |
+
{{- '<arg_key>' + k + '</arg_key>' }}
|
| 97 |
+
{{- '\n<arg_value>' }}
|
| 98 |
+
{%- if v is string %}
|
| 99 |
+
{{- v }}
|
| 100 |
+
{%- else %}
|
| 101 |
+
{{- v | tojson(ensure_ascii=False) }}
|
| 102 |
+
{%- endif %}
|
| 103 |
+
{{- '</arg_value>' }}
|
| 104 |
+
{%- endfor %}
|
| 105 |
+
{{- '\n</tool_call>' }}
|
| 106 |
+
{%- endfor %}
|
| 107 |
+
{%- endif %}
|
| 108 |
+
{{- '<|role_end|>' }}
|
| 109 |
+
{%- elif message.role == "tool" %}
|
| 110 |
+
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
|
| 111 |
+
{{- '<role>OBSERVATION</role>' }}
|
| 112 |
+
{%- endif %}
|
| 113 |
+
{{- '\n<tool_response>\n' }}
|
| 114 |
+
{{- content }}
|
| 115 |
+
{{- '\n</tool_response>' }}
|
| 116 |
+
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
|
| 117 |
+
{{- '<|role_end|>' }}
|
| 118 |
+
{%- endif %}
|
| 119 |
+
{%- endif %}
|
| 120 |
+
{%- endfor %}
|
| 121 |
+
|
| 122 |
+
{#- ==================== generation prompt ==================== -#}
|
| 123 |
+
{%- if add_generation_prompt %}
|
| 124 |
+
{{- '<role>ASSISTANT</role>' }}
|
| 125 |
+
{%- if thinking_option == 'on' %}
|
| 126 |
+
{{- '\n<think>' }}
|
| 127 |
+
{%- elif thinking_option == 'off' %}
|
| 128 |
+
{{- '\n<think></think>' }}
|
| 129 |
+
{%- endif %}
|
| 130 |
+
{%- endif %}
|