distil-whisper遇上WhisperKit Pro:蒸馏语音识别模型的速度与精度平衡之道

原创2026-11-09 19:40:511,734 阅读

distil-whisper遇上WhisperKit Pro:蒸馏语音识别模型的速度与精度平衡之道

WhisperKit Pro 是 Argmax 推出的 CoreML 语音识别模型仓库,收录了 distil-whisper 蒸馏语音识别模型(含标准版与 turbo 版),以及 tiny 到 large-v3 全尺寸 Whisper 的量化编译版本,专为苹果设备端侧离线转写优化。本文带你理解 distil-whisper 为什么快、快多少、该怎么选。

什么是 distil-whisper 蒸馏语音识别模型?

知识蒸馏(Knowledge Distillation)的核心思路:用大模型(教师)指导一个小模型(学生),让小模型逼近大模型的效果。

在 distil-whisper 中,蒸馏主要发生在解码器(TextDecoder)上:

  • 原版 Whisper large-v3 的编码器、解码器各有 32 层 Transformer
  • distil-whisper 保留了完整的 32 层编码器(保证语音特征提取精度),但把解码器压缩到 2 层

解码器是逐词自回归生成文本的部分,每生成一个 token 都要跑一遍,层数从 32 降到 2,生成速度自然大幅提升,而精度损失相对温和——这正是"速度与精度平衡之道"的技术来源。

💡 这个结构可以直接在仓库配置里验证:distil-whisper_distil-large-v3/config.json 中 encoder_layers 为 32、decoder_layers 仅为 2。

WhisperKit Pro 如何加速 distil-whisper:CoreML 编译细节

WhisperKit Pro 并不是简单存放原始权重,而是把每个模型编译成了苹果 Core ML 的 MLProgram 格式,并做了以下优化:

  1. 三组件拆分:每个模型目录都包含 MelSpectrogram.mlmodelc(梅尔频谱预处理)、AudioEncoder.mlmodelc(声学编码器)、TextDecoder.mlmodelc(文本解码器)三个可独立调度的子模型;
  2. Float16 存储与混合精度计算:以 distil-whisper_distil-large-v3/AudioEncoder.mlmodelc/metadata.json 为例,存储精度为 Float16,计算精度为 Mixed(Float16/Int32),显存占用减半;
  3. 带 KV Cache 的有状态解码器:TextDecoder 被编译成 TextDecoderStateful 模型,内置 self_attn_key_cache、encoder_attn_key_cache 等状态量,避免了逐 token 重复计算,同时输出 alignment_heads_weights 支持强制对齐(逐词时间戳);
  4. 量化瘦身版本:同一模型提供量化变体,例如 large-v3 有 626MB 的量化版(openai_whisper-large-v3-v20240930_626MB),distil-whisper 也有对应的 _turbo 版本。

系统要求:这些 MLProgram 模型需要 iOS 18 / macOS 15 及以上环境(见各 metadata.json 中的 availability 字段)。

模型仓库目录结构一览

仓库顶层按模型名组织目录,每个模型内部结构一致:

路径 说明
distil-whisper_distil-large-v3/ 蒸馏版 large-v3 标准模型(约 1.5GB,Float16)
distil-whisper_distil-large-v3_turbo/ 蒸馏版 turbo 变体,解码效率更高
openai_whisper-large-v3-v20240930/ 原版 large-v3(约 1.6GB)
openai_whisper-large-v3-v20240930_626MB/ large-v3 量化版,体积缩小约 60%
openai_whisper-base/ 等 tiny / base / small 全系列及 .en 纯英文变体

根目录的 config.json 是"总调度表":定义了各芯片支持哪些模型、默认加载哪个模型,以及每个模型的 SHA-256 校验和(model_checksums 字段),用于下载完整性校验。

各芯片支持哪些模型:distil-whisper 设备适配清单

distil-whisper 体积接近 1.5GB,因此被限制在性能与内存更强的设备上。根据 config.json 的 device_support 配置:

  • A12 ~ A14 芯片(iPhone 11/12/13 等):仅支持 tiny / base / small,不支持 distil-whisper
  • A15 ~ A19 Pro(iPhone 14 及以后):支持到 large-v3 的 626MB 量化版,仍不支持 distil-whisper
  • M1 芯片:支持 distil-whisper_distil-large-v3,默认模型仍为 626MB 量化版
  • M2 ~ M5 芯片:全部解锁,distil-whisper_distil-large-v3_turbo 与 openai_whisper-large-v3-v20240930_turbo 均可用,默认模型为原版 large-v3

也就是说:distil-whisper 是 M 系列 Mac 与高端 iPad 的"专属福利",选模型前先看芯片。

速度 vs 精度:蒸馏模型选型建议

结合仓库中各模型的实际体积(权重文件总大小),可以这样选型:

模型 体积 定位
openai_whisper-tiny 约 76MB 低配设备兜底,速度最快
openai_whisper-base 约 146MB 均衡入门
openai_whisper-small 约 460MB 小模型里的精度最优
openai_whisper-large-v3_626MB 约 624MB 量化压缩版,精度接近 full large-v3
distil-whisper_distil-large-v3 约 1.4GiB 解码器仅 2 层,转写速度显著快于 large-v3
openai_whisper-large-v3 约 1.5GiB 精度天花板,速度最慢

选择原则:

  1. 追求极致转写速度(长录音、实时字幕场景)→ 选 distil-whisper 系列,解码 32 层 → 2 层的收益在长文本上被放大;
  2. 追求最高精度、对耗时不敏感 → 选原版 large-v3 或 distil-large-v3_turbo 按需对比;
  3. 存储空间紧张的 A 系设备 → 选 626MB 量化版;
  4. 纯英文内容 → 优先选 .en 变体(词汇表更聚焦,精度更高)。

如何获取并校验 distil-whisper 模型文件

WhisperKit Pro 属于商业授权模型仓库,需要通过官方渠道(邮箱申请)获取访问权限后再拉取,模型受 LICENSE_NOTICE.txt 中的专有协议保护,仅限授权方使用。

拿到模型后建议用根目录 config.json 中 model_checksums 提供的 SHA-256 值校验下载完整性,例如 distil-whisper_distil-large-v3 对应 c87be28423880a465532fe46a9a5c661。

总结

  • distil-whisper 用"编码器保精度、解码器换速度"的蒸馏策略,成为端侧语音识别中速度/精度平衡的代表作;
  • WhisperKit Pro 通过 CoreML MLProgram 编译、Float16 量化、KV Cache 有状态解码,进一步把蒸馏模型的优势落在 M 系列 Mac 与新一代 iPad 上;
  • 选型口诀:M1+ 选 distil-whisper 拼速度,A 系设备选 626MB 量化版拼体积,追求极致精度选原版 large-v3。
登录后查看全文
whisperkit-pro