Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
9603ef89
Unverified
Commit
9603ef89
authored
Jun 01, 2023
by
Sanchit Gandhi
Committed by
GitHub
Jun 01, 2023
Browse files
[Flax Whisper] Update decode docstring (#23908)
parent
fabe17a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
src/transformers/models/whisper/modeling_flax_whisper.py
src/transformers/models/whisper/modeling_flax_whisper.py
+4
-3
No files found.
src/transformers/models/whisper/modeling_flax_whisper.py
View file @
9603ef89
...
...
@@ -1017,16 +1017,17 @@ class FlaxWhisperPreTrainedModel(FlaxPreTrainedModel):
```python
>>> from transformers import WhisperProcessor, FlaxWhisperForConditionalGeneration
>>> from datasets import load_dataset
>>> import jax.numpy as jnp
>>> processor = WhisperProcessor.from_pretrained("openai/whisper-tiny.en")
>>> model = FlaxWhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en", from_pt=True)
>>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
>>> inputs = processor(ds[0]["audio"]["array"], return_tensors="np")
>>> input_features = inputs.input_features
>>> input
_feature
s = processor(ds[0]["audio"]["array"], return_tensors="np")
.input_features
>>> encoder_outputs = model.encode(input_features=input_features)
>>> decoder_start_token_id = model.config.decoder_start_token_id
>>> decoder_input_ids = jnp.ones((input
s.input_id
s.shape[0], 1), dtype="i4") * decoder_start_token_id
>>> decoder_input_ids = jnp.ones((input
_feature
s.shape[0], 1), dtype="i4") * decoder_start_token_id
>>> outputs = model.decode(decoder_input_ids, encoder_outputs)
>>> last_decoder_hidden_states = outputs.last_hidden_state
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment