#10265·ms-swift

[错误] `--reward_funcs math` 发生崩溃: MathORM 仍然期望 InferRequest 对象,而 GRPO 奖励分发传递完成字符串

作者: Lesereingrape创建于 2026年9月29日更新于 2026年9月29日

import torch torch from swift.rl_core.data import GRPOSample from swift.rl_core.grpo_algorithm import compute_rewards_per_func from swift.rewards import orms orm = orms'math' samples = [GRPOSample(messages=[{'role': 'user', 'content': 'What is 1+2?'}], extra={'solution': '3'}), GRPOSample(messages=[{'role': 'user', 'content': 'What is 1+2?'}], extra={'solution': '4'})] print(compute_rewards_per_func(samples, [orm], [None], device=torch.device('cpu'))) Output on current main (dbc395ff): AttributeError: 'str' object has no attribute 'messages' # swift/rewards/orm.py:444 The failure mode depends on which ground-truth column the dataset carries. With the documented 'solution' column, the call fails before any parsing: TypeError: MathORM.call() missing 1 required positional argument: 'ground_truths' With a 'ground_truths' column added, the call reaches line 444 and raises the AttributeError above. toolbench, which does branch on the input shape, runs to completion in the same harness.

内容来源: modelscope/ms-swift