Autoparser: add optional argument reshuffle capability#20171
Autoparser: add optional argument reshuffle capability#20171pwilkin merged 3 commits intoggml-org:masterfrom
Conversation
| all_indices[i] = i; | ||
| } | ||
| args_seq = args_seq + build_opt_choices(all_indices); | ||
| } else { |
There was a problem hiding this comment.
I'd rather just do this for any number of optional arguments. Presumably a model should know not to generate a duplicate argument, but we will accept it since the JSON parser doesn't care.
There was a problem hiding this comment.
You mean just ignore the shuffle and use the "else" branch as the universal solution?
I think the overhead for building the permutations for 4 options is really small (only 24 branches) and it does add a bit of reliability for what I feel is a large number of cases. Unless you think we should just keep it uniform with the JSON parser.
There was a problem hiding this comment.
Yes. I simply don't see the need for the added complexity of permutations. A repetition of choice is more than good enough, IMO.
There was a problem hiding this comment.
Maybe try it out and see if there are any problems?
This problem also exists for the JSON tool calling parsers that still enforce order because of json-schema-to-grammar. However, we can explode the arguments out like the XML parsers with a repetition that has a leading comma.
There was a problem hiding this comment.
Agreed, the permutations are likely completely unnecessary.
There was a problem hiding this comment.
Someone's gotta reel in your genius.
There was a problem hiding this comment.
You meant "chaos", right? ;)
|
Idk is it right place to report issue (latest unsloth qwen3.5 35b) Is it known issue? |
|
@MikeLP, seems like your client is using a |
|
@MikeLP You have to modify your template to treat developer role as system. It's a known problem with using OpenAI tools, sadly. |
Thanks for quick response. |
| #include "json-schema-to-grammar.h" | ||
| #include "nlohmann/json.hpp" | ||
|
|
||
| #include <functional> |
* Allow reshuffled arguments in tagged argument parser format tool calls. * Remove shuffle just keep the optional parsers in any order * Remove unnecessary import
* Allow reshuffled arguments in tagged argument parser format tool calls. * Remove shuffle just keep the optional parsers in any order * Remove unnecessary import

Requires #18675
Some of the models that use tagged parsers (i.e. those that use quasi-XML tags for the arguments and their values) prefer a certain argument order with certain common tools. However, currently the grammar enforces the order in which the arguments are declared. If the tool tries to fill one optional argument first, it will be unable due to the grammar constraint to fill the other argument.
This manifests most often in failed calls to
read_filetools which have an optionallimitandoffsetparameter.Fixes #20164