A Language Model (LM) is the task of predicting what words come next. Informally, it is the probability distribution of the next word when the sequence of words is given.
There are primarily two types of language models:
- Statistical Language Models (N-Gram, Exponential, Continuous Space)
- Neural Language Models (RNN, LSTM)
Perplexity: In Language model, perplexity is used to measure how well that language model is predicting the next word. It is the normalized inverse probability of the test set. In mathematically, the equation of perplexity is, PP(p) = 2H(p) = 2**(−Σ𝑝(𝑥)log2𝑝(𝑥))
Some Common Examples of Language Models
- Machine Translation
- Speech Recognization
- Sentiment Analysis
- Text Suggestions
In this example I built a Gated Recurrent Unit (GRU) Language Model.
- Programming Language: Python
- Libraries: PyTorch
- LM Type: GRU RNN
- Dataset used: Wikitext-2
Inspired by: