Browse changelogs · TML Renderers
TML Renderers
v0.4.2
New
- Pass
efforttorenderers.Inkling(effort=e),renderers.Inkling2(effort=e), orv0.Renderer(tokenizer, effort=e)to fix the thinking effort (a float in[0, 1]) for every render, includingrender_for_sft. Before, training at an effort meant adding the effort message to each conversation yourself; the renderer now adds it in the right place. A renderer built with an effort raisesValueErrorfromrender_for_completion_with_effort; callrender_for_completioninstead.
Changes
to_oss_messagesandto_oss_dictwrite the content of atool_declaremessage with sorted keys and non-ASCII text as\uescapes, so the same tools always give the same string. This changes that string for some tools.
Fixed
- Corrects the image token count of
renderers.Inkling2()andv0.Renderer(tokenizers.H200kBaseChatTokenizer())for Inkling 2 Small, for images whose width is a multiple of 40 pixels. MessageListconversions now track turns.MessageList.from_openai_chat_dicts,MessageList.from_messageswithOpenAIMessages, and the renderers' render methods givenOpenAIMessages give each message's parts its list index asturn_id. To group messages you build yourself, setchat.MessageMetadataProduct(turn_id=...). Renderers keep adjacent user messages with differentturn_ids as separate turns. Before, the Qwen, Nemotron 3, Kimi, GLM, and GPT-OSS renderers merged them:"one"and"two"rendered asonetwo. Kimi renderers also keep adjacent system messages separate.- A tool result sent as a list of content parts now renders as one tool result in
GptOss,KimiK2,KimiK25,DeepSeekV3,DeepSeekV31, andDeepSeekV41. Before, these renderers wrote each part as a separate tool result. This changes rendered tokens for these tool results. MessageList.from_openai_chat_dictskeeps thenameof an assistant message, andInkling,Inkling2, andv0.Rendererrender it as the model's author name. Before, the name was dropped, so every assistant message rendered as unnamed. This changes rendered tokens for named assistant messages.-
DeepSeek:
DeepSeekV3andDeepSeekV31SFT examples no longer end the assistant's text before its tool calls. This changes trained tokens.DeepSeekV31.thinking()SFT examples close the reasoning block before an answer that has no reasoning. This changes trained tokens.DeepSeekV4andDeepSeekV41parsers mark a finished reply withModelEndSampling.DeepSeekV41separates the text parts of one message with a blank line. This changes rendered tokens.- Corrects the tool name that
GptOssparsers read from a call followed by<|constrain|>json:to=functions.read<|constrain|>jsonnow names the toolread, notread<|constrain|>json.
Deprecations
- None.
Breaking changes
KimiK31Pro.medium()andreasoning_effort="medium"are removed, because Kimi K3.1-Pro has no medium effort. Use.high()or.low().- Renderers no longer use
message_metadata.product_metadata.message_idto split turns; they usemessage_metadata.product_metadata.turn_id. If you build messages yourself and relied onmessage_id, setturn_idinstead. .aacaudio files no longer work. AAC was never a supported format, but previous versions accepted it. Use WAV, MP3, or FLAC.- The deprecated
tokenizers.o200k_base_chat(),tml_renderers.tinker.TokenSpanWrapper, andtml_renderers.tinker.RawTokenSpanare removed. Usetokenizers.O200kBaseChatTokenizer()andchat.TokenSpan, or stay on 0.4.1. - The
from_openai_chat_*andfrom_oss_*methods raiseValueErrorfor atool_call_idornamethat is not a string.
Dependencies
- PyTorch
>=2.10->>=2.11. The wheel does not install PyTorch; with2.10,import tml_renderersfails.
v0.4.1
New
- Adds
renderers.KimiK31Pro()andtokenizers.KimiK3Tokenizer()for Kimi K3.1-Pro. The default reasoning effort ismax; use.high(),.low(),.disable_thinking(), or.no_reasoning_effort()for other supported modes.
Changes
- None.
Fixed
- Kimi: Keeps
KimiK2andKimiK25streamed answer indices consistent with the completed message after an empty thinking block. - GLM: Trains the correct assistant-turn ending in
Glm52,Glm53, andGlm53Flashsupervised examples:<|observation|>after tool calls and<|user|>otherwise, matching the next prompt. This changes the last trained token of GLM SFT examples. - Qwen: Corrects
Qwen35Tokenizertoken IDs for more text. This changes rendered tokens in Qwen3.5 and Qwen3.8 prompts and SFT examples.
Deprecations
- None.
Breaking changes
- None.
Dependencies
- Python
>=3.10→>=3.11
v0.4.0
New
- Use
renderers.Inkling()for Inkling and Inkling-Small, orrenderers.Inkling2()for Inkling 2 Small. Each builds its matching tokenizer. Set thinking effort withrender_for_completion_with_effort(messages, effort). - Use
tokenizers.H200kBaseChatTokenizer(), the Inkling 2 Small tokenizer, with low-level TMLv0 rendering:v0.Renderer(tokenizers.H200kBaseChatTokenizer()).
Changes
- None.
Fixed
- GLM: Corrects
GlmTokenizertoken IDs for some text. This changes rendered tokens forGlm52,Glm53, andGlm53Flash. - Qwen: Corrects
Qwen35Tokenizertoken IDs for some text. This changes rendered tokens forQwen35andQwen38.
Deprecations
- None.
Breaking changes
parser.parse_tokens()andparser.parse()now returnParseResultinstead of a list. For list-specific operations, replacemessages = parser.parse_tokens(tokens)withmessages = parser.parse_tokens(tokens).messages; iteration and integer indexing still work on the result.result.token_countsreports counts per completed message, and streaming completion updates exposenum_tokens.renderers.DeepSeekR1andtokenizers.DeepSeekR1Tokenizerare removed. Select a supported model and its matching renderer/tokenizer before upgrading; applications that still require these R1 APIs must remain on 0.3.0.- A
v0.Rendererpickled with 0.3.0 or earlier raisesTypeErrorwhen loaded with 0.4.0. Recreate and re-save renderers after upgrading, and use matching package versions in workers that exchange them.
Dependencies
- Drops support for Python
3.10.
v0.3.0
New
- Parse sampled tokens incrementally with
parser.parse_stream(). Inside its context manager, callstream.feed(token_ids)for each chunk andstream.finish()at completion; each returnsParseUpdateobjects. - Continue a conversation without re-encoding its sampled prefix using
renderer.bridge_to_next_turn(prefix, message_history, next_messages). It returns the combined token spans, the appended suffix, and a parser for the next turn. - Use
renderers.Nemotron3VL()andtokenizers.Nemotron3VLTokenizer()for Nemotron 3.5 Super VL, including image inputs. Call.disable_thinking()for the non-thinking preset. - Preserve DeepSeek-V4.1 reasoning across turns with
renderers.DeepSeekV41.preserve_thinking_history()orDeepSeekV41(strip_thinking_from_history=False). - Use
chat.ParseErrorContent(error_message=..., sampled_tokens=...)to record a failed parse in a conversation. Renderers write only itserror_messageinto the prompt. DeepSeek-V3.1 does not accept it, and DeepSeek-V4, DeepSeek-V4.1, GLM, and GPT-OSS accept it only in user messages. - Convert OpenAI Chat Completions messages with
MessageList.from_openai_chat_dicts(messages, tools=...)and convert back withto_openai_chat_dicts(). A top-levelreasoning_contentbecomes reasoning, and the request'stoolslist becomes a tool declaration.OpenAIMessagehas the same methods.
Changes
- None.
Fixed
- Accepts repeated argument names when constructing or copying
InvokeToolcalls, such as calls returned by the parser. 0.2.x raisedValueError. - Keeps assistant dictionaries with
content: []as empty assistant turns during conversion, instead of dropping them. - Rejects zero-width or zero-height image pointers during image-dictionary conversion instead of failing later during rendering.
- Encodes adjacent same-weight text together in Qwen and Nemotron supervised targets, so the tokens match what the model samples. This changes SFT tokens.
- Corrects whitespace, newlines, and tool-result order in Qwen, Nemotron, GLM, and DeepSeek-V4 prompts. This changes prompt tokens for some conversations.
- Smaller parsing fixes for GLM, Nemotron, DeepSeek-V4, GPT-OSS, and Kimi: unfinished tool calls, string arguments, message authors, and adjacent assistant turns.
Deprecations
- The
from_oss_*andto_oss_*methods ofOpenAIMessageandMessageListare deprecated and emitDeprecationWarning. Use the*_openai_chat_*methods, ortinker_cookbook.third_party.tml_renderers_compatfor cookbook-format messages. No removal version or date is announced.
Breaking changes
- The TMLv0, Qwen3, Qwen3.5, Qwen3.8, Nemotron 3, DeepSeek-R1, and DeepSeek-V3.1 parsers now raise when a completion stops inside a message, instead of returning only the completed messages. The error is a
ValueError(v0.ParseErrorfor TMLv0). CatchValueErrorand readerror.completed_messagesto recover the completed messages. DeepSeek-V3, V4, and V4.1 errors now carrycompleted_messagestoo. This applies to bothparse_tokens()andparse(). Glm53andGlm53Flashnow preserve historical reasoning by default (clear_thinking=False), changing prompts and supervised examples. Passclear_thinking=True, including to.high()or.low(), to retain the previous behavior consistently in sampling and training.- The
from_oss_dict()andfrom_oss_messages()readers now reject a top-levelreasoning_contentinstead of dropping it. Read OpenAI Chat dicts with thefrom_openai_chat_dictorfrom_openai_chat_dictshelpers.
Dependencies
- None.
v0.2.1
New
- None.
Changes
renderers.GptOss()now defaults toreasoning_effort="medium"instead of"low". Passreasoning_effort="low"to retain the previous prompt setting.
Fixed
- Allows renderers and parsers to be used from a Python thread other than the one that created them, without raising
PanicException. - Prevents a deadlock when multiple threads construct their first tokenizer concurrently.
- When a reply is cut off after one or more finished messages,
parse_tokens()andparse()return the finished messages instead of raising. This applies to TMLv0, Qwen3, Qwen3.5, Qwen3.8, Nemotron 3, DeepSeek-R1, and DeepSeek-V3.1 in thinking mode. A reply cut off in its first message still raises. - Places system text at a fixed position in Qwen and Nemotron prompts that declare tools, whatever the message order: before the tool declarations for Qwen3 and Nemotron 3, and after them for Qwen3.5 and Qwen3.8, with a blank line before it. This changes prompt tokens, for example for a Qwen3.5 system message given before the tool declaration.
- Uses the correct special-token IDs in Qwen3.5 and Nemotron tool-declaration examples. User-provided text and schema strings remain literal text.
- TMLv0: Parses an empty message as
Text("")and keeps every value of a repeated tool-call argument, instead of raisingv0.ParseError.
Deprecations
- None.
Breaking changes
- TMLv0: Writes the tool name in the header of each structured tool-call message, for example
<|message_model|>get_weather<|content_invoke_tool_json|>. This restores the 0.1.0 tokens for tool calls converted from OpenAI-style messages, and adds the name for tool calls without an author name. A tool call whoseauthor.namediffers from the tool name now raisesValueError; unsetauthor.nameor set it to the tool name.
Dependencies
- None.
v0.2.0
New
- Introducing support for other model families in
tml-renderers: Qwen3, Qwen3.5, Qwen3.8, DeepSeek-V3, DeepSeek-R1, DeepSeek-V3.1, DeepSeek-V4, DeepSeek-V4.1, Kimi K2, Kimi K2.5, GLM-5.2, GLM-5.3, GLM-5.3-Flash, GPT-OSS, and Nemotron 3. - Set
chat.ImagePointer.override_widthandoverride_heightto request a rendering resolution different from the stored image dimensions. Rendered image spans carry the resolvedvirtual_widthandvirtual_height. - Normalize native or OpenAI-style message sequences with
chat.MessageList.from_messages(). The helper also accepts an existingMessageList. - Pass a tool failure as a content part such as
{"type": "tool_error", "text": "command failed"}in OpenAI-style messages. It converts tochat.ToolError, and TMLv0 renders it as a tool error. - Pickle renderers, for example to send them to worker processes. This includes
v0.Renderer. - Use
renderer.tokenizerto get a renderer's tokenizer, and type code that accepts any renderer withtml_renderers.Renderer.
Changes
- TMLv0: Parsed tool calls now carry a
tool_call_idnumbered in call order, for examplefunctions.read:0. 0.1.0 returnedNone.
Fixed
- TMLv0: Rejects TML image pointers with non-positive dimensions instead of silently rendering an image with zero tokens.
- Preserves WAV audio through OSS message round trips.
- TMLv0: Rejects sampled tool calls with an unknown field or an empty tool name with
v0.ParseError. 0.1.0 dropped the field, for example"trace"in{"name": "read", "args": {}, "trace": "abc"}, and accepted the empty name.
Deprecations
tokenizers.o200k_base_chat()is deprecated; usetokenizers.O200kBaseChatTokenizer(). The old factory remains available and emitsDeprecationWarning. No removal version or date is announced.tml_renderers.tinker.TokenSpanWrapperandRawTokenSpanremain as deprecated compatibility names. Annotate rendered spans withchat.TokenSpanand access the contained value through.span. No removal version or date is announced.
Breaking changes
- The old incremental parser methods
parse_token(),parse_updates(),flush_updates(),flush(),reset(), andis_at_message_boundary()are removed. Accumulate a completion and pass it toparse_tokens()orparse(); each call handles a complete parsing attempt. parse_errors.UnterminatedMessageErroris replaced byUnterminatedStructureErrorandUnterminatedContentError. Update imports and checks ofParseError.kindto distinguish incomplete structure from incomplete content.- TMLv0:
parse_tokens()andparse()now raisev0.ParseErrorwhen a completion stops inside a message, even when earlier messages completed. 0.1.0 returned only the completed messages, or[]. A completion with no message, such as a lone end-of-sampling token, also raises (EmptyResponseError). Catchv0.ParseErrorwhen a completion can reach a token limit. chat.InvokeToolraisesValueErrorfor an empty tool name, a repeated argument name, or rawtextcombined with a structured call, on construction and oncopy(). 0.1.0 accepted these. Remove repeated arguments, and usechat.InvokeTool("raw text")for a raw-text call.
Dependencies
- Adds support for Python
3.10.
v0.1.0
New
- Introducing
tml-renderers, including the TMLv0 renderer for use with Thinking Machines’ Inkling model.
Changes
- None.
Fixed
- None.
Deprecations
- None.
Breaking changes
- None.
Dependencies
- Requires Python
>=3.11. - PyTorch
>=2.10. Install it separately; the wheel does not install it.