fix: Train on the last turn only
truncate bug
#5115
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.
What does this PR do?
#4878 提出的 ”仅最后一轮参与训练“ 可以满足 Distillation、Reflective Chain 等场景的需求,但其实现方法存在一个小问题:
当对话总长度超过
cutoff_len
,会退出遍历encoded_pairs
的循环(截断),则最重要的最后一段对话无法加入训练数据中,且label
全为IGNORE_INDEX
,该条数据无意义。针对截断问题,即在保留最后一段对话的前提下,可行的解决方案有:
encoded_pairs
,新增元素从头部插入input_ids
和labels
,其余逻辑不变;PR 了采取第一种方法,以最小化改动对原代码的侵入性。
Fixes #4684
Before submitting