{"record":{"id":"04ad8b669a8ba822","repo":"microsoft/VibeVoice","slug":"loss-computation-is-not-implemented-in-this-versio","errorCode":null,"errorMessage":"Loss computation is not implemented in this version.","messagePattern":"Loss computation is not implemented in this version\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"vibevoice/modular/modeling_vibevoice_streaming_inference.py","lineNumber":392,"sourceCode":"            inputs_embeds = self.model.get_input_embeddings()(input_ids)\n\n        outputs = self.model.language_model(\n            inputs_embeds=inputs_embeds,\n            attention_mask=attention_mask,\n            position_ids=position_ids,\n            past_key_values=past_key_values,\n            use_cache=use_cache,\n            output_attentions=output_attentions,\n            output_hidden_states=output_hidden_states,\n            return_dict=return_dict,\n            cache_position=cache_position,\n            **kwargs,\n        )\n\n        hidden_states = outputs[0] if not return_dict else outputs.last_hidden_state\n                \n        if labels is not None:\n            raise NotImplementedError(\"Loss computation is not implemented in this version.\")\n\n        return BaseModelOutputWithPast(\n            past_key_values=outputs.past_key_values,\n            last_hidden_state=hidden_states,\n            attentions=outputs.attentions,\n        )\n\n    # @can_return_tuple\n    def forward_tts_lm(\n        self,\n        input_ids: torch.LongTensor = None,\n        attention_mask: Optional[torch.Tensor] = None,\n        position_ids: Optional[torch.LongTensor] = None,\n        past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,\n        inputs_embeds: Optional[torch.FloatTensor] = None,\n        labels: Optional[torch.LongTensor] = None,\n        use_cache: Optional[bool] = None,\n        output_attentions: Optional[bool] = None,","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/microsoft/VibeVoice/blob/94da20d98b2fa7688e9cbfaf7692ddb4954f7600/vibevoice/modular/modeling_vibevoice_streaming_inference.py#L374-L410","documentation":"forward_lm in the streaming inference wrapper is inference-only: it runs the base text LM and returns BaseModelOutputWithPast; if labels is not None it raises NotImplementedError. The wrapper ships without training loss computation for the text stage.","triggerScenarios":"Calling model.forward_lm(input_ids=..., labels=labels) — any non-None labels value triggers the raise immediately after the submodule call.","commonSituations":"Adapting a training script from the non-streaming model that passes labels; HF Trainer-style pipelines that always forward labels; SFT code reused against the streaming checkpoint.","solutions":["Call forward_lm without labels and compute your own loss from last_hidden_state if fine-tuning.","Use the non-streaming VibeVoiceModel classes (modeling_vibevoice.py) for training, which implement loss paths.","If Trainer passes labels automatically, subclass/override compute_loss to drop them.","Do not rely on .loss in the returned BaseModelOutputWithPast — it is never set here."],"exampleFix":"# before\nout = model.forward_lm(input_ids=ids, labels=labels)  # NotImplementedError\n\n# after\nout = model.forward_lm(input_ids=ids)  # inference only\nloss = my_own_loss(out.last_hidden_state, targets)  # if training","handlingStrategy":"validation","validationCode":"kwargs.pop(\"labels\", None)  # inference wrapper has no loss path\nout = model.forward_lm(**kwargs)","typeGuard":"def is_inference_only_forward(fn) -> bool:\n    return getattr(fn, \"__name__\", \"\") == \"forward_lm\"","tryCatchPattern":"try:\n    out = model.forward_lm(input_ids=ids, labels=labels)\nexcept NotImplementedError:\n    out = model.forward_lm(input_ids=ids)","preventionTips":["Never pass labels to the streaming inference wrapper","Compute custom losses from last_hidden_state if fine-tuning","Use the training model classes for loss-based training"],"tags":["streaming","inference","labels","notimplementederror","training-unsupported"],"backgroundTag":null,"analyzedSha":"94da20d98b2fa7688e9cbfaf7692ddb4954f7600","analyzedAt":"2026-08-15T04:12:07.418Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}