Hugging Face’s Transformers library now ships with built-in support for n-gram language models when decoding Wav2Vec2 speech recognition output, thanks to an integration with Kensho Technologies’ pyctcdecode library. The change closes a long-standing gap: previously, fine-tuned Wav2Vec2 checkpoints could transcribe audio without any external language model, but the results often contained phonetically plausible yet incorrect spellings.

The problem is visible in a single example from the blog post. Given the sentence “he tells us that at this festive season of the year with christmas and roast beef looming before us similes drawn from eating and its results occur most readily to the mind,” the vanilla Wav2Vec2 model produces “christmaus” instead of “christmas,” “rose” instead of “roast,” and “simalyis” instead of “similes.” All three errors are acoustically reasonable but lexically wrong. An n-gram model fixes exactly this class of mistake by scoring candidate transcriptions against word sequence probabilities.

Wav2Vec2’s transformer architecture already provides contextual audio representations, which is why the original paper’s Appendix C shows strong LibriSpeech results without any language model. But the same appendix also shows that pairing Wav2Vec2 with an LM yields meaningful gains, especially when the model was fine-tuned on just 10 minutes of transcribed audio. For low-resource fine-tuning scenarios, the LM effectively compensates for the model’s limited exposure to diverse word sequences.

The new pyctcdecode integration means developers no longer need to hack together custom decoding pipelines. You can build an n-gram with KenLM and plug it directly into the processor’s decoding step. That’s a meaningful usability win for anyone deploying ASR systems where spelling errors are unacceptable — transcription services, voice assistants, accessibility tools. The pattern mirrors what happened with CTC-based ASR years ago, where shallow fusion with an LM became standard practice. The difference now is that the tooling is actually accessible.