---
title: nlp_imt_translation_en2zh
canonical_url: "https://www.modelscope.cn/models/damo/nlp_imt_translation_en2zh"
md_url: "https://www.modelscope.cn/models/damo/nlp_imt_translation_en2zh.md"
repository: damo/nlp_imt_translation_en2zh
chinese_name: "交互式机器翻译-英中-通用领域-large"
last_updated: 2023-02-24
license: "Apache License 2.0"
pipeline_tag: translation
tasks:
  - translation
model_type:
  - csanmt
library_name:
  - tensorflow
frameworks:
  - tensorflow
language:
  - en-zh
domain:
  - nlp
downloads: 10964
stars: 9
tags:
  - "Interactive Machine Translation"
  - "Neural Machine Translation"
  - CSANMT
  - ACL2022
---

# nlp_imt_translation_en2zh

> nlp_imt_translation_en2zh - damo 在 ModelScope 开源的模型。交互式机器翻译英中模型，利用译文前缀，获取更好的翻译结果。

damo/nlp_imt_translation_en2zh 是 ModelScope 魔搭社区上的translation模型，采用 Apache License 2.0 许可。

- **Repository**: damo/nlp_imt_translation_en2zh
- **License**: Apache License 2.0
- **Tasks**: translation
- **Tags**: Interactive Machine Translation, Neural Machine Translation, CSANMT, ACL2022
- **Downloads**: 10964
- **Stars**: 9
- **Last updated**: 2023-02-24

Source: https://www.modelscope.cn/models/damo/nlp_imt_translation_en2zh

---

# 交互式机器翻译模型介绍
交互式机器翻译（Interactive Machine Translation）的输入为源文和译文前缀，输出为后续的译文，可以提高后续译文的翻译质量。当输入译文前缀的最后一个词不完整时，模型会输出当前词及后续译文。本模型基于[CSANMT连续语义增强机器翻译](https://www.modelscope.cn/models/damo/nlp_csanmt_translation_en2zh/summary)模型。


## 温馨提示
- 使用pipeline推理及在线体验功能的时候，尽量输入单句文本，如果是多句长文本建议人工分句！！！


## 模型描述
该模型利用输入译文的前缀作为Decoder的输入，使用强制解码Beam Search算法，预测后续译文。当输入译文前缀的最后一个词不完整时，生成一个匹配词典中每个单词前缀的MASK向量，通过这个MASK向量影响影响第一个的预测结果。

## 期望模型使用方式以及适用范围
该模型适用于的交互式机器翻译场景，输入为源文及译文前缀，输出为的后续译文。

### 如何使用
在ModelScope框架上，提供输入源文和译文前缀，即可通过简单的Pipeline调用来使用。

### 使用效果展示

<p align="center">
    <br>
        <video src="https://alitranx-online-service.oss-cn-zhangjiakou.aliyuncs.com/mass/imt/resources/IMT_Vedio.mp4" loop="loop" autoplay="autoplay" muted width="100%"></video>
    <br>
</p>


### 代码范例
```python
# English-to-Chinese

# 温馨提示: 使用pipeline推理及在线体验功能的时候，尽量输入单句文本，如果是多句长文本建议人工分句！！！

from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

input_sequence = 'Elon Musk, co-founder and chief executive officer of Tesla Motors.'
input_prefix = '特斯拉汽车公司'

pipeline_ins = pipeline(task=Tasks.translation, model='damo/nlp_imt_translation_en2zh')
# 以 '<PREFIX_SPLIT>' 拼接源文和译文前缀
outputs = pipeline_ins(input_sequence + '<PREFIX_SPLIT>' + input_prefix)

print(outputs['translation']) # '公司联合创始人兼首席执行官埃隆 · 马斯克。'
```

## 模型局限性以及可能的偏差
1. 模型在通用数据集上训练，部分垂直领域有可能产生一些偏差，请用户自行评测后决定如何使用。
2. 当前版本在tensorflow 2.3和1.14环境测试通过，其他环境下可用性待测试。

## 训练数据及流程
参考[CSANMT连续语义增强机器翻译](https://www.modelscope.cn/models/damo/nlp_csanmt_translation_en2zh/summary)模型训练数据。


## 数据评估及结果
参考[CSANMT连续语义增强机器翻译](https://www.modelscope.cn/models/damo/nlp_csanmt_translation_en2zh/summary)数据评估结果。

### 模型训练
```python
# English-to-Chinese

from modelscope.trainers.nlp import CsanmtTranslationTrainer

trainer = CsanmtTranslationTrainer(model="damo/nlp_imt_translation_en2zh")
trainer.train()

```


## 论文引用
如果你觉得这个该模型对有所帮助，请考虑引用下面的相关的论文：
``` bibtex
@inproceedings{wei-etal-2022-learning,
  title = {Learning to Generalize to More: Continuous Semantic Augmentation for Neural Machine Translation},
  author = {Xiangpeng Wei and Heng Yu and Yue Hu and Rongxiang Weng and Weihua Luo and Rong Jin},
  booktitle = {Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics, ACL 2022},
  year = {2022},
}
```
