InterfazeAI/diffusion-gemma-asr

GitHub: InterfazeAI/diffusion-gemma-asr

基于 DiffusionGemma 扩散解码器的多语言语音识别 adapter,用并行去噪生成替代自回归解码,实现与文本长度无关的恒定解码成本。

Stars: 7 | Forks: 1

# 基于 DiffusionGemma 的原生音频 ASR 这是一种通过 DiffusionGemma 的 diffusion decoder 而非 autoregressive decoder 运行的语音转文本技术。音频会被投影到 Gemma 的 embedding 空间中,并通过约 8 到 16 步的并行 diffusion denoising 生成转录文本,因此解码成本不会随着转录文本的长度而增加。支持多语言:英语、德语、法语、西班牙语、印地语、普通话。 它是一个构建在冻结骨干网络上的 adapter:在冻结的 26B DiffusionGemma 和冻结的 whisper-small encoder 之上,包含约 42M 个训练参数(0.16%)。 ## 工作原理 ``` audio (16 kHz) -> frozen whisper-small encoder acoustic features, 1500 x 768 -> trainable projector conv subsample 8x + linear to 2816, ~19M params -> 188 audio embeddings scattered into the prompt -> DiffusionGemma encoder causal, builds a read-only KV cache -> DiffusionGemma decoder bidirectional, denoises a 256-token canvas -> transcript ``` 训练使用了三个损失函数:diffusion 目标函数(生成器)、autoregressive 辅助损失,以及通过冻结的 `lm_head` 应用于 projector 的 CTC loss。CTC loss 使得冻结的骨干网络能够学习使用音频。它仅在训练期间运行,并在推理时被丢弃。 ## 结果 经过 Whisper 归一化的 WER/CER,16 个 diffusion 步骤。 | benchmark | metric | score | |---|---|---| | LibriSpeech test-clean (en) | WER | 6.6% | | FLEURS English | WER | 15.7% | | VoxPopuli English | WER | 18.5% | | FLEURS Hindi | CER | 15.8% | | FLEURS Mandarin | CER | 29.6% | 速度大约是实时速度的 11 到 17 倍。八个步骤已经接近最佳准确率,且速度最快;更多的步骤几乎没有帮助。 ## 目录结构 ``` modal_app.py Modal app: image, volumes, constants src/audio.py whisper features + trainable projector src/model.py audio injection, the three losses, diffusion generate src/data.py dataset + collator (dynamic canvas, CTC targets) src/train.py training entrypoint src/evaluate.py WER/CER + latency (--normalizer whisper|basic, --metric wer|cer) src/serve.py FastAPI inference endpoint (audio_url or raw bytes) scripts/download_data.py LibriSpeech / FLEURS / VoxPopuli -> Modal volume scripts/probe.py load and introspect the base model scripts/publish_hf.py push the adapter to the Hub scripts/publish_space.py build the Gradio demo Space space/ the Gradio demo (calls the served endpoint) ``` ## 用法 在 Modal 上运行。单个 H100 80 GB 即可容纳 26B 模型。 ``` # 数据 (单次) modal run scripts/download_data.py::prepare --subset train.clean.100 modal run scripts/download_data.py::prepare --subset test.clean # 训练 (冻结 backbone、projector + LoRA,三种 losses) modal run src/train.py::main --lora --ar-weight 1.0 --ctc-weight 1.0 \ --epochs 10 --batch-size 3 --grad-accum 4 --lr 5e-4 --run-name run1 # 评估 modal run src/evaluate.py::main --ckpt final --run-name run1 \ --subset test.clean --normalizer whisper --max-steps 16 # 服务 modal deploy src/serve.py ``` ## 注意事项 encoder 具有 30 秒的窗口,因此较长的音频会在静音处被分割,然后将各个片段拼接起来,这与 Whisper 采用的方法相同。基础模型在首次运行时会下载到 Modal volume 中;adapter 则单独发布。Checkpoints 和数据集存放在 Modal volume 上,而不在 git 中。
标签:凭据扫描, 逆向工具