granite-4.2-3b · HTML (think)
A full-parameter SFT of ibm-granite/granite-4.2-3b (3.66B dense, Apache-2.0) for structured HTML card generation. Given any instruction, the model first emits a reasoning block (closed by </think>) and then produces the normalized HTML card body.
Model Summary
| Item | Value |
|---|---|
| Base model | ibm-granite/granite-4.2-3b (bf16, Apache-2.0) |
| Training scope | Full-parameter SFT (embeddings and lm_head frozen) |
| Training data | Mario-HTML SFT, 830 examples (709 CoT-think + 121 direct), three-field user/think/body format |
| Learning rate / epochs | 2e-5 / 1.3 epochs (234 steps) |
| Sequence length / budget | 8192 / 16384 |
| Seed | 42 |
| Optimizer stack | Liger kernel, bf16 |
| Weight file | Single model.safetensors (6.82 GiB), sha256 c2f0e856ecaa10bd925609f2ec64cfdf94f5afa2d7654c79bc516f959ce51f79 |
🖼️ Demo
Rendered by the bundled WebUI (webui/) — the collapsed Chain of Thought panel on top, the raw model output rendered as an HTML card below it, unmodified.
who is the presidency of US now?
Observed behaviour
Measured with 19 generation probes:
- Think closure 17/17 — with thinking enabled, every reasoning block closed properly before the body started. The reasoning style is data-driven ("The user wants…"), not a base-model artefact.
- Closure needs in-distribution reinforcement. Under the same lr/epoch/seed: no-think data × full-parameter training welded the think tag on (86% unclosed); no-think data × attention-only training kept it but closed unreliably (~80–90%). This repo is the think-data × full-parameter variant.
- Body is a normalized HTML card (
ai-viewstructure), renderable directly by the bundled WebUI.
Deployment
vllm serve <this-directory> --max-model-len 65536 --gpu-memory-utilization 0.9
OpenAI-compatible endpoint. The bundled chat_template.jinja implements the ChatML-style format with <think> tags:
enable_thinking=true→ the prompt is prefixed with an open<think>and the model reasons first.enable_thinking=false→ the template pre-closes an empty think block (<think></think>) and the model answers directly.
Chat template
from transformers import AutoTokenizer
tok = AutoTokenizer.from_pretrained("wesjos/granite-4.2-3b-HTML")
text = tok.apply_chat_template(
[{"role": "user", "content": "Make me a card for a coffee shop."}],
tokenize=False,
add_generation_prompt=True,
enable_thinking=True,
)
🖥️ Bundled WebUI
A single-file FastAPI chat UI lives in webui/. It splits the <think> stream into a collapsible Chain of Thought panel and renders the answer body as an HTML card on a canvas.
# 1. serve the model
vllm serve . --served-model-name granite-4.2-3b-HTML \
--max-model-len 65536 --gpu-memory-utilization 0.9
# 2. serve the UI
cd webui
pip install -r requirements.txt
./run_webui.sh # → http://localhost:8791
It is model-agnostic: point api_url in webui/config.json at any OpenAI-compatible /v1 endpoint. See webui/README.md for the full file list and options.
A GGUF build of this model is available at wesjos/granite-4.2-3b-HTML-GGUF (Q8_0 + Q4_K_M).
Notes
config.jsonadditionally carries the legacy top-levelrope_theta/rope_scaling/torch_dtypekeys anduse_cache: true, so the repo loads cleanly on bothtransformers4.x and 5.x.- The tokenizer files are byte-identical to the base model's tokenizer (
tokenizer.jsonsha256883975314d58743726347caaf2c32ac89afd5ad57222cffbc4f052f2ab27b2d7);vocab.json,merges.txtandspecial_tokens_map.jsonare included fortransformers4.x compatibility.
License and attribution
Apache-2.0. This is an unofficial fine-tune of the IBM Granite model family; it is not endorsed by or affiliated with IBM. The base model ibm-granite/granite-4.2-3b is licensed under Apache-2.0.