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.
Instructions to use wesjos/granite-4.2-3b-HTML with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use wesjos/granite-4.2-3b-HTML with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="wesjos/granite-4.2-3b-HTML") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("wesjos/granite-4.2-3b-HTML") model = AutoModelForCausalLM.from_pretrained("wesjos/granite-4.2-3b-HTML", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use wesjos/granite-4.2-3b-HTML with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "wesjos/granite-4.2-3b-HTML" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "wesjos/granite-4.2-3b-HTML", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/wesjos/granite-4.2-3b-HTML
- SGLang
How to use wesjos/granite-4.2-3b-HTML with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "wesjos/granite-4.2-3b-HTML" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "wesjos/granite-4.2-3b-HTML", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "wesjos/granite-4.2-3b-HTML" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "wesjos/granite-4.2-3b-HTML", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use wesjos/granite-4.2-3b-HTML with Docker Model Runner:
docker model run hf.co/wesjos/granite-4.2-3b-HTML
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.
- Downloads last month
- 539
Model tree for wesjos/granite-4.2-3b-HTML
Base model
ibm-granite/granite-4.1-3b-base