Instructions to use kyr0/zaya1-base-8b-8bit-MLX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use kyr0/zaya1-base-8b-8bit-MLX 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("kyr0/zaya1-base-8b-8bit-MLX") 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
- LM Studio
- Pi new
How to use kyr0/zaya1-base-8b-8bit-MLX with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "kyr0/zaya1-base-8b-8bit-MLX"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "kyr0/zaya1-base-8b-8bit-MLX" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use kyr0/zaya1-base-8b-8bit-MLX 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 "kyr0/zaya1-base-8b-8bit-MLX"
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 kyr0/zaya1-base-8b-8bit-MLX
Run Hermes
hermes
- MLX LM
How to use kyr0/zaya1-base-8b-8bit-MLX with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "kyr0/zaya1-base-8b-8bit-MLX"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "kyr0/zaya1-base-8b-8bit-MLX" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kyr0/zaya1-base-8b-8bit-MLX", "messages": [ {"role": "user", "content": "Hello"} ] }'
Add files using upload-large-folder tool
Browse files- .gitattributes +1 -0
- README.md +76 -0
- chat_template.jinja +205 -0
- config.json +55 -0
- generation_config.json +10 -0
- model-00001-of-00002.safetensors +3 -0
- model-00002-of-00002.safetensors +3 -0
- model.safetensors.index.json +0 -0
- tokenizer.json +3 -0
- tokenizer_config.json +25 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: mlx
|
| 4 |
+
base_model: Zyphra/ZAYA1-8B
|
| 5 |
+
tags:
|
| 6 |
+
- mlx
|
| 7 |
+
pipeline_tag: text-generation
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# MLX convert - 8 bit quant
|
| 11 |
+
|
| 12 |
+
This model depends on the following PR merge status and mlx-ml release status: https://github.com/ml-explore/mlx-lm/pull/1261
|
| 13 |
+
|
| 14 |
+
You can either clone my fork: https://github.com/kyr0/mlx-lm/tree/feat/zaya-support or wait for mainline support for this model being merged by the MLX-ML team.
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
# Model Card for ZAYA1-base
|
| 18 |
+
|
| 19 |
+
ZAYA1 is an 800m active/8.3B total parameter MoE model, and the first trained entirely end-to-end on AMD’s hardware, software, and networking stack.
|
| 20 |
+
|
| 21 |
+
Our ZAYA1 base model benchmark performance is extremely competitive with the SoTA Qwen3 series of models of comparable scale, and outperforms comparable western open-source models such as SmolLM3, and Phi4. ZAYA1-base excels especially at complex and challenging mathematical and STEM reasoning tasks, nearly matching the performance of SoTA Qwen3 thinking models under high pass@k settings even prior to explicit post-training for reasoning, and exceeds other strong reasoning models such as Phi4-reasoning, and Deepseek-R1-Distill.
|
| 22 |
+
|
| 23 |
+
Details of our pretraining efforts, hardware specific optimizations, and ZAYA1 base model benchmarks are described in the [accompanying technical report](https://arxiv.org/abs/2511.17127).
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
## Model Details
|
| 27 |
+
|
| 28 |
+
ZAYA1's architecture includes several innovations developed at Zyphra. These include:
|
| 29 |
+
|
| 30 |
+
- **Compressed Convolutional Attention (CCA)**: [This novel attention](https://arxiv.org/abs/2510.04476) mechanism performs attention entirely in the latent space enabling significant reductions in parameter count, prefill compute, and KV cache size compared to alternative attention mechanisms, while also being more performant in loss/flop.
|
| 31 |
+
- **ZAYA1 Router**: The ZAYA1 router makes fundamental improvements to the linear router used in almost all existing large-scale MoE models. The ZAYA1 router replaces the linear with a downprojection followed by a depth-mixing EDA layer then a three-layer MLP per expert to add significant nonlinear expressivity to the router.
|
| 32 |
+
- **Residual Scaling**: We add learnable scalar gates and biases to the residual stream and the outputs of each block. This provides a lightweight method to allow the model to carefully control its own norm and degree of forgetting across depth.
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+

|
| 36 |
+
|
| 37 |
+
ZAYA1-base uses the [Gemma3](https://ai.google.dev/gemma/terms) tokenizer.
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
## Performance
|
| 41 |
+
|
| 42 |
+
ZAYA1-base performs extremely competitively against other base models of a similar and even greater scale.
|
| 43 |
+
|
| 44 |
+

|
| 45 |
+
|
| 46 |
+

|
| 47 |
+
|
| 48 |
+
## Quick start
|
| 49 |
+
|
| 50 |
+
### Prerequisites
|
| 51 |
+
|
| 52 |
+
To use ZAYA1, install `zaya` branch from our fork of `transformers` library, which is based on the v4.57.1 of `transformers`:
|
| 53 |
+
```bash
|
| 54 |
+
pip install "transformers @ git+https://github.com/Zyphra/transformers.git@zaya"
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
The command above relies on requirements for `transformers v4.57.1` being installed in your environment. If you're installing in a fresh Python environment, you might want to specify a specific extra, like `[dev-torch]`, to install all the dependencies:
|
| 58 |
+
```bash
|
| 59 |
+
pip install "transformers[dev-torch] @ git+https://github.com/Zyphra/transformers.git@zaya"
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
### Inference
|
| 64 |
+
|
| 65 |
+
```python
|
| 66 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 67 |
+
import torch
|
| 68 |
+
|
| 69 |
+
tokenizer = AutoTokenizer.from_pretrained("Zyphra/ZAYA1-base")
|
| 70 |
+
model = AutoModelForCausalLM.from_pretrained("Zyphra/ZAYA1-base", device_map="cuda", dtype=torch.bfloat16)
|
| 71 |
+
|
| 72 |
+
input_text = "What factors contributed to the fall of the Roman Empire?"
|
| 73 |
+
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
|
| 74 |
+
|
| 75 |
+
outputs = model.generate(**input_ids, max_new_tokens=100)
|
| 76 |
+
print(tokenizer.decode(outputs[0]))
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% macro render_extra_keys(json_dict, handled_keys) %}
|
| 2 |
+
{%- if json_dict is mapping %}
|
| 3 |
+
{%- for json_key in json_dict if json_key not in handled_keys %}
|
| 4 |
+
{%- if json_dict[json_key] is mapping or (json_dict[json_key] is sequence and json_dict[json_key] is not string) %}
|
| 5 |
+
{{- '\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson | safe) ~ '</' ~ json_key ~ '>' }}
|
| 6 |
+
{%- else %}
|
| 7 |
+
{{-'\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '</' ~ json_key ~ '>' }}
|
| 8 |
+
{%- endif %}
|
| 9 |
+
{%- endfor %}
|
| 10 |
+
{%- endif %}
|
| 11 |
+
{% endmacro %}
|
| 12 |
+
{%- set enable_thinking = enable_thinking if enable_thinking is defined else True %}
|
| 13 |
+
{# TODO: set truncate to true for deployment & agent evals. Keep on for SFT. #}
|
| 14 |
+
{%- set truncate_history_thinking = truncate_history_thinking if truncate_history_thinking is defined else False %}
|
| 15 |
+
{{- bos_token }}
|
| 16 |
+
{%- set ns = namespace(last_user_idx = -1) %}
|
| 17 |
+
{%- set loop_messages = messages %}
|
| 18 |
+
{%- for m in loop_messages %}
|
| 19 |
+
{%- if m["role"] == "user" %}
|
| 20 |
+
{%- set ns.last_user_idx = loop.index0 %}
|
| 21 |
+
{%- endif %}
|
| 22 |
+
{%- endfor %}
|
| 23 |
+
|
| 24 |
+
{%- if messages[0]["role"] == "system" %}
|
| 25 |
+
{%- set system_message = messages[0]["content"] %}
|
| 26 |
+
{%- set loop_messages = messages[1:] %}
|
| 27 |
+
{%- else %}
|
| 28 |
+
{%- set system_message = "" %}
|
| 29 |
+
{%- set loop_messages = messages %}
|
| 30 |
+
{%- endif %}
|
| 31 |
+
{%- if not tools is defined %}
|
| 32 |
+
{%- set tools = [] %}
|
| 33 |
+
{%- endif %}
|
| 34 |
+
{# Recompute last_user_idx relative to loop_messages after handling system #}
|
| 35 |
+
{%- set ns = namespace(last_user_idx = -1) %}
|
| 36 |
+
{%- for m in loop_messages %}
|
| 37 |
+
{%- if m["role"] == "user" %}
|
| 38 |
+
{%- set ns.last_user_idx = loop.index0 %}
|
| 39 |
+
{%- endif %}
|
| 40 |
+
{%- endfor %}
|
| 41 |
+
{%- if system_message is defined %}
|
| 42 |
+
{{- "<|im_start|>system\n" + system_message }}
|
| 43 |
+
{%- else %}
|
| 44 |
+
{%- if tools is iterable and tools | length > 0 %}
|
| 45 |
+
{{- "<|im_start|>system\n" }}
|
| 46 |
+
{%- endif %}
|
| 47 |
+
{%- endif %}
|
| 48 |
+
{%- if tools is iterable and tools | length > 0 %}
|
| 49 |
+
{%- if system_message is defined and system_message | length > 0 %}
|
| 50 |
+
{{- "\n\n" }}
|
| 51 |
+
{%- endif %}
|
| 52 |
+
{{- "# Tools\n\nYou have access to the following functions:\n\n" }}
|
| 53 |
+
{{- "<tools>" }}
|
| 54 |
+
{%- for tool in tools %}
|
| 55 |
+
{%- if tool.function is defined %}
|
| 56 |
+
{%- set tool = tool.function %}
|
| 57 |
+
{%- endif %}
|
| 58 |
+
{{- "\n<function>\n<name>" ~ tool.name ~ "</name>" }}
|
| 59 |
+
{%- if tool.description is defined %}
|
| 60 |
+
{{- '\n<description>' ~ (tool.description | trim) ~ '</description>' }}
|
| 61 |
+
{%- endif %}
|
| 62 |
+
{{- '\n<parameters>' }}
|
| 63 |
+
{%- if tool.parameters is defined and tool.parameters is mapping and tool.parameters.properties is defined and tool.parameters.properties is mapping %}
|
| 64 |
+
{%- for param_name, param_fields in tool.parameters.properties|items %}
|
| 65 |
+
{{- '\n<parameter>' }}
|
| 66 |
+
{{- '\n<name>' ~ param_name ~ '</name>' }}
|
| 67 |
+
{%- if param_fields.type is defined %}
|
| 68 |
+
{{- '\n<type>' ~ (param_fields.type | string) ~ '</type>' }}
|
| 69 |
+
{%- endif %}
|
| 70 |
+
{%- if param_fields.description is defined %}
|
| 71 |
+
{{- '\n<description>' ~ (param_fields.description | trim) ~ '</description>' }}
|
| 72 |
+
{%- endif %}
|
| 73 |
+
{%- if param_fields.enum is defined %}
|
| 74 |
+
{{- '\n<enum>' ~ (param_fields.enum | tojson | safe) ~ '</enum>' }}
|
| 75 |
+
{%- endif %}
|
| 76 |
+
{%- set handled_keys = ['name', 'type', 'description', 'enum'] %}
|
| 77 |
+
{{- render_extra_keys(param_fields, handled_keys) }}
|
| 78 |
+
{{- '\n</parameter>' }}
|
| 79 |
+
{%- endfor %}
|
| 80 |
+
{%- endif %}
|
| 81 |
+
{% set handled_keys = ['type', 'properties', 'required'] %}
|
| 82 |
+
{{- render_extra_keys(tool.parameters, handled_keys) }}
|
| 83 |
+
{%- if tool.parameters is defined and tool.parameters.required is defined %}
|
| 84 |
+
{{- '\n<required>' ~ (tool.parameters.required | tojson | safe) ~ '</required>' }}
|
| 85 |
+
{%- endif %}
|
| 86 |
+
{{- '\n</parameters>' }}
|
| 87 |
+
{%- set handled_keys = ['type', 'name', 'description', 'parameters'] %}
|
| 88 |
+
{{- render_extra_keys(tool, handled_keys) }}
|
| 89 |
+
{{- '\n</function>' }}
|
| 90 |
+
{%- endfor %}
|
| 91 |
+
{{- "\n</tools>" }}
|
| 92 |
+
|
| 93 |
+
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<zyphra_tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</zyphra_tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <zyphra_tool_call></zyphra_tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 94 |
+
{%- endif %}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
{%- if system_message is defined %}
|
| 98 |
+
{{- '<|im_end|>\n' }}
|
| 99 |
+
{%- else %}
|
| 100 |
+
{%- if tools is iterable and tools | length > 0 %}
|
| 101 |
+
{{- '<|im_end|>\n' }}
|
| 102 |
+
{%- endif %}
|
| 103 |
+
{%- endif %}
|
| 104 |
+
|
| 105 |
+
{%- for message in loop_messages %}
|
| 106 |
+
{%- if message.role == "assistant" %}
|
| 107 |
+
{# Add reasoning content in to content field for unified processing below. #}
|
| 108 |
+
{%- if message.reasoning_content is defined and message.reasoning_content is string and message.reasoning_content | trim | length > 0 %}
|
| 109 |
+
{%- set content = "<think>\n" ~ message.reasoning_content ~ "\n</think>\n\n" ~ (message.content | default('', true)) %}
|
| 110 |
+
{%- else %}
|
| 111 |
+
{%- set content = message.content | default('', true) %}
|
| 112 |
+
{%- if content is string -%}
|
| 113 |
+
{# Allow downstream logic to to take care of broken thought, only handle coherent reasoning here. #}
|
| 114 |
+
{%- if '<think>' not in content and '</think>' not in content -%}
|
| 115 |
+
{%- set content = "<think>\n</think>\n\n" ~ content -%}
|
| 116 |
+
{%- endif -%}
|
| 117 |
+
{%- else -%}
|
| 118 |
+
{%- set content = content -%}
|
| 119 |
+
{%- endif -%}
|
| 120 |
+
{%- endif %}
|
| 121 |
+
{%- if message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %}
|
| 122 |
+
{# Assistant message has tool calls. #}
|
| 123 |
+
{{- '<|im_start|>assistant\n' }}
|
| 124 |
+
{%- set include_content = not (truncate_history_thinking and loop.index0 < ns.last_user_idx) %}
|
| 125 |
+
{%- if content is string and content | trim | length > 0 %}
|
| 126 |
+
{%- if include_content %}
|
| 127 |
+
{{- (content | trim) ~ '\n\n' -}}
|
| 128 |
+
{%- else %}
|
| 129 |
+
{%- set c = (content | string) %}
|
| 130 |
+
{%- if '</think>' in c %}
|
| 131 |
+
{# Keep only content after the last closing think. Also generation prompt causes this. #}
|
| 132 |
+
{%- set c = c.split('</think>')[-1] %}
|
| 133 |
+
{%- elif '<think>' in c %}
|
| 134 |
+
{# If <think> was opened but never closed, drop the trailing think segment #}
|
| 135 |
+
{%- set c = c.split('<think>')[0] %}
|
| 136 |
+
{%- endif %}
|
| 137 |
+
{%- set c = "<think>\n</think>\n\n" ~ c | trim %}
|
| 138 |
+
{%- if c | length > 0 %}
|
| 139 |
+
{{- c ~ '\n' -}}
|
| 140 |
+
{%- endif %}
|
| 141 |
+
{%- endif %}
|
| 142 |
+
{%- else %}
|
| 143 |
+
{{- "<think>\n</think>\n\n" -}}
|
| 144 |
+
{%- endif %}
|
| 145 |
+
{%- for tool_call in message.tool_calls %}
|
| 146 |
+
{%- if tool_call.function is defined %}
|
| 147 |
+
{%- set tool_call = tool_call.function %}
|
| 148 |
+
{%- endif %}
|
| 149 |
+
{{- '<zyphra_tool_call>\n<function=' ~ tool_call.name ~ '>\n' -}}
|
| 150 |
+
{%- if tool_call.arguments is defined %}
|
| 151 |
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
| 152 |
+
{{- '<parameter=' ~ args_name ~ '>\n' -}}
|
| 153 |
+
{%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
|
| 154 |
+
{{- args_value ~ '\n</parameter>\n' -}}
|
| 155 |
+
{%- endfor %}
|
| 156 |
+
{%- endif %}
|
| 157 |
+
{{- '</function>\n</zyphra_tool_call>\n' -}}
|
| 158 |
+
{%- endfor %}
|
| 159 |
+
{{- '<|im_end|>\n' }}
|
| 160 |
+
{%- else %}
|
| 161 |
+
{# Assistant message doesn't have tool calls. #}
|
| 162 |
+
{%- if not (truncate_history_thinking and loop.index0 < ns.last_user_idx) %}
|
| 163 |
+
{{- '<|im_start|>assistant\n' ~ (content | default('', true) | string | trim) ~ '<|im_end|>\n' }}
|
| 164 |
+
{%- else %}
|
| 165 |
+
{%- set c = (content | default('', true) | string) %}
|
| 166 |
+
{%- if '<think>' in c and '</think>' in c %}
|
| 167 |
+
{%- set c = "<think>\n</think>\n\n" ~ (c.split('</think>')[-1] | trim) %}
|
| 168 |
+
{%- endif %}
|
| 169 |
+
{%- set c = c | trim %}
|
| 170 |
+
{%- if c | length > 0 %}
|
| 171 |
+
{{- '<|im_start|>assistant\n' ~ c ~ '<|im_end|>\n' }}
|
| 172 |
+
{%- else %}
|
| 173 |
+
{{- '<|im_start|>assistant\n<|im_end|>\n' }}
|
| 174 |
+
{%- endif %}
|
| 175 |
+
{%- endif %}
|
| 176 |
+
{%- endif %}
|
| 177 |
+
{%- elif message.role == "user" or message.role == "system" %}
|
| 178 |
+
{{- '<|im_start|>' + message.role + '\n' }}
|
| 179 |
+
{%- set content = message.content | string %}
|
| 180 |
+
{{- content }}
|
| 181 |
+
{{- '<|im_end|>\n' }}
|
| 182 |
+
{%- elif message.role == "tool" %}
|
| 183 |
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
| 184 |
+
{{- '<|im_start|>user\n' }}
|
| 185 |
+
{%- endif %}
|
| 186 |
+
{{- '<zyphra_tool_response>\n' }}
|
| 187 |
+
{{- message.content }}
|
| 188 |
+
{{- '\n</zyphra_tool_response>\n' }}
|
| 189 |
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
| 190 |
+
{{- '<|im_end|>\n' }}
|
| 191 |
+
{%- elif loop.last %}
|
| 192 |
+
{{- '<|im_end|>\n' }}
|
| 193 |
+
{%- endif %}
|
| 194 |
+
{%- else %}
|
| 195 |
+
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>\n' }}
|
| 196 |
+
{%- endif %}
|
| 197 |
+
{%- endfor %}
|
| 198 |
+
|
| 199 |
+
{%- if add_generation_prompt %}
|
| 200 |
+
{%- if enable_thinking %}
|
| 201 |
+
{{- '<|im_start|>assistant\n<think>\n' }}
|
| 202 |
+
{%- else %}
|
| 203 |
+
{{- '<|im_start|>assistant\n<think>\n</think>\n\n' }}
|
| 204 |
+
{%- endif %}
|
| 205 |
+
{%- endif %}
|
config.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_func": "swiglu",
|
| 3 |
+
"activation_func_fp8_input_store": false,
|
| 4 |
+
"add_bias_linear": false,
|
| 5 |
+
"architectures": [
|
| 6 |
+
"ZayaForCausalLM"
|
| 7 |
+
],
|
| 8 |
+
"attention_bias": false,
|
| 9 |
+
"attention_dropout": 0.0,
|
| 10 |
+
"bias_activation_fusion": true,
|
| 11 |
+
"bos_token_id": 2,
|
| 12 |
+
"cca": true,
|
| 13 |
+
"dtype": "bfloat16",
|
| 14 |
+
"eos_token_id": 106,
|
| 15 |
+
"ffn_hidden_size": 4096,
|
| 16 |
+
"gated_linear_unit": true,
|
| 17 |
+
"head_dim": 128,
|
| 18 |
+
"hidden_size": 2048,
|
| 19 |
+
"kv_channels": 128,
|
| 20 |
+
"lm_head_bias": false,
|
| 21 |
+
"mamba_cache_dtype": "float32",
|
| 22 |
+
"max_position_embeddings": 131072,
|
| 23 |
+
"model_type": "zaya",
|
| 24 |
+
"moe_router_topk": 1,
|
| 25 |
+
"norm_epsilon": 1e-05,
|
| 26 |
+
"normalization": "RMSNorm",
|
| 27 |
+
"num_attention_heads": 8,
|
| 28 |
+
"num_experts": 16,
|
| 29 |
+
"num_hidden_layers": 80,
|
| 30 |
+
"num_key_value_heads": 2,
|
| 31 |
+
"num_query_groups": 2,
|
| 32 |
+
"pad_token_id": 0,
|
| 33 |
+
"partial_rotary_factor": 0.5,
|
| 34 |
+
"quantization": {
|
| 35 |
+
"group_size": 64,
|
| 36 |
+
"bits": 8,
|
| 37 |
+
"mode": "affine"
|
| 38 |
+
},
|
| 39 |
+
"quantization_config": {
|
| 40 |
+
"group_size": 64,
|
| 41 |
+
"bits": 8,
|
| 42 |
+
"mode": "affine"
|
| 43 |
+
},
|
| 44 |
+
"residual_in_fp32": true,
|
| 45 |
+
"rope_scaling": false,
|
| 46 |
+
"rope_theta": 5000000,
|
| 47 |
+
"scale_residual_merge": true,
|
| 48 |
+
"sliding_window": null,
|
| 49 |
+
"transformers_version": "4.57.1",
|
| 50 |
+
"use_cache": true,
|
| 51 |
+
"vocab_size": 262272,
|
| 52 |
+
"zaya_mlp_expansion": 256,
|
| 53 |
+
"zaya_use_eda": true,
|
| 54 |
+
"zaya_use_mod": true
|
| 55 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 2,
|
| 4 |
+
"eos_token_id": 106,
|
| 5 |
+
"pad_token_id": 0,
|
| 6 |
+
"temperature": 1.0,
|
| 7 |
+
"top_k": -1,
|
| 8 |
+
"top_p": 0.95,
|
| 9 |
+
"transformers_version": "4.57.1"
|
| 10 |
+
}
|
model-00001-of-00002.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2387137c04539ff12521b6636657c245a708fcaad26e26d9d09ebefad72c9bc8
|
| 3 |
+
size 5368501086
|
model-00002-of-00002.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a35aaeb0a7bcb653d736ca1ea901147b3cb7a8c054f1a1bafe47379cdc5af1fc
|
| 3 |
+
size 4062798556
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:73aeac3336eaf0c25d1a803e7b21ca4e90f974cd17f189b8aee0eb7e958bede5
|
| 3 |
+
size 33385480
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"boi_token": "<start_of_image>",
|
| 4 |
+
"bos_token": "<bos>",
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eoi_token": "<end_of_image>",
|
| 7 |
+
"eos_token": "<|im_end|>",
|
| 8 |
+
"image_token": "<image_soft_token>",
|
| 9 |
+
"is_local": true,
|
| 10 |
+
"local_files_only": false,
|
| 11 |
+
"mask_token": "<mask>",
|
| 12 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 13 |
+
"model_specific_special_tokens": {
|
| 14 |
+
"boi_token": "<start_of_image>",
|
| 15 |
+
"eoi_token": "<end_of_image>",
|
| 16 |
+
"image_token": "<image_soft_token>"
|
| 17 |
+
},
|
| 18 |
+
"pad_token": "<pad>",
|
| 19 |
+
"processor_class": "Gemma3Processor",
|
| 20 |
+
"sp_model_kwargs": null,
|
| 21 |
+
"spaces_between_special_tokens": false,
|
| 22 |
+
"tokenizer_class": "GemmaTokenizer",
|
| 23 |
+
"unk_token": "<unk>",
|
| 24 |
+
"use_default_system_prompt": false
|
| 25 |
+
}
|