m0_74196153/Qwen3-ForcedAligner-0.6B
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

Qwen3-ForcedAligner-0.6B 在昇腾 NPU 上的部署

1. 简介

Qwen3-ForcedAligner-0.6B 是通义千问推出的强制对齐(Forced Alignment)模型,支持对 11 种语言的语音-文本对进行字/词级时间戳预测。该模型可在最长 5 分钟的音频上进行精确的对齐预测,精度超越现有的 E2E 强制对齐模型(如 NFA、WhisperX)。

本仓库提供基于 Ascend NPU 的适配方案,支持在华为昇腾设备上使用 torch_npu + transformers 后端进行推理。

  • 权重下载(ModelScope):https://modelscope.cn/models/Qwen/Qwen3-ForcedAligner-0.6B
  • 权重下载(HuggingFace):https://huggingface.co/Qwen/Qwen3-ForcedAligner-0.6B
  • 原始论文:https://arxiv.org/abs/2601.21337

2. 环境说明

2.1 已验证环境

组件版本
vllm-ascend0.18.0rc1
vllm0.18.0+empty
transformers4.57.6
torch-npu2.9.0.post1+gitee7ba04
qwen-asr0.0.6
  • NPU:1 逻辑卡(Atlas 800 A2)
  • OS:Linux 5.10.0 aarch64
  • Python:3.11.14

2.2 安装依赖

pip install qwen-asr

3. 快速开始

3.1 适配加载(关键步骤)

ForcedAligner 与 ASR 模型共享同一架构 Qwen3ASRForConditionalGeneration,加载前需注册自定义模型类:

from qwen_asr.core.transformers_backend.configuration_qwen3_asr import Qwen3ASRConfig
from qwen_asr.core.transformers_backend.modeling_qwen3_asr import Qwen3ASRForConditionalGeneration
from qwen_asr.core.transformers_backend.processing_qwen3_asr import Qwen3ASRProcessor
from transformers import AutoConfig, AutoModel, AutoProcessor

AutoConfig.register("qwen3_asr", Qwen3ASRConfig)
AutoModel.register(Qwen3ASRConfig, Qwen3ASRForConditionalGeneration)
AutoProcessor.register(Qwen3ASRConfig, Qwen3ASRProcessor)

3.2 强制对齐推理

使用 Qwen3ForcedAligner 封装类:

import torch
import torch_npu
from qwen_asr import Qwen3ForcedAligner

model = Qwen3ForcedAligner.from_pretrained(
    "/path/to/Qwen3-ForcedAligner-0.6B",
    dtype=torch.bfloat16,
    attn_implementation="eager",
    device_map=None,
)
model.model = model.model.to("npu:0")

results = model.align(
    audio="audio.wav",
    text="甚至出现交易几乎停滞的情况。",
    language="Chinese",
)
for item in results[0]:
    print(f"{item.text}: {item.start_time}s - {item.end_time}s")

3.3 命令行快速测试

python inference.py --audio test_audio_zh.wav --text "甚至出现交易几乎停滞的情况。" --language Chinese
python inference.py --audio test_audio_en.wav --text "Hmm. Oh yeah, yeah." --language English

4. 精度与性能

4.1 测试音频

样本语言时长对齐文本
test_audio_zh.wav中文4.20秒甚至出现交易几乎停滞的情况。(13字符)
test_audio_en.wav英文15.05秒Hmm. Oh yeah, yeah...(36词)

4.2 时间戳验证

中文时间戳(13字符):

字开始时间结束时间
甚0.400秒0.720秒
至0.720秒0.960秒
出0.960秒1.120秒
现1.120秒1.520秒
交1.520秒1.760秒
易1.760秒2.000秒
几2.000秒2.240秒
乎2.240秒2.480秒
停2.480秒2.720秒
滞2.720秒2.880秒
的2.880秒3.040秒
情3.040秒3.360秒
况3.360秒3.680秒

英文时间戳(前5词):

词开始时间结束时间
Hmm0.480秒0.880秒
Oh1.040秒1.280秒
yeah1.280秒1.520秒
yeah1.520秒1.920秒
He2.320秒2.400秒

所有时间戳均在音频时长范围内,单调递增且不重叠。

4.3 性能基准测试

语言音频时长Token数平均延迟P50P95吞吐量
中文4.20秒130.097秒0.097秒0.098秒10.27 样本/秒
英文15.05秒360.130秒0.130秒0.130秒7.70 样本/秒

5. 支持的语言

中文、英文、粤语、法语、德语、意大利语、日语、韩语、葡萄牙语、俄语、西班牙语

6. 参考

  • Qwen3-ASR Technical Report
  • vLLM-Ascend 官方文档
  • 原始模型卡片 (HuggingFace)