Downloads · 30 days
0
modelscope-unofficial/damo-csanmt-en-zh-base
damo-csanmt-en-zh-base is a translation model from modelscope-unofficial. Use it when you need text moved from one language to another. The card lists the license as apache-2.0.
The original model is at: https://www.modelscope.cn/models/damo/nlpcsanmttranslationen2zhbase/summary
Downloads · 30 days
0
Access
Public
Updated May 12, 2023
Repo size
823 MB
Likes
0
Public
Click a slice to open those files.
.data-00000-of-00001821 MB · 100%
From the Hugging Face model README
The original model is at: https://www.modelscope.cn/models/damo/nlp_csanmt_translation_en2zh_base/summary
Option 1: use modelscope library
pip install modelscope subword_nmt sacremoses jieba
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-en-zh-base')
pipe = pipeline(task=Tasks.translation, model=model_dir)
input_sequence = 'Elon Musk, co-founder and chief executive officer of Tesla Motors.'
outputs = pipe(input=input_sequence)
print(outputs['translation']) # 'Elon Musk,特斯拉汽车公司联合创始人兼首席执行官。'
batch_input_sequences = [
"Elon Musk, co-founder and chief executive officer of Tesla Motors.",
"What's the weather like today?"
]
input_sequence = '<SENT_SPLIT>'.join(batch_input_sequences)
outputs = pipe(input=input_sequence)
print(outputs['translation'].split('<SENT_SPLIT>'))