A 1.5B coding LLM with the Heartly hallucination-reduction architecture,
fine-tuned from Qwen2.5-Coder-1.5B with the conversational Stage-5 SFT recipe
(Fix1–4: natural phrasing, single refusal, persona — 5,200 samples in
heartly-qwen-code/sft_dataset_code_v3.jsonl).
v3 builds on the same v1/v2 Stage 1–4 numbers (grammar adoption 100%, boundary-head
AUROC 1.000, critic AUROC 1.000) — same Qwen2.5-Coder-1.5B base, now trained for
multi-turn conversational code chat. See HF_MODEL_CARD.md for
the Stage 1–2 probe/critic results carried over from the identical architecture.
0. Recommended — chat via the GitHub server (strips the grammar for you)
This model emits the Heartly grammar as ordinary multi-token text (the tags are
not tokenizer special tokens), so some front-ends (e.g. LM Studio) may decode
them mangled. The server.py FastAPI loader on GitHub loads this model and
runs every reply through reply_formatter.py, which canonicalises the tags
and returns only the clean answer.
bash
1pip install -r requirements.txt # fastapi + uvicorn + transformers + torch2python server.py --model eivintobias/heartly-qwen-code --port 800034curl -X POST http://127.0.0.1:8000/chat \5 -H "Content-Type: application/json"\6 -d '{"prompt":"Write a function that reverses a string"}'
Quick browser test (no curl): open http://127.0.0.1:8000/ — server.py serves an
HTML chat UI at GET /. The first message lazy-loads the model; code answers render
with real line breaks, and the Heartly grammar is stripped by the reply formatter.
Quick offline test (no server): python chat_smoke.py "Write a function that sorts a list".
📦 Model card source: this file (HF_MODEL_CARD_v3.md). When uploaded to
HuggingFace, copy it to README.md on the hub repo.
1. Transformers
python
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3tok = AutoTokenizer.from_pretrained("eivintobias/heartly-qwen-code")4model = AutoModelForCausalLM.from_pretrained(5"eivintobias/heartly-qwen-code", torch_dtype=torch.float32, device_map="cpu"6)7model.eval()8ids = tok.encode("User: Write a function that reverses a string\nAssistant: ", return_tensors="pt")9out = model.generate(**ids, max_new_tokens=256, pad_token_id=tok.eos_token_id, do_sample=False)10raw = tok.decode(out[0][ids.shape[1]:], skip_special_tokens=False)11# Strip the grammar -> clean answer:12from reply_formatter import format_reply
13print(format_reply(raw))
reply_formatter.py (grammar strip) and server.py are bundled in this repo (HF clone = flat layout; GitHub = heartly-qwen-code/). Clone it so from reply_formatter import format_reply resolves before the offline example.