---
title: Internal Language Modeling in ASR
url: https://www.emergentmind.com/topics/internal-language-modeling-ilm
type: topic
---

# Internal Language Modeling in ASR

Internal language modeling (ILM) in end-to-end automatic speech recognition denotes the implicit prior over output token sequences that is learned inside the recognizer itself. In this usage, the ASR posterior is not treated as a purely acoustic score: attention-based encoder-decoder (AED) decoders, RNN-Transducer (RNN-T) prediction pathways, and even modern CTC encoders absorb textual regularities from paired speech-transcript training data. ILM research therefore studies how this internal prior should be defined, estimated, subtracted or discounted during external language-model fusion, strengthened or adapted with text-only data, and interpreted in relation to perplexity, word error rate, rare-word recognition, and domain mismatch [2011.01991] [2104.05544] [2506.06096] [2607.05612].

## 1. Definition and architectural scope

In the strongest theoretical form, ILM is the label-sequence distribution induced by marginalizing the ASR posterior over acoustics. For AED, one formulation is
$$
P_{\mathrm{ILM}}(w_1^N)=\sum_{T,x_1^T} P_{\mathrm{AED}}(w_1^N\mid x_1^T)\,P(x_1^T),
$$
and for CTC the analogous definition is
$$
P_{\mathrm{ILM}}(a_1^S)=\sum_X Pr(X)\,P(a_1^S\mid X).
$$
Both papers state that this exact marginalization is intractable, which is why practical ILM work is dominated by estimators rather than direct computation [2104.05544] [2506.06096].

The architectural location of ILM depends on the recognition model. In RNN-T-style systems, the internal LM is commonly associated with the prediction network plus joint network once encoder contribution is removed. In AED, it is associated with the autoregressive decoder when attention-derived acoustic context is suppressed. In factorized transducers and MHAT-like models, the linguistic component is made more explicit by construction: non-blank token prediction contains a dedicated ILM term, while acoustic and blank pathways are separated more cleanly [2110.05354] [2302.08583] [2404.01716].

A recurrent misconception is that ILM is only relevant for explicitly autoregressive decoders. Recent CTC work disputes that view. Although classical CTC assumes label-context independence at the output factorization, modern Conformer-based CTC systems can still learn a context-dependent ILM through powerful encoders, and cross-domain results show that context-dependent ILM estimators outperform context-independent priors [2506.06096]. A related masking-based CTC study argues that contextual encoders exhibit source-domain semantic bias even without an autoregressive decoder, and operationalizes that bias as a pseudo internal LM estimated from masked-acoustic perturbations [2305.03837].

## 2. Bayesian interpretation and decoding with prior compensation

The central ILM argument is Bayesian. If an end-to-end posterior already contains a language prior, then adding an external LM by shallow fusion risks double counting. This motivates decoding rules of the form
$$
\hat{\mathbf{Y}}=\arg\max_{\mathbf{Y}}\left[\log P(\mathbf{Y}\mid \mathbf{X};\theta_{\mathrm{E2E}})+\lambda_E \log P(\mathbf{Y};\theta_{\mathrm{LM}})-\lambda_I \log P(\mathbf{Y};\theta_{\mathrm{ILM}})\right],
$$
which is the common structure behind internal language model estimation (ILME) for RNN-T and AED [2011.01991] [2102.01380].

For AED, the same idea is often written as a shallow-fusion score augmented with ILM compensation,
$$
\log p_{\mathrm{AED}}(a_1^S\mid x_1^T)+\lambda \log p_{\mathrm{LM}}(a_1^S)-\gamma \log p_{\mathrm{ILM}}(a_1^S),
$$
where \(\lambda\) scales the external LM and \(\gamma\) scales ILM subtraction. When \(\gamma=0\), the rule reduces to ordinary shallow fusion. The 2026 AED study treats this subtraction term as essential for interpreting the relation between external-LM perplexity and ASR error, because otherwise the external LM is fused with a score that already contains a decoder prior [2607.05612].

