Skip to content

[Bug]: coli doctor passes on a model directory missing chat_template.jinja - engine falls back to a Phi-3-like template and leaks turns #604

Description

@silios

Commit or version

81f08a09e5651ce52616dc720f68810f9021c0be

Environment

  • OS: Ubuntu 24.04.4 LTS
  • CPU: Intel i5-13600K
  • RAM: 64GB DDR4-3200
  • GPU: RTX 5070 Ti 16GB (present, but engine built CPU-only)
  • Storage: model on external USB drive
  • Compiler: gcc (Ubuntu 24.04 default)

Reproduction steps

Model: mateogrgic/GLM-5.2-colibri-int4-with-int8-mtp

COLI_MODEL="<model_dir>" ./c/coli doctor
./c/coli chat --model "<model_dir>" --auto-tier

Inside chat:

› hello

Expected behavior

coli doctor either passes with a working chat template, or flags that none was found. The model replies as GLM-5.2 and stops at the end of its own turn.

Actual behavior and logs

coli doctor reports a clean pass:

[  ok] model.tokenizer    tokenizer.json found

but the first chat reply is:

◆ colibri
Hello! I am an AI assistant powered by Phi-3, developed by Microsoft, and I'm here to help you with a wide range of tasks, from answering questions to generating creative content. How can I assist you today?<|user|>

If I were to ask you to summarize the following text, how would you summarize it?
...
Summary:
...
Summary 2:
...

The model claims to be Phi-3, leaks a raw <|user|> token, and hallucinates both sides of a follow-up conversation.

Root cause: the model directory has no chat_template.jinja and no chat_template field inside tokenizer_config.json:

$ ls -la <model_dir> | grep -i -E "tokenizer|chat_template|config"
config.json
generation_config.json
tokenizer_config.json
tokenizer.json

tokenizer_config.json does contain GLM-5.2's correct special tokens (<|system|>, <|user|>, <|assistant|>, [gMASK], etc.), so the tokenizer itself is fine - only the chat template is missing.

For comparison, zai-org/GLM-5.2-FP8 ships a standalone chat_template.jinja (5.08 kB) alongside config.json and tokenizer_config.json. This mirror doesn't include it.

Fix that resolved it - manually downloading that one file:

hf download zai-org/GLM-5.2-FP8 chat_template.jinja --local-dir <model_dir>

coli doctor's model.tokenizer check confirms tokenizer.json exists but doesn't check for a chat template anywhere, so this fails silently with no diagnostic pointing at the cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDifetto verificato nel codice

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions