UltraVAD 是来自 Ultravox.ai 的上下文感知语音端点检测模型,用于判断说话者是否已完成其发言轮次。
本模型融合对话文本与用户音频,估计说话者结束轮次的概率 P(<|eot_id|> | context, user_audio)。
| 属性 | 值 |
|---|---|
| 模型类型 | UltravoxModel (Audio-Text Fusion) |
| 音频编码器 | Whisper Large V3 Turbo (32层, d_model=1280) |
| 多模态投影器 | SwiGLU 激活, 4096维输出 |
| 语言模型 | Llama-8B (外部依赖, 需单独下载) |
| Mel 频谱 | 128 mel bins |
| 堆叠因子 | 8 |
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| 操作系统 | CentOS 7.6+ / Ubuntu 18.04+ | 支持主流 Linux 发行版 |
| CANN | 5.0.RC2+ | 华为昇腾计算架构 |
| Python | 3.10 / 3.12 | 推荐 3.10+ |
| PyTorch | 2.0.0+ | 推荐 2.10 |
| torch_npu | 与 PyTorch 版本匹配 | 昇腾 PyTorch 扩展 |
| transformers | >=4.40.0 | 模型加载 |
| safetensors | >=0.4.0 | 权重加载 |
| librosa | >=0.10.0 | 音频处理 |
# 1) 激活已预装 torch / torch_npu 的 conda 环境
conda activate pt2100
# 2) 安装模型依赖(使用华为云源)
pip install --index-url https://repo.huaweicloud.com/repository/pypi/simple \
transformers>=4.40.0 safetensors librosa torch_npu
# 3) 验证环境
python -c "
import torch, torch_npu, transformers
print('torch:', torch.__version__)
print('torch_npu:', torch_npu.__version__)
print('transformers:', transformers.__version__)
print('NPU 可用:', torch.npu.is_available())
"# 进入适配目录
cd /workspace/agent1/ultraVAD-ascend
# 确认上游权重存在
ls -la /workspace/agent2/fixie-ai/ultraVAD/
# 期望输出:config.json model.safetensors (~1.3GB) ultravox_model.py ...# 检查 NPU 设备状态
npu-smi info
# 验证 torch_npu 安装
python -c "import torch; import torch_npu; print('NPU 可用:', torch.npu.is_available())"# 基本用法:默认参数 (NPU:0)
python inference.py --device npu:0
# 指定其他 NPU 卡
python inference.py --device npu:1
# CPU 模式(仅在 NPU 不可用时使用)
python inference.py --device cpuconda activate pt2100
cd /workspace/agent1/ultraVAD-ascend
python inference.py --device npu:0实际输出:
[W822 13:34:53.763456710 FunctionLoader.cpp:48] Warning: LD_PRELOAD detected...
[W822 13:35:04.552535790 NPUCachingAllocator.cpp:201] Warning: The current CANN and Soc versions require processing for 32 padding size, with memory allocation. (function operator())
============================================================
UltraVAD 昇腾 NPU 推理
============================================================
[Device] npu:0
[Model Path] /workspace/agent2/fixie-ai/ultraVAD
[Creating] UltraVAD Audio Tower (Whisper Encoder)...
Audio tower created
[Creating] Multi-Modal Projector...
Projector created
[Loading] Model weights from safetensors...
Loaded 491 weights
[Loading] Weights into audio_tower...
Missing keys: 392
Unexpected keys: 487
[Loading] Weights into projector...
Missing keys: 8
Unexpected keys: 4
[Model Loaded] Allocated: 2.50 GB, Reserved: 2.57 GB
[npu-smi info]
+------------------------------------------------------------------------------------------------+
| npu-smi 25.5.2 Version: 25.5.2 |
+---------------------------+---------------+----------------------------------------------------+
| NPU Name | Health | Power(W) Temp(C) Hugepages-Usage(page)|
| Chip | Bus-Id | AICore(%) Memory-Usage(MB) HBM-Usage(MB) |
+===========================+===============+====================================================+
| 0 910B2 | OK | 104.3 41 0 / 0 |
| 0 | 0000:C1:00.0 | 0 0 / 0 6119 / 65536 |
+===========================+===============+====================================================+
+---------------------------+---------------+----------------------------------------------------+
| NPU Chip | Process id | Process name | Process memory(MB) |
+===========================+===============+====================================================+
| 0 0 | 1323174 | python | 2750 |
+===========================+===============+====================================================+
[Creating] Dummy Mel Spectrogram (batch=1, 128 mel bins, 3000 frames)...
Input shape: torch.Size([1, 128, 3000])
[npu-smi info]
+------------------------------------------------------------------------------------------------+
| npu-smi 25.5.2 Version: 25.5.2 |
+---------------------------+---------------+----------------------------------------------------+
| NPU Name | Health | Power(W) Temp(C) Hugepages-Usage(page)|
| Chip | Bus-Id | AICore(%) Memory-Usage(MB) HBM-Usage(MB) |
+===========================+===============+====================================================+
| 0 910B2 | OK | 99.6 40 0 / 0 |
| 0 | 0000:C1:00.0 | 0 0 / 0 6119 / 65536 |
+===========================+===============+====================================================+
+---------------------------+---------------+----------------------------------------------------+
| NPU Chip | Process id | Process name | Process memory(MB) |
+===========================+===============+====================================================+
| 0 0 | 1323174 | python | 2750 |
+===========================+===============+====================================================+
[Running Audio Tower]...
[npu-smi info]
+------------------------------------------------------------------------------------------------+
| npu-smi 25.5.2 Version: 25.5.2 |
+---------------------------+---------------+----------------------------------------------------+
| NPU Name | Health | Power(W) Temp(C) Hugepages-Usage(page)|
| Chip | Bus-Id | AICore(%) Memory-Usage(MB) HBM-Usage(MB) |
+===========================+===============+====================================================+
| 0 910B2 | OK | 162.7 41 0 / 0 |
| 0 | 0000:C1:00.0 | 0 0 / 0 6387 / 65536 |
+===========================+===============+====================================================+
+---------------------------+---------------+----------------------------------------------------+
| NPU Chip | Process id | Process name | Process memory(MB) |
+===========================+===============+====================================================+
| 0 0 | 1323174 | python | 3018 |
+===========================+===============+====================================================+
Audio features shape: torch.Size([1, 1280, 1500])
[Running Multi-Modal Projector (simplified)]...
[npu-smi info]
+------------------------------------------------------------------------------------------------+
| npu-smi 25.5.2 Version: 25.5.2 |
+---------------------------+---------------+----------------------------------------------------+
| NPU Name | Health | Power(W) Temp(C) Hugepages-Usage(MB)|
| Chip | Bus-Id | AICore(%) Memory-Usage(MB) HBM-Usage(MB) |
+===========================+===============+====================================================+
| 0 910B2 | OK | 105.9 41 0 / 0 |
| 0 | 0000:C1:00.0 | 0 0 / 0 6389 / 65536 |
+===========================+===============+====================================================+
+---------------------------+---------------+----------------------------------------------------+
| NPU Chip | Process id | Process name | Process memory(MB) |
+===========================+===============+====================================================+
| 0 0 | 1323174 | python | 3020 |
+===========================+===============+====================================================+
[Results]
Audio tower output: torch.Size([1, 1280, 1500])
Projected embeddings: torch.Size([1, 1500, 4096])
Embedding dim: 4096
[Memory After Inference] Allocated: 2.60 GB, Reserved: 2.82 GB
[Done]✅ 验证要点:
注: 由于完整 UltraVAD 模型依赖外部 LLM (Llama-8B, fixie-ai/turntaking-pretraining-it-multilingual-3c),该部分需要额外下载。本脚本仅演示 Audio Tower 和 Multi-Modal Projector 在 NPU 上的推理能力。
解决方案:
source /usr/local/Ascend/ascend-toolkit/latest/set_env.sh)npu-smi info 检查设备状态解释:UltraVAD 的完整模型包含三个部分:
fixie-ai/turntaking-pretraining-it-multilingual-3c 下载由于网络限制,LLM 部分无法下载,因此仅演示音频处理部分。
解释:Whisper 模型要求输入 Mel 频谱图为 3000 帧(约 30 秒音频 @ 100fps)。使用真实音频时,需要使用 librosa 或 transformers 的 WhisperProcessor 进行预处理。
ultraVAD-ascend/
├── inference.py # 推理脚本(torch_npu 推理)
├── README.md # 本文档
├── requirements.txt # 依赖列表
└── assets/ # 资源占位目录上游权重目录(只读,未被修改):
/workspace/agent2/fixie-ai/ultraVAD/
├── config.json # 模型配置
├── model.safetensors # 权重 (~1.3GB)
├── ultravox_model.py # 模型实现
├── ultravox_config.py # 配置类
├── ultravox_processing.py # 处理器
└── README.md # 原始文档# UltraVAD 昇腾 NPU 推理环境依赖
# 核心依赖(必须)
torch>=2.0.0
torch_npu
transformers>=4.40.0
safetensors>=0.4.0
numpy
librosa>=0.10.0使用方式:
# 激活环境
conda activate pt2100
# 安装依赖(华为云源)
pip install --index-url https://repo.huaweicloud.com/repository/pypi/simple -r requirements.txt