# Decode whisper logits to transcript using forward instead of generate method

**URL:** <https://discuss.huggingface.co/t/decode-whisper-logits-to-transcript-using-forward-instead-of-generate-method/27521>\
**Category:** 🤗Transformers\
**Created:** [December 9, 2022, 5:27am UTC](https://discuss.huggingface.co/t/decode-whisper-logits-to-transcript-using-forward-instead-of-generate-method/27521 "2022-12-09T05:27:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sankeerth](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sankeerth](https://discuss.huggingface.co/u/Sankeerth)\
**Post date:** [December 9, 2022, 5:27am UTC](https://discuss.huggingface.co/t/decode-whisper-logits-to-transcript-using-forward-instead-of-generate-method/27521/1 "2022-12-09T05:27:56Z")

</div>

I’m trying to use whisper to generate transcription. I can get results when using `model.generate()` . But when I try to use

```auto
    out = model(inputs, decoder_input_ids = torch.tensor([[50258]]).to('cuda'))
    predicted_ids = torch.argmax(out.logits, dim=-1)
    transcription = processor.batch_decode(predicted_ids)
    transcription
    ['<|startoftranscript|>']

```

I’m only getting one token output. Is the issue with `decoder_input_ids`? I want to use foward because I want use `encoder` and `decoder` embeddings for other tasks. Is there any workaround here?

---

<div class="post-metadata">

**Author:** ![Sankeerth](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sankeerth](https://discuss.huggingface.co/u/Sankeerth)\
**Post date:** [December 9, 2022, 6:55am UTC](https://discuss.huggingface.co/t/decode-whisper-logits-to-transcript-using-forward-instead-of-generate-method/27521/2 "2022-12-09T06:55:47Z")

</div>

We can get `hidden_states_embeddings` from `model.generate` by enabling the two flags `, output_hidden_states=True, return_dict_in_generate=True`.

---

<div class="post-metadata">

**Author:** ![Hannan](https://avatars.discourse-cdn.com/v4/letter/h/b4bc9f/32.png) [@Hannan](https://discuss.huggingface.co/u/Hannan)\
**Post date:** [December 16, 2022, 9:12am UTC](https://discuss.huggingface.co/t/decode-whisper-logits-to-transcript-using-forward-instead-of-generate-method/27521/3 "2022-12-16T09:12:58Z")

</div>

Is it possible to access logits by using model.generate?  
However it is possible to get logits from model but as you mentioned, I couldn’t get more than one token.

---

<div class="post-metadata">

**Author:** ![Sankeerth](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sankeerth](https://discuss.huggingface.co/u/Sankeerth)\
**Post date:** [December 20, 2022, 9:30am UTC](https://discuss.huggingface.co/t/decode-whisper-logits-to-transcript-using-forward-instead-of-generate-method/27521/4 "2022-12-20T09:30:38Z")

</div>

You can get scores in the `model.generate` function using `output_scores=True` and then apply `softmax` to get individual tokens logits.
