| | |
| | | for name, param in model.named_parameters(): |
| | | param.requires_grad = False |
| | | model.eval() |
| | | self.llm = model |
| | | llm_dim = model.get_input_embeddings().weight.shape[-1] |
| | | self.llm_dtype = llm_conf.get("llm_dtype", "fp32") |
| | | self.llm = model.to(dtype_map[self.llm_dtype]) |
| | | llm_dim = model.get_input_embeddings().weight.shape[-1] |
| | | |
| | | # adaptor |
| | | adaptor_class = tables.adaptor_classes.get(audio_adaptor) |
| | |
| | | |
| | | batch_size, frames, _ = speech.shape |
| | | |
| | | # audio encoder |
| | | encoder_out, encoder_out_lens = self.audio_encoder(speech.permute(0, 2, 1), speech_lengths) |
| | | with torch.cuda.amp.autocast(enabled=False): |
| | | # audio encoder |
| | | encoder_out, encoder_out_lens = self.audio_encoder( |
| | | speech.permute(0, 2, 1), speech_lengths |
| | | ) |
| | | |
| | | # audio_adaptor |
| | | encoder_out, encoder_out_lens = self.audio_adaptor(encoder_out, encoder_out_lens) |
| | | # audio_adaptor |
| | | encoder_out, encoder_out_lens = self.audio_adaptor(encoder_out, encoder_out_lens) |
| | | |
| | | input_ids[input_ids < 0] = 0 |
| | | inputs_embeds = self.llm.model.get_input_embeddings()(input_ids) |
| | |
| | | labels_ids[labels_ids == -1] = -100 |
| | | attention_mask[attention_mask < 0] = 0 |
| | | model_outputs = self.llm( |
| | | inputs_embeds=inputs_embeds, attention_mask=attention_mask, labels=labels_ids |
| | | inputs_embeds=inputs_embeds.to(dtype_map[self.llm_dtype]), |
| | | attention_mask=attention_mask, |
| | | labels=labels_ids, |
| | | ) |
| | | loss = model_outputs.loss |
| | | |