# enginex-mlu370-translation # translation-transformers ## Quickstart ```shell #构建docker镜像 docker build . -t mlu370_translation 其中基础镜像 mlu370-pytorch:v25.01-torch2.5.0-torchmlu1.24.1-ubuntu22.04-py310 联系寒武纪厂商技术支持可获取 #运行docker容器 docker run -it -p 10078:80 --device=/dev/cambricon_dev0:/dev/cambricon_dev0 --device=/dev/cambricon_ctl --device=/dev/cambricon_ipcm0:/dev/cambricon_ipcm0 -e MODEL_TYPE=opus_mt -e MODEL_NAME=moxying/opus-mt-zh-en --name mlu370_translation_test mlu370_translation ``` 等待模型下载完成,出现以下日志时,代表服务启动成功 ```shell INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:80 (Press CTRL+C to quit) ``` 执行测试程序 ```shell python3 test.py ``` 测试程序执行结果 ``` Succeed! Response: [{'translations': [{'origin_text': '生活就像一块巧克力', 'translated': 'Life is like a piece of chocolate.'}, {'origin_text': '你来自哪里', 'translated': 'Where are you from?'}, {'origin_text': '你吃饭了吗', 'translated': 'Have you eaten yet?'}]}] ``` 停止docker容器 ``` docker stop mlu370_translation_test ``` ## 模型支持 在Quickstart中运行容器时,通过环境变量的方式,指定模型的类型和具体的模型名称,即: ``` -e MODEL_TYPE=opus_mt -e MODEL_NAME=moxying/opus-mt-zh-en ``` 目前支持以下几种配置: | MODEL_TYPE | MODEL_NAME | | ---------- | --------------------------------------- | | nllb200 | facebook/nllb-200-distilled-600M | | small100 | aiyueqi/alirezamsh_small100 | | mbart | facebook/mbart-large-50-many-to-many-mmt| | opus_mt | moxying/opus-mt-zh-en | 其中,MODEL_TYPE代表模型类型,必须为以上表格列举之一;MODEL_NAME是modelscope上面能够拉取到的模型名称,需要和MODEL_TYPE对应