diff --git a/finetuning/sft_12hz.py b/finetuning/sft_12hz.py index cb0bd18..c21445a 100644 --- a/finetuning/sft_12hz.py +++ b/finetuning/sft_12hz.py @@ -93,15 +93,16 @@ def train(): input_embeddings = input_text_embedding + input_codec_embedding outputs = model.talker( - inputs_embeds=input_embeddings[:, :-1, :], - attention_mask=attention_mask[:, :-1], - labels=codec_0_labels[:, 1:], + inputs_embeds=input_embeddings, + attention_mask=attention_mask, + labels=codec_0_labels, output_hidden_states=True ) hidden_states = outputs.hidden_states[0][-1] - talker_hidden_states = hidden_states[codec_mask[:, 1:]] - talker_codec_ids = codec_ids[codec_mask] + target_codec_mask = codec_mask[:, 1:] + talker_hidden_states = hidden_states[:, :-1][target_codec_mask] + talker_codec_ids = codec_ids[:, 1:][target_codec_mask] sub_talker_logits, sub_talker_loss = model.talker.forward_sub_talker_finetune(talker_codec_ids, talker_hidden_states) diff --git a/qwen_tts/core/models/modeling_qwen3_tts.py b/qwen_tts/core/models/modeling_qwen3_tts.py index 8c86fb0..5fabb00 100644 --- a/qwen_tts/core/models/modeling_qwen3_tts.py +++ b/qwen_tts/core/models/modeling_qwen3_tts.py @@ -1321,7 +1321,11 @@ class Qwen3TTSTalkerCodePredictorModelForConditionalGeneration(Qwen3TTSPreTraine loss = None if labels is not None: - loss = self.loss_function(logits=logits, labels=labels, vocab_size=self.config.vocab_size, **kwargs) + loss = torch.nn.functional.cross_entropy( + logits.reshape(-1, self.config.vocab_size), + labels.reshape(-1), + ignore_index=-100, + ) return Qwen3TTSTalkerCodePredictorOutputWithPast( loss=loss,