Text Generation
MLX
Safetensors
English
Chinese
hy_v4
quantized
hy4
Mixture of Experts
conversational
4-bit precision
Instructions to use Xylolabs/Hy4-MLX-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use Xylolabs/Hy4-MLX-4bit 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("Xylolabs/Hy4-MLX-4bit") 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 Xylolabs/Hy4-MLX-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Xylolabs/Hy4-MLX-4bit"
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": "Xylolabs/Hy4-MLX-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use Xylolabs/Hy4-MLX-4bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "Xylolabs/Hy4-MLX-4bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "Xylolabs/Hy4-MLX-4bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8080/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Xylolabs/Hy4-MLX-4bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use Xylolabs/Hy4-MLX-4bit 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 "Xylolabs/Hy4-MLX-4bit"
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 Xylolabs/Hy4-MLX-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Xylolabs/Hy4-MLX-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Xylolabs/Hy4-MLX-4bit"
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 "Xylolabs/Hy4-MLX-4bit" \ --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"
Card: shorter text in our sections
Browse files
README.md
CHANGED
|
@@ -31,17 +31,13 @@ tags:
|
|
| 31 |
|
| 32 |
</div>
|
| 33 |
|
| 34 |
-
The text model of [tencent/Hy4](https://huggingface.co/tencent/Hy4) (770B parameters, 49B active) converted for [MLX](https://github.com/ml-explore/mlx), with the routed experts in 4-bit
|
| 35 |
-
|
| 36 |
-
- **Files:** the text weights (447.58 GB in 243 shards), `hy_v4.py` and the conversion script.
|
| 37 |
-
- **Not included:** the vision tower and the DFly2 drafter. Text in, text out.
|
| 38 |
-
- **Run it:** see [How to run](#how-to-run).
|
| 39 |
|
| 40 |
## Files
|
| 41 |
|
| 42 |
| File | What it is |
|
| 43 |
|---|---|
|
| 44 |
-
| `model-NNNNN-of-00245.safetensors` | the text weights, 447.58 GB (416.84 GiB) in 243 files
|
| 45 |
| `model.safetensors.index.json` | which file holds each tensor |
|
| 46 |
| `hy_v4.py` | the Hy4 text model for `mlx-lm`, named by `model_file` in `config.json` |
|
| 47 |
| `convert_hy4.py` | the script that made these files from the BF16 original |
|
|
@@ -50,6 +46,8 @@ The text model of [tencent/Hy4](https://huggingface.co/tencent/Hy4) (770B parame
|
|
| 50 |
| `ORIGINS.md`, `LICENSE.transformers` | where the code in `hy_v4.py` comes from, and the Apache-2.0 license of the Transformers code it ports |
|
| 51 |
| `LICENSE`, `NOTICE` | the Tencent Hy License, Version 1.0, and the notice |
|
| 52 |
|
|
|
|
|
|
|
| 53 |
## Tensor recipe
|
| 54 |
|
| 55 |
| Tensor class | Format |
|
|
@@ -73,20 +71,16 @@ mlx_lm.server --model Xylolabs/Hy4-MLX-4bit --trust-remote-code
|
|
| 73 |
|
| 74 |
## How this was made
|
| 75 |
|
| 76 |
-
1. Stream `tencent/Hy4` (BF16, revision `c10c0de5`) shard by shard with `convert_hy4.py`: download a shard, quantize its text tensors with `mx.quantize` (affine, group size 64, round to nearest)
|
| 77 |
2. `hy_v4.py` ports Transformers' `hy_v4` model. RoPE rotates adjacent pairs, as Transformers' `hy_v4_vl` class and its pull request 50589 do.
|
| 78 |
|
| 79 |
## License and notices
|
| 80 |
|
| 81 |
-
|
| 82 |
-
- **What we changed:** we quantized the weights and converted them to MLX with `convert_hy4.py`; `hy_v4.py` is the model code.
|
| 83 |
-
- **Code:** `hy_v4.py` contains code ported from Hugging Face Transformers (Apache-2.0, `LICENSE.transformers`) and from `mlx-lm` (MIT, notice in `ORIGINS.md`).
|
| 84 |
-
- **Notices:** `NOTICE` names the source model and its copyright holder.
|
| 85 |
-
- Xylolabs is not affiliated with or endorsed by Tencent.
|
| 86 |
|
| 87 |
## Tencent's original model description
|
| 88 |
|
| 89 |
-
|
| 90 |
|
| 91 |
<p align="left">
|
| 92 |
<a href="https://huggingface.co/tencent/Hy4/blob/main/README_CN.md">中文</a> | English
|
|
|
|
| 31 |
|
| 32 |
</div>
|
| 33 |
|
| 34 |
+
The text model of [tencent/Hy4](https://huggingface.co/tencent/Hy4) (770B parameters, 49B active) converted for [MLX](https://github.com/ml-explore/mlx), with the routed experts in 4-bit; the vision tower and the DFly2 drafter are not included, so it takes text and returns text.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
## Files
|
| 37 |
|
| 38 |
| File | What it is |
|
| 39 |
|---|---|
|
| 40 |
+
| `model-NNNNN-of-00245.safetensors` | the text weights, 447.58 GB (416.84 GiB) in 243 files |
|
| 41 |
| `model.safetensors.index.json` | which file holds each tensor |
|
| 42 |
| `hy_v4.py` | the Hy4 text model for `mlx-lm`, named by `model_file` in `config.json` |
|
| 43 |
| `convert_hy4.py` | the script that made these files from the BF16 original |
|
|
|
|
| 46 |
| `ORIGINS.md`, `LICENSE.transformers` | where the code in `hy_v4.py` comes from, and the Apache-2.0 license of the Transformers code it ports |
|
| 47 |
| `LICENSE`, `NOTICE` | the Tencent Hy License, Version 1.0, and the notice |
|
| 48 |
|
| 49 |
+
Each weight file is named after the `tencent/Hy4` shard it was converted from; shards 89 and 245 hold only the vision tower and the drafter, so they have no counterpart.
|
| 50 |
+
|
| 51 |
## Tensor recipe
|
| 52 |
|
| 53 |
| Tensor class | Format |
|
|
|
|
| 71 |
|
| 72 |
## How this was made
|
| 73 |
|
| 74 |
+
1. Stream `tencent/Hy4` (BF16, revision `c10c0de5`) shard by shard with `convert_hy4.py`: download a shard, quantize its text tensors with `mx.quantize` (affine, group size 64, round to nearest) as the tensor recipe lists and copy the rest, write them, delete the shard. Each attention `kv_b_proj` is split into per-head `embed_q` and `unembed_out`, as in `mlx-lm`'s DeepSeek-V3.2 model.
|
| 75 |
2. `hy_v4.py` ports Transformers' `hy_v4` model. RoPE rotates adjacent pairs, as Transformers' `hy_v4_vl` class and its pull request 50589 do.
|
| 76 |
|
| 77 |
## License and notices
|
| 78 |
|
| 79 |
+
These files are under the Tencent Hy License, Version 1.0, copied in `LICENSE`, including its extra terms for large Model-as-a-Service operators. We quantized the weights and converted them to MLX with `convert_hy4.py`. `hy_v4.py` is the model code; it contains code ported from Hugging Face Transformers (Apache-2.0, `LICENSE.transformers`) and from `mlx-lm` (MIT, notice in `ORIGINS.md`). `NOTICE` names the source model and its copyright holder. Xylolabs is not affiliated with or endorsed by Tencent.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
## Tencent's original model description
|
| 82 |
|
| 83 |
+
Below is the README of [tencent/Hy4](https://huggingface.co/tencent/Hy4) (copyright Tencent, Tencent Hy License) without its metadata header, unchanged except for heading levels and image paths; it describes the original checkpoints, not these files.
|
| 84 |
|
| 85 |
<p align="left">
|
| 86 |
<a href="https://huggingface.co/tencent/Hy4/blob/main/README_CN.md">中文</a> | English
|