Files

46 lines
2.2 KiB
Markdown
Raw Permalink Normal View History

2025-09-03 16:35:44 +08:00
# enginex-ascend-910-translation
2025-11-18 17:38:11 +08:00
运行于【昇腾-910】系列算力卡的【翻译】引擎基于 transformer 架构,支持 NLLB-200、SMaLL-100 等最新流行翻译模型
2025-09-04 15:01:25 +08:00
# translation-transformers
## Quickstart
```shell
#构建docker镜像
docker build . -t ascend_910_translation
#运行docker容器
2025-11-18 17:38:11 +08:00
docker run -it -e ASCEND_VISIBLE_DEVICES=0 --device /dev/davinci0:/dev/davinci0 --device /dev/davinci_manager --device /dev/devmm_svm --device /dev/hisi_hdc -v /mnt:/mnt -v /usr/local/dcmi:/usr/local/dcmi -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi -v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ -v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info -v /etc/ascend_install.info:/etc/ascend_install.info --privileged -p 10078:80 -e MODEL_TYPE=opus_mt -e MODEL_NAME=moxying/opus-mt-zh-en --name ascend_910_translation_test ascend_910_translation
2025-09-04 15:01:25 +08:00
```
等待模型下载完成,出现以下日志时,代表服务启动成功
```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 ascend_910_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对应