首页 > 解决方案 > 在 Google AutoML 翻译中使用带有自定义模型的词汇表

问题描述

我在 Google AutoML 语言翻译中构建了一个自定义模型和一个词汇表。有没有办法同时使用自定义模型和词汇表?如果是这样,request.json 应该是什么样的?

标签: modelrequestmachine-translationgoogle-cloud-automlglossary

解决方案


您完全可以同时使用词汇表和 AutoML。发出帖子请求:

POST https://translation.googleapis.com/v3/projects/project-number-or-id/locations/us-central1:translateText

有了这个有效载荷。模型应该指向您的 AutoML 模型路径,而词汇表配置应该指向您的词汇表 ID。

{
  "model": "projects/project-number-or-id/locations/us-central1/models/TRL1395675701985363739",
  "sourceLanguageCode": "en",
  "targetLanguageCode": "ru",
  "contents": "Dr. Watson, please discard your trash. You've shared unsolicited email with me. Let's talk about spam and importance ranking in a confidential mode.",
  "glossaryConfig": {
    "glossary": "projects/project-number/locations/us-central1/glossaries/glossary-id"
  }
}

推荐阅读