Repository navigation
Studio: keep tool-call arguments when training on tool-calling datasets - #12487
Conversation
… row is dropped When every render attempt failed, the error came from the row as loaded, so the dropped-row warning named a None key filled by the loader (e.g. "object of type 'NoneType' has no len()" for Llama parallel tool calls) instead of the template's real error. Raise the first attempt's error, document why the as-loaded fallback exists and that dict-typed arguments lose explicit nulls, and tighten the tests: the Qwen3.5 stand-in rejects string arguments like the real template, only None is dropped, and the template probe counts cleaned rows.
|
Pushed 8224cb5 on top.
Checked by rendering a JSONL fixture through |
|
Codex review on CI on the same head: upstream checks passed (44 passed, 3 skipped). The staging run had 3 failing jobs, all from the older merge base it was based on, not from this change: |
Lyxot
left a comment
There was a problem hiding this comment.
LGTM. Checked by rendering tool-calling rows through Studio's real dataset path with 26 chat templates, on this head merged with current main: tool-call arguments now render in each template's own format inside the trained span, and rows without tool calls are unchanged.
Resolve the conflict in chat_templates.py with unslothai#12487: rows now render through _render_conversation (tool-call cleanup) for both the system-column attempt and the fallback without it.
Fine-tuning on a chat dataset in the usual OpenAI tool-calling format, where each tool call's arguments are a JSON string, trained the wrong thing. Qwen3.5 learned tool calls with every argument missing (
<function=get_weather>and nothing inside), and Gemma 4 learned the raw JSON instead of its own call format. On Llama 3.1, 3.2 and 3.3 training would not start at all ("Chat template failed on all N rows: object of type 'NoneType' has no len()"), because loading the file fills every message with emptytool_callsand similar keys that the template trips over. Nothing warned about the first two.Each conversation is now cleaned up before the chat template renders it: empty keys added by the loader are dropped, and arguments stored as a JSON string are read as an object, as chat already does. Qwen3.5 and Gemma 4 now train on their real call format with the arguments in place, and Llama 3.x trains normally.
Datasets without tool calls render exactly as before, and arguments that are not valid JSON are left as they are.