-
Notifications
You must be signed in to change notification settings - Fork 571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support src_lang
/tgt_lang
in InferenceClient.translation()
#1763
Comments
@Wauplin I'd like to work on this. Could you tell me how I can find all the models which support these params? |
Hi @AkshathRaghav, thanks for proposing your help on this one! 🙏 Unfortunately, there is no easy way to list models supporting these parameters. This is why it should be made clear in the docstring that it is at the user discretion to select a model that handles them. In general, the information will be found in the Model Card of the model on the Hub (along with the list of support language codes). Therefore as a first step, I would simply implement the feature in |
@AkshathRaghav are you still working on this? I have implemented this in my fork. I can open a PR. |
@ceferisbarov HI, I haven't gotten a chance to work on it. Please go ahead! |
Closing this issue thanks to #1869 by @ceferisbarov ! 🚀 >>> from huggingface_hub import InferenceClient
>>> client = InferenceClient()
>>> client.translation("My name is Sarah Jessica Parker but you can call me Jessica", model="facebook/mbart-large-50-many-to-many-mmt", src_lang="en_XX", tgt_lang="fr_XX")
"Mon nom est Sarah Jessica Parker mais vous pouvez m'appeler Jessica"
>>> client.translation("My name is Sarah Jessica Parker but you can call me Jessica", model="facebook/mbart-large-50-many-to-many-mmt", src_lang="en_XX", tgt_lang="es_XX")
'Mi nombre es Sarah Jessica Parker pero puedes llamarme Jessica' |
…uggingface#1869) * add language support to translation client, solves huggingface#1763 * Update tests/test_inference_client.py Co-authored-by: Lucain <lucainp@gmail.com> * Update tests/test_inference_client.py Co-authored-by: Lucain <lucainp@gmail.com> * Update src/huggingface_hub/inference/_client.py Co-authored-by: Lucain <lucainp@gmail.com> * update the async client to match * add cassette for translation tests * Update src/huggingface_hub/inference/_client.py * Apply suggestions from code review * Update src/huggingface_hub/inference/_generated/_async_client.py --------- Co-authored-by: Lucain <lucainp@gmail.com>
Originally from @LysandreJik :
For some models (and some models only), it is possible to specify a source and target language in
transformers
and InferenceAPI. It would be nice to support it inInferenceClient
as well. Example: facebook/mbart-large-50-many-to-many-mmtTODO:
src_lang: Optional[str] = None
andtgt_lang: Optional[str] = None
toInferenceClient.translation
facebook/mbart-large-50-many-to-many-mmt
The text was updated successfully, but these errors were encountered: