diff --git a/README.md b/README.md index 9c41d8c19..4ba85d415 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ C/C++ speech-to-text inference library. Runs diverse STT model families via [GGU | MOSS-Transcribe-Diarize | `moss-transcribe-diarize` | diarize, segment timestamps | [docs/models/moss-transcribe-diarize.md](docs/models/moss-transcribe-diarize.md) | | Multitalker Parakeet Streaming 0.6B v1 | `multitalker-parakeet-streaming-0.6b-v1` | diarize, streaming, token timestamps | [docs/models/multitalker-parakeet-streaming-0.6b-v1.md](docs/models/multitalker-parakeet-streaming-0.6b-v1.md) | | Nemotron 3.5 ASR Streaming 0.6B | `nemotron-3.5-asr-streaming-0.6b` | streaming, token timestamps | [docs/models/nemotron-3.5-asr-streaming-0.6b.md](docs/models/nemotron-3.5-asr-streaming-0.6b.md) | +| Nemotron Labs Unified ASR 0.6B | `nemotron-labs-unified-asr-0.6b` | streaming, token timestamps | [docs/models/nemotron-labs-unified-asr-0.6b.md](docs/models/nemotron-labs-unified-asr-0.6b.md) | | Nemotron Speech Streaming EN 0.6B | `nemotron-speech-streaming-en-0.6b` | streaming, token timestamps | [docs/models/nemotron-speech-streaming-en-0.6b.md](docs/models/nemotron-speech-streaming-en-0.6b.md) | | Parakeet | `parakeet-ctc-0.6b`, `parakeet-ctc-1.1b`, `parakeet-primeline`, `parakeet-rnnt-0.6b`, `parakeet-rnnt-1.1b`, `parakeet-tdt-0.6b-v2`, `parakeet-tdt-0.6b-v3`, `parakeet-tdt-1.1b`, `parakeet-tdt_ctc-1.1b`, `parakeet-tdt_ctc-110m`, `parakeet-ultra`, `parakeet-unified-en-0.6b`, `orukeet`, `phonon-2` | streaming, token timestamps | [docs/models/parakeet.md](docs/models/parakeet.md) | | Qwen3-ASR | `qwen3-asr-0.6b`, `qwen3-asr-1.7b` | - | [docs/models/qwen3-asr.md](docs/models/qwen3-asr.md) | diff --git a/catalog/nemotron-labs-unified-asr-0.6b.json b/catalog/nemotron-labs-unified-asr-0.6b.json new file mode 100644 index 000000000..ac26d9a37 --- /dev/null +++ b/catalog/nemotron-labs-unified-asr-0.6b.json @@ -0,0 +1,124 @@ +{ + "schema": "transcribe-catalog-v1", + "variant": "nemotron-labs-unified-asr-0.6b", + "family": "parakeet", + "display_name": "Nemotron Labs Unified ASR", + "params": 626702592, + "license": { + "spdx": "other", + "display": "OpenMDW-1.1" + }, + "upstream_repo": "nvidia/nemotron-labs-unified-asr-0.6b", + "upstream_commit": "023ce90", + "published_repo": "handy-computer/nemotron-labs-unified-asr-0.6b-gguf", + "docs_page": "nemotron-labs-unified-asr-0.6b.md", + "languages": [ + "bg", "hr", "cs", "da", "nl", "en", "et", "fi", "fr", "de", "el", "hu", + "it", "lv", "lt", "mt", "pl", "pt", "ro", "sk", "sl", "es", "sv", "ru", + "uk" + ], + "language_tag_form": "bare-bcp47", + "long_form_strategy": "chunked-unbounded", + "speed_opt_in": ["m1"], + "benchmark_exceptions": [ + {"kind":"speed","match":{"machine":"m4"},"reason":"No base Apple M4 was available when this model was published; speed is published for the Apple M4 Max, the Ryzen 7 PRO 4750U, and an Apple M1 as a stand-in (speed_opt_in)."} + ], + "capabilities": { + "transcribe": {"supported":true,"verified":true}, + "translate": {"supported":false}, + "lang_detect": {"supported":true,"verified":false}, + "timestamps": {"supported":true,"verified":true,"granularities":["token"],"note":"word times equal NeMo 3.1 transcribe(timestamps=True) on fleurs-fr/fleurs-es/jfk (63/63 words, 0 ms difference)"}, + "streaming": { + "supported": true, + "verified": true, + "note": "per-chunk parity and transcripts vs NeMo speech_to_text_streaming_infer_rnnt.py (target_lang) at 70-13-13, 70-7-7, 70-2-5, 70-1-1; language prompt applied per chunk", + "mode": "buffered", + "presets": [ + {"name":"70-1-1","left_ms":5600,"chunk_ms":80,"right_ms":80,"lookahead_ms":160,"is_default":false}, + {"name":"70-1-2","left_ms":5600,"chunk_ms":80,"right_ms":160,"lookahead_ms":240,"is_default":false}, + {"name":"70-1-3","left_ms":5600,"chunk_ms":80,"right_ms":240,"lookahead_ms":320,"is_default":false}, + {"name":"70-2-5","left_ms":5600,"chunk_ms":160,"right_ms":400,"lookahead_ms":560,"is_default":false}, + {"name":"70-7-7","left_ms":5600,"chunk_ms":560,"right_ms":560,"lookahead_ms":1120,"is_default":false}, + {"name":"70-13-13","left_ms":5600,"chunk_ms":1040,"right_ms":1040,"lookahead_ms":2080,"is_default":true} + ] + }, + "diarize": {"supported":false}, + "batching": {"supported":true,"verified":true,"note":"batch 2/4/8 byte-equal to serial on CPU and Metal; CUDA batch 8 WER equals batch 1 (Modal L4)"}, + "punctuation": {"supported":true,"verified":true} + }, + "downloads": [ + {"quant":"F32","filename":"nemotron-labs-unified-asr-0.6b-F32.gguf","size_bytes":2506964864}, + {"quant":"F16","filename":"nemotron-labs-unified-asr-0.6b-F16.gguf","size_bytes":1255980928}, + {"quant":"Q8_0","filename":"nemotron-labs-unified-asr-0.6b-Q8_0.gguf","size_bytes":740361088}, + {"quant":"Q6_K","filename":"nemotron-labs-unified-asr-0.6b-Q6_K.gguf","size_bytes":610686848}, + {"quant":"Q5_K_M","filename":"nemotron-labs-unified-asr-0.6b-Q5_K_M.gguf","size_bytes":549012352}, + {"quant":"Q4_K_M","filename":"nemotron-labs-unified-asr-0.6b-Q4_K_M.gguf","size_bytes":485229440} + ], + "accuracy_benchmarks": [ + {"dataset":"librispeech","split":"test-clean","language":"en","language_hint":"en","backend":"cuda","quant":"F32","metric":"wer","err_pct":1.7,"ci95":[1.57,1.84],"n_utts":2620,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":708,"del":100,"ins":91},"empty_hyp":0,"utts_over_50pct":2}, + {"dataset":"librispeech","split":"test-clean","language":"en","language_hint":"en","backend":"cuda","quant":"F16","metric":"wer","err_pct":1.7,"ci95":[1.57,1.84],"n_utts":2620,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":707,"del":101,"ins":92},"empty_hyp":0,"utts_over_50pct":2}, + {"dataset":"librispeech","split":"test-clean","language":"en","language_hint":"en","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":1.69,"ci95":[1.56,1.83],"n_utts":2620,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":703,"del":101,"ins":91},"empty_hyp":0,"utts_over_50pct":2}, + {"dataset":"librispeech","split":"test-clean","language":"en","language_hint":"en","backend":"cuda","quant":"Q6_K","metric":"wer","err_pct":1.7,"ci95":[1.56,1.84],"n_utts":2620,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":704,"del":102,"ins":90},"empty_hyp":0,"utts_over_50pct":2}, + {"dataset":"librispeech","split":"test-clean","language":"en","language_hint":"en","backend":"cuda","quant":"Q5_K_M","metric":"wer","err_pct":1.71,"ci95":[1.57,1.85],"n_utts":2620,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":706,"del":106,"ins":93},"empty_hyp":0,"utts_over_50pct":2}, + {"dataset":"librispeech","split":"test-clean","language":"en","language_hint":"en","backend":"cuda","quant":"Q4_K_M","metric":"wer","err_pct":1.69,"ci95":[1.54,1.83],"n_utts":2620,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":701,"del":105,"ins":87},"empty_hyp":0,"utts_over_50pct":2}, + {"dataset":"fleurs","split":"test","language":"bg","language_hint":"bg","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":11.6,"ci95":[10.84,12.45],"n_utts":658,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":1289,"del":243,"ins":112},"empty_hyp":0,"utts_over_50pct":5}, + {"dataset":"fleurs","split":"test","language":"hr","language_hint":"hr","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":10.44,"ci95":[9.79,11.1],"n_utts":914,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":1459,"del":254,"ins":141},"empty_hyp":0,"utts_over_50pct":2}, + {"dataset":"fleurs","split":"test","language":"cs","language_hint":"cs","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":11.63,"ci95":[10.84,12.47],"n_utts":723,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":1305,"del":173,"ins":114},"empty_hyp":0,"utts_over_50pct":8}, + {"dataset":"fleurs","split":"test","language":"da","language_hint":"da","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":17.89,"ci95":[17.12,18.62],"n_utts":930,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":2853,"del":452,"ins":301},"empty_hyp":1,"utts_over_50pct":26}, + {"dataset":"fleurs","split":"test","language":"nl","language_hint":"nl","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":7.75,"ci95":[6.97,8.49],"n_utts":364,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":496,"del":78,"ins":77},"empty_hyp":0,"utts_over_50pct":0}, + {"dataset":"fleurs","split":"test","language":"en","language_hint":"en","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":4.74,"ci95":[4.33,5.23],"n_utts":647,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":490,"del":141,"ins":56},"empty_hyp":0,"utts_over_50pct":0}, + {"dataset":"fleurs","split":"test","language":"et","language_hint":"et","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":16.59,"ci95":[15.78,17.44],"n_utts":893,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":1772,"del":208,"ins":488},"empty_hyp":0,"utts_over_50pct":17}, + {"dataset":"fleurs","split":"test","language":"fi","language_hint":"fi","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":12.47,"ci95":[11.74,13.27],"n_utts":918,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":1496,"del":188,"ins":161},"empty_hyp":0,"utts_over_50pct":13}, + {"dataset":"fleurs","split":"test","language":"fr","language_hint":"fr","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":6.21,"ci95":[5.62,6.83],"n_utts":676,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":824,"del":157,"ins":136},"empty_hyp":0,"utts_over_50pct":4}, + {"dataset":"fleurs","split":"test","language":"de","language_hint":"de","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":5.32,"ci95":[4.85,5.79],"n_utts":862,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":774,"del":137,"ins":84},"empty_hyp":0,"utts_over_50pct":1}, + {"dataset":"fleurs","split":"test","language":"el","language_hint":"el","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":29.03,"ci95":[27.97,30.02],"n_utts":650,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":4106,"del":223,"ins":75},"empty_hyp":0,"utts_over_50pct":44}, + {"dataset":"fleurs","split":"test","language":"hu","language_hint":"hu","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":16.94,"ci95":[16.2,17.69],"n_utts":905,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":2306,"del":359,"ins":228},"empty_hyp":0,"utts_over_50pct":11}, + {"dataset":"fleurs","split":"test","language":"it","language_hint":"it","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":3.28,"ci95":[2.95,3.63],"n_utts":865,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":533,"del":96,"ins":67},"empty_hyp":0,"utts_over_50pct":0}, + {"dataset":"fleurs","split":"test","language":"lv","language_hint":"lv","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":21.09,"ci95":[20.23,22.01],"n_utts":851,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":2848,"del":188,"ins":216},"empty_hyp":0,"utts_over_50pct":19}, + {"dataset":"fleurs","split":"test","language":"lt","language_hint":"lt","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":19.96,"ci95":[19.2,20.74],"n_utts":986,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":2999,"del":311,"ins":110},"empty_hyp":0,"utts_over_50pct":30}, + {"dataset":"fleurs","split":"test","language":"mt","language_hint":"mt","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":18.28,"ci95":[17.5,19.07],"n_utts":926,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":3237,"del":556,"ins":271},"empty_hyp":0,"utts_over_50pct":14}, + {"dataset":"fleurs","split":"test","language":"pl","language_hint":"pl","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":7.24,"ci95":[6.69,7.81],"n_utts":758,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":880,"del":104,"ins":58},"empty_hyp":0,"utts_over_50pct":2}, + {"dataset":"fleurs","split":"test","language":"pt","language_hint":"pt","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":4.84,"ci95":[4.35,5.35],"n_utts":919,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":730,"del":161,"ins":148},"empty_hyp":0,"utts_over_50pct":3}, + {"dataset":"fleurs","split":"test","language":"ro","language_hint":"ro","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":10.68,"ci95":[10.09,11.33],"n_utts":883,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":1732,"del":354,"ins":135},"empty_hyp":0,"utts_over_50pct":6}, + {"dataset":"fleurs","split":"test","language":"sk","language_hint":"sk","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":9.79,"ci95":[9.05,10.58],"n_utts":792,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":1180,"del":238,"ins":74},"empty_hyp":4,"utts_over_50pct":10}, + {"dataset":"fleurs","split":"test","language":"sl","language_hint":"sl","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":22.63,"ci95":[21.55,23.78],"n_utts":834,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":2948,"del":471,"ins":319},"empty_hyp":0,"utts_over_50pct":52}, + {"dataset":"fleurs","split":"test","language":"es","language_hint":"es","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":3.39,"ci95":[3.07,3.72],"n_utts":908,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":579,"del":133,"ins":78},"empty_hyp":0,"utts_over_50pct":1}, + {"dataset":"fleurs","split":"test","language":"sv","language_hint":"sv","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":15.02,"ci95":[14.2,15.87],"n_utts":759,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":1764,"del":330,"ins":217},"empty_hyp":0,"utts_over_50pct":11}, + {"dataset":"fleurs","split":"test","language":"ru","language_hint":"ru","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":7.15,"ci95":[6.64,7.71],"n_utts":775,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":915,"del":108,"ins":57},"empty_hyp":0,"utts_over_50pct":0}, + {"dataset":"fleurs","split":"test","language":"uk","language_hint":"uk","backend":"cuda","quant":"Q8_0","metric":"wer","err_pct":9.31,"ci95":[8.67,9.95],"n_utts":750,"batch_size":8,"timestamps":"none","engine_sha":"88401d9c","publication_profile":"asr-publication-v2","measured_on":null,"errors":{"sub":1116,"del":146,"ins":76},"empty_hyp":0,"utts_over_50pct":1} + ], + "headline_benchmark": { + "dataset": "librispeech", + "split": "test-clean", + "language": "en", + "metric": "wer", + "batch_size": 8, + "timestamps": "none" + }, + "speed_benchmarks": [ + {"machine":"ryzen-4750u","backend":"cpu","quant":"Q4_K_M","sample":"dots","sample_duration_s":35.332,"total_ms":2454.0,"xrt_compute":14.4,"wall_ms":2481.0,"xrt_wall":14.24,"load_ms":578.2,"mel_ms":14.7,"encode_ms":2034.7,"decode_ms":404.6,"engine_sha":"205af375","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"ryzen-4750u","backend":"cpu","quant":"Q4_K_M","sample":"jfk","sample_duration_s":11.0,"total_ms":704.2,"xrt_compute":15.62,"wall_ms":715.2,"xrt_wall":15.38,"load_ms":375.3,"mel_ms":4.6,"encode_ms":612.6,"decode_ms":87.1,"engine_sha":"205af375","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"ryzen-4750u","backend":"cpu","quant":"Q8_0","sample":"dots","sample_duration_s":35.332,"total_ms":2935.6,"xrt_compute":12.04,"wall_ms":2962.6,"xrt_wall":11.93,"load_ms":368.0,"mel_ms":13.8,"encode_ms":2528.7,"decode_ms":393.2,"engine_sha":"205af375","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"ryzen-4750u","backend":"cpu","quant":"Q8_0","sample":"jfk","sample_duration_s":11.0,"total_ms":786.6,"xrt_compute":13.98,"wall_ms":798.0,"xrt_wall":13.78,"load_ms":375.0,"mel_ms":4.6,"encode_ms":695.9,"decode_ms":86.1,"engine_sha":"205af375","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"ryzen-4750u","backend":"vulkan","quant":"Q4_K_M","sample":"dots","sample_duration_s":35.332,"total_ms":1550.6,"xrt_compute":22.79,"wall_ms":1566.1,"xrt_wall":22.56,"load_ms":255.7,"mel_ms":14.7,"encode_ms":1146.3,"decode_ms":389.6,"engine_sha":"205af375","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"ryzen-4750u","backend":"vulkan","quant":"Q4_K_M","sample":"jfk","sample_duration_s":11.0,"total_ms":483.4,"xrt_compute":22.76,"wall_ms":496.0,"xrt_wall":22.18,"load_ms":257.6,"mel_ms":4.3,"encode_ms":391.8,"decode_ms":87.2,"engine_sha":"205af375","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"ryzen-4750u","backend":"vulkan","quant":"Q8_0","sample":"dots","sample_duration_s":35.332,"total_ms":1494.4,"xrt_compute":23.64,"wall_ms":1509.5,"xrt_wall":23.41,"load_ms":356.1,"mel_ms":14.4,"encode_ms":1090.5,"decode_ms":389.4,"engine_sha":"205af375","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"ryzen-4750u","backend":"vulkan","quant":"Q8_0","sample":"jfk","sample_duration_s":11.0,"total_ms":456.4,"xrt_compute":24.1,"wall_ms":468.9,"xrt_wall":23.46,"load_ms":365.2,"mel_ms":4.0,"encode_ms":364.8,"decode_ms":87.6,"engine_sha":"205af375","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m1","backend":"cpu","quant":"Q4_K_M","sample":"dots","sample_duration_s":35.332,"total_ms":2788.4,"xrt_compute":12.67,"wall_ms":2793.6,"xrt_wall":12.65,"load_ms":7695.4,"mel_ms":3.6,"encode_ms":2377.0,"decode_ms":407.8,"engine_sha":"c19938cd","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m1","backend":"cpu","quant":"Q4_K_M","sample":"jfk","sample_duration_s":11.0,"total_ms":881.2,"xrt_compute":12.48,"wall_ms":883.5,"xrt_wall":12.45,"load_ms":116.1,"mel_ms":1.3,"encode_ms":775.8,"decode_ms":104.2,"engine_sha":"c19938cd","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m1","backend":"cpu","quant":"Q8_0","sample":"dots","sample_duration_s":35.332,"total_ms":2618.9,"xrt_compute":13.49,"wall_ms":2624.8,"xrt_wall":13.46,"load_ms":318.5,"mel_ms":4.2,"encode_ms":2209.4,"decode_ms":405.2,"engine_sha":"c19938cd","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m1","backend":"cpu","quant":"Q8_0","sample":"jfk","sample_duration_s":11.0,"total_ms":957.8,"xrt_compute":11.48,"wall_ms":959.9,"xrt_wall":11.46,"load_ms":119.4,"mel_ms":1.2,"encode_ms":871.5,"decode_ms":85.2,"engine_sha":"c19938cd","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m1","backend":"metal","quant":"Q4_K_M","sample":"dots","sample_duration_s":35.332,"total_ms":1056.2,"xrt_compute":33.45,"wall_ms":1069.1,"xrt_wall":33.05,"load_ms":100.1,"mel_ms":3.5,"encode_ms":681.4,"decode_ms":371.3,"engine_sha":"c19938cd","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m1","backend":"metal","quant":"Q4_K_M","sample":"jfk","sample_duration_s":11.0,"total_ms":328.5,"xrt_compute":33.49,"wall_ms":334.9,"xrt_wall":32.85,"load_ms":64.9,"mel_ms":1.2,"encode_ms":209.6,"decode_ms":117.7,"engine_sha":"c19938cd","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m1","backend":"metal","quant":"Q8_0","sample":"dots","sample_duration_s":35.332,"total_ms":1050.3,"xrt_compute":33.64,"wall_ms":1066.9,"xrt_wall":33.12,"load_ms":67.6,"mel_ms":3.5,"encode_ms":648.7,"decode_ms":398.1,"engine_sha":"c19938cd","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m1","backend":"metal","quant":"Q8_0","sample":"jfk","sample_duration_s":11.0,"total_ms":304.3,"xrt_compute":36.15,"wall_ms":310.6,"xrt_wall":35.41,"load_ms":68.7,"mel_ms":1.2,"encode_ms":197.8,"decode_ms":105.3,"engine_sha":"c19938cd","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m4-max","backend":"cpu","quant":"Q4_K_M","sample":"dots","sample_duration_s":35.332,"total_ms":913.3,"xrt_compute":38.69,"wall_ms":916.5,"xrt_wall":38.55,"load_ms":192.1,"mel_ms":2.1,"encode_ms":857.7,"decode_ms":53.5,"engine_sha":"049e0c13","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m4-max","backend":"cpu","quant":"Q4_K_M","sample":"jfk","sample_duration_s":11.0,"total_ms":269.4,"xrt_compute":40.83,"wall_ms":271.0,"xrt_wall":40.59,"load_ms":84.6,"mel_ms":0.796,"encode_ms":256.3,"decode_ms":12.3,"engine_sha":"049e0c13","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m4-max","backend":"cpu","quant":"Q8_0","sample":"dots","sample_duration_s":35.332,"total_ms":728.6,"xrt_compute":48.5,"wall_ms":731.8,"xrt_wall":48.28,"load_ms":192.9,"mel_ms":2.1,"encode_ms":672.6,"decode_ms":53.8,"engine_sha":"049e0c13","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m4-max","backend":"cpu","quant":"Q8_0","sample":"jfk","sample_duration_s":11.0,"total_ms":216.4,"xrt_compute":50.82,"wall_ms":218.1,"xrt_wall":50.44,"load_ms":87.0,"mel_ms":0.784,"encode_ms":203.2,"decode_ms":12.5,"engine_sha":"049e0c13","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m4-max","backend":"metal","quant":"Q4_K_M","sample":"dots","sample_duration_s":35.332,"total_ms":167.4,"xrt_compute":211.11,"wall_ms":175.2,"xrt_wall":201.72,"load_ms":45.5,"mel_ms":2.2,"encode_ms":111.5,"decode_ms":53.7,"engine_sha":"049e0c13","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m4-max","backend":"metal","quant":"Q4_K_M","sample":"jfk","sample_duration_s":11.0,"total_ms":57.3,"xrt_compute":192.09,"wall_ms":62.0,"xrt_wall":177.39,"load_ms":48.0,"mel_ms":0.793,"encode_ms":43.9,"decode_ms":12.5,"engine_sha":"049e0c13","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m4-max","backend":"metal","quant":"Q8_0","sample":"dots","sample_duration_s":35.332,"total_ms":164.2,"xrt_compute":215.2,"wall_ms":171.9,"xrt_wall":205.55,"load_ms":49.8,"mel_ms":2.1,"encode_ms":108.6,"decode_ms":53.5,"engine_sha":"049e0c13","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null}, + {"machine":"m4-max","backend":"metal","quant":"Q8_0","sample":"jfk","sample_duration_s":11.0,"total_ms":56.2,"xrt_compute":195.67,"wall_ms":60.8,"xrt_wall":181.05,"load_ms":46.9,"mel_ms":0.807,"encode_ms":42.9,"decode_ms":12.5,"engine_sha":"049e0c13","publication_profile":"asr-publication-v2","measured_on":"2026-12-03","thermal_gated":null} + ] +} diff --git a/docs/environment-variables.md b/docs/environment-variables.md index c5d66463a..d90d03010 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -36,6 +36,7 @@ of tests. | `TRANSCRIBE_DUMP_DIR=` | Enable the per-stage tensor dumper; writes `.f32` + `.json` per dumped tensor into ``. The basis for the numerical-comparison harness (`scripts/compare_tensors.py`). | | `TRANSCRIBE_PERF_DEBUG` | Print a per-stage timing breakdown to stderr (DEBUG log) on the families that profile (`cohere`, `granite`, `canary`, `canary_qwen`, `moonshine`, `moonshine_streaming`, `moss`, `qwen3_asr`, `whisper`). For whisper, a value containing `cpu` or `all` additionally prints the CPU sub-section breakdown. | | `TRANSCRIBE_VOXTRAL_REALTIME_STREAM_TIMING` | Print a per-component streaming wall-time breakdown at stream finalize (voxtral_realtime). | +| `TRANSCRIBE_PARAKEET_FULL_ATTENTION_MAX_S=` | Offline full-attention limit for the unified parakeet checkpoints (`parakeet-unified-en-0.6b`, `nemotron-labs-unified-asr-0.6b`), default 120. Longer clips run the `[256, 256]` local window. `0` windows every clip longer than 20.5 s. Read at each run; streaming is unaffected. | | `TRANSCRIBE_MOONSHINE_STREAMING_ENC_WINDOW=` | Encoder frames emitted per window by the moonshine_streaming one-shot / batch encoder (default 1024, ~20 s). Windowing bounds encoder memory; it is mathematically exact (each window carries the full sliding-window context) and float-level differences stay at the backend's reduction-order noise. Set small to exercise the windowed path on short clips. Read at each run. | | `TRANSCRIBE_TEST_DEV_INIT_THROW=` | Fault injection: backend device init (`ggml_backend_dev_init`) throws for devices whose name contains `` (`*` matches every device). Exercises throw → skip → CPU-fallback in backend probing; an explicit backend request fails with `TRANSCRIBE_ERR_BACKEND`. Used by `backend_init_throw_unit` and `scripts/ci/vulkan_degradation_check.py`. | | `TRANSCRIBE_TEST_TEARDOWN_THROW` | Fault injection: any non-empty value injects a throw after each real free inside the `transcribe::safe_*` teardown wrappers, proving containment without leaking the handle. Used by `teardown_safety_unit`. | @@ -87,7 +88,8 @@ its var is unset. Convention: `TRANSCRIBE__GGUF`. | Variable | Test(s) | | --- | --- | | `TRANSCRIBE_PARAKEET_GGUF` | `parakeet_real_smoke`, `decoder_smoke` | -| `TRANSCRIBE_PARAKEET_UNIFIED_GGUF` | `parakeet_buffered_stream_eos_smoke`, `stream_offline_interleave_smoke` | +| `TRANSCRIBE_PARAKEET_UNIFIED_GGUF` | `parakeet_buffered_stream_eos_smoke`, `stream_offline_interleave_smoke`, `parakeet_unified_real_smoke` | +| `TRANSCRIBE_SENSEVOICE_GGUF` | `sensevoice_language_gate_smoke` | | `TRANSCRIBE_GIGAAM_GGUF` | `gigaam_workspace_release_smoke` | | `TRANSCRIBE_GIGAAM_V4_GGUF` | `gigaam_v4_e2e_smoke` | | `TRANSCRIBE_MULTITALKER_BUNDLE_GGUF` | `parakeet_multitalker_e2e_smoke` | diff --git a/docs/models/nemotron-labs-unified-asr-0.6b.md b/docs/models/nemotron-labs-unified-asr-0.6b.md new file mode 100644 index 000000000..cbff097ea --- /dev/null +++ b/docs/models/nemotron-labs-unified-asr-0.6b.md @@ -0,0 +1,338 @@ +# Nemotron Labs Unified ASR 0.6B + + +Upstream: [`nvidia/nemotron-labs-unified-asr-0.6b`](https://huggingface.co/nvidia/nemotron-labs-unified-asr-0.6b) at [`023ce90`](https://huggingface.co/nvidia/nemotron-labs-unified-asr-0.6b/commit/023ce90). + +Multilingual speech-to-text covering 25 European languages, with punctuation and capitalization. A FastConformer encoder with a language-prompt-conditioned RNN-T decoder, trained as a unified streaming/offline model. The source language is selected per call (--language de, fr, ...) or left to the model (auto). This port runs both offline and buffered streaming modes. Does not translate. + + +## What it's for + +Multilingual speech-to-text covering 25 European languages with greedy +RNN-T decoding. Outputs cased, punctuated transcripts. Token- and +word-level timestamps are available. + +The model is NVIDIA's multilingual counterpart to +[parakeet-unified-en-0.6b](parakeet-unified-en-0.6b.md). The encoder +output is concatenated with a one-hot language prompt and projected +before the joint, so the source language is selected per call +(`--language de`). Without a hint, or with `--language auto`, the model +uses its language-agnostic prompt. + +This port runs the model in both **offline** and **buffered streaming** +modes from the same GGUF weights: + +- Offline (`transcribe_run`): full attention over the whole clip up to + 120 s, as NeMo does; longer clips run the `[256, 256]` local-attention + window. See [Input limits](#input-limits). +- Streaming (`transcribe_stream_{begin,feed,finalize}` / + `transcribe-cli --stream-chunk-ms N --stream-buf-{left,chunk,right}-ms N`): + the same buffered `[left | chunk | right]` driver as + parakeet-unified-en-0.6b, with the language prompt applied to every + chunk. Lookahead latency ranges from 160 ms to 2.08 s. See + [Streaming](#streaming). + +See NVIDIA's [model card](https://huggingface.co/nvidia/nemotron-labs-unified-asr-0.6b) +for training data, intended use, and upstream evaluation results. + + +Licensed OpenMDW-1.1. Ported from upstream commit [`023ce90`](https://huggingface.co/nvidia/nemotron-labs-unified-asr-0.6b/commit/023ce90), pinned 2026-11-29. Validated against the NeMo reference at transcribe.cpp commit [`c19938cd`](https://github.com/handy-computer/transcribe.cpp/tree/c19938cd) on 2026-12-03. + + +## Input limits + +No practical per-call length limit (`transcribe_capabilities.max_audio_ms == 0`). +Offline clips up to 120 s run full attention and match NeMo's offline +output; longer clips switch to the `[256, 256]` local-attention window +(about ±20 s of context), and an INFO log line records the switch. +Encoder time under full attention grows quadratically with length; the +window keeps it linear. On long-form sets the window matches NeMo's own +`[256, 256]` run (TED-LIUM 3.44% vs 3.46%, Earnings-22 16.19% vs 16.19%) +and is as accurate as full attention. `TRANSCRIBE_PARAKEET_FULL_ATTENTION_MAX_S` +moves the limit. Streaming is unaffected. See the +[input-length contract](../input-limits.md). + +## Download + +Q8_0 matches F32 on every FLEURS language. Mean FLEURS WER over the 25 +languages, against a 12.13% NeMo reference: F16 12.13%, Q8_0 12.12%, +Q6_K 12.18%, Q5_K_M 12.22%, Q4_K_M 12.58%. Q4_K_M loses most in +Lithuanian, Hungarian, Latvian and Slovenian (about +0.9 pp) and is +unchanged on English. + + +| Quantization | Download | Size | WER (LibriSpeech test-clean) | +| --- | --- | ---: | ---: | +| F32 | [nemotron-labs-unified-asr-0.6b-F32.gguf](https://huggingface.co/handy-computer/nemotron-labs-unified-asr-0.6b-gguf/resolve/main/nemotron-labs-unified-asr-0.6b-F32.gguf) | 2.51 GB | 1.70% | +| F16 | [nemotron-labs-unified-asr-0.6b-F16.gguf](https://huggingface.co/handy-computer/nemotron-labs-unified-asr-0.6b-gguf/resolve/main/nemotron-labs-unified-asr-0.6b-F16.gguf) | 1.26 GB | 1.70% | +| Q8_0 | [nemotron-labs-unified-asr-0.6b-Q8_0.gguf](https://huggingface.co/handy-computer/nemotron-labs-unified-asr-0.6b-gguf/resolve/main/nemotron-labs-unified-asr-0.6b-Q8_0.gguf) | 740 MB | 1.69% | +| Q6_K | [nemotron-labs-unified-asr-0.6b-Q6_K.gguf](https://huggingface.co/handy-computer/nemotron-labs-unified-asr-0.6b-gguf/resolve/main/nemotron-labs-unified-asr-0.6b-Q6_K.gguf) | 611 MB | 1.70% | +| Q5_K_M | [nemotron-labs-unified-asr-0.6b-Q5_K_M.gguf](https://huggingface.co/handy-computer/nemotron-labs-unified-asr-0.6b-gguf/resolve/main/nemotron-labs-unified-asr-0.6b-Q5_K_M.gguf) | 549 MB | 1.71% | +| Q4_K_M | [nemotron-labs-unified-asr-0.6b-Q4_K_M.gguf](https://huggingface.co/handy-computer/nemotron-labs-unified-asr-0.6b-gguf/resolve/main/nemotron-labs-unified-asr-0.6b-Q4_K_M.gguf) | 485 MB | 1.69% | + + + +WER on the full LibriSpeech test-clean split (2,620 utterances), batch size 8, timestamps none, language hint `en`, decoded on cuda. Measured at transcribe.cpp `88401d9c`. + + + +Greedy RNN-T decoding, no external LM. NeMo reference baseline on the same +manifest: 1.70%. NVIDIA's self-reported number on the same split is 1.38%; it is +scored with the Open ASR Leaderboard normalizer, which counts joined and split +compounds as matches, and the same NeMo output scores 1.38% under it. + + +FLEURS test, language given: + + +**FLEURS test** + +| Language | Metric | Q8_0 | +| --- | --- | ---: | +| bg | WER | 11.60% | +| cs | WER | 11.63% | +| da | WER | 17.89% | +| de | WER | 5.32% | +| el | WER | 29.03% | +| en | WER | 4.74% | +| es | WER | 3.39% | +| et | WER | 16.59% | +| fi | WER | 12.47% | +| fr | WER | 6.21% | +| hr | WER | 10.44% | +| hu | WER | 16.94% | +| it | WER | 3.28% | +| lt | WER | 19.96% | +| lv | WER | 21.09% | +| mt | WER | 18.28% | +| nl | WER | 7.75% | +| pl | WER | 7.24% | +| pt | WER | 4.84% | +| ro | WER | 10.68% | +| ru | WER | 7.15% | +| sk | WER | 9.79% | +| sl | WER | 22.63% | +| sv | WER | 15.02% | +| uk | WER | 9.31% | + + +## Quick Start + +```bash +cmake -B build +cmake --build build + +build/bin/transcribe-cli \ + -m models/nemotron-labs-unified-asr-0.6b/nemotron-labs-unified-asr-0.6b-Q8_0.gguf \ + --language fr \ + samples/fleurs-fr.wav +``` + +If your audio is not already 16 kHz mono WAV, convert it first: + +```bash +ffmpeg -i input.mp3 -ar 16000 -ac 1 output.wav +``` + +## Performance + +### Apple M4 Max + + +Compute latency (mel + encode + decode), speedup over realtime in parentheses; profile `asr-publication-v2`: mean over 3 iterations after 1 warmup. + +| Backend | Sample | Q8_0 | Q4_K_M | +| ------- | ------------ | ---------------: | ---------------: | +| Metal | jfk (11.0s) | 56 ms (195.67×) | 57 ms (192.09×) | +| Metal | dots (35.3s) | 164 ms (215.20×) | 167 ms (211.11×) | +| CPU | jfk (11.0s) | 216 ms (50.82×) | 269 ms (40.83×) | +| CPU | dots (35.3s) | 729 ms (48.50×) | 913 ms (38.69×) | + +Apple M4 Max: transcribe.cpp `049e0c13` on 2026-12-03. + + +### AMD Ryzen 7 4750U Pro + + +Compute latency (mel + encode + decode), speedup over realtime in parentheses; profile `asr-publication-v2`: mean over 3 iterations after 1 warmup. + +| Backend | Sample | Q8_0 | Q4_K_M | +| ------- | ------------ | --------------: | --------------: | +| Vulkan | jfk (11.0s) | 456 ms (24.10×) | 483 ms (22.76×) | +| Vulkan | dots (35.3s) | 1.49 s (23.64×) | 1.55 s (22.79×) | +| CPU | jfk (11.0s) | 787 ms (13.98×) | 704 ms (15.62×) | +| CPU | dots (35.3s) | 2.94 s (12.04×) | 2.45 s (14.40×) | + +AMD Ryzen 7 PRO 4750U (Radeon RADV RENOIR): transcribe.cpp `205af375` on 2026-12-03. + + +### Apple M1 + +No base Apple M4 was available; the Apple M1 stands in for it. + + +Compute latency (mel + encode + decode), speedup over realtime in parentheses; profile `asr-publication-v2`: mean over 3 iterations after 1 warmup. + +| Backend | Sample | Q8_0 | Q4_K_M | +| ------- | ------------ | --------------: | --------------: | +| Metal | jfk (11.0s) | 304 ms (36.15×) | 328 ms (33.49×) | +| Metal | dots (35.3s) | 1.05 s (33.64×) | 1.06 s (33.45×) | +| CPU | jfk (11.0s) | 958 ms (11.48×) | 881 ms (12.48×) | +| CPU | dots (35.3s) | 2.62 s (13.49×) | 2.79 s (12.67×) | + +Apple M1 (stand-in for the base Apple M4): transcribe.cpp `c19938cd` on 2026-12-03. + + +Benchmark reproduction: + +```bash +uv run scripts/bench/run.py --profile --models nemotron-labs-unified-asr-0.6b +``` + +## Numerical Validation + +transcribe.cpp is validated tensor-by-tensor against NeMo on +`samples/jfk.wav`, `fleurs-fr.wav`, `fleurs-es.wav` and +`ru-long-padded.wav` (33.9 s, padded so both sides produce 424 encoder +frames) via `scripts/validate.py`. All compared tensors fall within +tolerance and every transcript matches the reference verbatim. + +| Field | Value | +| --- | --- | +| Reference | NeMo, `nvidia/nemotron-labs-unified-asr-0.6b` | +| Dump script | `scripts/dump_reference_parakeet_nemo.py` | +| Manifest | `tests/golden/parakeet/nemotron-labs-unified-asr-0.6b.manifest.json` | +| Command | `uv run scripts/validate.py all --family parakeet --variant nemotron-labs-unified-asr-0.6b` | + +Tensor dumps come from the in-tree NeMo 2.8 environment +(`scripts/envs/parakeet`). Stock NeMo 3.1, the release that produced the +checkpoint, agrees with it to 2.7e-5 on the encoder output and gives +identical LibriSpeech transcripts. + +On FLEURS the F32 GGUF is within ±0.04 pp of NeMo in all 25 languages, +with the language given and in `auto` mode. + +## Streaming + +Buffered streaming reuses the parakeet-unified-en-0.6b driver; see +[its Streaming section](parakeet-unified-en-0.6b.md#streaming) for the +chunk geometry and end-of-stream handling. The language prompt is +applied to the whole `[left | chunk | right]` window on every chunk, as +in NeMo's `speech_to_text_streaming_infer_rnnt.py`. + +The runtime `(L, C, R)` is set with `--stream-buf-left-ms`, +`--stream-buf-chunk-ms` and `--stream-buf-right-ms` (library: +`transcribe_parakeet_buffered_stream_ext`), in multiples of the 80 ms +encoder frame. The training menu is `L ∈ {70}`, `C ∈ {1, 2, 7, 13}`, +`R ∈ {0, 1, 2, 3, 4, 7, 13}` frames, and the default is `(70, 13, 13)`. +Any tuple with `C >= 1` and `L, R >= 0` frames runs; an off-menu tuple +is logged at INFO level. A window longer than 120 s is rejected. + +NVIDIA's recommended settings: + +| `(L, C, R)` frames | `(left, chunk, right)` | Lookahead latency | +| ------------------ | ---------------------- | ----------------: | +| `(70, 13, 13)` | `5.60 / 1.04 / 1.04 s` | 2.08 s (default) | +| `(70, 7, 7)` | `5.60 / 0.56 / 0.56 s` | 1.12 s | +| `(70, 2, 5)` | `5.60 / 0.16 / 0.40 s` | 560ms | +| `(70, 1, 3)` | `5.60 / 0.08 / 0.24 s` | 320ms | +| `(70, 1, 2)` | `5.60 / 0.08 / 0.16 s` | 240ms | +| `(70, 1, 1)` | `5.60 / 0.08 / 0.08 s` | 160ms | + +`(70, 2, 5)` is outside the training menu; NeMo's buffered loop accepts +it, and so does this port. + +```bash +build/bin/transcribe-cli \ + -m models/nemotron-labs-unified-asr-0.6b/nemotron-labs-unified-asr-0.6b-Q8_0.gguf \ + --language fr --stream-chunk-ms 560 \ + --stream-buf-left-ms 5600 --stream-buf-chunk-ms 560 --stream-buf-right-ms 560 \ + samples/fleurs-fr.wav +``` + +Per-chunk parity against NeMo holds on `jfk`, `fleurs-fr` and +`fleurs-es` at `(70, 13, 13)`, `(70, 7, 7)`, `(70, 2, 5)` and +`(70, 1, 1)`: bit-exact `audio_in` windows, encoder output within +tolerance, and equal transcripts apart from a trailing period from the +end-of-stream handling. WER at `(70, 7, 7)`, F32: + +| Set | NeMo | transcribe.cpp | +| --- | ---: | ---: | +| LibriSpeech test-clean, 512 utterances | 1.36% | 1.40% | +| FLEURS fr, 256 utterances | 8.09% | 8.32% | + +The differences are end-of-stream punctuation and one casing change. + +Pass the language when streaming at low latency: the first chunks carry +too little speech for `auto` to identify it. + +## Capabilities + +- **Languages:** `bg`, `cs`, `da`, `de`, `el`, `en`, `es`, `et`, `fi`, + `fr`, `hr`, `hu`, `it`, `lt`, `lv`, `mt`, `nl`, `pl`, `pt`, `ro`, `ru`, + `sk`, `sl`, `sv`, `uk`, selected via `--language `. Region forms + that map to the same prompt as an advertised code (`en-US`, `fr-FR`, + `de-DE`, ...) are accepted but not advertised. The checkpoint carries + NeMo's 118-entry prompt dictionary, but only the 25 languages and + `auto` have trained prompts; other entries (`es-ES`, `en-GB`, `pt-BR`, + `fr-CA`, ...) return `TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE`. +- **Language detection:** `auto` (or no hint) selects the + language-agnostic prompt. The model emits no language tag, so + `transcribe_detected_language` stays empty. +- **Punctuation & capitalization:** native (PnC). +- **Timestamps:** token- and word-level. Word times match NeMo's + `transcribe(..., timestamps=True)` on `jfk`, `fleurs-fr` and + `fleurs-es` (63/63 words, 0 ms difference). +- **Streaming:** buffered, see [Streaming](#streaming). +- **Batching:** `transcribe_run_batch` text equals the serial path on + CPU and Metal (F32, F16) and gives the same WER on CUDA. +- **Translation / diarization / VAD:** not supported. + +## Known limitations + +- `auto` mode is weaker on Greek and Cyrillic. On FLEURS it returns empty + transcripts for some clips (el 20, ru 10, bg 6, uk 4) and writes part + of the Greek output in Latin script; NeMo behaves the same. Mean FLEURS + WER rises from 12.13% to 13.24%, and Greek from 29.1% to 45.5%. Pass + the language for these. +- The tokenizer has no final sigma (ς), so every Greek word ending in it + is scored as an error. Ignoring the final sigma would roughly halve the + Greek WER. +- Published latency numbers cover the offline path. On the Ryzen 7 PRO + 4750U, Q8_0 streams at 2.5× realtime on CPU and 4.3× on Vulkan at + `(70, 13, 13)`, and 1.5× / 2.4× at `(70, 7, 7)`; every chunk re-encodes + the 5.6 s left context. + +## Reproduction + +### Convert + +The converter downloads the `.nemo` at the profile's pinned revision. + +```bash +uv run --project scripts/envs/parakeet \ + scripts/convert-parakeet.py nvidia/nemotron-labs-unified-asr-0.6b +``` + +### Quantize + +```bash +build/bin/transcribe-quantize \ + models/nemotron-labs-unified-asr-0.6b/nemotron-labs-unified-asr-0.6b-F32.gguf \ + models/nemotron-labs-unified-asr-0.6b/nemotron-labs-unified-asr-0.6b-Q8_0.gguf \ + --quant Q8_0 +``` + +### Validate + +Pass the pinned `.nemo` with `--model`; a bare repo id resolves the +default branch. + +```bash +hf download nvidia/nemotron-labs-unified-asr-0.6b nemotron-labs-unified-asr-0.6b.nemo \ + --revision 023ce907267a09a308a5cb69239447cb3d0c1597 \ + --local-dir ./upstream-nemotron-labs-unified-asr-0.6b + +uv run scripts/validate.py all --family parakeet --variant nemotron-labs-unified-asr-0.6b \ + --model ./upstream-nemotron-labs-unified-asr-0.6b/nemotron-labs-unified-asr-0.6b.nemo +``` diff --git a/docs/models/parakeet-unified-en-0.6b.md b/docs/models/parakeet-unified-en-0.6b.md index 7618ef3a0..140b7aba8 100644 --- a/docs/models/parakeet-unified-en-0.6b.md +++ b/docs/models/parakeet-unified-en-0.6b.md @@ -14,18 +14,22 @@ punctuated transcripts. Token- and word-level timestamps are available. This port runs the model in both **offline** and **buffered streaming** modes from the same GGUF weights: -- Offline (`transcribe_run`): the full audio is consumed in one pass - with full attention. +- Offline (`transcribe_run`): full attention over the whole clip up to + 120 s, as NeMo does; longer clips run the `[256, 256]` local-attention + window, which matches NeMo's own window run and is as accurate as full + attention on TED-LIUM and Earnings-22. + `TRANSCRIBE_PARAKEET_FULL_ATTENTION_MAX_S` moves the limit. - Streaming (`transcribe_stream_{begin,feed,finalize}` / `transcribe-cli --stream-chunk-ms N --stream-buf-{left,chunk,right}-ms N`): per-chunk encoder forward passes over a sliding `[left | chunk | right]` PCM window with the `chunked_limited_with_rc` 3-tuple attention mask, plus an RNN-T-state-carrying greedy decoder across - chunks. The runtime `(L, C, R)` tuple is selected at `stream_begin` - from the model's training menu (`L ∈ {70}`, `C ∈ {1, 2, 7, 13}`, + chunks. The runtime `(L, C, R)` tuple is selected at `stream_begin`. + The model's training menu (`L ∈ {70}`, `C ∈ {1, 2, 7, 13}`, `R ∈ {0, 1, 2, 3, 4, 7, 13}` encoder frames at the 80ms - post-subsample rate). All six published `(L, C, R)` configurations - are supported; see the [Streaming](#streaming) section below for + post-subsample rate) supplies the default; any other tuple with + `C >= 1` and `L, R >= 0` frames also runs. All six published + `(L, C, R)` configurations are supported; see the [Streaming](#streaming) section below for the WER and per-chunk latency of each. Default is `(70, 13, 13)` = `5.6s / 1.04s / 1.04s` (2.08s lookahead) — the highest-accuracy tuple and the row NVIDIA reports the model card's streaming WER for. @@ -142,7 +146,8 @@ attenuation through the encoder). ## Streaming Buffered streaming is supported for all six published `(L, C, R)` -configurations from the model's training menu. The cpp driver +configurations from the model's training menu, and for any other tuple +with `C >= 1` and `L, R >= 0` frames up to a 120 s window. The cpp driver reproduces NeMo's reference inference loop (`speech_to_text_streaming_infer_rnnt.py`) per-chunk: identical chunk geometry, bit-exact `audio_in` windows, and the same @@ -165,7 +170,9 @@ words on naturally ending clips. The runtime `(L, C, R)` is set via `--stream-buf-left-ms / --stream-buf-chunk-ms / --stream-buf-right-ms` (multiples of the -80ms post-subsample frame). Per-chunk lookahead latency is +80ms post-subsample frame; the chunk must be at least one frame). +Tuples outside the training menu, such as `(70, 2, 5)` (560ms), run and +are logged at INFO level. Per-chunk lookahead latency is `chunk + right` — the audio you must buffer before the chunk's tokens can be emitted. diff --git a/docs/models/parakeet.md b/docs/models/parakeet.md index 8599c232f..a9f742d8f 100644 --- a/docs/models/parakeet.md +++ b/docs/models/parakeet.md @@ -7,8 +7,8 @@ head), classical RNN-T, or CTC — and a TDT+CTC hybrid that ships both heads in one checkpoint. All variants take 16 kHz mono PCM through a mel frontend; English-only across the family, except `parakeet-tdt-0.6b-v3`, Moondream's post-trained `parakeet-ultra`, Oruk's -retune `orukeet` and the German fine-tune `parakeet-primeline`, which -cover 25 European languages. +retune `orukeet`, the German fine-tune `parakeet-primeline` and +`nemotron-labs-unified-asr-0.6b`, which cover 25 European languages. For the architecture deep-dive, validation contract, and porting notes, see the family doc at @@ -62,23 +62,24 @@ WER is on LibriSpeech test-clean for the **Q8_0** preset, measured by transcribe.cpp's WER pipeline. See each per-variant doc for the full quant matrix and the comparison to NVIDIA's self-reported numbers. - -| Variant | Params | Languages | Q8_0 size | Benchmark | Q8_0 | Capabilities | Doc | + +| Variant | Params | Languages | Q8_0 size | Benchmark | Q8_0 | Capabilities | Doc | | --- | ---: | --- | ---: | --- | ---: | --- | --- | -| `parakeet-tdt-0.6b-v2` | 618M | en | 730 MB | LibriSpeech test-clean (WER) | 1.69% | token timestamps | [parakeet-tdt-0.6b-v2.md](parakeet-tdt-0.6b-v2.md) | -| `parakeet-ultra` | 627M | 25 languages + auto-detect | 740 MB | LibriSpeech test-clean (WER) | 1.80% | token timestamps | [parakeet-ultra.md](parakeet-ultra.md) | -| `parakeet-tdt-0.6b-v3` | 627M | 25 languages + auto-detect | 740 MB | LibriSpeech test-clean (WER) | 1.94% | token timestamps | [parakeet-tdt-0.6b-v3.md](parakeet-tdt-0.6b-v3.md) | -| `orukeet` | 627M | 25 languages + auto-detect | 740 MB | LibriSpeech test-clean (WER) | 1.86% | token timestamps | [orukeet.md](orukeet.md) | -| `phonon-2` | 627M | en | 740 MB | LibriSpeech test-clean (WER) | 2.15% | token timestamps | [phonon-2.md](phonon-2.md) | -| `parakeet-primeline` | 627M | 25 languages + auto-detect | 740 MB | FLEURS de (WER) | 5.98% | token timestamps | [parakeet-primeline.md](parakeet-primeline.md) | -| `parakeet-tdt-1.1b` | 1.1B | en | 1.27 GB | LibriSpeech test-clean (WER) | 1.38% | token timestamps | [parakeet-tdt-1.1b.md](parakeet-tdt-1.1b.md) | -| `parakeet-tdt_ctc-110m` | 114M | en | 135 MB | LibriSpeech test-clean (WER) | 2.43% | token timestamps | [parakeet-tdt_ctc-110m.md](parakeet-tdt_ctc-110m.md) | -| `parakeet-tdt_ctc-1.1b` | 1.1B | en | 1.27 GB | LibriSpeech test-clean (WER) | 1.87% | token timestamps | [parakeet-tdt_ctc-1.1b.md](parakeet-tdt_ctc-1.1b.md) | -| `parakeet-rnnt-0.6b` | 617M | en | 730 MB | LibriSpeech test-clean (WER) | 1.62% | token timestamps | [parakeet-rnnt-0.6b.md](parakeet-rnnt-0.6b.md) | -| `parakeet-rnnt-1.1b` | 1.1B | en | 1.27 GB | LibriSpeech test-clean (WER) | 1.46% | token timestamps | [parakeet-rnnt-1.1b.md](parakeet-rnnt-1.1b.md) | -| `parakeet-ctc-0.6b` | 609M | en | 722 MB | LibriSpeech test-clean (WER) | 1.87% | token timestamps | [parakeet-ctc-0.6b.md](parakeet-ctc-0.6b.md) | -| `parakeet-ctc-1.1b` | 1.1B | en | 1.26 GB | LibriSpeech test-clean (WER) | 1.85% | token timestamps | [parakeet-ctc-1.1b.md](parakeet-ctc-1.1b.md) | -| `parakeet-unified-en-0.6b` | 618M | en | 731 MB | LibriSpeech test-clean (WER) | 1.60% | streaming, token timestamps | [parakeet-unified-en-0.6b.md](parakeet-unified-en-0.6b.md) | +| `parakeet-tdt-0.6b-v2` | 618M | en | 730 MB | LibriSpeech test-clean (WER) | 1.69% | token timestamps | [parakeet-tdt-0.6b-v2.md](parakeet-tdt-0.6b-v2.md) | +| `parakeet-ultra` | 627M | 25 languages + auto-detect | 740 MB | LibriSpeech test-clean (WER) | 1.80% | token timestamps | [parakeet-ultra.md](parakeet-ultra.md) | +| `parakeet-tdt-0.6b-v3` | 627M | 25 languages + auto-detect | 740 MB | LibriSpeech test-clean (WER) | 1.94% | token timestamps | [parakeet-tdt-0.6b-v3.md](parakeet-tdt-0.6b-v3.md) | +| `orukeet` | 627M | 25 languages + auto-detect | 740 MB | LibriSpeech test-clean (WER) | 1.86% | token timestamps | [orukeet.md](orukeet.md) | +| `phonon-2` | 627M | en | 740 MB | LibriSpeech test-clean (WER) | 2.15% | token timestamps | [phonon-2.md](phonon-2.md) | +| `parakeet-primeline` | 627M | 25 languages + auto-detect | 740 MB | FLEURS de (WER) | 5.98% | token timestamps | [parakeet-primeline.md](parakeet-primeline.md) | +| `parakeet-tdt-1.1b` | 1.1B | en | 1.27 GB | LibriSpeech test-clean (WER) | 1.38% | token timestamps | [parakeet-tdt-1.1b.md](parakeet-tdt-1.1b.md) | +| `parakeet-tdt_ctc-110m` | 114M | en | 135 MB | LibriSpeech test-clean (WER) | 2.43% | token timestamps | [parakeet-tdt_ctc-110m.md](parakeet-tdt_ctc-110m.md) | +| `parakeet-tdt_ctc-1.1b` | 1.1B | en | 1.27 GB | LibriSpeech test-clean (WER) | 1.87% | token timestamps | [parakeet-tdt_ctc-1.1b.md](parakeet-tdt_ctc-1.1b.md) | +| `parakeet-rnnt-0.6b` | 617M | en | 730 MB | LibriSpeech test-clean (WER) | 1.62% | token timestamps | [parakeet-rnnt-0.6b.md](parakeet-rnnt-0.6b.md) | +| `parakeet-rnnt-1.1b` | 1.1B | en | 1.27 GB | LibriSpeech test-clean (WER) | 1.46% | token timestamps | [parakeet-rnnt-1.1b.md](parakeet-rnnt-1.1b.md) | +| `parakeet-ctc-0.6b` | 609M | en | 722 MB | LibriSpeech test-clean (WER) | 1.87% | token timestamps | [parakeet-ctc-0.6b.md](parakeet-ctc-0.6b.md) | +| `parakeet-ctc-1.1b` | 1.1B | en | 1.26 GB | LibriSpeech test-clean (WER) | 1.85% | token timestamps | [parakeet-ctc-1.1b.md](parakeet-ctc-1.1b.md) | +| `parakeet-unified-en-0.6b` | 618M | en | 731 MB | LibriSpeech test-clean (WER) | 1.60% | streaming, token timestamps | [parakeet-unified-en-0.6b.md](parakeet-unified-en-0.6b.md) | +| `nemotron-labs-unified-asr-0.6b` | 627M | 25 languages + auto-detect | 740 MB | LibriSpeech test-clean (WER) | 1.69% | streaming, token timestamps | [nemotron-labs-unified-asr-0.6b.md](nemotron-labs-unified-asr-0.6b.md) | \* `parakeet-primeline` is scored on FLEURS German (862 utterances), @@ -111,8 +112,16 @@ graph, so their output is identical to full attention; beyond that, encoder time and memory grow linearly with length instead of quadratically, so a 25-minute talk runs on a 16 GB laptop and multi-hour recordings fit. `parakeet-tdt_ctc-1.1b` ships its own `[128, 128]` window and -`parakeet-ultra` keeps full attention inside its 30 s segments; the streaming -variants keep their chunked attention. +`parakeet-ultra` keeps full attention inside its 30 s segments; the cache-aware +streaming variants keep their chunked attention. + +The unified checkpoints (`parakeet-unified-en-0.6b`, +`nemotron-labs-unified-asr-0.6b`) run full attention offline, as NeMo +does, up to 120 s, so LibriSpeech and FLEURS match NeMo's offline output +exactly. Longer clips switch to the same `[256, 256]` window, which is as +accurate on long-form sets (TED-LIUM, Earnings-22) and keeps encoder time +linear. `TRANSCRIBE_PARAKEET_FULL_ATTENTION_MAX_S` moves the limit; +buffered streaming is unaffected. The port matches NeMo with the same window at tensor level (encoder blocks and `enc.final` within the family tolerances; six variants on a 70 s clip, @@ -166,13 +175,13 @@ All Parakeet variants support: - **Token-level timestamps** at the encoder frame rate (TDT and RNN-T; CTC also exposes frame-level alignment). -**Buffered streaming** is supported on `parakeet-unified-en-0.6b` -across all six published `(L, C, R)` configurations from the model's -training menu (lookahead latency from 160ms at `(70, 1, 1)` through -2.08s at the default `(70, 13, 13)`). See +**Buffered streaming** is supported on `parakeet-unified-en-0.6b` and +`nemotron-labs-unified-asr-0.6b`, from 160ms lookahead at `(70, 1, 1)` +to 2.08s at the default `(70, 13, 13)`. See [parakeet-unified-en-0.6b.md](parakeet-unified-en-0.6b.md#streaming) for the per-config WER and the `--stream-buf-{left,chunk,right}-ms` -CLI surface. Other Parakeet variants run offline only. +CLI surface. The cache-aware `nemotron-*-streaming` variants stream +through their own path; other Parakeet variants run offline only. What's not supported (consistent across the family): translation, speaker diarization, and VAD as a user-facing feature (`parakeet-ultra` uses diff --git a/docs/models/sensevoice-small.md b/docs/models/sensevoice-small.md index 0d4d28cd5..40665cfdc 100644 --- a/docs/models/sensevoice-small.md +++ b/docs/models/sensevoice-small.md @@ -129,7 +129,8 @@ build/bin/transcribe-cli \ ``` Pass `--language zh` / `yue` / `ja` / `ko` (or omit for auto-detection) for -the other supported languages. +the other supported languages. `--language auto` is equivalent to omitting +the flag. ```bash # Keep <|en|><|HAPPY|><|Speech|><|withitn|>… in the output text: diff --git a/docs/porting/families/parakeet.md b/docs/porting/families/parakeet.md index 9623b6db0..f8bef0d27 100644 --- a/docs/porting/families/parakeet.md +++ b/docs/porting/families/parakeet.md @@ -158,6 +158,16 @@ Allowed statuses: `PASS` | `SKIP — not exposed by runtime` | | multitalker-parakeet-streaming-0.6b-v1 | Batch (offline, single_speaker_mode) | run_batch fast path | `uv run scripts/batch_parity.py --model --list --batch-sizes 2,4,8 --backend cpu --language en` + `uv run scripts/batch_tensor_parity.py --model --wav samples/jfk.wav --batch 4 --backend cpu` | text byte-equal vs serial at sizes 2/4/8 (golden frozen at `tests/golden/batch/multitalker-parakeet-streaming-0.6b-v1.cpu.json`); same-length CPU tensor parity bit-exact (max_abs=0.0) at batch=4 on jfk.wav; **diverse-length** flash tensor parity bit-exact (max_abs=0.0) across arbitrary length mixes; full test-clean batch-8 WER == batch-1 (2.19%) after the causal var-len pre-encode masking fix (see forward-map Deviations) | PASS | | multitalker-parakeet-streaming-0.6b-v1 | Multitalker / speaker-attributed ASR (speaker-kernel injection + embedded Sortformer diarization + multi-instance + speaker-tagged segments) | multitalker | `TRANSCRIBE_MULTITALKER_BUNDLE_GGUF= ctest --test-dir build -R parakeet_multitalker` plus `scripts/diar/run_cpp_multitalker.py` / `score_cpwer.py` on AMI-IHM | structural two-speaker smoke in both supervision modes; cpWER vs NeMo `speech_to_text_multitalker_streaming_infer.py` | PASS — bundle GGUFs embed `diar_streaming_sortformer_4spk-v2.1`; `--diarize` runs bounded-state per-speaker streaming encoder/decoder instances and emits speaker-tagged segments. AMI-IHM F32 cpWER: C++ 19.35% kernel / 23.73% masked; NeMo 21.39% / 24.00%. | | multitalker-parakeet-streaming-0.6b-v1 | Speaker diarization (produce speaker turns) | diarization | same bundle smoke; inspect `transcribe_n_speaker_segments` | non-empty 1-based speaker turns, independent of transcript rows | PASS on bundle GGUFs — embedded Sortformer predictions populate speaker segments; plain GGUFs intentionally retain the single-speaker capability surface. | +| nemotron-labs-unified-asr-0.6b | Transcribe (offline) | explicit fr / es | `build/bin/transcribe-cli -m models/nemotron-labs-unified-asr-0.6b/nemotron-labs-unified-asr-0.6b-F32.gguf --language fr samples/fleurs-fr.wav` (and `es`) | transcript with PnC matching NeMo | PASS | +| nemotron-labs-unified-asr-0.6b | Transcribe (offline) | auto / no hint | `build/bin/transcribe-cli -m samples/jfk.wav` | English transcript with PnC; no language tag | PASS | +| nemotron-labs-unified-asr-0.6b | Language aliases | `auto`, `en-US`, `fr-FR`; `es-ES`, `zz` | `transcribe_decoder_smoke`, `transcribe_parakeet_prompt_language_unit`, `transcribe_parakeet_unified_gate_unit` | `auto` == no hint, `fr-FR` == `fr`; untrained or unknown codes return UNSUPPORTED_LANGUAGE (run, batch, stream) | PASS | +| nemotron-labs-unified-asr-0.6b | Punctuation/casing | output | same as the offline row | capitals and `,.?!` | PASS | +| nemotron-labs-unified-asr-0.6b | Word timestamps | `--timestamps word` | `transcribe-cli --timestamps word --language fr -m samples/fleurs-fr.wav` vs NeMo `transcribe(..., timestamps=True)` | jfk / fleurs-fr / fleurs-es: 63/63 words equal, 0 ms difference | PASS | +| nemotron-labs-unified-asr-0.6b | Streaming (buffered, language prompt per chunk) | explicit en/fr/es | `uv run --project scripts/envs/parakeet scripts/validate_buffered_streaming.py --nemo --gguf models/nemotron-labs-unified-asr-0.6b/nemotron-labs-unified-asr-0.6b-F32.gguf --audio samples/fleurs-fr.wav --language fr --out ` | every chunk within tolerance, transcripts equal at the default `(70, 13, 13)` | PASS | +| nemotron-labs-unified-asr-0.6b | Other latency settings | `(70, 7, 7)`, `(70, 2, 5)`, `(70, 1, 1)` | same harness with `--chunk-secs` / `--right-secs` | every chunk within tolerance; at `(70, 7, 7)` LibriSpeech-512 1.40% vs NeMo 1.36%, FLEURS fr-256 8.32% vs 8.09% (end-of-stream punctuation) | PASS | +| nemotron-labs-unified-asr-0.6b | Batch (offline) | run_batch fast path | `uv run scripts/batch_parity.py --model --list <8 clips> --batch-sizes 2,4,8 --backend cpu --golden-in tests/golden/batch/nemotron-labs-unified-asr-0.6b.cpu.json` | text equal to serial and the golden on CPU and Metal; CPU tensor parity bit-exact at batch 4 | PASS | +| nemotron-labs-unified-asr-0.6b | Batch (CUDA) | run_batch fast path | `modal run scripts/wer/remote/modal_sweep.py::sweep --models --quants Q8_0 --batch-sizes 1,8 --n-utts 512 --no-sort-by-length --language en` | batch 8 WER == batch 1 (1.36%); before the conformer mask clamp, 2.94% with 14 empty | PASS | +| nemotron-labs-unified-asr-0.6b | Long-form (offline, window above 120 s) | explicit en | `uv run scripts/wer/run.py --model --manifest --language en` vs NeMo `[256, 256]` | TED-LIUM 3.44% vs 3.46%; Earnings-22 16.19% = 16.19%; clips up to 120 s unchanged | PASS | | all variants | Word timestamps | only if exposed | `transcribe-cli --timestamps word -m ` (any variant) | per-word `t0_ms`/`t1_ms` in JSON output | PASS — derived host-side from emit-frame indices (TDT/RNNT) or per-frame argmax (CTC); same code path as the existing v2/v3 word-timestamp gate, no per-variant differences | ### parakeet-ultra (moondream/parakeet-ultra) diff --git a/examples/cli/cli.h b/examples/cli/cli.h index 5ff3c42dc..54a58dc97 100644 --- a/examples/cli/cli.h +++ b/examples/cli/cli.h @@ -84,11 +84,12 @@ struct cli_args { // nemotron-speech-streaming-en-0.6b settings. Set by // --stream-att-right N. Ignored when stream_chunk_ms == 0. int stream_att_right = -1; - // Parakeet buffered streaming (parakeet-unified-en-0.6b): override - // the (L, C, R) attention context tuple in milliseconds. -1 = use - // the model's default (highest-accuracy row of the training menu). - // Frame-aligned: the lib rounds each value down to the nearest - // post-subsample frame (80ms at 4x subsampling). Ignored when + // Parakeet buffered streaming (parakeet-unified-en-0.6b, + // nemotron-labs-unified-asr-0.6b): override the (L, C, R) attention + // context tuple in milliseconds. -1 = use the model's default + // (highest-accuracy row of the training menu). Each value must be an + // exact multiple of the 80 ms encoder frame (chunk >= 80 ms); tuples + // outside the training menu are accepted. Ignored when // stream_chunk_ms == 0 or when the model is not buffered-streaming. int stream_buf_left_ms = -1; int stream_buf_chunk_ms = -1; diff --git a/include/transcribe.h b/include/transcribe.h index 629f1d6c3..f4031302f 100644 --- a/include/transcribe.h +++ b/include/transcribe.h @@ -1178,6 +1178,13 @@ TRANSCRIBE_API void transcribe_session_params_init(struct transcribe_session_par * * language: source language hint as a BCP-47-ish short code, or * NULL to autodetect (only if the model supports it). + * When the model advertises languages, the hint must be + * one of them or an alias the family accepts without + * advertising (region forms of an advertised code, e.g. + * "en-US" for "en", or "auto" on models with an explicit + * language-agnostic mode, equivalent to NULL there); + * anything else fails with + * TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE. * * target_language: target language for translation tasks, or NULL. * @@ -1312,9 +1319,14 @@ struct transcribe_capabilities { * support and what data does it expose for them." * * supports_language_detect: gates the languages[] array's role. - * False means the autodetect path is unavailable; the listed - * languages (if any) are still the model's supported set when - * the caller passes a hint via transcribe_run_params::language. + * True means the model transcribes any listed language without + * a hint (language NULL). It does not promise that + * transcribe_detected_language reports the language: families + * that detect implicitly (parakeet v3, nemotron-labs-unified) + * leave it empty. False means the autodetect path is + * unavailable; the listed languages (if any) are still the + * model's supported set when the caller passes a hint via + * transcribe_run_params::language. * * supports_translate: gates TRANSCRIBE_TASK_TRANSLATE on * transcribe_run_params, plus the meaning of @@ -2555,8 +2567,9 @@ TRANSCRIBE_API int transcribe_n_tokens(const struct transc * - the caller passed an explicit `params->language` hint (the * library does not echo hints back through this field; callers * already know what they asked for), or - * - the model does not support language detection (English-only - * Whispers, families without an LID head), or + * - the model does not report a detected language (English-only + * Whispers, families without an LID head or language tags, even + * when supports_language_detect is true), or * - the family's LID head produced a non-language sentinel for this * audio (e.g. SenseVoice's <|nospeech|>). * diff --git a/include/transcribe/parakeet.h b/include/transcribe/parakeet.h index b19cf1d9d..cde17c4a3 100644 --- a/include/transcribe/parakeet.h +++ b/include/transcribe/parakeet.h @@ -67,9 +67,10 @@ struct transcribe_parakeet_stream_ext { TRANSCRIBE_API void transcribe_parakeet_stream_ext_init(struct transcribe_parakeet_stream_ext * ext); /* - * Chunked-attention (buffered) streaming knob (parakeet-unified-en-0.6b). + * Chunked-attention (buffered) streaming knob (parakeet-unified-en-0.6b, + * nemotron-labs-unified-asr-0.6b). * - * parakeet-unified-en-0.6b is trained with chunked_limited_with_rc + * The unified models are trained with chunked_limited_with_rc * attention over a menu of (left, chunk, right) context tuples * expressed in 80ms encoder frames. The user picks the active tuple at * stream_begin time; the encoder re-runs over each new @@ -83,17 +84,24 @@ TRANSCRIBE_API void transcribe_parakeet_stream_ext_init(struct transcribe_parake * which the published WER numbers correspond to. * < -1 caller bug; transcribe_stream_begin returns * TRANSCRIBE_ERR_INVALID_ARG. - * 0 a legitimate requested value when 0 frames is in the model's - * menu for that field. Not all fields admit 0. + * 0 a legitimate requested value for left and right; the chunk + * must be at least one encoder frame. * > 0 must be an exact positive multiple of the encoder frame size * (80 ms for every shipped FastConformer streaming variant). * A value that does not divide the frame returns * TRANSCRIBE_ERR_INVALID_ARG; the runtime never silently floors. * - * After per-field resolution the (L, C, R) frame tuple is validated - * against the model's training menu - * (stt.parakeet.encoder.att_chunk_{left,chunk,right}_choices); tuples - * outside the menu return TRANSCRIBE_ERR_INVALID_ARG. + * Any resolved tuple with left >= 0, chunk >= 1 and right >= 0 frames + * is accepted (chunk = 0 returns TRANSCRIBE_ERR_INVALID_ARG), up to a + * window cap: every chunk re-encodes the whole left + chunk + right + * window with full attention, so a window longer than 120 s of audio + * (the offline full-attention limit) returns TRANSCRIBE_ERR_INVALID_ARG. The + * model's training menu + * (stt.parakeet.encoder.att_chunk_{left,chunk,right}_choices) only + * supplies the defaults; a tuple outside it runs as requested and is + * reported with an INFO log line, matching NeMo's buffered loop, which + * takes any context and whose model cards recommend off-menu rows + * (e.g. 70/2/5 frames for 0.56 s latency). */ struct transcribe_parakeet_buffered_stream_ext { struct transcribe_ext ext; diff --git a/reports/porting/parakeet/forward-map.md b/reports/porting/parakeet/forward-map.md index 5ab261fa3..2489132e7 100644 --- a/reports/porting/parakeet/forward-map.md +++ b/reports/porting/parakeet/forward-map.md @@ -145,3 +145,14 @@ Subsampler pointwise bias is masked on padded frames via Global TDT budget uses the existing implementation. Gate tensors cover mel, subsampler, positional encoding, blocks 0/12/23, block-0 residual stages, encoder final, blank embedding, LSTM states and first joint logits. + +- **`nemotron-labs-unified-asr-0.6b`**: 24 layers, d_model=1024, n_mels=128, + `use_bias=true`, plain RNN-T head (vocab 4095), 128-slot language prompt + (118 dictionary keys, auto=127) on the `nemotron-3.5-asr-streaming-0.6b` + prompt path. The GGUF keeps `chunked_limited_with_rc` with the + parakeet-unified-en `(L, C, R)` menu: offline is full attention up to + 120 s, buffered streaming re-runs the encoder per `[left | chunk | right]` + window with the prompt applied to the whole window. `conv_context_style=dcc` + is never read at inference. Long-clip tensor coverage uses + `samples/ru-long-padded.wav` (3392 mel frames, 424 encoder frames on both + sides). diff --git a/reports/porting/parakeet/nemotron-labs-unified-asr-0.6b/_porting-log.md b/reports/porting/parakeet/nemotron-labs-unified-asr-0.6b/_porting-log.md new file mode 100644 index 000000000..ff2e32d16 --- /dev/null +++ b/reports/porting/parakeet/nemotron-labs-unified-asr-0.6b/_porting-log.md @@ -0,0 +1,149 @@ +# Porting log — nemotron-labs-unified-asr-0.6b + +Issue: https://github.com/handy-computer/transcribe.cpp/issues/250. +Checkpoint: `nvidia/nemotron-labs-unified-asr-0.6b` at +`023ce907267a09a308a5cb69239447cb3d0c1597` (`.nemo`, produced by NeMo 3.1.0). +Family: `parakeet`. Nearest siblings: `parakeet-unified-en-0.6b` (same +encoder style and streaming menu) and `nemotron-3.5-asr-streaming-0.6b` +(same `EncDecRNNTBPEModelWithPrompt` language prompt). + +## Architecture + +24-layer FastConformer, d_model 1024, 128 mels, `use_bias=true`, +`xscaling=true`, plain RNN-T head (vocab 4095, no TDT durations). The +encoder output is concatenated with a 128-slot one-hot language prompt and +projected by a two-layer MLP before the joint. The prompt dictionary has +118 keys; `auto` is slot 127. No `` tokens exist. + +`att_context_style=chunked_limited_with_rc`, `att_context_size=[-1, -1]`, +buffered streaming menu `L ∈ {70}`, `C ∈ {1, 2, 7, 13}`, +`R ∈ {0, 1, 2, 3, 4, 7, 13}`, the same as parakeet-unified-en. +`conv_context_style=dcc` is stored by NeMo but never read at inference; +the depthwise conv is plain symmetric `[4, 4]`. + +## Decisions + +- **Native attention style.** The first version of this port forced + `regular` attention (`offline_only`), which disabled streaming and applied + the `[256, 256]` long-form window to clips over 20.5 s. The converter now + keeps `chunked_limited_with_rc`: offline is full attention as in NeMo, + and buffered streaming is available. +- **Language prompt in buffered streaming.** `emit_buffered_chunk` fills + the prompt one-hot for every chunk, over the whole + `[left | chunk | right]` window before the left frames are dropped, as + NeMo's buffered loop does. It was previously left uninitialized. +- **Languages.** Comparing each prompt-kernel column with the untouched + slots shows trained prompts for the 25 card languages and `auto` (plus + ar, tr, no and weakly ko, which are not advertised). `es-ES` (slot 2), + `en-GB`, `pt-BR`, `fr-CA` and the other inherited keys are untrained. + The GGUF advertises the 25 bare codes. Dictionary keys on an advertised + slot (`en-US`, `fr-FR`, ...) and `auto` are accepted as aliases through + the new family alias hook; everything else returns + `TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE`. +- **Long audio.** NeMo's offline full attention needs 43 GB at 14 min and + runs out of memory past about 21 min on a 128 GB Mac. Its `[256, 256]` + window is as accurate on long-form sets (TED-LIUM 3.46% vs 3.50%, + Earnings-22 16.19% vs 17.53%). The C++ encoder stays near-linear in + memory under full attention, but its time grows quadratically (M4 Max + CPU, 20 min: 233 s full vs 30 s windowed). Unified checkpoints therefore + run full attention up to 120 s and the `[256, 256]` window above + (`TRANSCRIBE_PARAKEET_FULL_ATTENTION_MAX_S`). This also applies to + parakeet-unified-en, re-validated on the same sets (TED-LIUM 3.14% = + NeMo window; Earnings-22 14.38% vs NeMo window 14.40%; LibriSpeech + unchanged). +- **Buffered geometry.** Any `(L, C, R)` with `C >= 1` frame runs (NeMo's + loop accepts any tuple, and the card's 560ms row, `(70, 2, 5)`, is off + the training menu). Windows over 120 s are rejected. +- **Quantization.** Standard recipes for all six presets. A per-tensor + Q4_K_M recipe search recovered part of its multilingual loss at +32 MB + and was not adopted. + +## Reference + +Tensor dumps use the in-tree NeMo 2.8 env (`scripts/envs/parakeet`) with +`--offline-only` and no attention override. Stock NeMo 3.1 running the +card's `transcribe(..., target_lang=...)` recipe agrees with it to 2.7e-5 +on the encoder output and gives identical LibriSpeech transcripts. + +LibriSpeech test-clean: NeMo 1.7017% under `scripts/wer/score.py`. The +card's 1.38% comes from the Open ASR Leaderboard scorer, which counts +joined and split compounds as matches; the same NeMo output scores 1.377% +under it. + +## CUDA batch divergence + +A variable-length batch whose lengths differ by more than the +`[256, 256]` band gives padded queries of short utterances an all -inf +flash-attention mask row after the F16 cast. CPU and Metal flash kernels +return 0 for a zero row sum; CUDA divides 0/0. The NaN reaches real frames +through the conv module and the next layer's padded keys, and the +utterance decodes empty. The fix clamps the scaled mask to -3e4 when a +key-pad mask is present (`src/conformer/conformer.cpp`); rows with a real +key are unchanged. The PR author found the same cause independently and +reported it on nemotron-3.5; the clamp replaces both the variant-string +serial fallback and the author's sentinel change. Modal L4, Q8_0, 512 +unsorted LibriSpeech utterances, WER batch 1 / batch 8: + +| Build | nemotron-labs-unified | nemotron-3.5 | parakeet-tdt-0.6b-v3 | +| --- | --- | --- | --- | +| no fix | 1.35 / 1.35 | 2.15 / 45.0 (283 empty) | 1.58 / 9.76 | +| clamp | 1.35 / 1.35 | 2.15 / 2.13 | 1.58 / 1.56 | + +parakeet-ultra builds a key-pad mask for single utterances; its +`validate.py all` (jfk, dots, dots-full) is bit-identical with and without +the clamp. + +## Evidence + +| Check | Result | +| --- | --- | +| `validate.py all` (jfk, fleurs-fr, fleurs-es, ru-long-padded) | all compared tensors within tolerance, exact transcripts | +| LibriSpeech test-clean, F32 | 1.7017% = NeMo | +| FLEURS, 25 languages, F32 vs NeMo 3.1 | within ±0.04 pp everywhere, language given and `auto` (means 12.13 / 13.23 vs 12.13 / 13.24) | +| FLEURS quant means (language given) | F16 12.13, Q8_0 12.12, Q6_K 12.18, Q5_K_M 12.22, Q4_K_M 12.58 | +| Buffered streaming parity, en/fr/es at (70,13,13), (70,7,7), (70,2,5), (70,1,1) | every chunk within tolerance, transcripts equal apart from a trailing `.` from the end-of-stream handling | +| Streaming WER at (70,7,7), F32 vs NeMo | LibriSpeech-512 1.40% vs 1.36%; FLEURS fr-256 8.32% vs 8.09% | +| Long-form, F32 vs NeMo `[256, 256]` | TED-LIUM 3.44% vs 3.46%; Earnings-22 (3 calls) 16.19% = 16.19% | +| Word timestamps vs NeMo `timestamps=True` | jfk, fleurs-fr, fleurs-es: 63/63 words, 0 ms difference | +| Batch 2/4/8 | text equal to serial on CPU and Metal (F32, F16); CUDA batch 8 WER = batch 1 | +| ctest | default suite and parakeet real-model tests pass | + +`auto` mode returns empty transcripts for some FLEURS clips in el (20), +ru (10), bg (6) and uk (4), and writes part of the Greek output in Latin +script; NeMo does the same. The tokenizer has no final sigma, which +roughly doubles the Greek WER (29.06% vs 13.89% with ς ignored). + +Q8_0 CPU batch output differs from serial on 2 of 8 clips of a long mixed +list (`product-names`, `ja-long`); encoder outputs differ by up to 7.2e-3, +the same order as parakeet-unified-en Q8_0 on main. F32 and F16 are equal. + +## Artifacts + +`handy-computer/nemotron-labs-unified-asr-0.6b-gguf`: + +| File | Bytes | SHA256 | +| --- | ---: | --- | +| F32 | 2506964864 | `994283d557f12a6e792ec2131109ae3b883a3207066c037a75aa8619087d4f42` | +| F16 | 1255980928 | `f6db5a525812823401d369654c83d0842527932ee384c24161b8d4ad99c94c8b` | +| Q8_0 | 740361088 | `53af479a0b724cf53a4c60931bac1808f5cee6d3c0fe52bbd29a310ad8fd662c` | +| Q6_K | 610686848 | `66a69231e2eb2f420a1749b9eaa52b26bb5376e3fd0c15c00e6508de42df581d` | +| Q5_K_M | 549012352 | `d2c12832ead59a37f4702cc36fdbbc748b44aa7dba6c6fd41899d2675068c409` | +| Q4_K_M | 485229440 | `60135c7fea8cfcce6df60da3edfc2de7cd372238b6dc32f8308d1e1b78eb3e21` | + +Speed rows: Apple M4 Max, Ryzen 7 PRO 4750U, and an Apple M1 standing in +for the base Apple M4 (`speed_opt_in`, with a base-M4 speed exception). + +## Replay + +```bash +uv run --project scripts/envs/parakeet scripts/convert-parakeet.py \ + nvidia/nemotron-labs-unified-asr-0.6b +uv run scripts/quantize-all.py \ + models/nemotron-labs-unified-asr-0.6b/nemotron-labs-unified-asr-0.6b-F32.gguf +uv run scripts/validate.py all --family parakeet --variant nemotron-labs-unified-asr-0.6b \ + --model +uv run --project scripts/envs/parakeet scripts/validate_buffered_streaming.py \ + --nemo \ + --gguf models/nemotron-labs-unified-asr-0.6b/nemotron-labs-unified-asr-0.6b-F32.gguf \ + --audio samples/fleurs-fr.wav --language fr --out +``` diff --git a/reports/porting/parakeet/nemotron-labs-unified-asr-0.6b/intake.json b/reports/porting/parakeet/nemotron-labs-unified-asr-0.6b/intake.json new file mode 100644 index 000000000..1e1607f25 --- /dev/null +++ b/reports/porting/parakeet/nemotron-labs-unified-asr-0.6b/intake.json @@ -0,0 +1,292 @@ +{ + "schema_version": "transcribe-intake-v1", + "family": "parakeet", + "hf_repo": "nvidia/nemotron-labs-unified-asr-0.6b", + "hf_revision": "023ce907267a09a308a5cb69239447cb3d0c1597", + "sources": { + "config": { + "kind": "hf_file", + "path": "nemotron-labs-unified-asr-0.6b.nemo (./model_config.yaml)", + "status": "found", + "detail": "Uncompressed .nemo tar; model_config.yaml read directly. EncDecRNNTBPEModelWithPrompt, NeMo 3.1.0+7be3e2bf6, 24-layer FastConformer d_model=1024, n_heads=8, subsampling_factor=8, n_fft=512, hop=160, 16 kHz, conv_norm_type=batch_norm, att_context_style=chunked_limited_with_rc, RNNT decoder pred_hidden=640, joint_hidden=640, vocab_size=4095, num_prompts=128, prompt_dictionary with 118 entries across 128 prompt slots including fr=8/fr-FR=8, es=3/es-ES=2, auto=127." + }, + "preprocessor": { + "kind": "hf_file", + "path": "nemotron-labs-unified-asr-0.6b.nemo (model.cfg.preprocessor)", + "status": "found", + "detail": "AudioToMelSpectrogramPreprocessor from model_config.yaml: sample_rate=16000, features=128, n_fft=512, window_size=0.025, window_stride=0.01, window=hann, normalize=per_feature, dither=1e-05, frame_splicing=1, pad_to=0." + }, + "tokenizer_config": { + "kind": "hf_file", + "path": "nemotron-labs-unified-asr-0.6b.nemo (tokenizer.model)", + "status": "found", + "detail": "SentencePiece BPE, vocab_size=4095. Unlike nemotron-3.5 there are no tag tokens in this checkpoint; language is carried only by the one-hot prompt." + }, + "tokenizer_json": { + "kind": "hf_file", + "path": "tokenizer.json", + "status": "missing", + "detail": "SentencePiece proto only inside .nemo." + }, + "generation_config": { + "kind": "hf_file", + "path": "model.cfg.decoding inside .nemo", + "status": "found", + "detail": "RNN-T greedy decoding; no autoregressive generation config. Targets: offline full context and buffered streaming over the native (L, C, R) menu (default 70/13/13), language prompt applied per chunk." + }, + "safetensors_metadata": { + "kind": "hf_api", + "path": "HfApi.get_safetensors_metadata", + "status": "missing", + "detail": "PyTorch state_dict inside .nemo tar, not safetensors." + }, + "model_card": { + "kind": "hf_api", + "path": "https://huggingface.co/nvidia/nemotron-labs-unified-asr-0.6b", + "status": "found", + "detail": "Multilingual version of parakeet-unified-en-0.6b; 25 European languages; language-ID prompt conditioning on the encoder; offline full-context and buffered streaming; punctuation/capitalization; word timings; OpenMDW-1.1; publisher LibriSpeech test-clean 1.38 WER, FLEURS fr 5.28 / es 3.00. Runtime reference uses NeMo 2.8.0rc0 from the repo's pinned git dependency; the checkpoint was produced by NeMo 3.1.0+7be3e2bf6." + }, + "reference_modeling_code": { + "kind": "reference_code", + "path": "scripts/dump_reference_parakeet_nemo.py, scripts/convert-parakeet.py, src/arch/parakeet/ (prompt-conditioned RNN-T sibling nemotron-3.5)", + "status": "found", + "detail": "Same prompt class as nemotron-3.5; one-hot prompt handling, MLP projection, KV dictionary and language gate are already implemented in the family. New work is a converter profile, manifest, tolerance file and variant-aware smoke expectations." + } + }, + "variants": [ + { + "name": "nemotron-labs-unified-asr-0.6b", + "memory_gb": 2.5, + "files": [ + "nemotron-labs-unified-asr-0.6b.nemo" + ] + } + ], + "config": { + "architecture_candidates": [ + "encoder-transducer" + ], + "key_fields": { + "architectures": [ + "EncDecRNNTBPEModelWithPrompt" + ], + "model_type": "parakeet_unified_multilingual_rnnt_prompt", + "encoder.type": "Unified FastConformer (full-context offline, buffered chunked_limited_with_rc streaming)", + "encoder.n_layers": 24, + "encoder.d_model": 1024, + "encoder.n_heads": 8, + "encoder.ff_expansion_factor": 4, + "encoder.conv_kernel_size": 9, + "encoder.subsampling": "dw_striding", + "encoder.subsampling_factor": 8, + "encoder.subsampling_conv_channels": 256, + "encoder.self_attention_model": "rel_pos; offline full context, native buffered streaming menu in att_chunk_context_size", + "encoder.feat_in": 128, + "encoder.use_bias": true, + "encoder.causal_downsampling": false, + "encoder.conv_norm_type": "batch_norm", + "encoder.conv_context_size": null, + "encoder.att_context_style": "chunked_limited_with_rc (native). Superseded: the PR converter profile forced regular for offline-only; the GGUF now keeps the native style (offline full attention up to 120 s, [256, 256] window above; buffered streaming).", + "encoder.untie_biases": true, + "encoder.xscaling": true, + "encoder.pos_emb_max_len": 5000, + "language_conditioning.kind": "EncDecRNNTBPEModelWithPrompt", + "language_conditioning.nemo_target_class": "nemo.collections.asr.models.rnnt_bpe_models_prompt.EncDecRNNTBPEModelWithPrompt", + "language_conditioning.num_prompts": 128, + "language_conditioning.prompt_field": "target_lang", + "language_conditioning.modes": [ + "explicit target_lang=", + "target_lang=auto" + ], + "decoder.type": "RNNTDecoder", + "decoder.pred_rnn_layers": 2, + "decoder.pred_hidden": 640, + "decoder.blank_as_pad": true, + "joint.type": "RNNTJoint", + "joint.encoder_hidden": 1024, + "joint.joint_hidden": 640, + "joint.activation": "relu", + "joint.durations": null, + "joint.num_extra_outputs": 0, + "tokenizer.vocab_size": 4095, + "tokenizer.has_punctuation_capitalization": true, + "tokenizer.has_language_tag_tokens": false, + "encoder.att_context_size": [ + -1, + -1 + ], + "language_conditioning.prompt_ids": { + "fr": 8, + "fr-FR": 8, + "es": 3, + "es-ES": 2, + "en": 0, + "auto": 127 + }, + "encoder.att_chunk_context_size.left": [ + 70 + ], + "encoder.att_chunk_context_size.chunk": [ + 1, + 2, + 7, + 13 + ], + "encoder.att_chunk_context_size.right": [ + 0, + 1, + 2, + 3, + 4, + 7, + 13 + ], + "encoder.conv_context_style": "dcc (dropped to None by the offline oracle patch)", + "language_conditioning.auto_emits_tag": false, + "language_conditioning.auto_id": 127, + "runtime_nemo_version": "2.8.0rc0 from pinned git dependency 6967f48fda2a", + "checkpoint_nemo_version": "3.1.0+7be3e2bf6", + "encoder.conv_context_size.resolved": [ + 4, + 4 + ], + "language_conditioning.prompt_dictionary_entries": 118, + "language_conditioning.prompt_slots": 128 + }, + "varying_across_variants": [ + "language_conditioning.prompt_dictionary", + "tokenizer.vocab_size", + "encoder.att_context_style" + ] + }, + "dtype": { + "expected": "float32", + "source": "manual", + "evidence": "Measured from model_weights.ckpt inside the pinned .nemo: 969 float32 and 24 int64 tensors; NeMo restore reported model_dtype=f32. Gate A warned only because the reference artifact is a .nemo with no config.json torch_dtype; Gate B passed after conversion.", + "details": { + "config_declared": null, + "header_distribution": { + "torch.float32": 969, + "torch.int64": 24 + } + }, + "expected_f32_tensors": [] + }, + "frontend": { + "sample_rate": 16000, + "n_mels": 128, + "hop_length": 160, + "fft_size": 512, + "window": "hann_periodic", + "normalization": "per_feature", + "preemphasis": 0.97, + "dither": 1e-05, + "center": true, + "padding_mode": "constant", + "mel_filterbank_norm": "slaney" + }, + "tokenizer": { + "type": "sentencepiece", + "vocab_size": 4095, + "special_tokens": { + "unk": 0 + }, + "has_language_tokens": false, + "vocab_sha256": null + }, + "capabilities": { + "languages": [ + "bg", + "hr", + "cs", + "da", + "nl", + "en", + "et", + "fi", + "fr", + "de", + "el", + "hu", + "it", + "lv", + "lt", + "mt", + "pl", + "pt", + "ro", + "sk", + "sl", + "es", + "sv", + "ru", + "uk" + ], + "language_detection": true, + "translation": false, + "timestamps": [ + "token", + "word" + ], + "streaming": true, + "speaker_diarization": false + }, + "upstream_benchmarks": [ + { + "dataset": "LibriSpeech test-clean", + "language": "en", + "metric": "wer", + "score": 1.38, + "score_unit": "percent", + "source": "https://huggingface.co/nvidia/nemotron-labs-unified-asr-0.6b", + "notes": "Publisher offline full-context score; context only. Acceptance gate uses the measured NeMo Oracle baseline." + }, + { + "dataset": "FLEURS test fr", + "language": "fr", + "metric": "wer", + "score": 5.28, + "score_unit": "percent", + "source": "https://huggingface.co/nvidia/nemotron-labs-unified-asr-0.6b", + "notes": "Context only; used to select the explicit-language behavioral fixture." + }, + { + "dataset": "FLEURS test es", + "language": "es", + "metric": "wer", + "score": 3.0, + "score_unit": "percent", + "source": "https://huggingface.co/nvidia/nemotron-labs-unified-asr-0.6b", + "notes": "Context only; used to select the explicit-language behavioral fixture." + } + ], + "reference_framework": "nemo", + "reference_rationale": "First-party NeMo reference at git pin 6967f48fda2a (runtime 2.8.0rc0). The checkpoint was produced by NeMo 3.1.0+7be3e2bf6. The .nemo tar has no Transformers class or safetensors, and uses EncDecRNNTBPEModelWithPrompt, the same prompt-conditioned RNN-T class as the already-ported nemotron-3.5 variant.", + "architecture_pattern": "encoder-transducer", + "known_risks": [ + "Prompt-conditioned RNN-T with 128-d one-hot language vector concatenated to the 1024-d encoder output and projected through prompt_kernel MLP before the joint; converter must emit prompt weights and KV dictionary, C++ must gate on explicit language or null-hint auto.", + "Prompt dictionary includes many languages beyond the 25 advertised; advertise only the 25 supported bare codes; region keys on the same slot (en-US, fr-FR, ...) and auto are unadvertised aliases, other slots (es-ES = slot 2, untrained) are rejected.", + "Superseded: literal --language auto used to reach the exact-match language gate; the generic gate now accepts it as a family-declared alias (same slot as a null hint).", + "No tokens in this checkpoint's 4095-token SPM; observable for auto mode is a clean no-hint transcript, not a detected-language tag.", + "Resolved: the GGUF keeps the native att_context_style=chunked_limited_with_rc and its (L, C, R) menu (the PR's offline_only profile forced regular attention and the [256, 256] long-form window); offline is full attention like NeMo up to 120 s ([256, 256] window above, matching NeMo local256 on TED-LIUM / Earnings-22) and the oracle runs the native style with no dump_args. A 33.9 s clip covers full attention past the old 20.5 s band.", + "RNN-T word timestamps must be compared against NeMo transcribe(..., timestamps=True) with a signed-off rule for punctuation grouping and 80 ms stride boundaries.", + "Frontend uses normalize=per_feature and conv_norm_type=batch_norm; converter and frontend must match this checkpoint, not the older normalize=none nemotron siblings.", + "Streaming is buffered, not cache-aware: each chunk re-runs the encoder over [left | chunk | right] and NeMo applies the language prompt to the whole window's output (forward with prompt indices) before slicing; C++ must fill the prompt one-hot on every buffered chunk. Card rows include (70, 2, 5), outside the training menu, so the runtime accepts any (L >= 0, C >= 1, R >= 0) tuple.", + "Weight dtype must be verified from the checkpoint before fixing the converter reference dtype; do not assume float32 from sibling variants.", + "CPU-only reference runs are slower than GPU; full LibriSpeech WER baseline and batch parity are feasible but time-consuming." + ], + "intake_gaps": [ + { + "field": "tokenizer.vocab_sha256", + "reason": "Computed at convert time from the .nemo tokenizer proto." + }, + { + "field": "variants[].memory_gb", + "reason": "Estimated from model size; verify after conversion." + }, + { + "field": "streaming_disposition", + "reason": "Buffered streaming in scope (supports_streaming=true), validated per chunk and by WER against NeMo's buffered loop with target_lang." + } + ] +} diff --git a/samples/README.md b/samples/README.md index 29a263c70..90104e2c3 100644 --- a/samples/README.md +++ b/samples/README.md @@ -30,6 +30,7 @@ and is recorded here so each clip can be traced back. | `ko-long.wav` | 25.80 s | `ko_kr` | 15152963524414515048 | | `ru-short.wav` | 10.98 s | `ru_ru` | 2668014690611039917 | | `ru-long.wav` | 33.84 s | `ru_ru` | 10388523902227354213 | +| `ru-long-padded.wav` | 33.91 s | `ru_ru` | derived from `ru-long.wav` (10388523902227354213) + 1120 silent samples | | `uk-short.wav` | 10.98 s | `uk_ua` | 7177130321767122387 | | `uk-long.wav` | 28.92 s | `uk_ua` | 12340201221281017924 | | `vi-short.wav` | 10.98 s | `vi_vn` | 9897090359729012443 | diff --git a/samples/ru-long-padded.wav b/samples/ru-long-padded.wav new file mode 100644 index 000000000..fa9f0bc7e Binary files /dev/null and b/samples/ru-long-padded.wav differ diff --git a/scripts/convert-parakeet.py b/scripts/convert-parakeet.py index 13faba26e..0adc2990f 100644 --- a/scripts/convert-parakeet.py +++ b/scripts/convert-parakeet.py @@ -379,6 +379,46 @@ "license_name": "nvidia-open-model-license", "license_link": "https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/", }, + # Multilingual unified FastConformer-RNN-T with a 128-d one-hot + # language prompt (same EncDecRNNTBPEModelWithPrompt class as the + # nemotron-3.5 sibling). Vocab is 4095; the prompt dictionary carries + # 118 keys including aliases and auto=127. Like parakeet-unified-en-0.6b + # the GGUF keeps the native chunked_limited_with_rc style and its + # (L, C, R) menu: offline runs full attention up to 120 s (matching + # NeMo; the runtime's [256, 256] window above) and the runtime + # advertises buffered streaming with the language prompt applied per + # chunk. + "nemotron-labs-unified-asr-0.6b": { + "variant": "nemotron-labs-unified-asr-0.6b", + "display_name": "Nemotron Labs Unified ASR", + "version": "v1", + "size_label": "0.6B", + "basename": "parakeet-rnnt", + "head_kind": "rnnt", + "expected_vocab_size": 4095, + # The card's 25 languages, as the bare codes its examples pass + # (target_lang="de"). The 118-key prompt dictionary is inherited + # from nemotron-3.5; only the slots these codes select (plus auto) + # carry trained prompt-kernel columns. Region keys on the same slot + # ("en-US", "fr-FR", "de-DE", ...) and "auto" are accepted at run + # time as unadvertised aliases (prompt_language_aliases in + # src/arch/parakeet/model.cpp). Keys on other slots are rejected: + # "es-ES" is slot 2, an untrained column, not the Spanish slot 3. + "languages": [ + "bg", "hr", "cs", "da", "nl", "en", "et", "fi", "fr", "de", + "el", "hu", "it", "lv", "lt", "mt", "pl", "pt", "ro", "sk", + "sl", "es", "sv", "ru", "uk", + ], + # Transcribes without a hint (the trained auto prompt slot 127), + # like v3. No pieces, so transcribe_detected_language + # stays empty. + "lang_detect": True, + "has_prompt": True, + "hf_revision": "023ce907267a09a308a5cb69239447cb3d0c1597", + "license": "other", + "license_name": "openmdw-1.1", + "license_link": "https://openmdw.ai/license/1-1/", + }, # 0.6B multilingual cache-aware streaming RNN-T. Same FastConformer # encoder as the English predecessor (24L / d_model=1024 / 8h / # kernel=9 / subsampling=8) plus a top-level prompt MLP that @@ -1657,6 +1697,24 @@ def convert(model_spec: str, out_path: Path, repo_id: str | None = None, elif profile.get("source_format") == "hf_safetensors": model = load_hf_safetensors_model(model_spec, revision or profile.get("hf_revision")) else: + # A profile's pinned revision must be honoured when the caller + # passes a repo id; otherwise NeMo resolves the default branch and + # can silently convert a different checkpoint. + pinned = revision or profile.get("hf_revision") + if pinned and not Path(model_spec).exists() and "/" in model_spec and not model_spec.endswith(".nemo"): + from huggingface_hub import hf_hub_download, list_repo_files + # NeMo repos usually ship .nemo; fall back to the + # repo's only .nemo when the name differs. + filename = f"{model_spec.split('/')[-1]}.nemo" + nemo_files = [f for f in list_repo_files(model_spec, revision=pinned) if f.endswith(".nemo")] + if filename not in nemo_files: + if len(nemo_files) != 1: + raise SystemExit( + f"error: {model_spec}@{pinned} has {len(nemo_files)} .nemo files " + f"({nemo_files}); pass the .nemo path explicitly") + filename = nemo_files[0] + model_spec = str(hf_hub_download(model_spec, filename, revision=pinned)) + print(f"[revision] resolved pinned .nemo: {model_spec}") model = load_nemo_model(model_spec, prefer_direct=prefer_direct) config = OmegaConf.to_container(model.cfg, resolve=True) @@ -2256,8 +2314,8 @@ def main(argv: list[str]) -> int: "--revision", type=str, default=None, - help="HF revision for HF-safetensors or Fermion variants; " - "defaults to the profile's pinned revision.", + help="HF revision for NeMo .nemo, HF-safetensors or Fermion " + "variants; defaults to the profile's pinned revision.", ) args = p.parse_args(argv[1:]) diff --git a/scripts/dump_reference_parakeet_nemo.py b/scripts/dump_reference_parakeet_nemo.py index 939a38976..cfeaff8d7 100644 --- a/scripts/dump_reference_parakeet_nemo.py +++ b/scripts/dump_reference_parakeet_nemo.py @@ -39,6 +39,7 @@ from __future__ import annotations import argparse +import inspect import os import sys from pathlib import Path @@ -248,7 +249,7 @@ def load_model(args: argparse.Namespace): att_context = getattr(args, "att_context", None) if att_context: left, right = (int(x) for x in att_context.split(",")) - style = str(getattr(model.cfg.encoder, "att_context_style", "regular")) + style = att_context_style(model) if style != "regular": raise SystemExit(f"--att-context applies to regular-style encoders; this one is {style!r}") print(switch_attention(model, left, right)) @@ -256,6 +257,12 @@ def load_model(args: argparse.Namespace): +def att_context_style(model) -> str: + """Effective style after the offline patch, not the stale checkpoint cfg.""" + return str(getattr(model.encoder, "att_context_style", + getattr(model.cfg.encoder, "att_context_style", "regular"))) + + def switch_attention(model, left: int, right: int) -> str: """Set a regular-style encoder's attention window, mirroring the C++ TRANSCRIBE_PARAKEET_ATT_CONTEXT override: [left, right] >= 0 selects @@ -1153,6 +1160,21 @@ def cmd_buffered_streaming(args: argparse.Namespace) -> int: # The TDT decode driver exposed by NeMo for buffered streaming. decoding_computer = model.decoding.decoding.decoding_computer + # Prompt-conditioned models (nemotron-labs-unified-asr-0.6b): NeMo's + # buffered loop (speech_to_text_streaming_infer_rnnt.py, target_lang) + # passes one language index per utterance to the model forward, which + # applies the prompt kernel to the WHOLE [left | chunk | right] window's + # encoder output, once per chunk, before the left frames are sliced off. + # The index is constant across chunks. NeMo 2.8 names the kwarg + # `prompt_indices`; newer NeMo keeps it as a deprecated alias of + # `language_prompt_indices`. + prompt_kwargs: dict[str, Any] = {} + prompt_id = None + if is_prompt_aware(model): + prompt_id = resolve_prompt_id(model, args.language) + prompt_kwargs["prompt_indices"] = torch.tensor([prompt_id], dtype=torch.long) + print(f"prompt: target_lang={args.language!r} prompt_id={prompt_id}") + source = make_source( args=args, audio_path=audio_path, n_samples=pcm.size, sample_rate=sr, arch=arch ) @@ -1166,6 +1188,9 @@ def cmd_buffered_streaming(args: argparse.Namespace) -> int: "samples_chunk": int(samples_chunk), "samples_right": int(samples_right), } + if prompt_id is not None: + source["buffered_streaming"]["target_lang"] = str(args.language) + source["buffered_streaming"]["prompt_id"] = int(prompt_id) print( f"buffered streaming: (L,C,R)_frames=[{left_frames}, {chunk_frames}, {right_frames}] " f"= [{samples_left}, {samples_chunk}, {samples_right}] samples " @@ -1312,6 +1337,7 @@ def block0_wrapped(x, att_mask=None, pos_emb=None, pad_mask=None, encoder_output, encoder_output_len = model( input_signal=buffer.samples, input_signal_length=buffer.context_size_batch.total(), + **prompt_kwargs, ) encoder_output = encoder_output.transpose(1, 2) # (B, T_enc, D) encoder_context = buffer.context_size.subsample( @@ -1344,7 +1370,7 @@ def block0_wrapped(x, att_mask=None, pos_emb=None, pad_mask=None, f"buffered_streaming.{cap_name}", ) - chunk_batched_hyps, _, state = decoding_computer( + decode_out = decoding_computer( x=encoder_output_chunk, out_len=torch.where( is_last_chunk_batch, @@ -1354,6 +1380,8 @@ def block0_wrapped(x, att_mask=None, pos_emb=None, pad_mask=None, prev_batched_state=state, multi_biasing_ids=None, ) + # NeMo 2.8 returns (hyps, alignments, state); NeMo 3.1 returns (hyps, state). + chunk_batched_hyps, state = decode_out[0], decode_out[-1] if current_batched_hyps is None: current_batched_hyps = chunk_batched_hyps else: @@ -1367,9 +1395,11 @@ def block0_wrapped(x, att_mask=None, pos_emb=None, pad_mask=None, from nemo.collections.asr.parts.utils.rnnt_utils import ( batched_hyps_to_hypotheses, ) - hyps_view = batched_hyps_to_hypotheses( - current_batched_hyps, None, batch_size=1 - ) + # NeMo 2.8: (batched_hyps, alignments, batch_size); NeMo 3.1 dropped alignments. + if 'alignments' in inspect.signature(batched_hyps_to_hypotheses).parameters: + hyps_view = batched_hyps_to_hypotheses(current_batched_hyps, None, batch_size=1) + else: + hyps_view = batched_hyps_to_hypotheses(current_batched_hyps, batch_size=1) tokens_so_far: list[int] = [] if hyps_view and getattr(hyps_view[0], "y_sequence", None) is not None: tokens_so_far = [int(x) for x in hyps_view[0].y_sequence.tolist()] diff --git a/scripts/hf_cards/nemotron-labs-unified-asr-0.6b.yaml b/scripts/hf_cards/nemotron-labs-unified-asr-0.6b.yaml new file mode 100644 index 000000000..ed169d0d0 --- /dev/null +++ b/scripts/hf_cards/nemotron-labs-unified-asr-0.6b.yaml @@ -0,0 +1,34 @@ +# Spec for the HF README of handy-computer/nemotron-labs-unified-asr-0.6b-gguf. +# Prose only; numbers and metadata come from catalog/.json. See README.md. + +# The upstream revision 023ce90 was pinned by the porting PR (#286). +pin_date: 2026-11-29 + +# Validation pin for the most recent upload. Updated on each release; +# older HF revisions carry whatever value was current at their upload time. +validation: + reference: NeMo + commit: c19938cd + date: 2026-12-03 + +pipeline_tag: automatic-speech-recognition +tags: + - gguf + - transcribe.cpp + - asr + - speech-to-text + - parakeet + - fastconformer + - rnnt + - streaming + - multilingual + +summary: | + Multilingual speech-to-text covering 25 European languages, with punctuation and capitalization. A FastConformer encoder with a language-prompt-conditioned RNN-T decoder, trained as a unified streaming/offline model. The source language is selected per call (--language de, fr, ...) or left to the model (auto). This port runs both offline and buffered streaming modes. Does not translate. + +wer: + notes: | + Greedy RNN-T decoding, no external LM. NeMo reference baseline on the same + manifest: 1.70%. NVIDIA's self-reported number on the same split is 1.38%; it is + scored with the Open ASR Leaderboard normalizer, which counts joined and split + compounds as matches, and the same NeMo output scores 1.38% under it. diff --git a/scripts/validate_buffered_streaming.py b/scripts/validate_buffered_streaming.py index a3eda5ceb..d0d0a9f52 100755 --- a/scripts/validate_buffered_streaming.py +++ b/scripts/validate_buffered_streaming.py @@ -7,7 +7,9 @@ # /// """ validate_buffered_streaming.py - parity harness for buffered streaming -on parakeet-unified-en-0.6b. +on parakeet-unified-en-0.6b and the prompt-conditioned +nemotron-labs-unified-asr-0.6b (pass --language: it selects the same +language-ID prompt on both sides). For a target audio file at a chosen (L, C, R) tuple, runs: @@ -32,7 +34,7 @@ --out build/validate_buffered_streaming/parakeet-unified/jfk/default \\ [--left-secs 5.6 --chunk-secs 1.04 --right-secs 1.04] \\ [--backend cpu --threads 1] \\ - [--feed-ms 500] + [--feed-ms 500] [--language fr] Exit code 0 = per-chunk parity OK across all chunks (audio_in bit-exact + enc_out within fp32 tolerance). The final-transcript @@ -79,7 +81,7 @@ def run_subprocess(cmd: list[str], *, label: str, env: dict | None = None, def run_ref_dump(*, nemo: Path, audio: Path, out_dir: Path, left_secs: float, chunk_secs: float, right_secs: float, - force: bool) -> Path: + language: str | None, force: bool) -> Path: stamp = out_dir / "stream_history.json" if stamp.exists() and not force: print(f" [skip ref] {stamp} exists (pass --force to re-run)") @@ -96,6 +98,8 @@ def run_ref_dump(*, nemo: Path, audio: Path, out_dir: Path, "--chunk-secs", f"{chunk_secs}", "--right-secs", f"{right_secs}", ] + if language is not None: + cmd += ["--language", language] run_subprocess(cmd, label="ref dump", cwd=REPO) return out_dir @@ -105,7 +109,8 @@ def run_cpp_dump(*, gguf: Path, audio: Path, out_dir: Path, threads: int | None, left_ms: int | None, chunk_ms: int | None, - right_ms: int | None) -> tuple[Path, str]: + right_ms: int | None, + language: str | None) -> tuple[Path, str]: if out_dir.exists(): shutil.rmtree(out_dir) out_dir.mkdir(parents=True, exist_ok=True) @@ -132,6 +137,8 @@ def run_cpp_dump(*, gguf: Path, audio: Path, out_dir: Path, cmd += ["--stream-buf-chunk-ms", str(chunk_ms)] if right_ms is not None: cmd += ["--stream-buf-right-ms", str(right_ms)] + if language is not None: + cmd += ["--language", language] env = {"TRANSCRIBE_DUMP_DIR": str(out_dir)} proc = run_subprocess(cmd, label="cpp dump", env=env, cwd=REPO, capture=True) @@ -199,6 +206,12 @@ def compare_pair(name: str, ref_path: Path, cpp_path: Path, return {"name": name, "status": "OK", "max_abs": 0.0, "mean_abs": 0.0, "p99_abs": 0.0, "rel_max": 0.0, "n_elem": 0, **extra} diff = np.abs(ref - cpp) + if ref.ndim == 2 and ref.shape[0] > 1 and "pad_rows" not in extra: + # The last enc_out row is NeMo's conv-overhang frame: computed past + # the window's valid length and never decoded. Report the decoded + # body separately so overhang noise does not hide body drift. + extra["body_max_abs"] = float(diff[:-1].max()) + extra["overhang_max_abs"] = float(diff[-1].max()) max_abs = float(diff.max()) mean_abs = float(diff.mean()) p99_abs = float(np.quantile(np.abs(ref), 0.99)) @@ -228,6 +241,12 @@ def main() -> int: p.add_argument("--threads", type=int, default=1) p.add_argument("--feed-ms", type=int, default=500) p.add_argument("--force", action="store_true") + p.add_argument("--language", default=None, + help="Target language for prompt-conditioned models; must be " + "a prompt_dictionary key (e.g. en, fr, es-ES). Passed to " + "the NeMo dumper and transcribe-cli alike. Required for " + "those models: the dumper's default ('en') and the " + "CLI's default (auto prompt) differ.") args = p.parse_args() out_dir = args.out.resolve() @@ -240,6 +259,7 @@ def main() -> int: left_secs=args.left_secs, chunk_secs=args.chunk_secs, right_secs=args.right_secs, + language=args.language, force=args.force, ) cpp_path, cpp_text = run_cpp_dump( @@ -250,6 +270,7 @@ def main() -> int: left_ms=int(round(args.left_secs * 1000)), chunk_ms=int(round(args.chunk_secs * 1000)), right_ms=int(round(args.right_secs * 1000)), + language=args.language, ) # Final transcript byte equality @@ -310,6 +331,9 @@ def main() -> int: tag = "FAIL" fail_chunks += 1 extra = "" + if "body_max_abs" in r: + extra = (f" body_max_abs={r['body_max_abs']:.3e}" + f" overhang_max_abs={r['overhang_max_abs']:.3e}") if "pad_samples" in r: extra = f" eos_pad_samples={r['pad_samples']} (zeros: {r['pad_max_abs'] == 0.0})" if "eos_tail_max_abs" in r: diff --git a/scripts/wer/remote/modal_sweep.py b/scripts/wer/remote/modal_sweep.py index f019d663d..b672d0eae 100644 --- a/scripts/wer/remote/modal_sweep.py +++ b/scripts/wer/remote/modal_sweep.py @@ -914,6 +914,8 @@ def _dispatch(cells: list[dict], gpu: str, *, clean: bool = False, n_utts: int = for c, fut in futs: bs = c["bs"] slug = c["file"].replace(".gguf", "") + (f" b{bs}" if bs != 1 else "") + if (c.get("language") or "").lower() == "auto": + slug += " lang=auto" if c.get("att_context"): slug += " att=" + c["att_context"] try: @@ -926,7 +928,8 @@ def _dispatch(cells: list[dict], gpu: str, *, clean: bool = False, n_utts: int = stream_chunk_ms=stream_chunk_ms, stream_att_right=stream_att_right, n_utts=(n_utts if n_utts >= 0 else None), - att_context=c.get("att_context", "")) + att_context=c.get("att_context", ""), + language=c.get("language", "") or "") s = res["summary"] rows.append((slug, c["dataset"], s["n_utts"], s["audio_s"], s["wall_s"], s["rtf_wall"], str(path))) @@ -981,6 +984,12 @@ def sweep( ) -> None: """Fan WER across one or more models on one dataset and GPU class. + --dataset One spec or a comma-separated list (one cell per dataset), + e.g. "fleurs:bg,fleurs:cs,fleurs:de". + --language "" (default): each manifest's own language as an explicit + hint. "auto": no hint (the model's language-agnostic mode), + still scored in the manifest's language; hyps are tagged + .lang-auto. Anything else: that hint for every dataset. --models Comma-separated. Each entry is either a catalog variant (e.g. "moonshine-base" -> catalog/moonshine-base.json) or a HF repo path (e.g. "handy-computer/foo-gguf"). @@ -1003,11 +1012,15 @@ def sweep( specs = [s.strip() for s in models.split(",") if s.strip()] if not specs: raise SystemExit("--models is required (comma-separated)") + dataset_specs = [d.strip() for d in dataset.split(",") if d.strip()] + if not dataset_specs: + raise SystemExit("--dataset is required") quant_filter = [q.strip() for q in quants.split(",") if q.strip()] if quants else None print("==================== sweep config ====================") print(f" models = {specs}") - print(f" dataset = {dataset}") + print(f" datasets = {dataset_specs}") + print(f" language = {language or 'per-manifest explicit'}") print(f" quants = {quant_filter if quant_filter else 'all'}") print(f" gpu = {gpu}") print(f" n_utts = {'full manifest' if n_utts < 0 else n_utts}") @@ -1037,12 +1050,13 @@ def sweep( skipped.append((spec, f"no quants matched filter {quant_filter}")) continue for f in fns: - for bs in sizes: - for att in att_contexts: - cells.append({"repo": repo, "file": f, "dataset": dataset, "bs": bs, - "language": language, "timestamps": timestamps, - "publication_profile": publication_profile, - "backend": backend, "att_context": att}) + for ds_spec in dataset_specs: + for bs in sizes: + for att in att_contexts: + cells.append({"repo": repo, "file": f, "dataset": ds_spec, "bs": bs, + "language": language, "timestamps": timestamps, + "publication_profile": publication_profile, + "backend": backend, "att_context": att}) if skipped: print(">>> skipped (no cells generated):") for s, r in skipped: diff --git a/scripts/wer/remote/output_paths.py b/scripts/wer/remote/output_paths.py index 44da720cc..fbae441bf 100644 --- a/scripts/wer/remote/output_paths.py +++ b/scripts/wer/remote/output_paths.py @@ -41,6 +41,7 @@ def write_hyp( stream_att_right: int = -1, n_utts: int | None = None, att_context: str = "", + language: str = "", ) -> Path: out_dir = root / "reports" / "wer" out_dir.mkdir(parents=True, exist_ok=True) @@ -52,6 +53,9 @@ def write_hyp( r_tag = "" if stream_att_right < 0 else f".r{stream_att_right}" subset_tag = "" if n_utts is None else f".n{n_utts}" att_tag = att_context_tag(att_context) - out_path = out_dir / f"{slug}.{ds}{bs_tag}{ts_tag}{stream_tag}{r_tag}{subset_tag}{att_tag}.jsonl" + # Explicit-language cells keep the plain (published) name; the + # language-agnostic auto mode is tagged so it never overwrites them. + lang_tag = ".lang-auto" if language.lower() == "auto" else "" + out_path = out_dir / f"{slug}.{ds}{bs_tag}{ts_tag}{stream_tag}{r_tag}{subset_tag}{att_tag}{lang_tag}.jsonl" out_path.write_text(hyp_jsonl) return out_path diff --git a/scripts/wer/run.py b/scripts/wer/run.py index dfc4c10a7..8d54bf458 100644 --- a/scripts/wer/run.py +++ b/scripts/wer/run.py @@ -45,6 +45,11 @@ with this flag, run.py fails loud. If --language is omitted and the manifest has a single consistent language, it is inferred automatically. + --language auto runs language-agnostic: no hint reaches + transcribe-cli (a null hint, the model's auto mode), while + the manifest/dataset language is still stamped on the + report header so score.py routes the normalizer/metric + for the audio's real language. --itn MODE off | on | default. Unset resolves per variant from the GGUF's stt.variant (ITN_ON_VARIANTS): 'on' for fun-asr-mlt-nano-2512, whose library default is ITN on and @@ -237,7 +242,9 @@ def main() -> int: p.add_argument("--language", default=None, help="BCP-47 code passed to transcribe-cli --language. " "Auto-set from --dataset when applicable. " - "If a manifest entry's language disagrees, fail loud.") + "If a manifest entry's language disagrees, fail loud. " + "'auto' sends no hint (the model's auto mode) and " + "still scores in the manifest's language.") p.add_argument("--cli", type=Path, default=repo / "build/bin/transcribe-cli", help="transcribe-cli binary") @@ -308,6 +315,11 @@ def main() -> int: # Resolve --dataset first (may run ingest.py). --dataset takes # precedence over --manifest; if neither is set fall back to the # historical default for backward compat. + # --language auto: language-agnostic run. The hint stays null; the + # scoring language is resolved below exactly as an explicit run would. + auto_language = (args.language or "").lower() == "auto" + if auto_language: + args.language = None if args.dataset: if args.manifest: print(f"warning: --dataset overrides --manifest", file=sys.stderr) @@ -328,6 +340,8 @@ def main() -> int: out_path = args.out or derive_out_path( repo, args.model, args.manifest, args.timestamps, args.diarize ) + if auto_language and args.out is None: + out_path = out_path.with_name(out_path.stem + ".lang-auto.jsonl") out_path.parent.mkdir(parents=True, exist_ok=True) # Load manifest and build id→ref_text lookup. @@ -397,7 +411,12 @@ def _dur(e: dict) -> float: bs = args.batch_size if args.batch_size and args.batch_size > 1 else 1 print(f"model: {args.model}") print(f"manifest: {args.manifest} ({total} utterances)") - print(f"language: {args.language or '(default)'}") + # The language scored against (stamped on the report header) vs the hint + # sent to the model (none in auto mode). + score_language = args.language + hint_language = None if auto_language else args.language + print(f"language: {score_language or '(default)'}" + f"{' (auto mode: no hint sent)' if auto_language else ''}") print(f"itn: {args.itn}") print(f"output: {out_path}") print(f"mode: batch (single process, model loads once); " @@ -425,8 +444,8 @@ def _dur(e: dict) -> float: cmd += ["--backend", args.backend] if args.kv_type: cmd += ["--kv-type", args.kv_type] - if args.language: - cmd += ["--language", args.language] + if hint_language: + cmd += ["--language", hint_language] cmd += ["--timestamps", args.timestamps] if args.diarize: cmd += ["--diarize"] @@ -503,13 +522,13 @@ def _dur(e: dict) -> float: # no-speech thresholds, condition_on_prev=off) are documented there # and recorded here as "decode": "greedy+default-fallback". if result.get("type") == "batch_header": - if args.language: - result["language"] = args.language + if score_language: + result["language"] = score_language result["recipe"] = { "timestamps": args.timestamps, "diarize": args.diarize, "itn": args.itn, - "language": args.language or "auto-detect", + "language": hint_language or "auto-detect", "batch_size": bs, "backend": args.backend or "default", "kv_type": args.kv_type or "default", diff --git a/scripts/wer/run_reference_parakeet_buffered_streaming_nemo.py b/scripts/wer/run_reference_parakeet_buffered_streaming_nemo.py index 0ecf45ac0..d928cbc17 100644 --- a/scripts/wer/run_reference_parakeet_buffered_streaming_nemo.py +++ b/scripts/wer/run_reference_parakeet_buffered_streaming_nemo.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 """ run_reference_parakeet_buffered_streaming_nemo.py — NeMo buffered RNN-T -streaming batch transcribe for WER on parakeet-unified-en-0.6b. +streaming batch transcribe for WER on parakeet-unified-en-0.6b and the +prompt-conditioned nemotron-labs-unified-asr-0.6b. Mirrors `scripts/wer/run_reference_parakeet_streaming_nemo.py` (which drives cache-aware streaming) but runs NeMo's BUFFERED streaming @@ -11,13 +12,19 @@ sliding [left | chunk | right] PCM window with chunked_limited_with_rc attention; the RNN-T decoder state is carried across chunks. +Prompt-conditioned models get one language-ID index per utterance, applied +by the model forward to the whole window's encoder output on every chunk, +as upstream's `target_lang` / `lang_field` does: --language overrides every +entry; otherwise the entry's `lang` or `language` field is used, and "auto" +when it names none. The language must be a prompt_dictionary key. + Usage: uv run --project scripts/envs/parakeet \\ scripts/wer/run_reference_parakeet_buffered_streaming_nemo.py \\ --model /path/to/parakeet-unified-en-0.6b.nemo \\ --manifest samples/wer/test-clean.512.manifest.jsonl \\ --out reports/wer/parakeet-unified-buffered-REF.test-clean-512.jsonl \\ - [--left-secs 5.6 --chunk-secs 1.04 --right-secs 1.04] + [--left-secs 5.6 --chunk-secs 1.04 --right-secs 1.04] [--language fr] Output JSONL is run.py-compatible so scripts/wer/score.py scores it. """ @@ -25,6 +32,7 @@ from __future__ import annotations import argparse +import inspect import json import sys import time @@ -49,6 +57,11 @@ def main() -> int: "~5x speedup over cpu on parakeet-unified buffered " "streaming. Defaults to cpu for reproducibility.") p.add_argument("--limit", type=int, default=0) + p.add_argument("--language", default=None, + help="Target language (prompt_dictionary key) for every " + "utterance of a prompt-conditioned model. Default: " + "each entry's lang/language field, else 'auto'. " + "Ignored by models without a language prompt.") args = p.parse_args() if not args.manifest.exists(): @@ -62,39 +75,18 @@ def main() -> int: torch.set_num_threads(args.torch_threads) torch.set_num_interop_threads(1) - # Reuse the conformer-kwarg drop hack from the offline dumper. - # force_regular_att_style=False — unified-en must keep its native - # chunked_limited_with_rc style. + # Load through the dumper so the model class (incl. the prompt-aware + # EncDecRNNTBPEModelWithPrompt) is restored from the .nemo's own config + # and the conformer-kwarg drop hack applies. offline_only=False keeps + # the native chunked_limited_with_rc style. The hack drops + # conv_context_style='dcc', which NeMo stores but never reads at + # inference (conformer_encoder.py), so it is inert here. sys.path.insert(0, str(Path(__file__).resolve().parents[1])) - from dump_reference_parakeet_nemo import _patch_conformer_for_offline - _patch_conformer_for_offline(force_regular_att_style=False) + from dump_reference_parakeet_nemo import is_prompt_aware, load_model, resolve_prompt_id print(f"loading: {args.model}") t0 = time.monotonic() - from nemo.collections.asr.models import ASRModel - try: - model = ASRModel.from_pretrained(args.model, map_location="cpu") - except TypeError as e: - if "abstract class" not in str(e): - raise - from nemo.collections.asr.models.rnnt_bpe_models import EncDecRNNTBPEModel - last = e - try: - model = EncDecRNNTBPEModel.from_pretrained(args.model, map_location="cpu") - except Exception as e2: - last = e2 - local = Path(args.model) - if local.exists(): - model = EncDecRNNTBPEModel.restore_from(str(local), map_location="cpu") - else: - raise last - except Exception: - local = Path(args.model) - if local.exists(): - from nemo.collections.asr.models.rnnt_bpe_models import EncDecRNNTBPEModel - model = EncDecRNNTBPEModel.restore_from(str(local), map_location="cpu") - else: - raise + model = load_model(argparse.Namespace(model=args.model, offline_only=False, att_context=None)) model.eval() if args.device != "cpu": model = model.to(args.device) @@ -169,7 +161,20 @@ def main() -> int: left=samples_left, chunk=samples_chunk, right=samples_right, ) - def transcribe_one(audio_path: str) -> str: + prompt_aware = is_prompt_aware(model) + prompt_ids: dict[str, int] = {} + + def prompt_kwargs_for(entry: dict) -> dict: + if not prompt_aware: + return {} + lang = args.language or entry.get("lang") or entry.get("language") or "auto" + if lang not in prompt_ids: + prompt_ids[lang] = resolve_prompt_id(model, lang) + print(f"prompt: target_lang={lang!r} prompt_id={prompt_ids[lang]}") + return {"prompt_indices": torch.tensor([prompt_ids[lang]], dtype=torch.long, + device=args.device)} + + def transcribe_one(audio_path: str, prompt_kwargs: dict) -> str: pcm, sr = sf.read(audio_path, dtype="float32", always_2d=False) if pcm.ndim > 1: pcm = pcm.mean(axis=1) @@ -214,6 +219,7 @@ def transcribe_one(audio_path: str) -> str: encoder_output, encoder_output_len = model( input_signal=buffer.samples, input_signal_length=buffer.context_size_batch.total(), + **prompt_kwargs, ) encoder_output = encoder_output.transpose(1, 2) encoder_context = buffer.context_size.subsample( @@ -224,7 +230,7 @@ def transcribe_one(audio_path: str) -> str: ) encoder_output_chunk = encoder_output[:, encoder_context.left:] - chunk_batched_hyps, _, state = decoding_computer( + decode_out = decoding_computer( x=encoder_output_chunk, out_len=torch.where( is_last_chunk_batch, @@ -234,6 +240,8 @@ def transcribe_one(audio_path: str) -> str: prev_batched_state=state, multi_biasing_ids=None, ) + # NeMo 2.8 returns (hyps, alignments, state); NeMo 3.1 returns (hyps, state). + chunk_batched_hyps, state = decode_out[0], decode_out[-1] if current_batched_hyps is None: current_batched_hyps = chunk_batched_hyps else: @@ -244,9 +252,11 @@ def transcribe_one(audio_path: str) -> str: right_sample = min(right_sample + context_samples.chunk, audio_tensor.shape[1]) - hyps_view = batched_hyps_to_hypotheses( - current_batched_hyps, None, batch_size=1 - ) + # NeMo 2.8: (batched_hyps, alignments, batch_size); NeMo 3.1 dropped alignments. + if 'alignments' in inspect.signature(batched_hyps_to_hypotheses).parameters: + hyps_view = batched_hyps_to_hypotheses(current_batched_hyps, None, batch_size=1) + else: + hyps_view = batched_hyps_to_hypotheses(current_batched_hyps, batch_size=1) if not hyps_view or hyps_view[0].y_sequence is None: return "" ids = [int(x) for x in hyps_view[0].y_sequence.tolist()] @@ -273,6 +283,7 @@ def transcribe_one(audio_path: str) -> str: "left_secs": float(args.left_secs), "chunk_secs": float(args.chunk_secs), "right_secs": float(args.right_secs), + "target_lang": (args.language if prompt_aware else None), }, }) + "\n") fout.flush() @@ -282,7 +293,7 @@ def transcribe_one(audio_path: str) -> str: audio = entry.get("audio") or entry.get("audio_filepath") t0 = time.monotonic() try: - text = transcribe_one(audio) + text = transcribe_one(audio, prompt_kwargs_for(entry)) err = None except Exception as e: text = "" diff --git a/scripts/wer/run_reference_parakeet_nemo.py b/scripts/wer/run_reference_parakeet_nemo.py index 1b1ba2425..01615ee7a 100644 --- a/scripts/wer/run_reference_parakeet_nemo.py +++ b/scripts/wer/run_reference_parakeet_nemo.py @@ -136,6 +136,7 @@ def main() -> int: sys.path.insert(0, str(Path(__file__).resolve().parents[1])) from dump_reference_parakeet_nemo import ( _patch_conformer_for_offline, + att_context_style, apply_att_context_right_override, is_prompt_aware, resolve_prompt_id, @@ -191,7 +192,7 @@ def main() -> int: model.eval() apply_att_context_right_override(model, args.att_context_right) if att_context is not None: - style = str(getattr(model.cfg.encoder, "att_context_style", "regular")) + style = att_context_style(model) if style != "regular": print(f"error: --att-context applies to regular-style encoders; " f"this checkpoint is {style!r}", file=sys.stderr) diff --git a/src/arch/parakeet/model.cpp b/src/arch/parakeet/model.cpp index 8ade1bb15..46c676056 100644 --- a/src/arch/parakeet/model.cpp +++ b/src/arch/parakeet/model.cpp @@ -174,6 +174,44 @@ int32_t resolve_prompt_id(const ParakeetHParams & hp, const char * language_hint return -1; } +// The language hints a prompt-conditioned variant accepts beyond its +// advertised caps.languages: every prompt-dictionary key that selects the +// same prompt slot as an advertised language ("en-US" and "English" for +// "en") plus the dictionary's auto slot ("auto", the same slot a null +// hint selects). Keys on other slots stay rejected even though NeMo would +// take them: the checkpoint inherits the dictionary of a wider-coverage +// sibling, and slots outside the advertised set may be untrained (on +// nemotron-labs-unified-asr-0.6b "es-ES" is slot 2, an untrained column, +// while "es" is the trained slot 3). +std::vector prompt_language_aliases(const ParakeetHParams & hp, const transcribe_capabilities & caps) { + std::vector aliases; + if (!hp.has_prompt) { + return aliases; + } + std::set slots; + std::set advertised; + for (int i = 0; i < caps.n_languages && caps.languages != nullptr; ++i) { + if (caps.languages[i] == nullptr) { + continue; + } + advertised.insert(caps.languages[i]); + const int32_t pid = resolve_prompt_id(hp, caps.languages[i]); + if (pid >= 0) { + slots.insert(pid); + } + } + if (hp.prompt_auto_id >= 0) { + slots.insert(hp.prompt_auto_id); + } + for (size_t i = 0; i < hp.prompt_dictionary_locales.size(); ++i) { + const std::string & key = hp.prompt_dictionary_locales[i]; + if (slots.count(hp.prompt_dictionary_indices[i]) != 0 && advertised.count(key) == 0) { + aliases.push_back(key); + } + } + return aliases; +} + // Fill a [num_prompts, T_enc, 1, n_batch] buffer with a one-hot at // column prompt_id of each utterance, replicated across T_enc (one id // per utterance in prompt_ids). Host-side replication keeps the in-graph @@ -201,6 +239,66 @@ bool fill_prompt_one_hot(std::vector & out, return true; } +} // namespace + +// Offline full-attention limit for chunked_limited_with_rc (unified) GGUFs +// (kOfflineFullAttentionMaxSeconds, weights.h). Offline, NeMo runs these +// checkpoints with full attention: work and memory grow with T^2, so long +// audio runs the Regular-local [256, 256] window (kLongformAttContext, +// NeMo's rel_pos_local_attn) instead. Up to the limit the encoder runs full +// attention and matches NeMo's offline output on every standard eval set +// (LibriSpeech and FLEURS clips are <= 35 s); above it the window keeps +// memory and time linear in length, and NeMo's [256, 256] window is as +// accurate on long audio (nemotron-labs-unified: TED-LIUM 3.46% vs 3.50% +// full, Earnings-22 16.19% vs 17.53%). Measured encoder time, M4 Max, Q8_0, +// Metal / CPU, full attention vs window: +// 2 min 0.45 / 4.5 s vs 0.39 / 2.6 s (compute buffer 0.5 GB both) +// 5 min 1.9 / 17 s vs 1.0 / 6.7 s (1.3 GB both) +// 10 min 6.6 / 50 s vs 2.0 / 14 s (2.6 GB both) +// 20 min 27 / 233 s vs 4.0 / 30 s (7.8 GB vs 5.1 GB) +// Flash attention keeps C++ memory near-linear either way, so the limit is +// set by time: 2 min keeps exact NeMo parity for dictation-length input at +// under 2x the windowed CPU cost. +double parse_full_attention_max_seconds(const char * value) { + if (value == nullptr || value[0] == '\0') { + return kOfflineFullAttentionMaxSeconds; + } + char * end = nullptr; + const double s = std::strtod(value, &end); + if (end != value && *end == '\0' && std::isfinite(s) && s >= 0.0) { + return s; + } + log_msg(TRANSCRIBE_LOG_LEVEL_WARN, + "parakeet: ignoring TRANSCRIBE_PARAKEET_FULL_ATTENTION_MAX_S=\"%s\" (want seconds >= 0); using %.0f s", + value, kOfflineFullAttentionMaxSeconds); + return kOfflineFullAttentionMaxSeconds; +} + +double offline_full_attention_max_seconds() { + return parse_full_attention_max_seconds(transcribe::env::str("TRANSCRIBE_PARAKEET_FULL_ATTENTION_MAX_S")); +} + +bool offline_runs_windowed(const ParakeetModel * pm, int64_t n_samples, double max_seconds) { + if (!pm->hparams_longform.has_value()) { + return false; + } + // Up to kLongformAttContext encoder frames the [256, 256] band covers + // every (q, k) pair and the encoder builds the full-attention graph + // anyway, so a limit below that span (the override at 0) leaves those + // clips on the model's own hparams and in the batched path. + const double samples_per_frame = + static_cast(pm->hparams.enc_subsampling_factor) * static_cast(pm->hparams.fe_hop_length); + const double band_samples = static_cast(kLongformAttContext) * samples_per_frame; + const double limit_samples = max_seconds * static_cast(pm->hparams.fe_sample_rate); + return static_cast(n_samples) > std::max(limit_samples, band_samples); +} + +const ParakeetHParams & offline_hparams(const ParakeetModel * pm, int64_t n_samples, double max_seconds) { + return offline_runs_windowed(pm, n_samples, max_seconds) ? *pm->hparams_longform : pm->hparams; +} + +namespace { + // Fuse inference-time BatchNorm into scale + bias tensors: // BN eval: y = (x - mean) / sqrt(var + eps) * weight + bias // fused: y = x * scale + shift, scale = weight / sqrt(var + eps), @@ -456,6 +554,9 @@ transcribe_status load(Loader & loader, const transcribe_model_load_params * par return st; } + // Prompt-conditioned variants take more spellings than they advertise. + m->set_language_aliases(prompt_language_aliases(m->hparams, m->caps)); + // A VAD head means transcribe_run segments long audio // itself (run_longform): advertise the long-form chunker. if (m->hparams.has_vad_head) { @@ -481,6 +582,19 @@ transcribe_status load(Loader & loader, const transcribe_model_load_params * par m->caps.supports_streaming = true; } + // Unified (chunked_limited_with_rc) GGUFs: the offline long-audio + // encoder config (see offline_hparams). Same weights; only the offline + // attention style and window change. + if (m->hparams.enc_att_context_style == ParakeetHParams::AttContextStyle::ChunkedLimitedWithRc && + !m->hparams.kestrel_length_masking) { + ParakeetHParams lf = m->hparams; + lf.enc_att_context_style = ParakeetHParams::AttContextStyle::Regular; + lf.enc_att_context_left = kLongformAttContext; + lf.enc_att_context_right = kLongformAttContext; + lf.enc_att_context_size_choices.assign(1, std::make_pair(kLongformAttContext, kLongformAttContext)); + m->hparams_longform = std::move(lf); + } + // Construct the mel front-end (precomputes Hann window + Slaney mel // filterbank); amortized across every run on every context. { @@ -1120,6 +1234,19 @@ transcribe_status run_one_shot_inner(ParakeetSession * pc, int n_samples, const transcribe_run_params * params, const MultitalkerPass * mt) { + // Unified GGUFs run long offline clips windowed (offline_hparams). The + // override is read once per run. + const double full_attention_max_s = + pm->hparams_longform.has_value() ? offline_full_attention_max_seconds() : kOfflineFullAttentionMaxSeconds; + const ParakeetHParams & hp_run = offline_hparams(pm, n_samples, full_attention_max_s); + if (&hp_run != &pm->hparams) { + log_msg(TRANSCRIBE_LOG_LEVEL_INFO, + "parakeet: %.1f s is past the %.0f s full-attention limit; offline encoder uses local attention " + "[%d, %d]", + static_cast(n_samples) / static_cast(pm->hparams.fe_sample_rate), full_attention_max_s, + kLongformAttContext, kLongformAttContext); + } + // Pre-run abort check (the single observation point on this path). if (pc->poll_abort()) { return TRANSCRIBE_ERR_ABORTED; @@ -1151,7 +1278,7 @@ transcribe_status run_one_shot_inner(ParakeetSession * pc, shape, 2, "encoder.mel"); } // Kestrel-masked checkpoints mask the padding frame in-graph instead. - if (!pm->hparams.kestrel_length_masking) { + if (!hp_run.kestrel_length_masking) { mel_n_frames = pm->mel->drop_nemo_padding_frame(pc->mel_buf, mel_n_frames, static_cast(n_samples)); } @@ -1161,7 +1288,7 @@ transcribe_status run_one_shot_inner(ParakeetSession * pc, // an inactive target) zero out, and original exact-zero features take // the log-floor mask_value. Mirrors the reference quirk exactly. if (mt != nullptr && !mt->use_kernel) { - const int sub = pm->hparams.enc_subsampling_factor > 0 ? pm->hparams.enc_subsampling_factor : 8; + const int sub = hp_run.enc_subsampling_factor > 0 ? hp_run.enc_subsampling_factor : 8; const size_t T_diar = mt->spk.size(); for (int m = 0; m < mel_n_mels; ++m) { float * row = pc->mel_buf.data() + static_cast(m) * mel_n_frames; @@ -1220,7 +1347,7 @@ transcribe_status run_one_shot_inner(ParakeetSession * pc, // the encoder length by a frame at the clip tail). std::vector mt_keep; if (spk_supervision && !mt->keep_enc_frames.empty()) { - const bool causal = (pm->hparams.enc_att_context_style == ParakeetHParams::AttContextStyle::ChunkedLimited); + const bool causal = (hp_run.enc_att_context_style == ParakeetHParams::AttContextStyle::ChunkedLimited); const int T_pred = pre_encode_time_out(pre_encode_time_out(pre_encode_time_out(mel_n_frames, causal), causal), causal); mt_keep.reserve(mt->keep_enc_frames.size()); @@ -1231,10 +1358,10 @@ transcribe_status run_one_shot_inner(ParakeetSession * pc, } } const int mt_keep_frames = static_cast(mt_keep.size()); - const bool kestrel_masks = pm->hparams.kestrel_length_masking; - EncoderBuild eb = build_encoder_graph(pc->compute_ctx, pm->weights, pm->hparams, mel_n_frames, resolved_kv, - pm->backend.c_str(), /*buf_mask=*/nullptr, /*n_batch=*/1, - /*batch_var_len=*/kestrel_masks, spk_supervision, mt_keep_frames); + const bool kestrel_masks = hp_run.kestrel_length_masking; + EncoderBuild eb = build_encoder_graph(pc->compute_ctx, pm->weights, hp_run, mel_n_frames, resolved_kv, + pm->backend.c_str(), /*buf_mask=*/nullptr, /*n_batch=*/1, + /*batch_var_len=*/kestrel_masks, spk_supervision, mt_keep_frames); if (eb.mel_in == nullptr || eb.out == nullptr || eb.graph == nullptr) { return TRANSCRIBE_ERR_GGUF; // build_encoder_graph logged } @@ -1267,7 +1394,7 @@ transcribe_status run_one_shot_inner(ParakeetSession * pc, int T_valid = -1; if (kestrel_masks) { std::vector real_tenc; - fill_length_masks(eb, { pre_encode_stage_lengths(pm->hparams, n_samples, mel_n_frames) }, { mel_n_frames }, + fill_length_masks(eb, { pre_encode_stage_lengths(hp_run, n_samples, mel_n_frames) }, { mel_n_frames }, static_cast(eb.out->ne[1]), real_tenc); T_valid = real_tenc[0]; } @@ -1320,7 +1447,7 @@ transcribe_status run_one_shot_inner(ParakeetSession * pc, const int P = static_cast(eb.prompt_one_hot_in->ne[0]); const int T_oh = static_cast(eb.prompt_one_hot_in->ne[1]); const char * lang_hint = (params != nullptr) ? params->language : nullptr; - const int32_t pid = resolve_prompt_id(pm->hparams, lang_hint); + const int32_t pid = resolve_prompt_id(hp_run, lang_hint); if (pid < 0) { log_msg(TRANSCRIBE_LOG_LEVEL_ERROR, "parakeet run: language %s%s%s not in prompt " @@ -1349,17 +1476,17 @@ transcribe_status run_one_shot_inner(ParakeetSession * pc, // pe[i, 2k] = sin(positions[i] * div_term[k]) // pe[i, 2k+1] = cos(positions[i] * div_term[k]) if (eb.pos_emb_in != nullptr) { - const int d_model = pm->hparams.enc_d_model; + const int d_model = hp_run.enc_d_model; const int pos_len = static_cast(eb.pos_emb_in->ne[1]); // Position of relative offset 0 in the buffer: (pos_len-1)/2 for // full/dense ChunkedLimited; W_left for dense Regular local // attention; window_left + chunk - 1 for the bounded-window graph. - const bool is_chunked = (pm->hparams.enc_att_context_style == ParakeetHParams::AttContextStyle::ChunkedLimited); + const bool is_chunked = (hp_run.enc_att_context_style == ParakeetHParams::AttContextStyle::ChunkedLimited); const bool is_local_pe = !eb.full_attention_shortcut && (!is_chunked) && - (pm->hparams.enc_att_context_left >= 0 && pm->hparams.enc_att_context_right >= 0); + (hp_run.enc_att_context_left >= 0 && hp_run.enc_att_context_right >= 0); const int zero_index = eb.window_chunk > 0 ? eb.window_left + eb.window_chunk - 1 : - is_local_pe ? pm->hparams.enc_att_context_left : + is_local_pe ? hp_run.enc_att_context_left : (pos_len - 1) / 2; pc->pos_buf.assign(static_cast(pos_len) * d_model, 0.0f); @@ -1393,8 +1520,8 @@ transcribe_status run_one_shot_inner(ParakeetSession * pc, // take the compact [W, C, 1, N] layout for the same chunk band, or the // Regular-local |q-k| band. if (eb.chunked_mask_in != nullptr) { - const int chunk_size = pm->hparams.enc_att_context_right + 1; - const int left_chunks = (chunk_size > 0) ? (pm->hparams.enc_att_context_left / chunk_size) : 0; + const int chunk_size = hp_run.enc_att_context_right + 1; + const int left_chunks = (chunk_size > 0) ? (hp_run.enc_att_context_left / chunk_size) : 0; const int T_enc = static_cast(eb.out->ne[1]); const int T_k = static_cast(eb.chunked_mask_in->ne[0]); @@ -1402,11 +1529,11 @@ transcribe_status run_one_shot_inner(ParakeetSession * pc, const int N = static_cast(eb.chunked_mask_in->ne[3]); const bool windowed = eb.window_chunk > 0; std::vector mask_buf(static_cast(T_k) * T_q * N, -std::numeric_limits::infinity()); - if (windowed && pm->hparams.enc_att_context_style == ParakeetHParams::AttContextStyle::ChunkedLimited) { + if (windowed && hp_run.enc_att_context_style == ParakeetHParams::AttContextStyle::ChunkedLimited) { compute_chunked_limited_window_mask(mask_buf.data(), T_enc, T_enc, chunk_size, left_chunks); } else if (windowed) { - compute_local_window_mask(mask_buf.data(), T_enc, T_enc, eb.window_chunk, pm->hparams.enc_att_context_left, - pm->hparams.enc_att_context_right); + compute_local_window_mask(mask_buf.data(), T_enc, T_enc, eb.window_chunk, hp_run.enc_att_context_left, + hp_run.enc_att_context_right); } else { // Dense reference layout [T_k,T_q,1,1]. for (int q = 0; q < T_enc; ++q) { @@ -1520,7 +1647,7 @@ transcribe_status run_one_shot_inner(ParakeetSession * pc, static_cast(T_valid) * static_cast(d_enc), shape, 2, "encoder.final"); } - const char * enc_dump_name = pm->hparams.has_prompt ? "dec.enc_out_prompted" : nullptr; + const char * enc_dump_name = hp_run.has_prompt ? "dec.enc_out_prompted" : nullptr; return decode_and_populate(pc, pm, params, pc->enc_host.data(), T_valid, d_enc, /*utt_index=*/-1, enc_dump_name); } @@ -1528,7 +1655,7 @@ transcribe_status run_one_shot_inner(ParakeetSession * pc, // Prompt-conditioned models: eb.out is the post-prompt tensor // ("dec.enc_out_prompted"); also read back the pre-prompt final_out // as "dec.enc_out" so both reference dump names match. - if (pm->hparams.has_prompt && eb.dumps.final_out != nullptr && transcribe::debug::enabled()) { + if (hp_run.has_prompt && eb.dumps.final_out != nullptr && transcribe::debug::enabled()) { std::vector unprompted(pc->enc_host.size()); ggml_backend_tensor_get(eb.dumps.final_out, unprompted.data(), 0, unprompted.size() * sizeof(float)); const long long shape[2] = { T_enc, d_enc }; @@ -1537,7 +1664,7 @@ transcribe_status run_one_shot_inner(ParakeetSession * pc, "decoder.enc_out"); } - const char * enc_dump_name = pm->hparams.has_prompt ? "dec.enc_out_prompted" : nullptr; + const char * enc_dump_name = hp_run.has_prompt ? "dec.enc_out_prompted" : nullptr; return decode_and_populate(pc, pm, params, pc->enc_host.data(), T_enc, d_enc, /*utt_index=*/-1, enc_dump_name); } @@ -2163,10 +2290,17 @@ transcribe_status run_batch(transcribe_session * session, } // Any long-form clip sends the batch through transcribe_run's per-utterance - // paths, so batched and serial results match. + // paths, so batched and serial results match. That includes a unified + // GGUF's clip past the full-attention limit: its windowed encoder config + // differs from the batch graph's. + const double full_attention_max_s = + pm->hparams_longform.has_value() ? offline_full_attention_max_seconds() : kOfflineFullAttentionMaxSeconds; bool any_longform = false; for (int i = 0; i < n; ++i) { - any_longform = any_longform || (pcm[i] != nullptr && n_samples[i] > 0 && needs_longform(pm, n_samples[i])); + any_longform = + any_longform || + (pcm[i] != nullptr && n_samples[i] > 0 && + (needs_longform(pm, n_samples[i]) || offline_runs_windowed(pm, n_samples[i], full_attention_max_s))); } if (any_longform) { for (int i = 0; i < n; ++i) { @@ -3152,6 +3286,36 @@ transcribe_status emit_buffered_chunk(ParakeetSession * pc, ggml_backend_tensor_set(eb.chunked_mask_in, mask_buf.data(), 0, mask_buf.size() * sizeof(float)); } + // Prompt one-hot upload (multilingual unified variants only). The + // graph is rebuilt per chunk, so the prompt is re-uploaded every chunk + // across the whole [left | chunk | right] window; NeMo's buffered loop + // applies the prompt to the full window's encoder output the same way + // (EncDecRNNTBPEModelWithPrompt.forward with language_prompt_indices) + // before slicing off the left frames. The language hint lives in + // pc->stream_run_params, as on the cache-aware path. + if (eb.prompt_one_hot_in != nullptr) { + const int P = static_cast(eb.prompt_one_hot_in->ne[0]); + const int T_oh = static_cast(eb.prompt_one_hot_in->ne[1]); + const char * lang_hint = pc->stream_run_params.language; + const int32_t pid = resolve_prompt_id(pm->hparams, lang_hint); + if (pid < 0) { + log_msg(TRANSCRIBE_LOG_LEVEL_ERROR, + "parakeet buffered: language %s%s%s not in prompt " + "dictionary", + lang_hint ? "\"" : "", lang_hint ? lang_hint : "", lang_hint ? "\"" : ""); + return TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE; + } + std::vector one_hot_buf; + if (!fill_prompt_one_hot(one_hot_buf, P, T_oh, /*n_batch=*/1, { pid })) { + log_msg(TRANSCRIBE_LOG_LEVEL_ERROR, + "parakeet buffered: prompt_id %d out of range " + "[0, %d)", + pid, P); + return TRANSCRIBE_ERR_GGUF; + } + ggml_backend_tensor_set(eb.prompt_one_hot_in, one_hot_buf.data(), 0, one_hot_buf.size() * sizeof(float)); + } + // ----- Threading ----- transcribe::configure_sched_n_threads(pc->sched, pc->n_threads); @@ -3217,7 +3381,15 @@ transcribe_status emit_buffered_chunk(ParakeetSession * pc, pc->enc_host.resize(static_cast(d_enc) * static_cast(T_enc_full)); ggml_backend_tensor_get(eb.out, pc->enc_host.data(), 0, pc->enc_host.size() * sizeof(float)); - transcribe::debug::dump_tensor("enc.final", eb.out, "encoder.final"); + // Prompt-conditioned models: eb.out is the post-prompt tensor; dump the + // pre-prompt encoder output under "enc.final" (matching the offline path) + // and the prompted one under "enc.prompted". + if (eb.dumps.prompted_out != nullptr && eb.dumps.final_out != nullptr) { + transcribe::debug::dump_tensor("enc.final", eb.dumps.final_out, "encoder.final"); + transcribe::debug::dump_tensor("enc.prompted", eb.out, "encoder.prompted"); + } else { + transcribe::debug::dump_tensor("enc.final", eb.out, "encoder.final"); + } // Subsample session into encoder frames — mirrors NeMo's // buffer.context_size.subsample(factor=encoder_frame2audio_samples). @@ -3279,12 +3451,14 @@ transcribe_status emit_buffered_chunk(ParakeetSession * pc, // Pure validation of the buffered-stream extension: resolves (L, C, R) // to encoder frames. Does NOT touch pc->buf_*; out pointers written only -// on TRANSCRIBE_OK. +// on TRANSCRIBE_OK. log_off_menu: stream_begin logs an off-menu tuple once +// (stream_validate resolves the same tuple silently first). transcribe_status resolve_buffered_stream_geom(const ParakeetModel * pm, const transcribe_stream_params * stream_params, int * out_L_frames, int * out_C_frames, - int * out_R_frames) { + int * out_R_frames, + bool log_off_menu = false) { const int frame_ms = (pm->hparams.enc_subsampling_factor * pm->hparams.fe_hop_length * 1000) / std::max(pm->hparams.fe_sample_rate, 1); @@ -3342,6 +3516,37 @@ transcribe_status resolve_buffered_stream_geom(const ParakeetModel * return TRANSCRIBE_ERR_INVALID_ARG; } + // Any (L >= 0, C >= 1, R >= 0) frame tuple is accepted: NeMo's buffered + // loop takes arbitrary contexts and the publisher recommends tuples off + // the training menu (nemotron-labs-unified-asr-0.6b's 0.56 s row is + // L/C/R = 70/2/5 with R=5 untrained). The menu only picks the defaults; + // an off-menu tuple is logged, not rejected. + if (C_frames < 1) { + log_msg(TRANSCRIBE_LOG_LEVEL_ERROR, + "parakeet buffered: requested chunk = %d encoder frames (%d ms); the chunk must be at least " + "one %d ms encoder frame", + C_frames, C_frames * safe_frame_ms, safe_frame_ms); + return TRANSCRIBE_ERR_INVALID_ARG; + } + + // Every chunk re-encodes the whole [left | chunk | right] window with + // full attention, so one window is capped at the offline full-attention + // limit (kOfflineFullAttentionMaxSeconds). int64 throughout: the + // relaxed tuple takes caller-sized fields. + const int64_t samples_per_frame = + static_cast(pm->hparams.enc_subsampling_factor) * static_cast(pm->hparams.fe_hop_length); + const int64_t window_frames = + static_cast(L_frames) + static_cast(C_frames) + static_cast(R_frames); + const int64_t window_cap_samples = + static_cast(kOfflineFullAttentionMaxSeconds * static_cast(pm->hparams.fe_sample_rate)); + if (samples_per_frame <= 0 || window_frames > window_cap_samples / samples_per_frame) { + log_msg(TRANSCRIBE_LOG_LEVEL_ERROR, + "parakeet buffered: requested (L, C, R) = (%d, %d, %d) encoder frames spans more than the %.0f s " + "buffered-window limit (left + chunk + right)", + L_frames, C_frames, R_frames, kOfflineFullAttentionMaxSeconds); + return TRANSCRIBE_ERR_INVALID_ARG; + } + auto contains = [](const std::vector & v, int x) -> bool { for (auto y : v) { if (y == x) { @@ -3350,29 +3555,25 @@ transcribe_status resolve_buffered_stream_geom(const ParakeetModel * } return false; }; - if (!contains(pm->hparams.enc_att_chunk_left_choices, L_frames) || - !contains(pm->hparams.enc_att_chunk_chunk_choices, C_frames) || - !contains(pm->hparams.enc_att_chunk_right_choices, R_frames)) { - std::string allowed = "L="; + if (log_off_menu && (!contains(pm->hparams.enc_att_chunk_left_choices, L_frames) || + !contains(pm->hparams.enc_att_chunk_chunk_choices, C_frames) || + !contains(pm->hparams.enc_att_chunk_right_choices, R_frames))) { + std::string menu = "L="; for (auto v : pm->hparams.enc_att_chunk_left_choices) { - allowed += std::to_string(v) + ","; + menu += std::to_string(v) + ","; } - allowed += " C="; + menu += " C="; for (auto v : pm->hparams.enc_att_chunk_chunk_choices) { - allowed += std::to_string(v) + ","; + menu += std::to_string(v) + ","; } - allowed += " R="; + menu += " R="; for (auto v : pm->hparams.enc_att_chunk_right_choices) { - allowed += std::to_string(v) + ","; + menu += std::to_string(v) + ","; } - log_msg(TRANSCRIBE_LOG_LEVEL_ERROR, - "parakeet buffered: requested (L, C, R) = (%d, %d, %d) " - "encoder frames not in model menu. Allowed %s", - L_frames, C_frames, R_frames, allowed.c_str()); - return TRANSCRIBE_ERR_INVALID_ARG; - } - if (C_frames < 1) { - return TRANSCRIBE_ERR_INVALID_ARG; + log_msg(TRANSCRIBE_LOG_LEVEL_INFO, + "parakeet buffered: (L, C, R) = (%d, %d, %d) encoder frames is outside the training menu (%s); " + "running it as requested", + L_frames, C_frames, R_frames, menu.c_str()); } *out_L_frames = L_frames; @@ -3440,8 +3641,8 @@ transcribe_status resolve_cache_aware_stream_geom(const ParakeetModel * // Pre-flight: validate caller extension fields without mutating state. // Called by the dispatcher before clear_result, so a rejection leaves the // previous snapshot intact. stream_begin re-runs the same resolvers. -transcribe_status stream_validate(const transcribe_session * session, - const transcribe_run_params * /*run_params*/, +transcribe_status stream_validate(const transcribe_session * session, + const transcribe_run_params * run_params, const transcribe_stream_params * stream_params) { const auto * pc = static_cast(session); const auto * pm = static_cast(pc->model); @@ -3449,6 +3650,19 @@ transcribe_status stream_validate(const transcribe_session * session, return TRANSCRIBE_ERR_INVALID_ARG; } + // Prompt-conditioned models resolve the language on every chunk; reject + // a hint outside the prompt dictionary at begin rather than at the first + // feed. The generic gate (accepts_language) already refuses these; this + // is defense in depth for callers that reach the hook directly. + if (pm->hparams.has_prompt) { + const char * lang_hint = (run_params != nullptr) ? run_params->language : nullptr; + if (resolve_prompt_id(pm->hparams, lang_hint) < 0) { + log_msg(TRANSCRIBE_LOG_LEVEL_ERROR, "parakeet stream: language %s%s%s not in prompt dictionary", + lang_hint ? "\"" : "", lang_hint ? lang_hint : "", lang_hint ? "\"" : ""); + return TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE; + } + } + const bool is_chunked_limited = (pm->hparams.enc_att_context_style == ParakeetHParams::AttContextStyle::ChunkedLimited); const bool is_chunked_with_rc = @@ -3509,21 +3723,22 @@ transcribe_status stream_begin(transcribe_session * session, // produces the parsed values we configure state from). int L_frames = 0, C_frames = 0, R_frames = 0; if (const transcribe_status st = - resolve_buffered_stream_geom(pm, stream_params, &L_frames, &C_frames, &R_frames); + resolve_buffered_stream_geom(pm, stream_params, &L_frames, &C_frames, &R_frames, + /*log_off_menu=*/true); st != TRANSCRIBE_OK) { return st; } - const int subsampling_factor = pm->hparams.enc_subsampling_factor; - const int hop = pm->hparams.fe_hop_length; - const int samples_per_frame = subsampling_factor * hop; + const int subsampling_factor = pm->hparams.enc_subsampling_factor; + const int hop = pm->hparams.fe_hop_length; + const int64_t samples_per_frame = static_cast(subsampling_factor) * static_cast(hop); pc->buf_left_frames = L_frames; pc->buf_chunk_frames = C_frames; pc->buf_right_frames = R_frames; - pc->buf_samples_left = L_frames * samples_per_frame; - pc->buf_samples_chunk = C_frames * samples_per_frame; - pc->buf_samples_right = R_frames * samples_per_frame; + pc->buf_samples_left = static_cast(L_frames) * samples_per_frame; + pc->buf_samples_chunk = static_cast(C_frames) * samples_per_frame; + pc->buf_samples_right = static_cast(R_frames) * samples_per_frame; pc->buf_next_audio_read = 0; pc->buf_ctx_left = 0; pc->buf_ctx_chunk = 0; diff --git a/src/arch/parakeet/parakeet.h b/src/arch/parakeet/parakeet.h index 9d2fee81c..fda5a1912 100644 --- a/src/arch/parakeet/parakeet.h +++ b/src/arch/parakeet/parakeet.h @@ -85,6 +85,21 @@ void compute_chunked_limited_window_mask(float * out_buf, int T, int T_alloc, in // n*chunk_size - left. void compute_local_window_mask(float * out_buf, int T, int T_alloc, int chunk_size, int left, int right); +// Offline full-attention switch for unified (chunked_limited_with_rc) +// GGUFs; see kOfflineFullAttentionMaxSeconds. parse_full_attention_max_seconds +// takes a TRANSCRIBE_PARAKEET_FULL_ATTENTION_MAX_S value (seconds >= 0, the +// whole string a number; anything else falls back to the default with a +// WARN); offline_full_attention_max_seconds reads the environment. +struct ParakeetModel; +double parse_full_attention_max_seconds(const char * value); +double offline_full_attention_max_seconds(); +// True when an offline encode of n_samples runs the windowed copy +// (hparams_longform): unified GGUFs only, and only past both the limit and +// the [256, 256] band span (shorter clips build the full-attention graph +// either way). +bool offline_runs_windowed(const ParakeetModel * pm, int64_t n_samples, double max_seconds); +const ParakeetHParams & offline_hparams(const ParakeetModel * pm, int64_t n_samples, double max_seconds); + // Family defaults — applied before transcribe::read_capability_kv runs // (KV present overrides, KV absent leaves the default). Defined in // capabilities.cpp. There is no per-variant resolver: variant identity @@ -96,10 +111,15 @@ void apply_family_invariants(transcribe_model & model); // data buffer; the destructor frees it, invalidating every borrowed // ggml_tensor* in `weights`. struct ParakeetModel final : public transcribe_model { - Tokenizer tok; - ParakeetHParams hparams; - ParakeetWeights weights; - ggml_context * ctx_meta = nullptr; + Tokenizer tok; + ParakeetHParams hparams; + // chunked_limited_with_rc (unified) GGUFs only: `hparams` with the + // offline encoder switched to the Regular-local [256, 256] window, used + // for offline runs longer than the full-attention threshold (see + // offline_hparams in model.cpp). Unset for every other style. + std::optional hparams_longform; + ParakeetWeights weights; + ggml_context * ctx_meta = nullptr; // Runtime backend plan, resolved at load() via // load_common::init_backends (see transcribe-backend.h). plan's @@ -361,9 +381,9 @@ struct ParakeetSession final : public transcribe_session { int32_t buf_left_frames = 0; // L (expected) int32_t buf_chunk_frames = 0; // C int32_t buf_right_frames = 0; // R - int32_t buf_samples_left = 0; // L * encoder_frame2audio_samples - int32_t buf_samples_chunk = 0; - int32_t buf_samples_right = 0; + int64_t buf_samples_left = 0; // L * encoder_frame2audio_samples + int64_t buf_samples_chunk = 0; + int64_t buf_samples_right = 0; // Next sample index in stream_pcm_buffer to feed (= NeMo's // `left_sample` at the start of the next step). 0 at stream_begin; // advances by num_new_samples after each emit. diff --git a/src/arch/parakeet/weights.cpp b/src/arch/parakeet/weights.cpp index 7eafe2a3e..8ebfdea5d 100644 --- a/src/arch/parakeet/weights.cpp +++ b/src/arch/parakeet/weights.cpp @@ -539,7 +539,6 @@ transcribe_status read_parakeet_hparams(const gguf_context * gguf, ParakeetHPara // ships with. kestrel-masked checkpoints (parakeet-ultra) keep full // attention: they cut long audio at pauses and their contract is // kestrel's output. The streaming styles keep their trained menus. - constexpr int kLongformAttContext = 256; if (hp.enc_att_context_style == ParakeetHParams::AttContextStyle::Regular && hp.enc_att_context_left < 0 && hp.enc_att_context_right < 0 && !hp.kestrel_length_masking) { hp.enc_att_context_left = kLongformAttContext; diff --git a/src/arch/parakeet/weights.h b/src/arch/parakeet/weights.h index 885dfea53..73345525a 100644 --- a/src/arch/parakeet/weights.h +++ b/src/arch/parakeet/weights.h @@ -47,6 +47,22 @@ namespace transcribe::parakeet { // per-head decoder dispatch in run(). enum class HeadKind { TDT, RNNT, CTC }; +// Long-form local attention window, in encoder frames each side: NeMo's +// rel_pos_local_attn [256, 256], the long-audio mode NVIDIA documents for +// the family. Full-attention (Regular) GGUFs run it on every clip (it covers +// clips up to 256 frames exactly); chunked_limited_with_rc (unified) GGUFs +// run it offline above kOfflineFullAttentionMaxSeconds. +constexpr int kLongformAttContext = 256; + +// Offline full-attention limit for chunked_limited_with_rc (unified) +// GGUFs, in seconds of audio: longer offline clips run the +// kLongformAttContext window (rationale and measurements at +// parse_full_attention_max_seconds in model.cpp; +// TRANSCRIBE_PARAKEET_FULL_ATTENTION_MAX_S overrides it per run). It also +// caps one buffered-streaming window (left + chunk + right), which every +// chunk re-encodes with full attention. +constexpr double kOfflineFullAttentionMaxSeconds = 120.0; + struct ParakeetHParams { HeadKind head_kind = HeadKind::TDT; diff --git a/src/arch/sensevoice/model.cpp b/src/arch/sensevoice/model.cpp index 5867a5069..cfc3f245d 100644 --- a/src/arch/sensevoice/model.cpp +++ b/src/arch/sensevoice/model.cpp @@ -103,6 +103,9 @@ transcribe_status load(Loader & loader, const transcribe_model_load_params * par if (auto st = read_languages_kv(loader.gguf(), *m); st != TRANSCRIBE_OK) { return st; } + // "auto" selects the <|auto|> prefix row, same as a null hint + // (resolve_lid_idx); accept it at the generic language gate. + m->set_language_aliases({ "auto" }); if (auto st = m->tok.load(loader.gguf()); st != TRANSCRIBE_OK) { return st; diff --git a/src/conformer/conformer.cpp b/src/conformer/conformer.cpp index 68362d7cb..c4a3e1a5a 100644 --- a/src/conformer/conformer.cpp +++ b/src/conformer/conformer.cpp @@ -914,6 +914,20 @@ ggml_tensor * rel_pos_mhsa(ggml_context * ctx, if (flash) { if (!split_flash_mask) { matrix_bd = ggml_scale(ctx, matrix_bd, scale); + // Variable-length batch: a padded query whose band (Regular-local + // band padding, dense chunked mask) reaches no real key has every + // entry masked, and the F16 cast turns the -1e30 key-pad sentinel + // into -inf. This is the one place every such mask meets the F16 + // cast, so one clamp here covers all of them. + // Flash kernels without a zero-rowsum guard (CUDA) emit 0/0 = + // NaN for such rows; the NaN reaches real frames through the + // conv (NaN * 0 mask) and the next layer's padded keys, so the + // whole utterance decodes empty. Clamping to a finite floor keeps + // those rows finite (the graph drops them) and is exact for rows + // with a real key: exp(-3e4 - max) underflows to 0 like -inf. + if (params.attn_pad_mask != nullptr) { + matrix_bd = ggml_clamp(ctx, matrix_bd, -30000.0f, INFINITY); + } matrix_bd = ggml_cast(ctx, matrix_bd, GGML_TYPE_F16); } diff --git a/src/transcribe-asr.cpp b/src/transcribe-asr.cpp index ffbfa0c2a..95b606452 100644 --- a/src/transcribe-asr.cpp +++ b/src/transcribe-asr.cpp @@ -125,19 +125,11 @@ transcribe_status validate_run_params_common(const transcribe_session * session, return TRANSCRIBE_ERR_UNSUPPORTED_TIMESTAMPS; } } - if (params->language != nullptr && session->model->caps.n_languages > 0 && - session->model->caps.languages != nullptr) { - bool found = false; - for (int i = 0; i < session->model->caps.n_languages; ++i) { - const char * entry = session->model->caps.languages[i]; - if (entry != nullptr && std::strcmp(entry, params->language) == 0) { - found = true; - break; - } - } - if (!found) { - return TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE; - } + // Source-language gate: the advertised languages plus any aliases or + // mode keywords ("auto") the family declared at load. Inert when the + // model advertises no languages. + if (params->language != nullptr && !session->model->accepts_language(params->language)) { + return TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE; } // Translation-target gate: for a TRANSLATE request naming a target // language, reject up front when the model advertises a target set diff --git a/src/transcribe-model.cpp b/src/transcribe-model.cpp index 8bf79f23c..1a48d2e95 100644 --- a/src/transcribe-model.cpp +++ b/src/transcribe-model.cpp @@ -7,6 +7,7 @@ #include "transcribe-backend.h" #include "transcribe-session.h" +#include #include transcribe_model::~transcribe_model() = default; @@ -91,6 +92,30 @@ void transcribe_model::set_translation_pairs(std::vector pairs) { translation_pair_storage_ = std::move(pairs); } +void transcribe_model::set_language_aliases(std::vector aliases) { + language_alias_storage_ = std::move(aliases); +} + +bool transcribe_model::accepts_language(const char * lang) const { + if (caps.n_languages <= 0 || caps.languages == nullptr) { + return true; + } + if (lang == nullptr) { + return false; + } + for (int i = 0; i < caps.n_languages; ++i) { + if (caps.languages[i] != nullptr && std::strcmp(caps.languages[i], lang) == 0) { + return true; + } + } + for (const auto & alias : language_alias_storage_) { + if (alias == lang) { + return true; + } + } + return false; +} + bool transcribe_model::allows_translation_pair(const char * src, const char * dst) const { if (translation_pair_storage_.empty()) { return true; diff --git a/src/transcribe-model.h b/src/transcribe-model.h index e37c439ae..e9c45afc3 100644 --- a/src/transcribe-model.h +++ b/src/transcribe-model.h @@ -168,6 +168,19 @@ struct transcribe_model { void set_translation_pairs(std::vector pairs); bool allows_translation_pair(const char * src, const char * dst) const; + // Extra values run_params::language accepts beyond caps.languages: + // aliases the family resolves to an advertised language ("en-US" for + // "en") and mode keywords it implements ("auto"). Not advertised: the + // capability list stays the clean set of supported languages. Per-family + // load() calls this when its language input takes more spellings than + // it advertises. + void set_language_aliases(std::vector aliases); + + // The generic source-language gate: true when `lang` is advertised in + // caps.languages or is one of the family's aliases, and always when + // the model advertises no languages (the gate is inert then). + bool accepts_language(const char * lang) const; + private: // Backing storage for the languages chain. Kept private so the only // way to mutate it is through set_languages(), which guarantees the @@ -182,6 +195,9 @@ struct transcribe_model { // Backing storage for optional generic translation pair validation. std::vector translation_pair_storage_; + + // Accepted-but-unadvertised language hints (see set_language_aliases). + std::vector language_alias_storage_; }; namespace transcribe { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e115ac68f..d56ac0784 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -603,9 +603,11 @@ set(TRANSCRIBE_FIXTURE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/corrupt_magic.gguf ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/tokenizer_minimal.gguf ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/tokenizer_minimal_v3.gguf + ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/tokenizer_minimal_prompt.gguf ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/tokenizer_minimal_streaming.gguf ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/tokenizer_minimal_streaming_cache_aware.gguf ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/tokenizer_minimal_streaming_buffered.gguf + ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/tokenizer_minimal_prompt_buffered.gguf ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/arch_cohere_minimal.gguf ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/arch_granite5_ctc_minimal.gguf ${CMAKE_CURRENT_SOURCE_DIR}/fixtures/arch_gigaam_v4_minimal.gguf @@ -779,6 +781,39 @@ if(TRANSCRIBE_UV) set_tests_properties(transcribe_stream_capability_unit PROPERTIES SKIP_RETURN_CODE 77) + # ------------------------------------------------------------------------- + # Source-language gate on a prompt-conditioned parakeet model + # ------------------------------------------------------------------------- + # + # Toy one-hot language prompt fixture: unadvertised family aliases + # ("en-US", "English", "auto") pass the generic gate on run and + # run_batch; a dictionary key on an unadvertised slot ("es-ES") and + # unknown codes are UNSUPPORTED_LANGUAGE. + add_executable(transcribe_parakeet_prompt_language_unit + parakeet_prompt_language_unit.cpp) + target_link_libraries(transcribe_parakeet_prompt_language_unit PRIVATE transcribe) + target_compile_definitions(transcribe_parakeet_prompt_language_unit PRIVATE + "TRANSCRIBE_TEST_FIXTURES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/fixtures\"") + transcribe_apply_warnings(transcribe_parakeet_prompt_language_unit) + add_dependencies(transcribe_parakeet_prompt_language_unit fixtures) + add_test(NAME transcribe_parakeet_prompt_language_unit + COMMAND transcribe_parakeet_prompt_language_unit) + + # Unified (chunked_limited_with_rc + prompt) gates: stream_begin language + # gate, the offline full-attention switch and its env override, and + # batch == serial routing past the switch. Reaches internal parakeet + # helpers, so it includes src/. + add_executable(transcribe_parakeet_unified_gate_unit + parakeet_unified_gate_unit.cpp) + target_link_libraries(transcribe_parakeet_unified_gate_unit PRIVATE transcribe ggml) + target_include_directories(transcribe_parakeet_unified_gate_unit PRIVATE ${CMAKE_SOURCE_DIR}/src) + target_compile_definitions(transcribe_parakeet_unified_gate_unit PRIVATE + "TRANSCRIBE_TEST_FIXTURES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/fixtures\"") + transcribe_apply_warnings(transcribe_parakeet_unified_gate_unit) + add_dependencies(transcribe_parakeet_unified_gate_unit fixtures) + add_test(NAME transcribe_parakeet_unified_gate_unit + COMMAND transcribe_parakeet_unified_gate_unit) + # ------------------------------------------------------------------------- # Parakeet streaming extension sentinel-reject regression # ------------------------------------------------------------------------- @@ -1091,6 +1126,33 @@ if(TRANSCRIBE_BUILD_REAL_MODEL_TESTS) COMMAND transcribe_parakeet_buffered_stream_eos_smoke) set_tests_properties(transcribe_parakeet_buffered_stream_eos_smoke PROPERTIES SKIP_RETURN_CODE 77) + + # Unified-model offline switch (batch == serial around the full-attention + # limit) and an off-menu buffered tuple; skips without the unified model. + add_executable(transcribe_parakeet_unified_real_smoke + parakeet_unified_real_smoke.cpp) + target_link_libraries(transcribe_parakeet_unified_real_smoke + PRIVATE transcribe transcribe-common-example) + target_compile_definitions(transcribe_parakeet_unified_real_smoke PRIVATE + "TRANSCRIBE_TEST_SAMPLES_DIR=\"${CMAKE_SOURCE_DIR}/samples\"") + transcribe_apply_warnings(transcribe_parakeet_unified_real_smoke) + add_test(NAME transcribe_parakeet_unified_real_smoke + COMMAND transcribe_parakeet_unified_real_smoke) + set_tests_properties(transcribe_parakeet_unified_real_smoke PROPERTIES + SKIP_RETURN_CODE 77) + + # SenseVoice "auto" alias at the generic language gate. + add_executable(transcribe_sensevoice_language_gate_smoke + sensevoice_language_gate_smoke.cpp) + target_link_libraries(transcribe_sensevoice_language_gate_smoke + PRIVATE transcribe transcribe-common-example) + target_compile_definitions(transcribe_sensevoice_language_gate_smoke PRIVATE + "TRANSCRIBE_TEST_SAMPLES_DIR=\"${CMAKE_SOURCE_DIR}/samples\"") + transcribe_apply_warnings(transcribe_sensevoice_language_gate_smoke) + add_test(NAME transcribe_sensevoice_language_gate_smoke + COMMAND transcribe_sensevoice_language_gate_smoke) + set_tests_properties(transcribe_sensevoice_language_gate_smoke PROPERTIES + SKIP_RETURN_CODE 77) endif() # ----------------------------------------------------------------------------- diff --git a/tests/decoder_smoke.cpp b/tests/decoder_smoke.cpp index 585066811..f5c4a5b6f 100644 --- a/tests/decoder_smoke.cpp +++ b/tests/decoder_smoke.cpp @@ -159,7 +159,7 @@ int main() { if (variant == "tdt-0.6b-phonon-2") { reference_text = k_phonon_jfk_reference_text; max_edit_distance = 0; - } else if (variant != "tdt-0.6b-v2") { + } else if (variant != "tdt-0.6b-v2" && variant != "nemotron-labs-unified-asr-0.6b") { std::fprintf(stderr, "decoder_smoke: no transcript golden for variant " "\"%s\"\n", @@ -480,6 +480,38 @@ int main() { CHECK(transcribe_returned_timestamp_kind(ctx) == prior_timestamp_kind); } + // ---- Language hints on the prompt-conditioned variant ---------- + // + // nemotron-labs-unified advertises bare codes; "auto" (the auto + // prompt slot, same slot as a null hint) and region forms on an + // advertised slot ("en-US" = "en") pass the library gate and decode + // exactly like their canonical spelling. Unknown codes are rejected. + if (std::string(transcribe_model_variant_string(model)) == "nemotron-labs-unified-asr-0.6b") { + auto text_for = [&](const char * lang, transcribe_status * st_out) { + transcribe_run_params rl; + transcribe_run_params_init(&rl); + rl.language = lang; + *st_out = transcribe_run(ctx, pcm.data(), static_cast(pcm.size()), &rl); + return std::string(transcribe_full_text(ctx)); + }; + transcribe_status st_null = TRANSCRIBE_OK, st_auto = TRANSCRIBE_OK, st_en = TRANSCRIBE_OK, + st_en_us = TRANSCRIBE_OK, st_zz = TRANSCRIBE_OK; + const std::string t_null = text_for(nullptr, &st_null); + // No pieces: implicit detection reports nothing. + CHECK(std::strcmp(transcribe_detected_language(ctx), "") == 0); + const std::string t_auto = text_for("auto", &st_auto); + const std::string t_en = text_for("en", &st_en); + const std::string t_en_us = text_for("en-US", &st_en_us); + text_for("zz", &st_zz); + CHECK(st_null == TRANSCRIBE_OK); + CHECK(st_auto == TRANSCRIBE_OK); + CHECK(st_en == TRANSCRIBE_OK); + CHECK(st_en_us == TRANSCRIBE_OK); + CHECK(st_zz == TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE); + CHECK(t_auto == t_null); + CHECK(t_en_us == t_en); + } + // ---- Teardown -------------------------------------------------- transcribe_session_free(ctx); transcribe_model_free(model); diff --git a/tests/fixtures/make_gguf_fixtures.py b/tests/fixtures/make_gguf_fixtures.py index b4ea1263d..c20da70a3 100644 --- a/tests/fixtures/make_gguf_fixtures.py +++ b/tests/fixtures/make_gguf_fixtures.py @@ -2330,6 +2330,51 @@ def emit_fixtures(out_dir: Path) -> None: ), ) + # Prompt-conditioned variant (nemotron-3.5 / nemotron-labs-unified + # style). Same toy model plus a 4-slot one-hot language prompt MLP and + # a dictionary shaped like the real one: aliases sharing a slot with + # an advertised code (en-US/English -> en's slot 0), a region key on a + # different slot than its bare code (es-ES slot 1 vs es slot 2), and + # auto on its own slot. Advertises only "en" and "es", so the + # source-language gate must accept en-US/English/auto as aliases and + # reject es-ES (a slot no advertised language selects). + d_model = PARAKEET_HP["enc_d_model"] + n_prompts = 4 + prompt_h = 4 + prompt_dict = [("en-US", 0), ("en", 0), ("English", 0), ("es-ES", 1), ("es", 2), ("auto", 3)] + prompt_descriptors = [ + ("prompt.mlp.0.weight", [d_model + n_prompts, prompt_h]), + ("prompt.mlp.0.bias", [prompt_h]), + ("prompt.mlp.2.weight", [prompt_h, d_model]), + ("prompt.mlp.2.bias", [d_model]), + ] + prompt_tensors = [ + Tensor(name, ne, GGML_TYPE_F32, _f32_seq(ne[0] * (ne[1] if len(ne) > 1 else 1), i)) + for i, (name, ne) in enumerate(prompt_descriptors) + ] + _write( + out_dir / "tokenizer_minimal_prompt.gguf", + _build_full_gguf( + GGUF_MAGIC, + [ + _pack_kv_string("general.architecture", "parakeet"), + _pack_kv_string("stt.variant", "rnnt-prompt-toy"), + _pack_kv_bool("stt.capability.lang_detect", True), + _pack_kv_array_string("general.languages", ["en", "es"]), + _pack_kv_uint32("stt.parakeet.prompt.num_prompts", n_prompts), + _pack_kv_uint32("stt.parakeet.prompt.hidden", prompt_h), + _pack_kv_string("stt.parakeet.prompt.field", "target_lang"), + _pack_kv_string("stt.parakeet.prompt.activation", "relu"), + _pack_kv_array_string("stt.parakeet.prompt.dictionary.locales", [k for k, _ in prompt_dict]), + _pack_kv_array_int32("stt.parakeet.prompt.dictionary.indices", [v for _, v in prompt_dict]), + _pack_kv_uint32("stt.parakeet.prompt.auto_id", 3), + *tokenizer_kv, + *parakeet_hparams_kv, + ], + parakeet_tensors + prompt_tensors, + ), + ) + # Streaming-capability variant. Same toy vocabulary, same hparams, # same tensor catalog as v2 — but adds stt.capability.streaming = true # to flip caps.supports_streaming on at the model surface. The @@ -2448,6 +2493,43 @@ def emit_fixtures(out_dir: Path) -> None: ), ) + # Prompt-conditioned buffered-streaming variant + # (nemotron-labs-unified-style): the buffered fixture's + # chunked_limited_with_rc menus plus the prompt fixture's dictionary and + # MLP. Exercises stream_begin's language gate and the offline + # full-attention switch (hparams_longform) on a unified-style model. + _write( + out_dir / "tokenizer_minimal_prompt_buffered.gguf", + _build_full_gguf( + GGUF_MAGIC, + [ + _pack_kv_string("general.architecture", "parakeet"), + _pack_kv_string("stt.variant", "rnnt-prompt-buffered-toy"), + _pack_kv_bool("stt.capability.streaming", True), + _pack_kv_bool("stt.capability.lang_detect", True), + _pack_kv_array_string("general.languages", ["en", "es"]), + _pack_kv_string("stt.parakeet.encoder.att_context_style", + "chunked_limited_with_rc"), + _pack_kv_array_int32( + "stt.parakeet.encoder.att_chunk_left_choices", [70]), + _pack_kv_array_int32( + "stt.parakeet.encoder.att_chunk_chunk_choices", [1, 2, 7, 13]), + _pack_kv_array_int32( + "stt.parakeet.encoder.att_chunk_right_choices", [0, 1, 2, 4, 7, 13]), + _pack_kv_uint32("stt.parakeet.prompt.num_prompts", n_prompts), + _pack_kv_uint32("stt.parakeet.prompt.hidden", prompt_h), + _pack_kv_string("stt.parakeet.prompt.field", "target_lang"), + _pack_kv_string("stt.parakeet.prompt.activation", "relu"), + _pack_kv_array_string("stt.parakeet.prompt.dictionary.locales", [k for k, _ in prompt_dict]), + _pack_kv_array_int32("stt.parakeet.prompt.dictionary.indices", [v for _, v in prompt_dict]), + _pack_kv_uint32("stt.parakeet.prompt.auto_id", 3), + *tokenizer_kv, + *parakeet_hparams_kv, + ], + parakeet_tensors + prompt_tensors, + ), + ) + # Granite Speech 5.0 TurboCTC minimal fixture. The tokenizer is # decode-only for this CTC family, so an empty merge table is legal. granite5_ctc_tokenizer_kv = [ diff --git a/tests/golden/batch/nemotron-labs-unified-asr-0.6b.cpu.json b/tests/golden/batch/nemotron-labs-unified-asr-0.6b.cpu.json new file mode 100644 index 000000000..ab548af6b --- /dev/null +++ b/tests/golden/batch/nemotron-labs-unified-asr-0.6b.cpu.json @@ -0,0 +1,15 @@ +{ + "model": "models/nemotron-labs-unified-asr-0.6b/nemotron-labs-unified-asr-0.6b-F32.gguf", + "backend": "cpu", + "language": "en", + "texts": { + "samples/jfk.wav": "And so, my fellow Americans, ask not what your country can do for you, ask what you can do for your country.", + "samples/fleurs-fr.wav": "L'accident a eu lieu en terrain montagneux et il semblerait que cela ait été causé par un incendie malveillant.", + "samples/fleurs-es.wav": "Fue tanta la cantidad de gente que se concentró que no todos pudieron acceder al funeral en la plaza de San Pedro.", + "samples/fleurs-de.wav": "Er griff auch alles an, was ins Wasser kam. Selbst ein großer Dinosaurier wie der T-Rex war ihm nicht gewachsen.", + "samples/fleurs-en.wav": "However, due to the slow communication channels, styles in the west could lag behind by 25 to 30 years.", + "samples/fleurs-ru.wav": "В различных местах Рима были установлены большие телевизионные экраны, с помощью которых люди могли наблюдать за церемонией.", + "samples/ja-long.wav": "Perishwa takisatni modo de Konyano Ko Kasunokao Mikiyameshi Kono Senkyosen de Jimungasumbeki Michigaru Kado Kao Handan Suto Novemashtata Nochini Senkyosen Poli Ichigas Niju Jin South Carolina Shunisen Nichbas Novemashta", + "samples/ru-long-padded.wav": "Начиная с 1988 года урны для избирательных бюллетений должны быть прозрачными, чтобы избиратели и наблюдатели могли убедиться в том, что в начале голосования внутри нет конвертов и что к ним не добавлены какие-либо другие конверты, кроме конвертов тех людей, которых допустили к участию в голосовании и голоса которых подсчитали надлежащим образом." + } +} diff --git a/tests/golden/parakeet/nemotron-labs-unified-asr-0.6b.manifest.json b/tests/golden/parakeet/nemotron-labs-unified-asr-0.6b.manifest.json new file mode 100644 index 000000000..37c161c2b --- /dev/null +++ b/tests/golden/parakeet/nemotron-labs-unified-asr-0.6b.manifest.json @@ -0,0 +1,94 @@ +{ + "schema": "transcribe-golden-manifest-v1", + "family": "parakeet", + "variant": "nemotron-labs-unified-asr-0.6b", + "source_model": { + "hf_repo": "nvidia/nemotron-labs-unified-asr-0.6b", + "hf_revision": "023ce907267a09a308a5cb69239447cb3d0c1597" + }, + "expected_dtype": "float32", + "dtype_source": "manual", + "reference": { + "kind": "nemo", + "source": "https://github.com/NVIDIA-NeMo/NeMo", + "revision": "6967f48fda2a", + "entrypoint": "scripts/dump_reference_parakeet_nemo.py", + "dump_args": [] + }, + "frontend": { + "sample_rate": 16000, + "n_mels": 128, + "hop_length": 160, + "fft_size": 512, + "win_length": 400, + "window": "hann_periodic", + "normalization": "per_feature", + "preemphasis": 0.97, + "dither": 1e-05 + }, + "tokenizer_summary": { + "type": "sentencepiece", + "vocab_size": 4095, + "special_tokens": { + "unk": 0, + "blank": 4095 + }, + "has_language_tokens": false + }, + "capabilities": { + "languages": [ + "bg", + "hr", + "cs", + "da", + "nl", + "en", + "et", + "fi", + "fr", + "de", + "el", + "hu", + "it", + "lv", + "lt", + "mt", + "pl", + "pt", + "ro", + "sk", + "sl", + "es", + "sv", + "ru", + "uk" + ], + "language_detection": true, + "translation": false, + "timestamps": [ + "token", + "word" + ], + "streaming": true, + "speaker_diarization": false + }, + "tolerance_file": "tests/tolerances/nemotron-labs-unified-asr-0.6b.json", + "cases": [ + { + "audio": "jfk", + "language": "en" + }, + { + "audio": "fleurs-fr", + "language": "fr" + }, + { + "audio": "fleurs-es", + "language": "es" + }, + { + "audio": "ru-long-padded", + "language": "ru" + } + ] +} diff --git a/tests/parakeet_prompt_language_unit.cpp b/tests/parakeet_prompt_language_unit.cpp new file mode 100644 index 000000000..eb5ef1a8e --- /dev/null +++ b/tests/parakeet_prompt_language_unit.cpp @@ -0,0 +1,130 @@ +// parakeet_prompt_language_unit.cpp - source-language gate on a +// prompt-conditioned parakeet model (nemotron-3.5 / nemotron-labs-unified +// style one-hot language prompt). +// +// The fixture advertises {"en", "es"} and carries a prompt dictionary +// {en-US:0, en:0, English:0, es-ES:1, es:2, auto:3}, auto_id 3. Pins: +// +// 1. caps.languages stays the advertised set (aliases are not listed). +// 2. The generic gate in validate_run_params_common accepts the family's +// unadvertised aliases: region/long forms on an advertised slot +// ("en-US", "English") and "auto" (the auto slot, same as NULL), on +// transcribe_run and transcribe_run_batch. +// 3. It rejects with UNSUPPORTED_LANGUAGE a dictionary key on a slot no +// advertised language selects ("es-ES"), an unknown code ("zz") and +// the empty string. +// +// Accepted hints are checked as "not UNSUPPORTED_LANGUAGE": the toy +// weights make the transcript meaningless, only the gate is under test. + +#include "transcribe.h" + +#include + +#include +#include +#include +#include +#include + +#ifndef TRANSCRIBE_TEST_FIXTURES_DIR +# error "TRANSCRIBE_TEST_FIXTURES_DIR must be defined by the build system" +#endif + +namespace { + +int g_failures = 0; + +#define CHECK(cond) \ + do { \ + if (!(cond)) { \ + std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \ + ++g_failures; \ + } \ + } while (0) + +transcribe_status run_with(transcribe_session * ctx, const char * lang) { + transcribe_run_params rp; + transcribe_run_params_init(&rp); + rp.language = lang; + std::vector pcm(16000, 0.0f); + return transcribe_run(ctx, pcm.data(), static_cast(pcm.size()), &rp); +} + +transcribe_status run_batch_with(transcribe_session * ctx, const char * lang) { + transcribe_run_params rp; + transcribe_run_params_init(&rp); + rp.language = lang; + std::vector a(16000, 0.0f); + std::vector b(8000, 0.0f); + const float * pcm[2] = { a.data(), b.data() }; + const int n[2] = { static_cast(a.size()), static_cast(b.size()) }; + return transcribe_run_batch(ctx, pcm, n, 2, &rp); +} + +} // namespace + +int main() { + const std::string path = std::string(TRANSCRIBE_TEST_FIXTURES_DIR) + "/tokenizer_minimal_prompt.gguf"; + struct stat st{}; + if (::stat(path.c_str(), &st) != 0) { + std::fprintf(stderr, "parakeet_prompt_language_unit: fixture not found: %s\n", path.c_str()); + return EXIT_FAILURE; + } + + transcribe_model_load_params mp; + transcribe_model_load_params_init(&mp); + mp.backend = TRANSCRIBE_BACKEND_CPU; + transcribe_model * model = nullptr; + if (transcribe_model_load_file(path.c_str(), &mp, &model) != TRANSCRIBE_OK || model == nullptr) { + std::fprintf(stderr, "parakeet_prompt_language_unit: load failed\n"); + return EXIT_FAILURE; + } + transcribe_session_params sp; + transcribe_session_params_init(&sp); + sp.n_threads = 1; + transcribe_session * ctx = nullptr; + if (transcribe_session_init(model, &sp, &ctx) != TRANSCRIBE_OK || ctx == nullptr) { + std::fprintf(stderr, "parakeet_prompt_language_unit: session init failed\n"); + transcribe_model_free(model); + return EXIT_FAILURE; + } + + transcribe_capabilities caps; + transcribe_capabilities_init(&caps); + CHECK(transcribe_model_get_capabilities(model, &caps) == TRANSCRIBE_OK); + CHECK(caps.n_languages == 2); + if (caps.n_languages == 2 && caps.languages != nullptr) { + CHECK(std::strcmp(caps.languages[0], "en") == 0); + CHECK(std::strcmp(caps.languages[1], "es") == 0); + } + + for (const char * ok : { "en", "es", "en-US", "English", "auto" }) { + const transcribe_status s = run_with(ctx, ok); + if (s == TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE) { + std::fprintf(stderr, "FAIL: run rejected accepted hint \"%s\"\n", ok); + ++g_failures; + } + } + CHECK(run_with(ctx, nullptr) != TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE); + for (const char * bad : { "es-ES", "zz", "" }) { + if (run_with(ctx, bad) != TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE) { + std::fprintf(stderr, "FAIL: run accepted unsupported hint \"%s\"\n", bad); + ++g_failures; + } + } + + CHECK(run_batch_with(ctx, "auto") != TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE); + CHECK(run_batch_with(ctx, "en-US") != TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE); + CHECK(run_batch_with(ctx, "es-ES") == TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE); + + transcribe_session_free(ctx); + transcribe_model_free(model); + + if (g_failures > 0) { + std::fprintf(stderr, "parakeet_prompt_language_unit: %d failures\n", g_failures); + return EXIT_FAILURE; + } + std::fprintf(stdout, "parakeet_prompt_language_unit: ok\n"); + return EXIT_SUCCESS; +} diff --git a/tests/parakeet_real_smoke.cpp b/tests/parakeet_real_smoke.cpp index 453b49264..f711aa02e 100644 --- a/tests/parakeet_real_smoke.cpp +++ b/tests/parakeet_real_smoke.cpp @@ -154,11 +154,12 @@ int main() { // These variants share the 0.6B tensor layout; capability and // vocabulary assertions below distinguish the converted sources. - const std::string variant = transcribe_model_variant_string(model); - const bool is_v2 = (variant == "tdt-0.6b-v2"); - const bool is_v3 = (variant == "tdt-0.6b-v3"); - const bool is_phonon = (variant == "tdt-0.6b-phonon-2"); - if (!is_v2 && !is_v3 && !is_phonon) { + const std::string variant = transcribe_model_variant_string(model); + const bool is_v2 = (variant == "tdt-0.6b-v2"); + const bool is_v3 = (variant == "tdt-0.6b-v3"); + const bool is_phonon = (variant == "tdt-0.6b-phonon-2"); + const bool is_unified = (variant == "nemotron-labs-unified-asr-0.6b"); + if (!is_v2 && !is_v3 && !is_phonon && !is_unified) { std::fprintf(stderr, "FAIL: unexpected variant \"%s\"\n", variant.c_str()); ++g_failures; } @@ -180,8 +181,10 @@ int main() { CHECK_STR_EQ(caps->languages[0], "en"); } } - if (is_v3) { + if (is_v3 || is_unified) { CHECK(caps->supports_language_detect == true); + // nemotron-labs-unified advertises the card's 25 bare codes; + // region forms and "auto" are unadvertised prompt aliases. CHECK_EQ_INT(caps->n_languages, 25); if (caps->n_languages == 25 && caps->languages != nullptr) { // Spot-check the first three from the converter's @@ -192,6 +195,10 @@ int main() { CHECK_STR_EQ(caps->languages[2], "cs"); } } + if (is_unified) { + // Native chunked_limited_with_rc + (L, C, R) menu: buffered streaming. + CHECK(caps->supports_streaming); + } } // Internal-view assertions. From here on we treat the model as a @@ -211,7 +218,7 @@ int main() { CHECK_EQ_INT(hp.enc_conv_kernel, 9); CHECK_EQ_INT(hp.enc_subsampling_factor, 8); CHECK_EQ_INT(hp.enc_subsampling_channels, 256); - CHECK_EQ_INT(hp.enc_use_bias, 0); + CHECK_EQ_INT(hp.enc_use_bias, is_unified ? 1 : 0); CHECK_EQ_INT(hp.enc_head_dim(), 128); // 1024 / 8 CHECK_EQ_INT(hp.pred_hidden, 640); CHECK_EQ_INT(hp.pred_n_layers, 2); @@ -223,6 +230,18 @@ int main() { CHECK_EQ_INT(hp.pred_vocab, 8193); // 8192 + 1 start row CHECK_EQ_INT(hp.joint_n_classes(), 8198); // 8192 + 5 + 1 } + if (is_unified) { + CHECK_EQ_INT(hp.pred_vocab, 4096); // 4095 + 1 start row + CHECK_EQ_INT(hp.joint_n_classes(), 4096); // plain RNN-T: 4095 + blank + // Offline is full attention (no long-form window); streaming menu + // L={70}, C={1,2,7,13}, R={0,1,2,3,4,7,13} like parakeet-unified-en. + CHECK(hp.enc_att_context_style == transcribe::parakeet::ParakeetHParams::AttContextStyle::ChunkedLimitedWithRc); + CHECK_EQ_INT(hp.enc_att_context_left, -1); + CHECK_EQ_INT(hp.enc_att_context_right, -1); + CHECK_EQ_INT(static_cast(hp.enc_att_chunk_left_choices.size()), 1); + CHECK_EQ_INT(static_cast(hp.enc_att_chunk_chunk_choices.size()), 4); + CHECK_EQ_INT(static_cast(hp.enc_att_chunk_right_choices.size()), 7); + } if (is_phonon) { CHECK(hp.kestrel_length_masking); CHECK(hp.mask_after_pointwise); @@ -231,18 +250,22 @@ int main() { CHECK(caps != nullptr && !caps->supports_streaming); } CHECK_EQ_INT(hp.joint_hidden, 640); - CHECK_EQ_INT(hp.joint_num_extra_outputs, 5); + CHECK_EQ_INT(hp.joint_num_extra_outputs, is_unified ? 0 : 5); CHECK_STR_EQ(hp.joint_activation, "relu"); - // TDT durations: every published Parakeet 0.6B variant ships - // [0, 1, 2, 3, 4]; loader cross-validates that the array length - // matches num_extra_outputs. - CHECK_EQ_INT(static_cast(hp.tdt_durations.size()), 5); - CHECK_EQ_INT(hp.tdt_durations[0], 0); - CHECK_EQ_INT(hp.tdt_durations[1], 1); - CHECK_EQ_INT(hp.tdt_durations[2], 2); - CHECK_EQ_INT(hp.tdt_durations[3], 3); - CHECK_EQ_INT(hp.tdt_durations[4], 4); - CHECK_EQ_INT(hp.tdt_max_symbols, 10); + // Plain RNN-T checkpoints have no TDT duration head. TDT variants + // ship [0, 1, 2, 3, 4]; loader cross-validates the array length + // against num_extra_outputs. + if (is_unified) { + CHECK_EQ_INT(static_cast(hp.tdt_durations.size()), 0); + } else { + CHECK_EQ_INT(static_cast(hp.tdt_durations.size()), 5); + CHECK_EQ_INT(hp.tdt_durations[0], 0); + CHECK_EQ_INT(hp.tdt_durations[1], 1); + CHECK_EQ_INT(hp.tdt_durations[2], 2); + CHECK_EQ_INT(hp.tdt_durations[3], 3); + CHECK_EQ_INT(hp.tdt_durations[4], 4); + CHECK_EQ_INT(hp.tdt_max_symbols, 10); + } CHECK_EQ_INT(hp.fe_num_mels, 128); CHECK_EQ_INT(hp.fe_sample_rate, 16000); CHECK_STR_EQ(hp.fe_type, "mel"); @@ -294,7 +317,7 @@ int main() { CHECK(t != nullptr); if (t != nullptr) { CHECK_EQ_INT(t->ne[0], 640); // pred_hidden - CHECK_EQ_INT(t->ne[1], hp.pred_vocab); // 1025 or 8193 + CHECK_EQ_INT(t->ne[1], hp.pred_vocab); // 1025, 4096, or 8193 } } { @@ -302,7 +325,7 @@ int main() { CHECK(t != nullptr); if (t != nullptr) { CHECK_EQ_INT(t->ne[0], 640); // joint_hidden - CHECK_EQ_INT(t->ne[1], hp.joint_n_classes()); // 1030 or 8198 + CHECK_EQ_INT(t->ne[1], hp.joint_n_classes()); // 1030, 4096, or 8198 } } diff --git a/tests/parakeet_stream_ext_reject_unit.cpp b/tests/parakeet_stream_ext_reject_unit.cpp index 3aa8a5a80..5aa44fe8e 100644 --- a/tests/parakeet_stream_ext_reject_unit.cpp +++ b/tests/parakeet_stream_ext_reject_unit.cpp @@ -7,8 +7,10 @@ // // -1 "use the model default for this field" // < -1 caller bug; transcribe_stream_begin returns INVALID_ARG -// 0 a real requested value (when 0 is in the model's menu) -// > 0 must be exact (frame multiple) / in-menu; otherwise INVALID_ARG +// 0 a real requested value (left/right; the buffered chunk must be >= 1 frame) +// > 0 cache-aware: must be in the menu; buffered: must be an exact frame +// multiple (off-menu tuples are accepted) and left + chunk + right +// must fit the 120 s window cap; otherwise INVALID_ARG // // Two paths use this rule: // @@ -221,12 +223,73 @@ void test_buffered_zero_is_real_value() { transcribe_model_free(model); } +// Buffered tuples outside the training menu run as requested (NeMo's +// buffered loop accepts any context; the unified cards recommend off-menu +// rows such as 70/2/5 frames). chunk = 0 and windows past the 120 s cap are +// rejected. The toy encoder cannot run compute, so feeding an off-menu +// tuple is covered by parakeet_unified_real_smoke (70/3/5). +void test_buffered_off_menu_accepted_chunk_zero_rejected() { + struct transcribe_model * model = nullptr; + struct transcribe_session * ctx = nullptr; + if (!load_and_init("tokenizer_minimal_streaming_buffered.gguf", &model, &ctx)) { + return; + } + transcribe_session_free(ctx); + + transcribe_run_params rp; + transcribe_run_params_init(&rp); + + // Fresh session per begin so each request starts from IDLE. + auto begin = [&](int32_t L, int32_t C, int32_t R, bool * stayed_idle) { + struct transcribe_session * s = nullptr; + if (transcribe_session_init(model, nullptr, &s) != TRANSCRIBE_OK || s == nullptr) { + return TRANSCRIBE_ERR_BACKEND; + } + transcribe_parakeet_buffered_stream_ext ext; + transcribe_parakeet_buffered_stream_ext_init(&ext); + ext.left_ms = L; + ext.chunk_ms = C; + ext.right_ms = R; + transcribe_stream_params sp; + transcribe_stream_params_init(&sp); + sp.family = &ext.ext; + const transcribe_status st = transcribe_stream_begin(s, &rp, &sp); + if (stayed_idle != nullptr) { + *stayed_idle = transcribe_stream_get_state(s) == TRANSCRIBE_STREAM_IDLE; + } + transcribe_session_free(s); + return st; + }; + + // frame_ms = 1 on this fixture: ms == frames. R=5, L=30, C=3 and L=0 + // are all outside the toy menu. + CHECK(begin(70, 2, 5, nullptr) == TRANSCRIBE_OK); + CHECK(begin(30, 3, 5, nullptr) == TRANSCRIBE_OK); + CHECK(begin(0, 1, 0, nullptr) == TRANSCRIBE_OK); + + // chunk = 0 is a pre-flight reject. + bool idle = false; + CHECK(begin(70, 0, 13, &idle) == TRANSCRIBE_ERR_INVALID_ARG); + CHECK(idle); + + // One [left | chunk | right] window is capped at the offline + // full-attention limit (120 s); a huge field must be rejected, not + // overflow the int32 sample count. + idle = false; + CHECK(begin(2000000000, 1, 0, &idle) == TRANSCRIBE_ERR_INVALID_ARG); + CHECK(idle); + CHECK(begin(70, 2000000000, 2000000000, nullptr) == TRANSCRIBE_ERR_INVALID_ARG); + + transcribe_model_free(model); +} + } // namespace int main() { test_cache_aware_rejects_sub_sentinel(); test_buffered_rejects_sub_sentinel(); test_buffered_zero_is_real_value(); + test_buffered_off_menu_accepted_chunk_zero_rejected(); if (g_failures > 0) { std::fprintf(stderr, "parakeet_stream_ext_reject_unit: %d failures\n", g_failures); diff --git a/tests/parakeet_unified_gate_unit.cpp b/tests/parakeet_unified_gate_unit.cpp new file mode 100644 index 000000000..f98df2d68 --- /dev/null +++ b/tests/parakeet_unified_gate_unit.cpp @@ -0,0 +1,189 @@ +// parakeet_unified_gate_unit.cpp - unified (chunked_limited_with_rc + +// language prompt) parakeet gates on a toy fixture +// (tokenizer_minimal_prompt_buffered.gguf: advertises {"en", "es"}, prompt +// dictionary {en-US:0, en:0, English:0, es-ES:1, es:2, auto:3}). +// +// 1. transcribe_stream_begin's language gate: "zz" and "es-ES" (a slot no +// advertised language selects) return UNSUPPORTED_LANGUAGE before any +// state change (the session stays IDLE); "auto" and an advertised code +// are accepted. +// 2. The offline full-attention switch (kOfflineFullAttentionMaxSeconds): +// parse_full_attention_max_seconds accepts only a whole non-negative +// number and falls back to the default otherwise; offline_runs_windowed +// switches past the limit, never below the [256, 256] band span, and +// never for a non-unified model. +// +// The toy encoder (subsampling 2) cannot run compute, so batch == serial past +// the switch and feeding an off-menu buffered tuple are covered by the +// real-model parakeet_unified_real_smoke. + +#include "arch/parakeet/parakeet.h" +#include "arch/parakeet/weights.h" +#include "transcribe-model.h" +#include "transcribe.h" + +#include + +#include +#include +#include +#include +#include + +#ifndef TRANSCRIBE_TEST_FIXTURES_DIR +# error "TRANSCRIBE_TEST_FIXTURES_DIR must be defined by the build system" +#endif + +namespace { + +int g_failures = 0; + +#define CHECK(cond) \ + do { \ + if (!(cond)) { \ + std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \ + ++g_failures; \ + } \ + } while (0) + +const char * kEnv = "TRANSCRIBE_PARAKEET_FULL_ATTENTION_MAX_S"; + +transcribe_model * load(const char * name) { + const std::string path = std::string(TRANSCRIBE_TEST_FIXTURES_DIR) + "/" + name; + struct stat st{}; + if (::stat(path.c_str(), &st) != 0) { + std::fprintf(stderr, "parakeet_unified_gate_unit: fixture not found: %s\n", path.c_str()); + ++g_failures; + return nullptr; + } + transcribe_model_load_params mp; + transcribe_model_load_params_init(&mp); + mp.backend = TRANSCRIBE_BACKEND_CPU; + transcribe_model * model = nullptr; + if (transcribe_model_load_file(path.c_str(), &mp, &model) != TRANSCRIBE_OK || model == nullptr) { + std::fprintf(stderr, "parakeet_unified_gate_unit: load failed: %s\n", name); + ++g_failures; + return nullptr; + } + return model; +} + +transcribe_session * session(transcribe_model * model) { + transcribe_session_params sp; + transcribe_session_params_init(&sp); + sp.n_threads = 1; + transcribe_session * ctx = nullptr; + if (transcribe_session_init(model, &sp, &ctx) != TRANSCRIBE_OK) { + return nullptr; + } + return ctx; +} + +void test_stream_begin_language(transcribe_model * model) { + for (const char * bad : { "zz", "es-ES" }) { + transcribe_session * ctx = session(model); + CHECK(ctx != nullptr); + if (ctx == nullptr) { + return; + } + transcribe_run_params rp; + transcribe_run_params_init(&rp); + rp.language = bad; + const transcribe_status st = transcribe_stream_begin(ctx, &rp, nullptr); + if (st != TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE) { + std::fprintf(stderr, "FAIL: stream_begin(\"%s\") returned %s\n", bad, transcribe_status_string(st)); + ++g_failures; + } + CHECK(transcribe_stream_get_state(ctx) == TRANSCRIBE_STREAM_IDLE); + transcribe_session_free(ctx); + } + for (const char * ok : { "auto", "en", "en-US" }) { + transcribe_session * ctx = session(model); + CHECK(ctx != nullptr); + if (ctx == nullptr) { + return; + } + transcribe_run_params rp; + transcribe_run_params_init(&rp); + rp.language = ok; + const transcribe_status st = transcribe_stream_begin(ctx, &rp, nullptr); + if (st != TRANSCRIBE_OK) { + std::fprintf(stderr, "FAIL: stream_begin(\"%s\") returned %s\n", ok, transcribe_status_string(st)); + ++g_failures; + } + transcribe_session_free(ctx); + } +} + +void test_parse() { + using transcribe::parakeet::kOfflineFullAttentionMaxSeconds; + using transcribe::parakeet::parse_full_attention_max_seconds; + CHECK(parse_full_attention_max_seconds(nullptr) == kOfflineFullAttentionMaxSeconds); + CHECK(parse_full_attention_max_seconds("") == kOfflineFullAttentionMaxSeconds); + CHECK(parse_full_attention_max_seconds("0") == 0.0); + CHECK(parse_full_attention_max_seconds("30.5") == 30.5); + CHECK(parse_full_attention_max_seconds("600") == 600.0); + for (const char * bad : { "-1", "abc", "120abc", "nan", "inf", " 5x" }) { + if (parse_full_attention_max_seconds(bad) != kOfflineFullAttentionMaxSeconds) { + std::fprintf(stderr, "FAIL: parse(\"%s\") did not fall back to the default\n", bad); + ++g_failures; + } + } + ::setenv(kEnv, "120abc", 1); + CHECK(transcribe::parakeet::offline_full_attention_max_seconds() == kOfflineFullAttentionMaxSeconds); + ::setenv(kEnv, "45", 1); + CHECK(transcribe::parakeet::offline_full_attention_max_seconds() == 45.0); + ::unsetenv(kEnv); + CHECK(transcribe::parakeet::offline_full_attention_max_seconds() == kOfflineFullAttentionMaxSeconds); +} + +void test_switch(transcribe_model * unified, transcribe_model * plain) { + using namespace transcribe::parakeet; + const auto * pm = static_cast(unified); + CHECK(pm->hparams_longform.has_value()); + if (!pm->hparams_longform.has_value()) { + return; + } + const int64_t sr = pm->hparams.fe_sample_rate; + const int64_t band = + static_cast(kLongformAttContext) * pm->hparams.enc_subsampling_factor * pm->hparams.fe_hop_length; + const int64_t lim = static_cast(kOfflineFullAttentionMaxSeconds) * sr; + + CHECK(!offline_runs_windowed(pm, lim, kOfflineFullAttentionMaxSeconds)); + CHECK(offline_runs_windowed(pm, lim + 1, kOfflineFullAttentionMaxSeconds)); + CHECK(&offline_hparams(pm, lim, kOfflineFullAttentionMaxSeconds) == &pm->hparams); + CHECK(&offline_hparams(pm, lim + 1, kOfflineFullAttentionMaxSeconds) == &*pm->hparams_longform); + // Limit 0: clips inside the band span keep the model's own hparams. + CHECK(!offline_runs_windowed(pm, band, 0.0)); + CHECK(offline_runs_windowed(pm, band + 1, 0.0)); + // Windowed copy: Regular-local [256, 256]; the model keeps its style. + CHECK(pm->hparams_longform->enc_att_context_style == ParakeetHParams::AttContextStyle::Regular); + CHECK(pm->hparams_longform->enc_att_context_left == kLongformAttContext); + CHECK(pm->hparams_longform->enc_att_context_right == kLongformAttContext); + CHECK(pm->hparams.enc_att_context_style == ParakeetHParams::AttContextStyle::ChunkedLimitedWithRc); + + const auto * pp = static_cast(plain); + CHECK(!pp->hparams_longform.has_value()); + CHECK(!offline_runs_windowed(pp, lim * 100, 0.0)); +} + +} // namespace + +int main() { + transcribe_model * unified = load("tokenizer_minimal_prompt_buffered.gguf"); + transcribe_model * plain = load("tokenizer_minimal.gguf"); + if (unified != nullptr && plain != nullptr) { + test_stream_begin_language(unified); + test_parse(); + test_switch(unified, plain); + } + transcribe_model_free(unified); + transcribe_model_free(plain); + + if (g_failures > 0) { + std::fprintf(stderr, "parakeet_unified_gate_unit: %d failures\n", g_failures); + return EXIT_FAILURE; + } + std::fprintf(stdout, "parakeet_unified_gate_unit: ok\n"); + return EXIT_SUCCESS; +} diff --git a/tests/parakeet_unified_real_smoke.cpp b/tests/parakeet_unified_real_smoke.cpp new file mode 100644 index 000000000..540fd514b --- /dev/null +++ b/tests/parakeet_unified_real_smoke.cpp @@ -0,0 +1,163 @@ +// parakeet_unified_real_smoke.cpp - real-model checks for the unified +// (chunked_limited_with_rc) parakeet GGUFs that the toy fixtures cannot run: +// +// 1. Offline full-attention switch: with TRANSCRIBE_PARAKEET_FULL_ATTENTION_MAX_S +// at 0 a batch holding a clip past the [256, 256] band span (the 33.9 s +// ru-long-padded) routes per utterance, and with the default limit the +// same batch runs batched; both equal serial runs. +// 2. Relaxed buffered (L, C, R): an off-menu tuple (70, 3, 5) streams jfk +// and commits audio before finalize. +// +// Gated on TRANSCRIBE_PARAKEET_UNIFIED_GGUF (nemotron-labs-unified-asr-0.6b or +// parakeet-unified-en-0.6b); exits 77 when unset. + +#include "transcribe.h" +#include "transcribe/parakeet.h" +#include "wav.h" + +#include + +#include +#include +#include +#include +#include +#include + +namespace { + +int g_failures = 0; + +#define CHECK(cond) \ + do { \ + if (!(cond)) { \ + std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \ + ++g_failures; \ + } \ + } while (0) + +const char * kEnv = "TRANSCRIBE_PARAKEET_FULL_ATTENTION_MAX_S"; + +bool file_exists(const std::string & path) { + struct stat st{}; + return ::stat(path.c_str(), &st) == 0; +} + +void check_batch_equals_serial(transcribe_session * ctx, + const std::vector> & clips, + const char * env_value) { + if (env_value != nullptr) { + ::setenv(kEnv, env_value, 1); + } else { + ::unsetenv(kEnv); + } + transcribe_run_params rp; + transcribe_run_params_init(&rp); + rp.language = "en"; + + std::vector serial; + for (const auto & clip : clips) { + CHECK(transcribe_run(ctx, clip.data(), static_cast(clip.size()), &rp) == TRANSCRIBE_OK); + const char * t = transcribe_full_text(ctx); + serial.emplace_back(t != nullptr ? t : ""); + } + CHECK(!serial.front().empty()); // jfk; the Russian clip may decode empty on English-only models + std::vector pcm; + std::vector n; + for (const auto & clip : clips) { + pcm.push_back(clip.data()); + n.push_back(static_cast(clip.size())); + } + CHECK(transcribe_run_batch(ctx, pcm.data(), n.data(), static_cast(clips.size()), &rp) == TRANSCRIBE_OK); + CHECK(transcribe_batch_n_results(ctx) == static_cast(clips.size())); + for (int i = 0; i < transcribe_batch_n_results(ctx) && i < static_cast(clips.size()); ++i) { + CHECK(transcribe_batch_status(ctx, i) == TRANSCRIBE_OK); + const char * t = transcribe_batch_full_text(ctx, i); + if (serial[static_cast(i)] != (t != nullptr ? t : "")) { + std::fprintf(stderr, "FAIL: %s=%s utt %d: batch \"%s\" != serial \"%s\"\n", kEnv, + env_value != nullptr ? env_value : "", i, t != nullptr ? t : "", + serial[static_cast(i)].c_str()); + ++g_failures; + } + } + ::unsetenv(kEnv); +} + +void check_off_menu_stream(transcribe_session * ctx, const std::vector & pcm) { + transcribe_run_params rp; + transcribe_run_params_init(&rp); + rp.language = "en"; + transcribe_parakeet_buffered_stream_ext ext; + transcribe_parakeet_buffered_stream_ext_init(&ext); + ext.left_ms = 5600; // 70 frames + ext.chunk_ms = 240; // 3 frames: not in C = {1, 2, 7, 13} + ext.right_ms = 400; // 5 frames: not in R = {0, 1, 2, 3, 4, 7, 13} + transcribe_stream_params sp; + transcribe_stream_params_init(&sp); + sp.family = &ext.ext; + CHECK(transcribe_stream_begin(ctx, &rp, &sp) == TRANSCRIBE_OK); + + int64_t committed_before_final = 0; + for (size_t pos = 0; pos < pcm.size();) { + const size_t take = std::min(8000, pcm.size() - pos); + transcribe_stream_update update; + transcribe_stream_update_init(&update); + CHECK(transcribe_stream_feed(ctx, pcm.data() + pos, static_cast(take), &update) == TRANSCRIBE_OK); + committed_before_final = update.audio_committed_ms; + pos += take; + } + // At least one chunk ran before finalize. + CHECK(committed_before_final > 0); + transcribe_stream_update final; + transcribe_stream_update_init(&final); + CHECK(transcribe_stream_finalize(ctx, &final) == TRANSCRIBE_OK); + const char * t = transcribe_full_text(ctx); + CHECK(t != nullptr && std::string(t).find("country") != std::string::npos); +} + +} // namespace + +int main() { + const char * model_path = std::getenv("TRANSCRIBE_PARAKEET_UNIFIED_GGUF"); + if (model_path == nullptr || *model_path == '\0' || !file_exists(model_path)) { + std::fprintf(stderr, "skipping: TRANSCRIBE_PARAKEET_UNIFIED_GGUF unset or missing\n"); + return 77; + } + std::vector jfk, ru; + std::string error; + const std::string dir = TRANSCRIBE_TEST_SAMPLES_DIR; + if (!transcribe_cli::load_wav_mono_16k(dir + "/jfk.wav", jfk, error) || + !transcribe_cli::load_wav_mono_16k(dir + "/ru-long-padded.wav", ru, error)) { + std::fprintf(stderr, "failed to load samples: %s\n", error.c_str()); + return 1; + } + + transcribe_model_load_params mp; + transcribe_model_load_params_init(&mp); + transcribe_session_params sp; + transcribe_session_params_init(&sp); + transcribe_model * model = nullptr; + transcribe_session * ctx = nullptr; + if (transcribe_model_load_file(model_path, &mp, &model) != TRANSCRIBE_OK || + transcribe_session_init(model, &sp, &ctx) != TRANSCRIBE_OK) { + std::fprintf(stderr, "failed to initialize model/session\n"); + transcribe_model_free(model); + return 1; + } + + // ru-long-padded is Russian; decoded with an English hint it still + // exercises the routing (only batch == serial is compared). + const std::vector> clips = { jfk, ru }; + check_batch_equals_serial(ctx, clips, "0"); + check_batch_equals_serial(ctx, clips, nullptr); + check_off_menu_stream(ctx, jfk); + + transcribe_session_free(ctx); + transcribe_model_free(model); + if (g_failures != 0) { + std::fprintf(stderr, "parakeet_unified_real_smoke: %d failure(s)\n", g_failures); + return 1; + } + std::fprintf(stdout, "parakeet_unified_real_smoke: ok\n"); + return 0; +} diff --git a/tests/sensevoice_language_gate_smoke.cpp b/tests/sensevoice_language_gate_smoke.cpp new file mode 100644 index 000000000..5a596dedd --- /dev/null +++ b/tests/sensevoice_language_gate_smoke.cpp @@ -0,0 +1,106 @@ +// sensevoice_language_gate_smoke.cpp - SenseVoice's unadvertised "auto" +// language alias at the generic source-language gate. +// +// SenseVoice declares "auto" (the <|auto|> prefix row, the same row a null +// hint selects) via set_language_aliases. Pins: caps.languages does not list +// it; transcribe_run accepts "auto" and an advertised code; an unknown code +// and the empty string return UNSUPPORTED_LANGUAGE; "auto" and a null hint +// give the same transcript. +// +// Gated on TRANSCRIBE_SENSEVOICE_GGUF; exits 77 when unset. + +#include "transcribe.h" +#include "wav.h" + +#include + +#include +#include +#include +#include +#include + +namespace { + +int g_failures = 0; + +#define CHECK(cond) \ + do { \ + if (!(cond)) { \ + std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \ + ++g_failures; \ + } \ + } while (0) + +bool file_exists(const char * path) { + struct stat st{}; + return ::stat(path, &st) == 0; +} + +transcribe_status run_with(transcribe_session * ctx, + const std::vector & pcm, + const char * lang, + std::string * text) { + transcribe_run_params rp; + transcribe_run_params_init(&rp); + rp.language = lang; + const transcribe_status st = transcribe_run(ctx, pcm.data(), static_cast(pcm.size()), &rp); + if (text != nullptr) { + const char * t = transcribe_full_text(ctx); + *text = t != nullptr ? t : ""; + } + return st; +} + +} // namespace + +int main() { + const char * model_path = std::getenv("TRANSCRIBE_SENSEVOICE_GGUF"); + if (model_path == nullptr || *model_path == '\0' || !file_exists(model_path)) { + std::fprintf(stderr, "skipping: TRANSCRIBE_SENSEVOICE_GGUF unset or missing\n"); + return 77; + } + std::vector pcm; + std::string error; + if (!transcribe_cli::load_wav_mono_16k(std::string(TRANSCRIBE_TEST_SAMPLES_DIR) + "/jfk.wav", pcm, error)) { + std::fprintf(stderr, "failed to load jfk.wav: %s\n", error.c_str()); + return 1; + } + transcribe_model_load_params mp; + transcribe_model_load_params_init(&mp); + transcribe_session_params sp; + transcribe_session_params_init(&sp); + transcribe_model * model = nullptr; + transcribe_session * ctx = nullptr; + if (transcribe_model_load_file(model_path, &mp, &model) != TRANSCRIBE_OK || + transcribe_session_init(model, &sp, &ctx) != TRANSCRIBE_OK) { + std::fprintf(stderr, "failed to initialize model/session\n"); + transcribe_model_free(model); + return 1; + } + + transcribe_capabilities caps; + transcribe_capabilities_init(&caps); + CHECK(transcribe_model_get_capabilities(model, &caps) == TRANSCRIBE_OK); + for (int i = 0; i < caps.n_languages && caps.languages != nullptr; ++i) { + CHECK(caps.languages[i] == nullptr || std::strcmp(caps.languages[i], "auto") != 0); + } + + std::string auto_text, null_text; + CHECK(run_with(ctx, pcm, "auto", &auto_text) == TRANSCRIBE_OK); + CHECK(run_with(ctx, pcm, nullptr, &null_text) == TRANSCRIBE_OK); + CHECK(!auto_text.empty()); + CHECK(auto_text == null_text); + CHECK(run_with(ctx, pcm, "en", nullptr) == TRANSCRIBE_OK); + CHECK(run_with(ctx, pcm, "zz", nullptr) == TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE); + CHECK(run_with(ctx, pcm, "", nullptr) == TRANSCRIBE_ERR_UNSUPPORTED_LANGUAGE); + + transcribe_session_free(ctx); + transcribe_model_free(model); + if (g_failures != 0) { + std::fprintf(stderr, "sensevoice_language_gate_smoke: %d failure(s)\n", g_failures); + return 1; + } + std::fprintf(stdout, "sensevoice_language_gate_smoke: ok\n"); + return 0; +} diff --git a/tests/tolerances/nemotron-labs-unified-asr-0.6b.json b/tests/tolerances/nemotron-labs-unified-asr-0.6b.json new file mode 100644 index 000000000..bddbe18cc --- /dev/null +++ b/tests/tolerances/nemotron-labs-unified-asr-0.6b.json @@ -0,0 +1,80 @@ +{ + "_comment": [ + "Finalized for nemotron-labs-unified-asr-0.6b against the NeMo 2.8.0rc0 oracle at git pin 6967f48fda2a, F32 CPU, four cases.", + "Checkpoint producer is NeMo 3.1.0+7be3e2bf6; the in-tree pinned reference runtime is 2.8.0rc0.", + "The GGUF keeps the native chunked_limited_with_rc style, whose offline mode is full attention up to 120 s (the [256, 256] window above; every golden case is shorter), so the oracle runs the native style with no dump_args (it used --offline-only --att-context 256,256 while the PR forced 'regular').", + "The long case uses samples/ru-long-padded.wav (3392 mel frames) so both sides produce 424 encoder frames and every long-form activation is value-compared.", + "Conv-heavy FastConformer intermediates carry larger CPU drift (pre_encode, block 0/12); output-adjacent tensors stay tight.", + "Positional table: both sides dump 2T-1 rows under full attention; shape_optional is kept as a guard and skips value comparison only when shapes differ.", + "AArch64 (GB10) CPU drift on the French case reaches 1.004e-3 in prompted encoder output; budget widened to 2e-3 with mean held at 4e-5.", + "Native-style oracle on M4 Max CPU (1 thread): enc.block.12.out reaches 1.011 on jfk (p99 |ref| ~31); budget widened to 1.2 with mean held at 6e-3. Output-adjacent tensors are unchanged (enc.final <= 1.7e-4, enc.prompted <= 1.02e-3)." + ], + "enc.mel.in": { + "max_abs": 0.001, + "mean_abs": 1e-05 + }, + "enc.pos_emb": { + "shape_optional": true, + "max_abs": 0.0005, + "mean_abs": 1e-05, + "_comment": [ + "Full attention: both sides dump 2T-1 rows (275/255/243/847 on the four cases) and are value-compared." + ] + }, + "enc.pre_encode.out": { + "max_abs": 0.2, + "mean_abs": 0.01 + }, + "enc.block.0.out": { + "max_abs": 0.05, + "mean_abs": 0.003 + }, + "enc.block.12.out": { + "max_abs": 1.2, + "mean_abs": 0.006 + }, + "enc.block.23.out": { + "max_abs": 0.0003, + "mean_abs": 6e-06 + }, + "enc.final": { + "max_abs": 0.0003, + "mean_abs": 6e-06 + }, + "enc.prompted": { + "max_abs": 0.002, + "mean_abs": 4e-05 + }, + "dec.enc_out": { + "max_abs": 0.0003, + "mean_abs": 6e-06 + }, + "dec.enc_out_prompted": { + "max_abs": 0.002, + "mean_abs": 4e-05 + }, + "dec.embed.0": { + "max_abs": 1e-06, + "mean_abs": 1e-06 + }, + "dec.lstm.0.h.0": { + "max_abs": 1e-06, + "mean_abs": 1e-07 + }, + "dec.lstm.0.c.0": { + "max_abs": 1e-06, + "mean_abs": 1e-07 + }, + "dec.lstm.1.h.0": { + "max_abs": 1e-06, + "mean_abs": 1e-07 + }, + "dec.lstm.1.c.0": { + "max_abs": 1e-06, + "mean_abs": 1e-07 + }, + "dec.joint.0": { + "max_abs": 0.001, + "mean_abs": 0.0005 + } +}