A unified RNN-T analysis gives two decoding-level reasons for the gains from ILM correction. First, prior removal rebalances the label distribution so that the external LM contributes more directly to context modeling. Second, dividing by the ILM boosts non-blank labels against the usually high blank probability, permitting larger external-LM weights without inducing severe deletion behavior [2110.06841]. That paper verifies the two effects separately: a length reward mainly simulates the blank-suppression component, while a blank-preserving renormalization mainly simulates label rebalancing.

One extension is adaptive rather than fixed prior compensation. ILME-ADA compares scaled internal-LM and external-LM log-likelihoods at each decoding step and chooses the larger one. If the scaled ILM score dominates, the subtraction and addition cancel and decoding falls back to the baseline E2E objective; if the external LM dominates, decoding reduces to standard ILME-style fusion. In Mandarin RNN-T and LAS domain adaptation, this adaptive rule gave substantially better target-domain CER with much smaller degradation on the general domain than either shallow fusion or fixed ILME, especially with n-gram LMs [2211.00968].

## 3. Estimation methods across AED, RNN-T, and CTC

Because exact acoustic marginalization is intractable, ILM research is largely a study of estimators.

For AED, the standard estimator family replaces the decoder context vector \(c_i\) with a surrogate \(\hat c_i\). Early baselines used zero context, but several papers report that this is too crude. One AED study showed that using encoder-bias information is better than masking the input representation: global attention-context averages, global encoder averages, and especially a trained mini-LSTM context generator all outperformed zero-attention and density-ratio baselines, with the mini-LSTM giving the best WER and the lowest ILM perplexity among the valid prior estimators it studied [2104.05544]. A later LAS paper proposed explicit context-vector learning. OTCL replaces every decoder context vector with a single learned vector, while LSCL predicts a dynamic context vector from the decoder query/state by a lightweight feed-forward network. On BLSTM, Transformer, and Conformer encoders, LSCL achieved the lowest held-out transcript perplexities—\(235\), \(428\), and \(463\), respectively—whereas zero-out context gave \(387\), \(6247\), and \(3271\), indicating that learned context surrogates are far better matched to the frozen decoder than naive zeroing [2201.11627].

