How to get embeddings using hubert model

#2
by pulkitmehtawork - opened

Example code:
import torch from transformers
import Wav2Vec2Processor, HubertForCTC
from datasets import load_dataset

processor = Wav2Vec2Processor.from_pretrained("facebook/hubert-large-ls960-ft")
model = HubertForCTC.from_pretrained("facebook/hubert-large-ls960-ft")
input_values = processor('array from audio file., return_tensors="pt").input_values

How to get embeddings after this ? There is no last hidden state in the model .

Hi, the above code snippet only passes the raw inputs to the processor (processor) to get the model input input_values .

You will have to load the model, and pass the inputs input_values (along others maybe) to the loaded model.

yes , i mean after that , we can only get logits as that is the only key but how to get embeddings .

Hi @pulkitmehtawork Could you try adding output_hidden_states=True either in the loaded model config , or during the call to the model?

Let me know if you need more info about how to do this.

Sign up or log in to comment