translation license:apache-2.0 region:us
---
license: apache-2.0
pipeline_tag: translation
---
The original model is at:
https://www.modelscope.cn/models/damo/nlp_csanmt_translation_zh2en/summary

## Usage

Option 1: use modelscope library

```
pip install modelscope subword_nmt sacremoses jieba
```

```python
from huggingface_hub import snapshot_download
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

model_dir = snapshot_download('modelscope-unofficial/damo-csanmt-zh-en-large')

pipe = pipeline(task=Tasks.translation, model=model_dir)

input_sequence = '特斯拉汽车公司联合创始人兼首席执行官埃隆 · 马斯克。'
outputs = pipe(input=input_sequence)

print(outputs['translation'])  # 'Elon Musk, co-founder and chief executive officer of Tesla Motors.'


batch_input_sequences = [
    "特斯拉汽车公司联合创始人兼首席执行官埃隆 · 马斯克。",
    "今天的天气怎么样？"
]
input_sequence = '<SENT_SPLIT>'.join(batch_input_sequences)
outputs = pipe(input=input_sequence)
print(outputs['translation'].split('<SENT_SPLIT>'))
```

