Skip to content

Support assistant-only loss for the Inkling chat template - #8513

Merged
albertvillanova merged 2 commits into
mainfrom
support-inkling-assistant-only-loss
Nov 24, 2026
Merged

albertvillanova merged 2 commits into
mainfrom
support-inkling-assistant-only-loss

Conversation

@albertvillanova

@albertvillanova albertvillanova commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

This PR makes assistant_only_loss=True work for the Inkling chat template: thinkingmachines/Inkling, thinkingmachines/Inkling-Small and thinkingmachines/Inkling-Small-NVFP4, which ship the same template.

Part of #7962.

Motivation

TRL does not store the Inkling template, and it has no {% generation %} markers, so get_training_chat_template raises and SFTTrainer with assistant_only_loss=True fails at init.

Changes

  • Add inkling.jinja, the original template, and inkling_training.jinja. The training template wraps each assistant turn with {% generation %} markers. The first <|message_model|> of the turn stays outside, since the generation prompt already ends with it. The later ones, between the reasoning, text and tool-call messages, are generated by the model, so they stay inside, with the closing <|content_model_end_sampling|>. The rendered text is unchanged.
  • Run the training template suite on the tiny Inkling model, check the reference repo in check_chat_templates.py, and document the templates.

On the real thinkingmachines/Inkling-Small tokenizer, the training template renders like the original, keeps prefix preservation and trains the stop token. The trained spans start right after the generation prompt.

This PR is stacked on #8512, which adds the generation script for trl-internal-testing/tiny-InklingForConditionalGeneration; the tests run on that model.


Note

Low Risk
Adds a new model-family template path and tests; no changes to auth, security, or core training loops beyond template selection.

Overview
Adds first-class Inkling chat template support so SFTTrainer with assistant_only_loss=True works for thinkingmachines/Inkling and related checkpoints.

Ships inkling.jinja (Hub reference) and inkling_training.jinja, which wrap each assistant turn in {% generation %} markers while keeping the opening <|message_model|> outside the mask (generation prompt) and reasoning, text, tool-call segments, plus <|content_model_end_sampling|> inside. get_training_chat_template maps the base template to the training variant. Docs, trl/chat_templates/README.md, the template drift check (thinkingmachines/Inkling), and the existing training-template test suite are updated for the new family.

Reviewed by Cursor Bugbot for commit 236e310. Bugbot is set up for automated code reviews on this repo. Configure here.

@bot-ci-comment

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Pages changed in this PR:

@albertvillanova
albertvillanova force-pushed the support-inkling-assistant-only-loss branch 2 times, most recently from 14abbd4 to f5f463d Compare November 24, 2026 10:51
Base automatically changed from tiny-inkling to main November 24, 2026 12:25
@albertvillanova
albertvillanova force-pushed the support-inkling-assistant-only-loss branch from f5f463d to 236e310 Compare November 24, 2026 12:25
@albertvillanova

Copy link
Copy Markdown
Member Author

The failing "Check chat templates against the Hub" job is unrelated to this PR: Mistral Large 4 and Mistral Medium 3.5 now ship a new chat template revision on the Hub (#8559, #8560).

@albertvillanova
albertvillanova merged commit 56b0144 into main Nov 24, 2026
12 of 13 checks passed
@albertvillanova
albertvillanova deleted the support-inkling-assistant-only-loss branch November 24, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants