Instructions to use MythThrazz/datastar-4b-v2-mlx-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use MythThrazz/datastar-4b-v2-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("MythThrazz/datastar-4b-v2-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 MythThrazz/datastar-4b-v2-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 "MythThrazz/datastar-4b-v2-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": "MythThrazz/datastar-4b-v2-mlx-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use MythThrazz/datastar-4b-v2-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 "MythThrazz/datastar-4b-v2-mlx-4bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "MythThrazz/datastar-4b-v2-mlx-4bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MythThrazz/datastar-4b-v2-mlx-4bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use MythThrazz/datastar-4b-v2-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 "MythThrazz/datastar-4b-v2-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 MythThrazz/datastar-4b-v2-mlx-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use MythThrazz/datastar-4b-v2-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 "MythThrazz/datastar-4b-v2-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 "MythThrazz/datastar-4b-v2-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"
datastar-4b-v2-mlx-4bit
A small local model that knows Datastar, the hypermedia framework (backend-driven HTML over SSE, signals for the bits of frontend state you actually need).
I built it because every big model I asked about Datastar made things up. They'd confuse it with some npm package, or write React and call it "Datastar-compatible". I wanted something I can run on my Mac for quick questions, that gets the attributes, the SSE events and the Tao right.
It's Qwen3.5-4B, fine-tuned with QLoRA plus one round of self-distillation (SDFT) with a 9B judge, merged and converted to MLX 4-bit. About 2.2 GB on disk.
Usage
pip install mlx-lm
mlx_lm server --model MythThrazz/datastar-4b-v2-mlx-4bit --port 8099 \
--chat-template-args '{"enable_thinking": false}'
Then any OpenAI-compatible client works:
curl http://localhost:8099/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "MythThrazz/datastar-4b-v2-mlx-4bit",
"messages": [{"role": "user", "content": "How does CQRS work in Datastar?"}],
"max_tokens": 400, "temperature": 0.7}'
Keep thinking disabled. The training data has no thinking traces, so the answers are better without it.
Training
- Base model: Qwen/Qwen3.5-4B, loaded in 4-bit NF4 for training.
- Data: Q&A pairs built from the data-star.dev docs (57 pages scraped in March 2026). The pipeline went 508 raw pairs, then 536 cleaned and augmented (code-generation pairs added from the examples), then 523 after I removed 13 bad ones by hand, then 544 after I added 21 short conceptual pairs on the Tao, CQRS and signals. v2 was trained on those 544. Roughly half the set is API reference, the rest is concepts, code generation, debugging, SDK specifics and best practices.
- QLoRA: rank 16, alpha 32, dropout 0.05, all attention and MLP projections (q, k, v, o, gate, up, down), 3 epochs, effective batch 8, lr 2e-4 cosine, 8-bit AdamW, max length 2048. 21.2M trainable params. Loss went from 2.17 to 0.31 over 204 steps, 68 min on an RTX 4070 12GB (2026-04-06).
- SDFT: one round on top of that adapter (2026-04-07). The model answers 100 training questions, Qwen3.5-9B (Q4_K_M) scores each answer 1-10 against the reference, good answers are kept as-is and bad ones replaced by the reference, then one epoch of training on the result. 92 of 100 kept, average judge score 0.717.
- Export: PEFT
merge_and_unload()into aQwen3_5ForCausalLM, thenmlx_lm convert -q --q-bits 4(group size 64).
Evaluation
All numbers below come from my own training notes. Small samples, my own questions. Treat them as a sanity check, not a benchmark.
| What | Model | Result | Date |
|---|---|---|---|
10 novel questions, not in training (CDN URL, @peek, patch modes, delete via SSE, form reset, view transitions, philosophy, "In Morph We Trust", CQRS, signals vs backend state) |
v2 (SDFT adapter, before 4-bit conversion) | 9 pass, 1 partial: 9.5/10 | 2026-04-07 |
| Same kind of novel questions | v1 (523 samples, SDFT round 6) | 4/6 | 2026-04-04 |
| SDFT on-policy rate (share of answers the 9B judge accepted) | v2 | 92% | 2026-04-07 |
| SDFT on-policy rate | v1, rounds 5-7 | 95%, 97%, 96% | 2026-04-04/05 |
The 9.5/10 was measured on the adapter, before the merge and 4-bit quantization. I checked the MLX build by hand after conversion and the Datastar knowledge was intact, but I didn't rerun the 10 questions on it. The one partial was "reset all form signals" - it described an SSE approach and missed @setAll.
I also have a 50-question holdout set with expected keywords, but I don't have a scored run of v2 on it, so there's no number for that here.
Known weak spots
- Long answers drift. After roughly 100 words, especially in multi-step code generation, it starts inventing things. Ask narrow questions and keep
max_tokensmodest. - Repeated
<|im_end|>. It sometimes emits several end tokens in a row at the end of an answer. It's a chat template quirk, the answer itself is fine. Strip them on the client, or set<|im_end|>as a stop sequence. - Knowledge cutoff is the docs as of March/April 2026. Anything Datastar added later, it doesn't know.
- It's a 4B model. Great for "what does
data-ignore-morphdo" or "how do I stream a patch from PHP". For general coding or anything outside Datastar, use something bigger. - Speed: about 61 tok/s on an M3 Pro in my tests. Your numbers will depend on the machine and what else is running.
License
Apache-2.0, same as the base model.
- Downloads last month
- 29
4-bit