nvidia/parakeet-ctc-1.1b 是 NVIDIA 开源的一款基于 CTC(Connectionist Temporal Classification)的自动语音识别(ASR)模型,参数量约 1.1B。该模型采用 FastConformer 编码器架构,使用 CTC 解码算法,能够将输入的音频信号转换为文本输出,支持英语语音识别场景。
本仓库完成了该模型在华为昇腾 910 NPU 上的适配工作,基于 transformers + torch_npu 推理框架实现推理部署。通过 transformers 的 ParakeetForCTC 模型类和昇腾 NPU 的算力支撑,实现高效的语音识别推理。
| 属性 | 值 |
|---|---|
| 模型名称 | nvidia/parakeet-ctc-1.1b |
| 模型架构 | ParakeetForCTC (FastConformer + CTC) |
| 参数量 | 1,062,540,289 (~1.06B) |
| 框架 | transformers (4.57.6) |
| 任务类型 | 自动语音识别 (ASR) |
| 语言 | 英语 |
| 模型来源 | hf-mirror.com / HuggingFace |
| 组件 | 规格 |
|---|---|
| NPU | Ascend 910 |
| NPU 数量 | 2 |
| NPU 显存 | 64GB HBM / 卡 |
| 服务器架构 | aarch64 |
| 组件 | 版本 |
|---|---|
| 操作系统 | Ubuntu 22.04.5 LTS |
| Python | 3.11.14 |
| CANN | 8.5.1 |
| torch | 2.9.0 |
| torch_npu | 2.9.0.post1 |
| transformers | 4.57.6 |
| numpy | 1.26.4 |
| soundfile | 0.13.1 |
npu-smi 25.5.5
NPU 芯片: Ascend910
HBM 总容量: 65536MB/卡pip install -r requirements.txt# 从 hf-mirror.com 拉取
HF_ENDPOINT=https://hf-mirror.com huggingface-cli download nvidia/parakeet-ctc-1.1b --local-dir ./parakeet-ctc-1.1b
# 或从 HuggingFace 直接拉取
huggingface-cli download nvidia/parakeet-ctc-1.1b --local-dir ./parakeet-ctc-1.1bpython inference.py sample.wav --model ./parakeet-ctc-1.1bimport torch
import torch_npu
from transformers import AutoModelForCTC, AutoProcessor
model = AutoModelForCTC.from_pretrained(
"nvidia/parakeet-ctc-1.1b",
dtype=torch.bfloat16,
trust_remote_code=True
).to("npu:0")
model.eval()
processor = AutoProcessor.from_pretrained("nvidia/parakeet-ctc-1.1b", trust_remote_code=True)
# 读取音频
import soundfile as sf
audio, sr = sf.read("sample.wav")
# 推理
inputs = processor(audio, sampling_rate=sr, return_tensors="pt")
input_features = inputs["input_features"].to("npu:0", dtype=torch.bfloat16)
with torch.no_grad():
logits = model(input_features).logits
predicted_ids = torch.argmax(logits, dim=-1)
text = processor.batch_decode(predicted_ids)[0]
print(text)python -c "import torch; import torch_npu; print(f'NPU可用: {torch.npu.is_available()}, 设备数: {torch.npu.device_count()}')"python -c "
from transformers import AutoModelForCTC, AutoConfig
import torch
config = AutoConfig.from_pretrained('./parakeet-ctc-1.1b', trust_remote_code=True)
model = AutoModelForCTC.from_pretrained('./parakeet-ctc-1.1b', config=config, dtype=torch.bfloat16, trust_remote_code=True)
model = model.to('npu:0')
print(f'模型加载成功: {sum(p.numel() for p in model.parameters()):,} 参数')
"python inference.py test.wav --model ./parakeet-ctc-1.1b# 在推理过程中查看 NPU 占用
npu-smi info以下为在 Ascend 910 NPU 上的实测性能(5.86 秒 LibriSpeech 语音):
| 测试项 | 值 |
|---|---|
| 首次推理延迟 | 288.3ms |
| 预热后推理延迟 | ~56ms |
| 平均推理延迟(5次) | 103.2ms |
| 模型加载时间 | ~3秒(1694个权重文件) |
| 输出特征形状 | [1, 74, 1025] |
| 输入特征形状 | [1, 586, 80] |
| 推理引擎 | transformers + torch_npu |
| 数据类型 | bfloat16 |
| 指标 | 值 |
|---|---|
| NPU HBM 使用 | ~3732MB |
| 进程内存 | 1636~2511MB |
| 已分配显存 | 2028.9MB |
| 参数量 | 1,062,540,289 |
| 权重文件大小 | ~4.05GB |
| 指标 | 说明 |
|---|---|
| WER (词错误率) | 参考 NVIDIA 官方公布数据 |
| CER (字符错误率) | 参考 NVIDIA 官方公布数据 |
使用 LibriSpeech clean/dev/test 或其他标准 ASR 测试集进行评估。
测试输入:LibriSpeech 真实英语语音(5.86 秒,16kHz)
推理结果:
| 项目 | 内容 |
|---|---|
| 参考文本 | MISTER QUILTER IS THE APOSTLE OF THE MIDDLE CLASSES AND WE ARE GLAD TO WELCOME HIS GOSPEL |
| 模型转写 | mr quilter is the apostle of the middle classes and we are glad to welcome his gospel |
| 内容匹配 | 完全一致(MISTER→mr 为模型词表正常映射) |
| 输出 logits 形状 | [1, 74, 1025] |
| 推理延迟(预热后) | ~56ms |
| 平均延迟(5次) | 103.2ms |
NPU 资源占用(实测):
| 指标 | 值 |
|---|---|
| NPU HBM 使用 | ~3732MB / 65536MB |
| NPU 进程内存 | 1636~2511MB |
| NPU 已分配显存 | 2028.9MB |
| NPU 保留显存 | 2290.0MB |
| 推理引擎 | transformers + torch_npu (bfloat16) |
该实测结果证明模型已在昇腾 910 NPU 上真实、正确地完成语音转写。
trust_remote_code=True 参数以加载 ParakeetForCTC 自定义代码。ParakeetForCTC,使用 FastConformer 编码器 + CTC 解码,非标准 transformers 架构。.to('npu:0') 加载到 NPU。torch.npu.set_device(0) 和 torch.npu.synchronize() 进行调试。