Hidden Markov Models
A Hidden Markov Model (HMM) is the best-known type of probabilistic/statistical generative model that is used to solve the problem of finding the most likely sequence of states in a finite-state system, given a sequence of observable events or observations (referred to as observables), such as a sequence of input words. The input words are considered observed events, while the POS tags are considered hidden events. HMM is based on the Markov chain, a model that informs us about the probabilities of sequences of random variables or states whose values can be taken from some set. Those sets are finite, like words, tags, or symbols.
The HMM is a probabilistic finite-state formalism characterized by a tuple . T is a finite set of POS tags from a given tagset. is the initial tag’s probability given the first occurring word in sequence. is the transition matrix, while B is the emission matrix.
Matrix A contains transition probabilities, and matrix contains the observation likelihoods. The values of A represent tag transition probabilities of a tag occurring given the previous tag. The maximum likelihood estimate of this transition can be computed as follows:
(1)
The values of matrix B represent the emission probabilities . It is the probability of a POS tag associated with a given word .
(2)
A first-order HMM within the context of POS tagging instantiates two assumptions: (1) the Markov assumption and (2) the output independence assumption. Within the Markov assumption, the probability of any given POS tag only depends on the tag before. Formally put:
(3)
While the Markov assumption tells us that only the previous tag matters when predicting the current tag. The second assumption ensures that the probability of a word depends only on the POS tag that produced the word; formally:
(4)
The training of an HMM for POS tagging depends on our resources according to two types of training: supervised or unsupervised. For supervised training, the HMM model is trained using an annotated dataset where the words and their corresponding POS tags are known. This allows for a direct estimation of transition probabilities between the tags and the emission probabilities of the words given the tags. Conversely, for unsupervised training, the HMM model is trained using an unannotated dataset, relying only on the words. Since there are no POS tags available in the dataset, the model treats them as hidden variables where their probabilities are estimated using the expectation-maximization algorithm. However, since the unsupervised HMM training is less accurate, we use supervised HMM training in this study.
Within HMM, our goal is to find the most likely POS tag for any given word ; however, the 2 gives us an answer that seems counter-intuitive to our goal, namely, if we have the tag , how likely is it that the input word would be . More generally, we want to
find the most likely sequence out of hidden variables (POST tags) corresponding to the sequence of the observations (input words) .
Formally:
(5)
By applying Bayes’ rule and the two simplification 3 and 4 on 6, we end up with the following notation:
(6)
Solving 6 and finding the value of would require trying all the possible paths in the range of . Therefore, we would need computations. We would need a tremendous amount of calculations for any simple corpus with a handful of tags. For example, if we have a tagset T of 50 tags and a dataset with 1000 sentences, each sentence averages 20 words. The upper limit of the number of computations for tagging this corpus would be computations, which is fatally inefficient. \ The best solution for overcoming this inefficacy is the Viterbi algorithm (Viterbi 1967). The algorithm guarantees to find the optimal solution quickly, at most with a complexity of . For the previous example, the Viterbi algorithm would need no more than computations.
Conditional Random Field model
One of the prevalent challenges in NLP, in general, and within POS tagging, in particular, is the unknown words or more technically Out-of-Vocabulary words. New words are oftentimes added to languages in the open-class word category, and in the case of LRLs, the training data may not contain all words. This means that already-built models like HMM cannot recognize those newly added or unseen words. In addition, generative models, like HMM, cannot capture global knowledge (the entire sequence of words and their associated probabilities), because the transitions and the emissions are all local knowledge (the immediate context in which a word appears). We can solve this problem by using higher-order HMMs; however, this raises the computation cost needed for performing fast POS tagging.
% Moreover, within HMM, we optimize the joint probability of POS tags and words; calculating the conditional probability is more interesting and intuitive.
Therefore, the conditional random field (CRF) (Lafferty et al. 2001) model is introduced to overcome this problem.
CRF is a discriminative model that considers more realistically the inherent lack of complete datasets required to build a robust and wide-coverage statistical model. Given an input sequence (words) , the goal of a discriminative POS tagger is to find the most likely sequence of POS tags .
We want to find the sequence among all possible tags .
(7)
In addition, CRF can be considered a big version of what multinomial logistic regression does for a specific word.
CRF uses a set of features to represent each word in the sentence, such as the word itself, its previous and next words, its position in the sentence, and other linguistic features. Then it applies a set of weights to each feature to determine the probability of assigning a particular tag to the word. In addition, CRF utilizes the notion of feature function , which maps an entire input sequence (words) and an entire output sequence (POS tags) to a feature vector. The feature functions allow us to encode any dependency in the data. For example, we can have a function that outputs a one every time it encounters a noun following an adverb; otherwise, it is a zero. 7 describes the linear chain CRF, the most common CRF model used for NLP tasks. Linear chain CRF restricts the model to use only the current observed POS tag , the previous one , and the entire input sequence W at a specific position in the input sequence. This restriction makes the CRF more efficient in the task of POS tagging.
CRF computes the log-linear functions over a set of relevant features instead of computing the probability for each tag at each time step. A global probability for the whole tagset is computed by aggregating and normalizing the local features.
Formally, given K features, each equipped with weight, we can define our conditional probability as follows:
(8)
(9)
(10)
10 demonstrates that each local feature at position only depends on information from the current POS tag , the previous , the entire input words :
Leave a Reply