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 a Qwen3_5ForCausalLM, then mlx_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_tokens modest.
  • 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-morph do" 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
Safetensors
Model size
4B params
Tensor type
U32
ยท
BF16
ยท
MLX
Hardware compatibility
Log In to add your hardware

4-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for MythThrazz/datastar-4b-v2-mlx-4bit

Finetuned
Qwen/Qwen3.5-4B
Quantized
(649)
this model