Add M2M100 & NLLB model - #392
Conversation
|
I also saw these warnings that I do not understand: |
|
@aymanosman thanks for the PR, looks clean, and great job adding the tests :) |
jonatanklosko
left a comment
There was a problem hiding this comment.
@aymanosman thanks! I will have a look at improving the language configuration soon :)
|
@aymanosman here's how you can specify the source and target language as expected by the model: source_lang = "eng_Latn"
target_lang = "fra_Latn"
target_token = Bumblebee.Tokenizer.token_to_id(tokenizer, target_lang)
generation_config = Bumblebee.configure(generation_config, forced_bos_token_id: target_token)
serving = Bumblebee.Text.generation(model_info, tokenizer, generation_config)
text = "The bank of the river is beautiful in spring"
Nx.Serving.run(serving, "#{source_lang} #{text}")(From brief testing it seems that specifying the source language improves the translation quality) I am still considering how to best fit this into Bumblebee APIs, but this should unblock your testing :) |
|
@jonatanklosko Thanks. Looking forward to the improved API. I was thinking of modifying the generation serving to take structured input that contained more than just the input text but also the source and target languages. So something like this would be possible: Nx.Serving.run(serving, {"eng_Latn", "fra_Latn", "The bank of the river is beautiful in spring"})But I'll wait for you to come up with a better idea :). |
|
Yeah, we already accept map inputs in this and other servings. In this case we need a separate translation serving, because languages require special handling. The tricky part is to allow languages to be dynamic (part of serving input, rather than known at model compilation time), but I have an idea how we can do that reasonably. |
|
@aymanosman implemented in #395 :) |
The values used in the tests were obtained by running this python script:
Here is a notebook demonstrating that it works, but there are issues regarding adding the language codes.