AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
[TOC] ## 翻译 我们使用 pipeline的 参数 `translation_xx_to_yy`使用英文转中文 ``` from transformers import pipeline, AutoModelWithLMHead, AutoTokenizer model = AutoModelWithLMHead.from_pretrained("Helsinki-NLP/opus-mt-en-zh") tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-en-zh") translation = pipeline("translation_en_to_zh", model=model, tokenizer=tokenizer) text = "The Home of Machine Learning" translated_text = translation(text, max_length=40)[0]['translation_text'] print(translated_text) // 机器学习之家 ```