🐛 fix: fix reward model train seq_cls #3921
Merged
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.
PR type
PR information
修复了使用奖励模型(reward model)作为基础模型进行多分类训练时的问题。当 reward model 用于序列分类(seq_cls)任务且 num_labels > 1 时,由于模型结构差异可能导致尺寸不匹配的问题。此修复通过自动设置
ignore_mismatched_sizes=True
来解决这个问题。主要改动:
get_model_tokenizer_from_local
函数中,当检测到是 reward model 且用于多分类任务(num_labels > 1)时,自动设置ignore_mismatched_sizes=True
(重新添加 分类头)Experiment results
不需要实验结果,这是一个功能性修复,确保了在以下场景可以正常工作: