Multilingual models converted to TFLite doesn't work #778
-
Hello everyone! I'm here asking for some guidance. I'm trying to convert the models to TFLite to be used on mobile. *.en based models work, but not the multilingual ones.
Testing the model on python with TFLite (using interpreter) gives me a bad translation (gibberbish). Testing it on android with TFLite it dies with:
It looks like the model conversion is not correct with multilingual models. Any hint/tip what i'm doing wrong? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 13 comments 26 replies
-
@shadowofsoul Could you please change the line in the above notebook that reads 'max_new_tokens=223, #change as needed' to 'max_new_tokens=447, #change as needed'? |
Beta Was this translation helpful? Give feedback.
-
@dkakaie Could you provide a notebook that demonstrates how to generate the encoder.onnx and decoder.onnx files and perform inference with them? |
Beta Was this translation helpful? Give feedback.
-
@nyadla-sys Any updates? Is the notebook running correctly? |
Beta Was this translation helpful? Give feedback.
-
@dkakaie i managed to generate encoder and decoder tflite models and just pending to complete the decoder post processing to generate tokens with text If you could help in post-processing that's appreciated. |
Beta Was this translation helpful? Give feedback.
-
@nyadla-sys @shadowofsoul here it is: device = 'cuda' if torch.cuda.is_available() else 'cpu'
torch.onnx.export(model.decoder,
(torch.tensor([[50258, 50259, 50359, 50363]]).to(device), #sample input ids
torch.randn(1, 1500, 384).to(device)), #encoder outputs
"./decoder.onnx", #final onnx model name
opset_version=10, #opset 13 fails for me with unsupported squeeze sth
input_names=['tokens', 'hidden_states'], # the model's input names,
output_names=['output'], #self-set output node name
dynamic_axes={'tokens': {1: 'toks'}, # variable length axes, inputs ids, tokens are index=1 and we want that dimension
'output': {1: 'toks'}}) #variable output axes |
Beta Was this translation helpful? Give feedback.
-
with the below code i am able to give dynamic input to tflite model interpreter = tf.lite.Interpreter(model_path=tflite_model_path) decoder_input_ids = torch.tensor([50258, 50259, 50359, 50363]) input_tensor_1 = interpreter.get_input_details()[0]['index'] input_tensor_2 = interpreter.get_input_details()[1]['index'] output_tensor = interpreter.get_output_details()[0]['index'] interpreter.invoke() output_data = interpreter.get_tensor(output_tensor) cleaned = np.argmax(output_data, axis=-1) |
Beta Was this translation helpful? Give feedback.
-
@dkakaie I managed to run decoder tflite model |
Beta Was this translation helpful? Give feedback.
-
this will open up multilingual support for whisper tflite models |
Beta Was this translation helpful? Give feedback.
-
@dkakaie Can you assist me in running inference on the below Whisper ONNX model from HuggingFace? This will help me understand the input and output processing for creating a full int8 model. !python -m transformers.onnx --model=openai/whisper-tiny.en onnx/ |
Beta Was this translation helpful? Give feedback.
-
Hi, I too also on the same page, I am looking for the word timestamp after converting the tflite model, Is there any possibility should we implement the word timestamp of tflite model? |
Beta Was this translation helpful? Give feedback.
-
Hi, NiranJan Yadla. Thanks for your reply.
Can please explain where or how I can get total language code list? Thanks.
…On Fri, Oct 27, 2023 at 10:57 PM Niranjan Yadla ***@***.***> wrote:
<|it|>": 50274,
—
Reply to this email directly, view it on GitHub
<#778 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZUX3PHQBDY6SN27TNQZDTDYBQGZTAVCNFSM6AAAAAATM3MIXKVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TIMBXGE3TA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks a lot
…On Sat, Oct 28, 2023 at 7:34 PM Davud Kakaie ***@***.***> wrote:
Here
<https://huggingface.co/openai/whisper-large-v2/blob/main/added_tokens.json>'s
the list
—
Reply to this email directly, view it on GitHub
<#778 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZUX3PB2PWOWLYYJWFLREPLYBUXZ7AVCNFSM6AAAAAATM3MIXKVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TIMJSGE3DS>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi researcher I'm very interested in multilingual model. I tried to test
whisper-tiny.tflite model, but it doesn't work. Do we have any method to
convert specified language to tflite model like english model? I've tried
decode & encode method, but speed is very slow.
I hope the answer for converting specified language to tflite model. For
example, Italian.
…On Sun, Oct 29, 2023 at 7:13 PM Li Ming ***@***.***> wrote:
Thanks a lot
On Sat, Oct 28, 2023 at 7:34 PM Davud Kakaie ***@***.***>
wrote:
> Here
> <https://huggingface.co/openai/whisper-large-v2/blob/main/added_tokens.json>'s
> the list
>
> —
> Reply to this email directly, view it on GitHub
> <#778 (reply in thread)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AZUX3PB2PWOWLYYJWFLREPLYBUXZ7AVCNFSM6AAAAAATM3MIXKVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TIMJSGE3DS>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
Beta Was this translation helpful? Give feedback.
@dkakaie I managed to run decoder tflite model
https://colab.research.google.com/github/usefulsensors/openai-whisper/blob/main/notebooks/whisper_encoder_decoder_tflite.ipynb