---
title: nlp_csanmt_translation_zh2fr
canonical_url: "https://www.modelscope.cn/models/damo/nlp_csanmt_translation_zh2fr"
md_url: "https://www.modelscope.cn/models/damo/nlp_csanmt_translation_zh2fr.md"
repository: damo/nlp_csanmt_translation_zh2fr
chinese_name: "CSANMT连续语义增强机器翻译-中法-通用领域"
last_updated: 2023-08-11
license: "Apache License 2.0"
pipeline_tag: translation
tasks:
  - translation
model_type:
  - csanmt
library_name:
  - tensorflow
frameworks:
  - tensorflow
language:
  - zh-fr
domain:
  - nlp
downloads: 84
stars: 0
tags:
  - CSANMT
  - "Neural Machine Translation"
  - "Continuous Semantic Augmentation"
  - ACL2022
---

# nlp_csanmt_translation_zh2fr

> nlp_csanmt_translation_zh2fr - damo 在 ModelScope 开源的模型。桥接模型：CSANMT连续语义增强机器翻译-中英-通用领域-large 和 CSANMT连续语义增强机器翻译-英法-通用领域-base

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

- **Repository**: damo/nlp_csanmt_translation_zh2fr
- **License**: Apache License 2.0
- **Tasks**: translation
- **Tags**: CSANMT, Neural Machine Translation, Continuous Semantic Augmentation, ACL2022
- **Downloads**: 84
- **Stars**: 0
- **Last updated**: 2023-08-11

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

---

# 基于连续语义增强的神经机器翻译模型介绍
本模型基于邻域最小风险优化策略，backbone选用先进的transformer-large模型，编码器和解码器深度分别为24和6，相关论文已发表于ACL 2022，并获得Outstanding Paper Award。

## 温馨提示
- 使用pipeline推理及在线体验功能的时候，尽量输入单句文本，如果是多句长文本建议人工分句，否则可能出现漏译或未译等情况！！！

## 模型描述
基于连续语义增强的神经机器翻译模型【[论文链接](https://arxiv.org/abs/2204.06812)】由编码器、解码器以及语义编码器三者构成。其中，语义编码器以大规模多语言预训练模型为基底，结合自适应对比学习，构建跨语言连续语义表征空间。此外，设计混合高斯循环采样策略，融合拒绝采样机制和马尔可夫链，提升采样效率的同时兼顾自然语言句子在离散空间中固有的分布特性。最后，结合邻域风险最小化策略优化翻译模型，能够有效提升数据的利用效率，显著改善模型的泛化能力和鲁棒性。

具体来说，我们将双语句子对两个点作为球心，两点之间的欧氏距离作为半径，构造邻接语义区域（即邻域），邻域内的任意一点均与双语句子对语义等价。为了达到这一点，我们引入切线式对比学习，通过线性插值方法构造困难负样例，其中负样本的游走范围介于随机负样本和切点之间。然后，基于混合高斯循环采样策略，从邻接语义分布中采样增强样本，通过对差值向量进行方向变换和尺度缩放，可以将采样目标退化为选择一系列的尺度向量。

## 期望模型使用方式以及适用范围
本模型适用于具有一定数据规模（百万级以上）的所有翻译语向，同时能够与离散式数据增强方法（如back-translation）结合使用。

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

### 代码范例
```python

# 温馨提示: 使用pipeline推理及在线体验功能的时候，尽量输入单句文本，如果是多句长文本建议人工分句，否则可能出现漏译或未译等情况！！！

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

input_sequence = '声明补充说，沃伦的同事都深感震惊，并且希望他能够投案自首。'

pipeline_ins_zh2en = pipeline(Tasks.translation, model='damo/nlp_csanmt_translation_zh2en')
pipeline_ins_en2fr = pipeline(Tasks.translation, model='damo/nlp_csanmt_translation_en2fr')

privot_sequence_en = pipeline_ins_zh2en(input=input_sequence)['translation']
outputs = pipeline_ins_en2fr(input=privot_sequence_en)

print(outputs['translation']) 
```
```python
# 支持batch推理

# 温馨提示: 使用pipeline推理及在线体验功能的时候，尽量输入单句文本，如果是多句长文本建议人工分句，否则可能出现漏译或未译等情况！！！

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

batch_input_sequences = ['特斯拉汽车公司联合创始人兼首席执行官埃隆 · 马斯克。', '阿里巴巴集团的使命是让世界没有困难的生意', '今天的天气怎么样？']
input_sequence = '<SENT_SPLIT>'.join(batch_input_sequences)   # 用特定的连接符<SENT_SPLIT>，将多个句子进行串联

pipeline_ins_zh2en = pipeline(Tasks.translation, model='damo/nlp_csanmt_translation_zh2en')
pipeline_ins_en2fr = pipeline(Tasks.translation, model='damo/nlp_csanmt_translation_en2fr')

privot_sequence_en = pipeline_ins_zh2en(input=input_sequence)['translation']
outputs = pipeline_ins_en2fr(input=privot_sequence_en)

print(outputs['translation'].split('<SENT_SPLIT>'))
```

## 数据评估及结果
|  WMT18 (阿里翻译内部生产)|    Remark   |
|:---------------------:|:-----------:|
|          24.4         |    DeepL   |
|          25.1         |    Google   |
|          25.9         |  ModelScope |


## 论文引用
如果你觉得这个该模型对有所帮助，请考虑引用下面的相关的论文：
``` 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},
}
```
