Files
enginex-mlu370-asr/README.md
2025-09-19 10:07:20 +08:00

55 lines
4.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 寒武纪MLU370系列 FunASR
## 镜像构造
```shell
docker build -f ./Dockerfile.funasr-mlu370 -t <your_image> .
```
其中基础镜像 mlu370-pytorch:v25.01-torch2.5.0-torchmlu1.24.1-ubuntu22.04-py310 通过联系寒武纪厂商技术支持可获取
## 使用说明
### 快速镜像测试
对funasr的测试需要在以上构造好的镜像容器内测试测试步骤
1. 本项目中附带上了示例测试数据,音频文件为`lei-jun-test.wav`,音频的识别准确内容文件为`lei-jun.txt`用户需要准备好相应的ASR模型路径本例中假设我们已经下载好了SenseVoiceSmall模型存放于/model/SenseVoiceSmall
2. 在本项目路径下执行以下快速测试命令
```shell
docker run -it \
-v $PWD:/tmp/workspace \
-v /model:/model \
--device=/dev/cambricon_dev0:/dev/cambricon_dev0 \
--device=/dev/cambricon_ctl:/dev/cambricon_ctl \
-e MODEL_DIR=/model/SenseVoiceSmall \
-e TEST_FILE=lei-jun-test.wav \
-e ANSWER_FILE=lei-jun.txt \
-e CUSTOM_DEVICE=MLU370 \
-e RESULT_FILE=result.json \
--cpus=4 --memory=16g \
<your_image>
```
上述测试指令成功运行将会在terminal中看到对测试音频的识别结果运行时间以及1-cer效果指标并且当前文件下会生成一个`result.json`文件记录刚才的测试结果
### 定制化手动运行
用户可使用类似上述的docker run指令以交互形式进入镜像中主要的测试代码为`test_funasr.py`,用户可自行修改代码中需要测试的模型路径、测试文件路径以及调用funASR逻辑
## 寒武纪MLU370系列加速卡 模型适配情况
我们在寒武纪MLU370系列加速卡上针对funASR部分进行了所有大类的适配测试方式为在Nvidia A100环境下和寒武纪MLU370系列加速卡上对同一段长音频进行语音识别任务获取运行时间1-cer指标。运行时都只使用一张显卡
### 寒武纪MLU370-X8
| 模型大类 | 模型地址 |A100运行时间(秒)|寒武纪MLU370-X8运行时间(秒)|A100 1-cer|寒武纪MLU370-X8 1-cer| 备注 |
|------|---------------|-----|----|-------|-------|---------------------|
| sense_voice | https://www.modelscope.cn/models/iic/SenseVoiceSmall | 1.4021 | 1.7852 | 0.980033 | 0.980033 | |
| whisper | https://www.modelscope.cn/models/iic/Whisper-large-v3 | 18.3006 | 45.8322 | 0.910150 | 0.910150 | |
| paraformer | https://modelscope.cn/models/iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch | 3.9866 | 7.9367 | 0.955075 | 0.955075 | |
| conformer | https://www.modelscope.cn/models/iic/speech_conformer_asr_nat-zh-cn-16k-aishell2-vocab5212-pytorch | 83.8346 | 138.5394 | 0.349418 | 0.346090 | |
| uni_asr | https://www.modelscope.cn/models/iic/speech_UniASR-large_asr_2pass-zh-cn-16k-common-vocab8358-tensorflow1-offline | 118.4741 | 175.5439 | 0.717138 | 0.950083 | 寒武纪上1-cer效果明显要更高<sup>(*)</sup> |
### 寒武纪MLU370-X4
| 模型大类 | 模型地址 |A100运行时间(秒)|寒武纪MLU370-X4运行时间(秒)|A100 1-cer|寒武纪MLU370-X4 1-cer| 备注 |
|------|---------------|-----|----|-------|-------|---------------------|
| sense_voice | https://www.modelscope.cn/models/iic/SenseVoiceSmall | 1.2767 | 1.6982 | 0.980033 | 0.980033 | |
| whisper | https://www.modelscope.cn/models/iic/Whisper-large-v3 | 18.8058 | 42.1840 | 0.910150 | 0.910150 | |
| paraformer | https://modelscope.cn/models/iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch | 4.2537 | 7.9753 | 0.955075 | 0.955075 | |
| conformer | https://www.modelscope.cn/models/iic/speech_conformer_asr_nat-zh-cn-16k-aishell2-vocab5212-pytorch | 82.9607 | 128.3273 | 0.349418 | 0.346090 | |
| uni_asr | https://www.modelscope.cn/models/iic/speech_UniASR-large_asr_2pass-zh-cn-16k-common-vocab8358-tensorflow1-offline | 109.2819 | 112.0971 | 0.717138 | 0.950083 | 寒武纪上1-cer效果明显要更高<sup>(*)</sup> |
(*) uni_asr模型寒武纪卡表现出与A100以及CPU上运行很不同的行为uni_asr模型比较特殊的是自带VAD功能测试音频中途有演讲人停顿的地方uni_asr模型会只识别出一部分语音内容所以导致A100、CPU上测出的1-cer分数较低0.71但是寒武纪显卡在同样代码调用过程中识别出了所有音频内容所以识别分数较高0.95。虽然说看起来也比较正确但是这一行为与A100/CPU以及其他国产显卡同样这一套测试的行为预期不同可能模型内部VAD功能失效