Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion swift/llm/template/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,8 @@ def _swift_encode(self, inputs: StdTemplateInputs):
if template_meta.auto_add_bos and sep_token:
res_context_list.append(sep_token)
res_context_types.append(ContextType.SUFFIX)
res_context_list, loss_scale_list = self.loss_scale(res_context_list, res_context_types, inputs.messages)
res_context_list, loss_scale_list = self.loss_scale(res_context_list, res_context_types, inputs.messages,
**inputs.extra_kwargs)
Comment on lines +1149 to +1150
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

感谢您的贡献!您在 _swift_encode 中正确地将 inputs.extra_kwargs 传递给了 self.loss_scale

但是,LossScale.__call__ 方法 (位于 swift/plugin/loss_scale/loss_scale.py) 似乎没有将这些额外的关键字参数 (**kwargs) 传递给 get_loss_scale 方法。

为了让您的修改完全生效,LossScale.__call__ 中的 get_loss_scale 调用点也需要更新。

目前的实现:

# swift/plugin/loss_scale/loss_scale.py:73
new_context, loss_scale = self.get_loss_scale(context, context_type, is_last_round, query=query)

建议修改为:

# swift/plugin/loss_scale/loss_scale.py:73
new_context, loss_scale = self.get_loss_scale(context, context_type, is_last_round, query=query, **kwargs)

这样才能确保 extra_kwargs 能够被各个 LossScale 子类中的 get_loss_scale 方法接收和使用。请您检查并补充这一修改。

if self.is_training:
answer_len = len(extra_context_list) + bool(response is not None)
else:
Expand Down
Loading