For RNN-T, a common approximation is to remove encoder contribution and reuse the prediction network and joint network as a text-only scorer. Several alternatives then differ in how closely that scorer is tied to the transducer. Density-ratio methods use a standalone source LM trained on transcripts; zero-encoder methods derive the ILM directly from the transducer; low-order density ratio replaces the usual strong source LM by a deliberately weak low-order model, based on the claim that the RNN-T ILM is weak and low-order rather than a full-context neural LM. In LibriSpeech in-domain results, the source-trained DR LM had the lowest transcript perplexity among the compared ILM estimates, but ILME still achieved the best WER and LODR stayed close, supporting the claim that lower perplexity does not imply a better match to the transducer’s internal prior [2203.16776]. A complementary theoretical paper later generalized the HAT-style decomposition and introduced exact-ILM training via a learned acoustic-independent logit term \(J'(a_1^{s-1})\), improving history-dependent mini-LSTM ILM estimation [2110.06841].

CTC required separate developments. One line of work derives prefix-conditioned next-label posteriors from CTC prefix probabilities and distills them into a small autoregressive LM. In TED-LIUM2 cross-domain evaluation, label-level knowledge distillation with smoothing reduced test WER from \(15.9\) with shallow fusion to \(13.8\), more than \(13\%\) relative, and outperformed context-independent frame priors and unigrams. The same study argues that these gains are evidence that modern CTC models learn a context-dependent ILM despite the classical label-context-independence assumption [2506.06096]. Another line of work estimates a pseudo ILM by iteratively masking equal acoustic partitions, accumulating masked log-posteriors only at timesteps whose posteriors change substantially, and subtracting that pseudo-likelihood during decoding. Across multiple out-of-domain datasets, this masking-based CTC ILME improved WER by up to \(9.8\%\) and OOV F1 by up to \(24.6\%\) relative to shallow fusion when target-domain text was available; in zero-shot adaptation it still improved WER by up to \(9.3\%\) relative [2305.03837].

## 4. Training, adaptation, and explicit factorization of the internal LM

A major shift in the literature is from estimating ILM at inference time to training or adapting the internal LM directly.

Internal LM training (ILMT) adds an auxiliary ILM loss to ordinary end-to-end training, but applies that loss only to the components used later as the internal LM estimate. For RNN-T this means the prediction and joint networks; for AED it means the decoder. The resulting objective is
$$
\mathcal{L}_{\mathrm{ILMT}}=\mathcal{L}_{\mathrm{E2E}}+\alpha \mathcal{L}_{\mathrm{ILM}}.
$$
In 30K-hour RNN-T and AED experiments, ILMT reduced RNN-T ILM perplexity from \(99.4\) to \(52.0\) and AED ILM perplexity from \(796.7\) to \(46.1\), and ILMT combined with ILME-based inference achieved up to \(31.5\%\) relative WER reduction from standard E2E training with shallow fusion on out-of-domain LibriSpeech [2102.01380].

Internal language model adaptation (ILMA) goes further by fine-tuning the internal LM with text-only data so that no external LM is needed at inference. For transformer transducers, the key design choice was to update only the non-blank output rows of the joiner, because text-only data provide no blank supervision and modifying components that affect blank probability can harm alignment. In 30K-hour transformer-transducer experiments, ILMA achieved up to \(34.9\%\) relative WER reduction from the unadapted baseline, and the most effective setting updated only the non-blank joiner output layer [2110.05354].

JEIT extends this logic to joint training with large-scale unpaired text. It optimizes the normal E2E loss on paired speech and an ILM cross-entropy loss on unpaired text in one stage, so that the paired-data objective regularizes the strengthened internal LM and obviates the separate Kullback-Leibler regularization required by ILMA-style adaptation. On HAT and MHAT, JEIT improved rare-word recognition, and with 100B unpaired sentences JEIT/CJJT improved rare-word recognition accuracy by up to \(16.4\%\) over a model trained without unpaired text [2302.08583].

Factorized transducer work treats ILM as an explicit branch rather than only an estimated hidden prior. In the factorized model, non-blank prediction is decomposed into an acoustic log-probability \(\log P_{am}\) and an internal LM log-probability \(\log P_{ilm}\), while blank probability is modeled separately. That paper argues that explicitness alone is insufficient: the ILM branch must be pretrained on text-only data, decoded with a score that uses \(\log P_{ilm}\) both inside and outside the non-blank softmax, and ideally optimized with an ILM-fusion-aware MWER objective. On LibriSpeech, the proposed decoding rule delivered a \(17\%\) relative improvement over standard factorized-transducer decoding, and the resulting system exceeded a strong RNN-T plus external-LM shallow-fusion baseline by \(5.5\%\) relative on general sets and by \(8.9\%\) on rare-word WER without any external LM at inference [2404.01716].

## 5. Empirical phenomena: perplexity, saturation, rare words, and sequence training

One of the most developed empirical findings is that ILM changes how external-LM perplexity maps to ASR error. In a 2026 study on Conformer AED for LibriSpeech dev-other, the relation between subword-level external-LM perplexity and WER remained piecewise linear in log-log space, but ILM subtraction substantially steepened the low-perplexity slope: the fitted low-PPL slope changed from \(0.200\) without ILM subtraction to \(0.294\) with ILM subtraction, while the high-PPL slopes stayed near zero at \(0.011\) and \(0.007\). The same paper reported the AED’s internal LM perplexity as \(110\), very close to the empirical break point around PPL \(100\). Its interpretation is that once the external LM becomes weaker than, or comparable to, the decoder’s own internal LM, WER saturates and differences among weaker external LMs matter little [2607.05612].

The same work contrasts AED with CTC. On LibriSpeech dev-other, the fitted CTC slope dropped from \(0.267\) below PPL \(50\) to \(0.092\) above PPL \(50\), so the high-perplexity regime still benefited from external-LM quality. AED, with a strong decoder prior, showed much stronger saturation. The paper also showed that weakening CTC encoder context made external LM gains much larger: with full context, the best Transformer LM improved average dev-other/test-other WER from \(5.00\%\) to \(3.88\%\), whereas with only \(0.3\) s of context, LM-assisted decoding reduced WER from \(40.83\%\) to \(18.05\%\). This suggests that internal sequence-modeling strength, whether decoder-side or encoder-side, directly controls how much external LM quality can be observed in WER [2607.05612].

Another important empirical relation is between ILM subtraction and sequence discriminative training. For neural transducers, a theoretical derivation shows that the global optimum of MMI training with integrated LM has the form of the empirical posterior divided by an LM prior, up to renormalization and exponentiation, which is structurally similar to ILM subtraction. Empirically, on LibriSpeech full-context RNN-T, CE training plus shallow fusion gave test-other WER \(4.9\); CE plus ILM subtraction reduced it to \(4.3\); but MMI or MBR fine-tuning with shallow fusion already reached about \(4.3\), leaving only negligible additional gain for ILM subtraction. That paper further showed that sequence discriminative training had little effect on the commonly used zero-encoder ILM estimate after blank renormalization, but it did reshape both encoder and prediction/joint behavior, including blank suppression [2309.14130].

Rare-word and hallucination behavior provide a separate diagnostic. AdaptLMD studies RNN-T from the perspective that the prediction network acts as an overconfident internal LM which can override acoustics, especially for rare or out-of-domain words. It estimates an implicit acoustic model and an ILM by masking one side or the other before the joint network, then discounts the ILM adaptively based on recent token rarity and the KL divergence between ILM and IAM distributions. On conversational code-mixed Hindi-English ASR, this reduced overall WER by up to \(4\%\) and rare-word PER by up to \(14\%\) relative, supporting the claim that internal language priors can directly cause acoustically inconsistent hallucinations [2203.02317].

## 6. Limitations, ambiguity of the acronym, and adjacent usages

Across the ASR literature, ILM remains an estimated object rather than an exactly recovered one. The common derivations rely on approximate decompositions of end-to-end posteriors, such as removing encoder contribution in RNN-T or zeroing attention context in AED, and several papers explicitly note that these are not exact probabilistic factorizations [2011.01991] [2102.01380]. AED work likewise reports that estimator quality varies strongly with architectural details, that zero-context methods can be badly mismatched to Transformer and Conformer decoders, and that some studies establish the phenomenon more clearly than the estimator design space itself [2201.11627] [2607.05612].

Estimator quality also conditions downstream conclusions. ILME-ADA shows that adaptive fusion is only as good as the ILM estimate it compares against; in LAS, zeroing the context vector was markedly weaker than AvgH, LSCL, or OTCL under a general-domain-degradation constraint [2211.00968]. For CTC, one paper reports that ILM perplexity is not predictive of ASR performance, so checkpoint selection must still rely on development-set WER rather than ILM PPL alone [2506.06096]. These results suggest that ILM research is less about identifying a single canonical estimator than about matching the estimator to the model family and the decoding objective.

The acronym itself is overloaded. In a distinct literature on language evolution and emergent communication, “ILM” denotes the Iterated Learning Model or Iterated Learning Method rather than internal language modeling. There it refers to tutor-pupil transmission through a bottleneck, used to study compositionality, language contact, and neural sender-receiver systems [2406.06878] [2101.11739]. That usage is conceptually separate from ASR ILM, even though both concern the interaction between learned linguistic structure and transmission constraints.

Taken together, the ASR papers suggest a stable interpretation. ILM is the model-internal sequence prior that modern end-to-end recognizers learn from transcripts; external-LM fusion is therefore a prior-replacement problem rather than simple score addition; and the practical value of perplexity, LM fusion, or domain adaptation depends on how accurately that internal prior is estimated, discounted, trained, or factorized [2607.05612].

Source: https://www.emergentmind.com/topics/internal-language-modeling-ilm