You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: dolci_tool_use transform for Dolci-Instruct-SFT tool rows - #64
This PR introduces transforms required to adapt the tool call rows from the Dolci-Instruct dataset. Without it, the tool call rows are rendered incorrectly.
This PR adds a dolci_tool_use transform to preserve Dolci-Instruct-SFT tool data in the standard SFT pipeline, addressing the Qwen3 rendering loss described in #63.
Changes:
Converts Dolci tool definitions, calls, and environment responses into standard tool fields.
Preserves tool_calls through the SFT dataset schema.
Adds parsing, rejection, and Qwen3 rendering tests.
File
Description
tests/test_transforms.py
Tests Dolci conversion and tool-data preservation through rendering.
Prevent keyword-rename collisions and preserve original names
src/post_training/data/transforms.py:701
A valid argument named _kw_from is not rewritten by _rename_keyword_args, but these lines still rename it to from. A call containing both from="EUR" and _kw_from="USD" also collapses the two arguments into one, silently losing a value. Use a collision-free rename mapping and restore only argument names that were actually rewritten.
Reject non-finite values during JSON round-trip validation
src/post_training/data/transforms.py:703
The round-trip check still accepts infinity: wx.get(value=1e309) produces {"value": Infinity}, and Python's permissive json.loads returns the same infinite float. Qwen3 inserts this string verbatim, so the training target contains an invalid JSON tool call. Set allow_nan=False so non-finite values follow the existing rejection path.
This strips _kw_ from legitimate parameter names, not just names introduced by _rename_keyword_args. For example, wx.get(_kw_from="EUR") is accepted but becomes arguments {"from": "EUR"}, changing the tool invocation and potentially colliding with a separate from parameter. Track which argument names were actually rewritten, using collision-free temporary names, and restore only those.
Reject non-finite values during round-trip validation
src/post_training/data/transforms.py:763
The round-trip check accepts infinity: wx.get(q=1e309) serializes to {"q": Infinity}, which Python's JSON decoder reads back as the same float. Qwen3 inserts this string verbatim, so the row trains an invalid JSON tool call instead of being rejected. Set allow_nan=False so non-finite values follow the existing ValueError rejection path.
Preserve valid tool names during carriage-return repair
src/post_training/data/transforms.py:786
A bare carriage-return separator is treated as a lost initial r: wx.get(q='a')\rwx.get(q='b') becomes calls to wx.get and rwx.get. This silently changes the tool invocation and retains the unknown name. Consult the declared tool names before inserting a letter, preserving names that are already valid.
Restrict newline repair to separators outside strings
src/post_training/data/transforms.py:811
When a block contains both a literal \n separator and a string argument containing )\n, the original block fails tokenization and this global substitution rewrites both occurrences. For example, the raw block wx.get(q="a)\nb")\nwx.get(q="b") gains a real newline inside the quoted argument, so the entire otherwise-convertible row is dropped. Restrict this repair to separators outside string literals, including when the original block does not tokenize successfully.
Refactor condition to improve readability and maintainability.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces transforms required to adapt the tool call rows from the Dolci-Instruct dataset. Without it, the tool call rows are rendered incorrectly.
Fixes #63
Type of change
Validation
New tests are written and a small run (~20 steps) was tried on LUMI.