Models & evaluation
Check the chat template before blaming your local LLM
Inspect Transformers chat formatting, generation prompts and special tokens before treating a local model’s weak answer as a capability problem.

Messages need a model-specific representation
A list of role and content messages is not the final sequence a chat model receives. A chat template converts it into text and control tokens that identify speakers and message boundaries. Models from the same base family can expect different representations. Copying another model’s template can therefore change behavior, not merely presentation.
Start with the exact model revision and its tokenizer files. A base model and an instruct model need not share a usable conversation format. Check support for system messages and tool use rather than assuming every chat interface accepts the same roles.
Inspect formatting before generation
With the matching tokenizer prepared, inspect a small synthetic conversation using tokenizer.apply_chat_template with tokenize=False. Locate the user’s message, message endings and the assistant’s response boundary. This checks formatting without generating an answer. It cannot establish response quality.
Where the template supports it, add_generation_prompt=True prepares a new assistant turn. Continuing an existing assistant message is a different operation. Do not combine this option with continue_final_message; select the behavior required by the final message.
Messages → model-specific chat template → tokens
Inspect: apply_chat_template(messages, tokenize=False)
Tokenize directly: apply_chat_template(messages, tokenize=True)
Separate tokenization: check add_special_tokens=False
New assistant turn ≠ continue an existing assistant messageInspection outline; it does not run a model or validate every model’s settings.
Download example text ↓Choose one tokenization path
One route is to let apply_chat_template tokenize directly with tokenize=True. If you instead format text and tokenize it in a separate step, follow the library guidance on add_special_tokens=False to avoid adding control tokens again. Do not manually decorate a sequence already formatted by the template.
Keep two fixture conversations: a new request ending with the user, and a multi-turn exchange containing a previous assistant reply. Inspect both. Synthetic text is sufficient; diagnosing a template does not require sending private documents to a public demo.
To understand tokenizer-dependent counts, read .
Keep formatting in the experiment record
Record model identifier, file revision, library version and formatting path. If the tokenizer or template changes between runs, weights are not the only possible cause of a response difference. Raw text token counts can also differ from the full serialized conversation with roles and control tokens.
This is a configuration inspection guide, not a benchmark of a named model. Unsupported roles and formats need model-specific documentation. A useful result states exactly which sequence will be passed onward, which files created it and which assumptions remain unchecked.
Sources & further reading
References support the concept and documented library behavior. Data and calculations are synthetic examples, not commercial product benchmarks.
Sources support concepts and features; proposed trials are educational examples.
Prepared with AI assistance. Educational examples are not product tests; actual measurements identify their method and scope. Editorial approach ↗

