modelscope / modelscope/ms-swift

ToolCallScheduler response_token_ids问题

Open
#8,471 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
15.7k
Forks
1.7k
Avg merge
1d 16h
Merged PRs (30d)
136

Description

https://github.com/modelscope/ms-swift/blob/24cf166175fa4acfda1b47b58721d82209f4b373/examples/train/grpo/plugin/plugin.py#L1203

# append tool result to the completion
infer_request.messages[-1]['content'] += (tool_results[0])

tokenizer = self.tokenizer
result_tokens = tokenizer.encode(tool_results[0], add_special_tokens=False)
token_ids.extend(result_tokens)
loss_mask.extend([0] * len(result_tokens))

这里不见得能对得上吧?比如str_a的编码ids为str_a_idsstr_b的编码ids为str_b_idsstr_c=str_a+str_b,但是str_c_ids不见得等于str_a_ids+str_b_ids把?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at examples/train/grpo/plugin/plugin.py around line 1203 and inspect how ToolCallScheduler builds token_ids after appending the tool result. Compare tokenizer.encode(tool_results[0], add_special_tokens=False) with encoding the complete concatenated content, then identify the expected token and loss-mask behavior and validate it with the relevant GRPO tool-call tests, if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.