Hugging Face just showed off a custom inference handler that crams three heavyweight capabilities into a single Inference Endpoint: automatic speech recognition, speaker diarization, and speculative decoding for faster transcription. The setup leans on Whisper for ASR and Pyannote — currently the strongest open-source diarization model — to split transcripts by speaker. The pipeline is modular, so teams that don’t need diarization can run the ASR piece alone without dragging along unnecessary overhead.
The speculative decoding angle is where things get interesting for anyone watching inference costs. By pairing Whisper with a smaller assistant model — Hugging Face recommends a distilled version — the endpoint generates candidate tokens cheaply and lets the larger model validate them. But the approach isn’t free lunch. Speculative decoding requires the assistant model’s decoder to share the same architecture as the main model, and batch size is capped at one. If your production workload depends on processing multiple audio files simultaneously, standard batching might actually beat the speedup from speculative decoding.
Deployment comes with a few practical gotchas. The diarization model from Pyannote requires a Hugging Face token passed explicitly as an environment variable — hardcoding it is blocked for security reasons, which means you’ll need to create the endpoint through an API call rather than clicking through the web interface. The handler also runs on PyTorch 2.2 or later, where SDPA supports Flash Attention 2 out of the box for faster processing.
For teams already running Whisper pipelines, the real takeaway is flexibility. Inference Endpoints mount the entire repository at initialization, so handler.py can reference separate files like diarization_utils.py and config.py instead of cramming everything into one script. That’s a small detail, but it makes maintaining custom pipelines far less painful. The same pattern could apply to plenty of other multi-model workflows beyond speech — which is likely the broader point Hugging Face is making here.