Run this model with HF Jobs

Run wesjos/granite-4.2-3b-HTML on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/wesjos/granite-4.2-3b-HTML. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/wesjos/granite-4.2-3b-HTML on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/wesjos/granite-4.2-3b-HTML. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/wesjos/granite-4.2-3b-HTML. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
granite-4.2-3b-HTML / README.md
wesjos's picture
add webui + demo (README.md)
e52ce15 verified
|
Raw History Blame Contribute Delete
4.84 kB
metadata
license: apache-2.0
library_name: transformers
base_model: ibm-granite/granite-4.2-3b
base_model_relation: finetune
pipeline_tag: text-generation
language:
  - en
  - zh
tags:
  - text-generation
  - sft
  - thinking
  - html-card
  - full-finetune
  - granite

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?

WebUI chat demo: the Chain of Thought panel above shows the model reasoning about which president to name, and the answer below renders as an HTML card with a blue callout, a Joe Biden detail card, and a Context Note panel; the status bar shows 7.66s, 61.4 tok/s and 470 tokens

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-view structure), 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.json additionally carries the legacy top-level rope_theta / rope_scaling / torch_dtype keys and use_cache: true, so the repo loads cleanly on both transformers 4.x and 5.x.
  • The tokenizer files are byte-identical to the base model's tokenizer (tokenizer.json sha256 883975314d58743726347caaf2c32ac89afd5ad57222cffbc4f052f2ab27b2d7); vocab.json, merges.txt and special_tokens_map.json are included for transformers 4.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.