Add a response_template for parsing assistant responses

#1
by qgallouedec HF Staff - opened

Adds a response_template to tokenizer_config.json so tokenizer.parse_response(...) turns raw generated text back into a message dict (transformers >= 5.13, https://github.com/huggingface/transformers/pull/45847):

>>> tokenizer.parse_response("A cat sitting on a mat.<|END_OF_TURN_TOKEN|>", prefix=prompt)
{'role': 'assistant', 'content': 'A cat sitting on a mat.'}

The model emits plain content between <|CHATBOT_TOKEN|> and <|END_OF_TURN_TOKEN|> — no thinking or tool-call fields — so the template is a single content field.

Verified: round-trips apply_chat_template -> parse_response at the token level, and every truncated prefix of a response parses without error (streaming-safe). No other behavior changes.

d-rau changed pull request status to merged

Sign up or log in to comment