我可以在我的 python NLP 项目中使用 Facebook 翻译服务吗?
我希望您感觉良好且安全。
我正在攻读硕士学位的自然语言处理项目,我确实需要翻译 我的当地方言到 ENG,我注意到 Facebook 翻译机对我的当地方言翻译得很好。
所以我的问题是有什么方法可以在我的项目中使用 Facebook 翻译服务,比如是否有任何 api 或 python 模块使用它。
I hope you are feeling good and safe.
I'm working on Natural language processing project for my master degree, and I do need to translate
my local dialect to ENG, and I noticed that Facebook translate machine did very well with my local dialect.
So my question is there any way to use Facebook translate service in my project, like is there any api or python module that use it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的当地语言是什么?
Facebook有很多机器翻译模型,所以这取决于它必须有多好以及你有多少计算能力。我不确定他们是否提供最新的最先进的翻译工具,并在其产品中作为独立的翻译工具使用。
第一个选项:在本地运行完整模型
一种方法是在 Huggingface 上使用他们的模型之一(请参阅“生成”部分):
https://huggingface.co/docs/transformers/model_doc/m2m_100#训练和生成
他们的 torch.hub 模块中还有一些易于使用的预训练模型(但这可能不涵盖您的本地语言):
https://github.com/pytorch/fairseq/blob/ main/examples/translation/README.md
第二个选项:API
正如我所说,这取决于您需要什么质量,您可以尝试一些易于使用的(非 facebook)API 和看看这能让你走多远,因为这更容易,你可以在线使用它们:
例如 https://libretranslate.com/< /a>
或者查看 API 比较:https://rapidapi.com/collection/google-translate-api-alternatives
API 通常会限制每月/每天/分钟的最大字符数/单词数/请求数,因此您必须看看这是否足以满足您的情况以及质量是否可以接受。
第三种选择:使用 API 的 pip 包
例如查看: https://pypi.org/project/ deep-translator/
第四个选项:在本地运行翻译的 pip 包装器包
一个很棒的包,实际上拥有一些非常强大的 facebook MT 模型:https://pypi.org/project/EasyNMT/ (它也有强大的 m2m_100 模型)
更轻量级,但可能不那么强大:https://github.com/argosopentech/argos-translate
结论:
因为我假设您的本地语言不受该支持对于许多型号,我会首先尝试第四个选项(从最大的型号开始,如果不起作用,请尝试较小的型号)。
如果这不起作用,您可以尝试是否可以让 API 适合您的情况。
如果您拥有强大的计算能力并且想要更深入,您可以使用 Huggingface 或 fairseq 在本地运行完整的模型推理。
Which language is your local language?
Facebook has many machine translation models, so it depends on how good it has to be and how much computing power you have. I am not sure if they offer their latest state-of-the-art ones that they use in their products as an independent translation tool as well.
First Option: Run full models locally
One way would be using one of their models on huggingface (see the "Generation" part):
https://huggingface.co/docs/transformers/model_doc/m2m_100#training-and-generation
They also have some easy-to-use pretrained models in their torch.hub module (but that probably doesnt cover your local language):
https://github.com/pytorch/fairseq/blob/main/examples/translation/README.md
Second Option: APIs
As I said it depends on what quality you need, you could try out some easy-to-use (non-facebook) APIs and see how far that gets you, as this is much easier and you can use them online:
e.g. https://libretranslate.com/
Or check out this comparison of APIs: https://rapidapi.com/collection/google-translate-api-alternatives
APIs are usually limited to a maximum number of characters/words/requests per month/day/minute so you'll have to see if that is enough for your case and if the quality is acceptable.
Third Option: pip packages which use APIs
For example check out: https://pypi.org/project/deep-translator/
Fourth Option: pip wrapper packages which run translation locally
A great package which actually has some pretty strong facebook MT models is: https://pypi.org/project/EasyNMT/ (it also has their strong m2m_100 models)
More lightweight but probably not as strong: https://github.com/argosopentech/argos-translate
Conclusion:
Since I assume your local language is not supported by that many models I would first try the fourth option (start with biggest models and if it doesnt work try smaller ones).
If that doesnt work out you can try if you can get APIs work for your case.
If you have a lot of computing power and want to go a bit deeper you can run the full model inference locally using huggingface or fairseq.