N-Gram Language Models
An -gram model is a language model that estimates the probability of a token based on the previous tokens using frequency statistics from a corpus. It assumes a finite Markov dependency structure over sequences. Formally, for a token sequence ,
giving an -step approximation of the full distribution . In turn, this results in loss of long-range dependencies in exchange for reduced complexity.Parameter estimation in n-gram models is grounded in empirical frequency counts from a corpus. Using maximum likelihood estimation, conditional probabilities are computed as normalized counts, such that
where denotes the context, is the size of the vocabulary, and is a Laplace smoothing constant that alleviates the sparsity problem, where many plausible -grams receive zero probability as , simply because they were not observed in the training data.