diff --git a/swift/llm/template/base.py b/swift/llm/template/base.py index e9224ee82..0b9091195 100644 --- a/swift/llm/template/base.py +++ b/swift/llm/template/base.py @@ -181,7 +181,8 @@ def _kto_encode(self, inputs: StdTemplateInputs) -> Dict[str, Any]: def _seq_cls_encode(self, inputs: StdTemplateInputs) -> Dict[str, Any]: encoded = self._encode(inputs) - encoded['labels'] = int(inputs.label) + if inputs.label is not None: + encoded['labels'] = int(inputs.label) return encoded def encode(self,