broken-model-fixed

This repository is a corrected version of yunmorning/broken-model, created as part of an engineering debugging exercise.


Problem (a) — Root Cause Analysis and Fixes

[main] Fix 1: Added chat_template to tokenizer_config.json

What was missing: The tokenizer_config.json had no chat_template field.

Why this breaks /chat/completions: OpenAI-compatible inference servers receive requests as a list of {role, content} message objects. Before any token is fed to the model, the server must serialize this list into a flat string using the model's chat template. This serialization step is handled by HuggingFace's tokenizer.apply_chat_template(), which reads the chat_template field from tokenizer_config.json.

Without this field, apply_chat_template() raises a TemplateError immediately — the request never reaches the model weights. The failure is pre-inference and 100% reproducible on every request.

Fix applied: Added the chat_template from the official Qwen/Qwen3-8B repository. The template implements:

  • Per-turn format: <|im_start|>{role}\n{content}<|im_end|>\n
  • enable_thinking=False → injects <think>\n\n</think>\n\n after <|im_start|>assistant\n to suppress reasoning tokens
  • Tool call serialization via <tool_call> / <tool_response> tags
  • Multi-turn tool use with correct role handling

[Documentation] Fix 2: Corrected base_model in README.md

Before: base_model: meta-llama/Meta-Llama-3.1-8B
After: base_model: Qwen/Qwen3-8B

Why this is wrong: The model is clearly Qwen3-based ("model_type": "qwen3"), not Llama-3. Since Qwen3 and Llama-3 use different tokenizers and chat formats, keeping the wrong base_model metadata could cause inference systems to apply the wrong chat template.


Other fields reviewed

File Field Value Notes
config.json intermediate_size 12288 Verified via parameter count: total_size (16,381,470,720 bytes) / 2 (bfloat16) = 8.191B params. With intermediate_size=12288 the computed total is ~8.191B (matches); with 22016 it would be ~12.5B (does not match).
config.json max_position_embeddings 40960 Matches the standard context length configuration for Qwen3-8B.
tokenizer_config.json model_max_length 131072 Larger than max_position_embeddings, but this does not directly break inference and is sometimes seen in extended-context variants.
config.json rope_scaling null Consistent with the default context configuration.
model.safetensors.index.json Cross-shard weights Layers 7, 17, and 27 span multiple shards Looked consistent with normal safetensors sharding behavior.
generation_config.json temperature, top_k, top_p 0.6 / 20 / 0.95 Matches the official Qwen3 recommended sampling settings.
Downloads last month
4
Safetensors
Model size
8B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for pkhyrn268/broken-model-fixed

Finetuned
Qwen/Qwen3-8B
Finetuned
(2151)
this model