Algorithmadvanced
Bayesian HMM tagging
Also called unsupervised Bayesian POS tagging.
Unsupervised part-of-speech induction with an HMM under sparse Dirichlet priors. The parameters are integrated out, and collapsed Gibbs sampling draws the tags.
- Solves
- Part-of-speech tagging
- Time
- Θ(s n k) worst
- Space
- Θ(n + k^2 + k V) extra
- Where
- V = the number of word types; k = the number of tags; n = the number of tokens in the corpus; s = the number of sweeps
- Model
- Word RAM
- Properties
- randomizednot exactofflineiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Sharon Goldwater, Thomas L. Griffiths, 2007
Bayesian HMM tagging learns part-of-speech classes from untagged text. It uses the same hidden Markov model as the HMM tagger, but it does not estimate one set of transition and emission probabilities. It puts sparse Dirichlet priors on them, integrates them out, and samples the tags themselves with collapsed Gibbs sampling. The Gibbs sampling page gives the general sampler for any joint distribution; this page derives the conditional of one tag in the collapsed HMM, where three counts change at once, and shows how the sparse prior changes the result. The method is due to Goldwater and Griffiths (2007).
In plain words
We have plenty of text but no tags. We want to group words into classes that behave like nouns, verbs and so on. The model says that each tag tends to be followed by only a few other tags and tends to produce only a few words. Instead of fixing these tendencies as numbers, the method keeps every possible setting of them and averages over all of them. Then it walks through the text again and again. At each word it takes the tag away, asks how well each tag would fit given all the other tags in the corpus, and draws a new tag at random in proportion to that fit. After many passes, the tags settle into groups that reuse a small number of patterns.
The problem
Input: a corpus of sentences over word types, the number of tags , and hyperparameters . The model, in its first-order form (Goldwater and Griffiths use second order):
Tag is the sentence boundary, used as and as the tag after the last word, so each row has outcomes. Each has outcomes. Output: samples from the posterior , which is proportional to the marginal likelihood
where , , and are transition and emission counts of the tagging and is the rising factorial. The induced tags have no names. They are compared with gold tags by a mapping such as many-to-one accuracy, or with a tag dictionary that limits the tags of each word.
The algorithm
Remove one token from the counts. The conditional of its tag is a product of three ratios: the emission of its word, the transition from the left tag into it, and the transition from it to the right tag . The last ratio needs two corrections, because when the transition has already been added to the row of .
BHMM-GIBBS(w, k, α, β, S) ▷ tag 0 is the boundary at both ends of a sentence- 1
give each token a random tag in 1..k; set the counts n_{a,b}, n_a, n_{t,w}, n_t - 2
for s ← 1 to S do - 3
for each token i, with word w_i, left tag a and right tag b (0 at a sentence end) do - 4
remove (a, t_i), (t_i, b) and (t_i, w_i) from the counts - 5
for t ← 1 to k do p_t ← (n_{t,w_i}+β)/(n_t+Vβ) · (n_{a,t}+α)/(n_a+Kα) · (n_{t,b}+[a=t=b]+α)/(n_t+[a=t]+Kα) - 6
draw t_i = t with probability p_t / (p_1 + ... + p_k) - 7
add (a, t_i), (t_i, b) and (t_i, w_i) to the counts - 8
record the tagging t as sample s - 9
return the samples
In L5, the count in the emission ratio is the number of tokens with tag , and in the last ratio it is the number of transitions out of . In this model the two numbers are equal, since each token has one outgoing transition, but the code keeps them apart. The ratio for one outcome follows from the Dirichlet-multinomial predictive rule: after counts with sum , the next outcome is with probability (Goldwater and Griffiths 2007, equation 5).
The second-order model of Goldwater and Griffiths has the same form with tag trigrams. Resampling one tag changes three trigrams, so their conditional (Figure 2) has four ratios and more indicator terms.
Example
Take four word types, the (0), dog (1), barks (2) and cat (3), with , and , so and . The current tagging is "the/1 dog/2 barks/1" and "the/1 cat/2". Resample the tag of "barks", with and . After L4 the counts are: transitions , , , so , , ; emissions , , so tokens.
| t | emission | transition a to t | transition t to b | product |
|---|---|---|---|---|
| 1 | (0 + 1/10)/(2 + 2/5) = 1/24 | (0 + 1/2)/(1 + 3/2) = 1/5 | (0 + 0 + 1/2)/(2 + 0 + 3/2) = 1/7 | 1/840 |
| 2 | (0 + 1/10)/(2 + 2/5) = 1/24 | (0 + 1/2)/(1 + 3/2) = 1/5 | (1 + 0 + 1/2)/(1 + 1 + 3/2) = 3/7 | 1/280 |
So and . The same numbers come from the ratio of exact marginal likelihoods. Without the correction in the last denominator, the last ratio for would be , and the sampler would draw tag 1 with probability , not .
The test file checks the conditional against the ratio of exact marginals on random corpora in rational arithmetic. It also runs 20000 sweeps on a corpus of 4 tokens, whose 16 taggings have an exact posterior by enumeration, and the frequencies agree within 0.01. On 30 synthetic sentences where two classes alternate and use disjoint words, 150 sweeps with find the two classes exactly, up to the names of the tags.
Correctness
proofs/correctness.md proves three things. The marginal likelihood is the product of Dirichlet-multinomial factors, one per row, by the normalizing constant of the Dirichlet distribution. The conditional of L5 is the ratio of two such marginals: add the emission, then the transition from , then the transition to , each by the predictive rule, and track how the second step changes the row of when . A Gibbs update that draws one variable from its exact conditional leaves the posterior invariant, and since every tag has positive probability at every step, the chain is irreducible and aperiodic, so its law converges to the posterior. The theorem gives no rate.
Proof: The collapsed conditional of the Bayesian HMM, and why the Gibbs sampler targets the posteriorfull
Setting. Tags are , and marks the sentence boundary before the first word and after the last word of each sentence. Row has transition probabilities over the outcomes . Tag has emission probabilities over the word types (the code calls this number W). All these vectors are independent. For a tagging of a corpus , let be the number of transitions from to (with the boundary transitions), , the number of tokens of word with tag , and . Write for the rising factorial, so .
Lemma 1: the marginal likelihood
Proof. Given and , the probability of is . The vectors are independent, so the expectation over the prior splits into one factor per row. For one row with a symmetric Dirichlet with parameter on outcomes and counts with sum ,
by the Dirichlet normalizing constant. Taking , for the transition rows and , for the emission rows gives the formula.
Lemma 2: the collapsed conditional
Fix a token at position of a sentence, with word , left neighbour tag (or at the start) and right neighbour tag (or at the end). Let denote the counts of all other tokens and transitions: the counts of without the transitions and and without the emission . Then for ,
where is the number of transitions out of in (the code keeps it as out[t]), and is 1 when the condition holds and 0 otherwise.
Proof. The conditional is proportional, as a function of , to the marginal with , since the other tags and the words are fixed. By Lemma 1 the marginal is a product of row factors, and each row factor can be built by adding the counts one at a time: adding one more outcome to a row with counts and total multiplies the factor by , because and . The rows are exchangeable, so the order of adding does not matter.
Start from the counts ; the factor they give does not depend on . Add the three events of position in this order:
- The emission multiplies the emission row of by .
- The transition multiplies the transition row of by . After this step, row has one more count in total and one more count at .
- The transition multiplies the transition row of by , where and are the counts of row after step 2. If , step 2 changed another row, so and . If , step 2 added one to the total of row , and also one to its entry exactly when . So and .
The product of the three multipliers is the stated formula.
Lines L4, L5 and L7 of the code implement Lemma 2: L4 removes the three events, L5 forms the product, and L7 adds the events back with the new tag. The test file checks Lemma 2 against the ratio of exact marginals of Lemma 1 in rational arithmetic, on random corpora and on the case .
Theorem: the sampler leaves the posterior invariant
Each update at L6 draws from its exact conditional and keeps the other tags. Such an update leaves invariant: if , then has its marginal under , and the new is drawn from , so the new pair has law . A sweep is a composition of such updates, so it also leaves invariant.
With every conditional gives positive probability to every tag, so one sweep can move from any tagging to any other with positive probability. The chain on the finite set of taggings is therefore irreducible and aperiodic (it can stay where it is), and by the convergence theorem for finite Markov chains the law of the state after sweeps converges to as . This is the standard argument for Gibbs sampling; it gives no bound on the number of sweeps, and on real corpora mixing is slow. The test file checks the invariance in practice: on a corpus of 4 tokens with 16 taggings, the frequencies of 20000 sweeps match the exact posterior, computed by enumeration with Lemma 1, within 0.01.
Complexity
One update costs for the products of L5 and the draw of L6, and a sweep makes updates, so sweeps cost time. This is the same per tag as the second-order sampler, whose conditional also has a constant number of ratios. The counts take space, and the tags take . A forward-filtering backward-sampling sampler that redraws a whole sentence at once costs per sweep instead, and it needs the parameters, so it does not fit the collapsed model directly.
Properties
- Randomized: the output depends on the seed. Goldwater and Griffiths report averages over 5 runs.
- No point estimate of the parameters: the tagging is drawn with the parameters integrated out. This lets the model use priors with that favor sparse rows, where a maximum a posteriori estimate can be degenerate (Goldwater and Griffiths 2007, Section 2.1).
- Label switching: the posterior is symmetric under any renaming of the tags, so tags are only defined up to a permutation. Average quantities that do not depend on the names, or use one sample.
- Measured results (24000 words of the WSJ with a full tag dictionary, 20000 iterations with annealing): 86.8% accuracy with and , against 74.5% for an HMM trained by EM and decoded by Viterbi, and 90.1% for the contrastive estimation CRF of Smith and Eisner (2005) (Goldwater and Griffiths 2007, Section 3 and Table 1).
Variants and improvements
- Annealing: Goldwater and Griffiths raise the conditional to the power and lower the temperature from 2 to 0.08 over the run, so the last sample is near a mode (Sections 2.3 and 3).
- Hyperparameter inference: they put an improper uniform prior on and and resample them by Metropolis-Hastings after each sweep (Section 4). BHMM2 uses a separate for each tag.
- Tag dictionaries: limiting the tags of each word to those listed in a dictionary turns induction into disambiguation, and the emission rows have outcomes instead of .
- Second order and other priors: the trigram model of the paper; hierarchical Dirichlet process HMMs let the number of tags grow with the data (see the Dirichlet process).
- Point estimates: the Baum-Welch algorithm (EM) fits one maximum likelihood HMM; variational Bayes fits an approximate posterior over the parameters.
When to use it
Use it when there is no tagged corpus and you want word classes that follow the sparse structure of real tags, for example as a first step for a new language. Use the sparse prior when the corpus is small: the gain over EM is largest there. With tagged data, a supervised tagger such as the HMM tagger or a discriminative model is far more accurate.
Pitfalls
- Forgetting the indicator terms of L5. They matter whenever a tag repeats next to itself, and without them the sampler does not target the posterior. The example above shows a change from 1/4 to 5/26.
- Updating counts in the wrong order: remove all three events of the token before computing L5, and add them back after the draw.
- Using the denominator of the emission row by mistake. The emission row has outcomes, the transition row has .
- Reading one sample as a clustering without dealing with label switching, or averaging tag identities across runs.
- Judging convergence by the log marginal alone: it can stay flat while the chain is stuck in one mode. Use several seeds.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/bayesian-hmm-tagging/. The authors are listed in prov/FKE3K3.jsonl.
"""Collapsed Gibbs sampling for a first-order Bayesian HMM tagger.
Model. Tags are 1..k; 0 is the sentence boundary, used before the first word
and after the last word. Each row a in 0..k has transition probabilities
tau_a ~ Dirichlet(alpha) over the k + 1 outcomes 0..k, and each tag t has
emission probabilities omega_t ~ Dirichlet(beta) over the W word types.
Integrating out tau and omega gives the marginal P(t, w) of a tagging, and
the conditional of one tag given all the others is a product of three count
ratios (line L5). Goldwater and Griffiths (2007) use the same construction
for a second-order model; this file keeps the first-order case.
The arithmetic is generic: with Fraction hyperparameters the conditional
and the marginal are exact rationals.
"""
import math
import random
from fractions import Fraction
from typing import Dict, List, Sequence, Tuple
class Counts:
"""The sufficient statistics of a tagging: transition and emission counts."""
def __init__(self, k: int, W: int):
self.k, self.W = k, W
self.trans = [[0] * (k + 1) for _ in range(k + 1)] # n_{a,b}
self.out = [0] * (k + 1) # n_a = sum_b n_{a,b}
self.emit = [[0] * W for _ in range(k + 1)] # n_{t,w}
self.ntag = [0] * (k + 1) # n_t = sum_w n_{t,w}
def add_trans(self, a: int, b: int, d: int) -> None:
self.trans[a][b] += d
self.out[a] += d
def add_emit(self, t: int, w: int, d: int) -> None:
self.emit[t][w] += d
self.ntag[t] += d
def build_counts(words: Sequence[Sequence[int]], tags: Sequence[Sequence[int]], k: int, W: int) -> Counts:
c = Counts(k, W)
for ws, ts in zip(words, tags):
prev = 0
for w, t in zip(ws, ts):
c.add_trans(prev, t, 1)
c.add_emit(t, w, 1)
prev = t
c.add_trans(prev, 0, 1)
return c
def conditional(c: Counts, a: int, w: int, b: int, alpha, beta) -> List:
"""Unnormalized P(t_i = t | all other tags, words) for t = 1..k.
c must hold the counts without position i: without (a, t_i), (t_i, b)
and (t_i, w). Entry 0 of the result is 0 (the boundary is not a tag).
"""
K1 = c.k + 1
p = [0 * alpha]
for t in range(1, c.k + 1):
e = (c.emit[t][w] + beta) / (c.ntag[t] + c.W * beta) # @line L5
t1 = (c.trans[a][t] + alpha) / (c.out[a] + K1 * alpha)
same = 1 if a == t else 0
t2 = (c.trans[t][b] + (1 if (a == t and t == b) else 0) + alpha) / (c.out[t] + same + K1 * alpha)
p.append(e * t1 * t2)
return p
def gibbs(words: Sequence[Sequence[int]], k: int, W: int, alpha: float, beta: float,
sweeps: int, seed: int, init=None):
"""Run collapsed Gibbs sampling. Return (the final tags, the list of samples).
Each sample is the tagging after one sweep, as a tuple of tuples. words
holds word ids in 0..W-1. init is an optional starting tagging.
"""
rng = random.Random(seed)
if init is None:
tags = [[rng.randint(1, k) for _ in ws] for ws in words] # @line L1
else:
tags = [list(ts) for ts in init]
c = build_counts(words, tags, k, W)
samples = []
for _ in range(sweeps): # @line L2
for s, ws in enumerate(words):
ts = tags[s]
n = len(ws)
for i in range(n): # @line L3
a = ts[i - 1] if i > 0 else 0
b = ts[i + 1] if i + 1 < n else 0
old = ts[i]
c.add_trans(a, old, -1) # @line L4
c.add_trans(old, b, -1)
c.add_emit(old, ws[i], -1)
p = conditional(c, a, ws[i], b, alpha, beta)
r = rng.random() * sum(p) # @line L6
new = 1
acc = p[1]
while acc <= r and new < k:
new += 1
acc += p[new]
ts[i] = new
c.add_trans(a, new, 1) # @line L7
c.add_trans(new, b, 1)
c.add_emit(new, ws[i], 1)
samples.append(tuple(tuple(ts) for ts in tags)) # @line L8
return tags, samples # @line L9
def rising(x, n: int):
"""The rising factorial x (x + 1) ... (x + n - 1) = Gamma(x + n) / Gamma(x)."""
r = 1
for j in range(n):
r = r * (x + j)
return r
def marginal(words, tags, k: int, W: int, alpha, beta):
"""P(tags, words | alpha, beta) with tau and omega integrated out.
Each Dirichlet-multinomial factor is prod_b rising(alpha, n_b) / rising(K alpha, n).
With Fraction hyperparameters the result is exact.
"""
c = build_counts(words, tags, k, W)
p = Fraction(1) if isinstance(alpha, Fraction) else 1.0
for a in range(k + 1):
for b in range(k + 1):
p *= rising(alpha, c.trans[a][b])
p /= rising((k + 1) * alpha, c.out[a])
for t in range(1, k + 1):
for w in range(W):
p *= rising(beta, c.emit[t][w])
p /= rising(W * beta, c.ntag[t])
return p
def all_taggings(words, k: int):
"""Every tagging of the corpus with tags 1..k (k^N of them)."""
out = [[]]
for ws in words:
nxt = []
for prefix in out:
seqs = [[]]
for _ in ws:
seqs = [s + [t] for s in seqs for t in range(1, k + 1)]
for s in seqs:
nxt.append(prefix + [s])
out = nxt
return out
def exact_posterior(words, k: int, W: int, alpha, beta) -> Dict[Tuple, object]:
"""P(tags | words) for every tagging, by enumeration and normalization."""
ps = {}
for tg in all_taggings(words, k):
ps[tuple(tuple(ts) for ts in tg)] = marginal(words, tg, k, W, alpha, beta)
z = sum(ps.values())
return {key: v / z for key, v in ps.items()}
def many_to_one_accuracy(gold: Sequence[Sequence[str]], pred: Sequence[Sequence[int]]) -> float:
"""Map each induced tag to the gold tag it most often meets, then count matches."""
table: Dict[int, Dict[str, int]] = {}
for gs, ps in zip(gold, pred):
for g, p in zip(gs, ps):
row = table.setdefault(p, {})
row[g] = row.get(g, 0) + 1
hit = sum(max(row.values()) for row in table.values())
total = sum(len(gs) for gs in gold)
return hit / total if total else 1.0
def log_marginal(words, tags, k: int, W: int, alpha: float, beta: float) -> float:
"""log P(tags, words) with lgamma, for corpora too large for exact rationals."""
c = build_counts(words, tags, k, W)
s = 0.0
for a in range(k + 1):
for b in range(k + 1):
s += math.lgamma(c.trans[a][b] + alpha) - math.lgamma(alpha)
s -= math.lgamma(c.out[a] + (k + 1) * alpha) - math.lgamma((k + 1) * alpha)
for t in range(1, k + 1):
for w in range(W):
s += math.lgamma(c.emit[t][w] + beta) - math.lgamma(beta)
s -= math.lgamma(c.ntag[t] + W * beta) - math.lgamma(W * beta)
return s
test_bayesian_hmm_tagging.py 140 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/bayesian-hmm-tagging/. The authors are listed in prov/FKE3K3.jsonl.
import math
import random
from fractions import Fraction
from bayesian_hmm_tagging import (all_taggings, build_counts, conditional, exact_posterior, gibbs,
log_marginal, many_to_one_accuracy, marginal, rising)
def without_position(words, tags, k, W, s, i):
c = build_counts(words, tags, k, W)
ts = tags[s]
a = ts[i - 1] if i > 0 else 0
b = ts[i + 1] if i + 1 < len(ts) else 0
c.add_trans(a, ts[i], -1)
c.add_trans(ts[i], b, -1)
c.add_emit(ts[i], words[s][i], -1)
return c, a, b
def test_rising_factorial():
assert rising(Fraction(1, 2), 0) == 1
assert rising(Fraction(1, 2), 3) == Fraction(1, 2) * Fraction(3, 2) * Fraction(5, 2)
assert rising(3, 4) == math.factorial(6) // math.factorial(2)
def test_conditional_is_ratio_of_marginals():
"""The collapsed conditional equals P(t with t_i = t, w) / sum over t' of the same, exactly."""
rng = random.Random(1)
for _ in range(40):
k = rng.randint(1, 3)
W = rng.randint(1, 4)
alpha = Fraction(rng.randint(1, 9), rng.randint(1, 9))
beta = Fraction(rng.randint(1, 9), rng.randint(1, 9))
words = [[rng.randrange(W) for _ in range(rng.randint(1, 4))] for _ in range(rng.randint(1, 3))]
tags = [[rng.randint(1, k) for _ in ws] for ws in words]
s = rng.randrange(len(words))
i = rng.randrange(len(words[s]))
c, a, b = without_position(words, tags, k, W, s, i)
p = conditional(c, a, words[s][i], b, alpha, beta)
joint = []
for t in range(1, k + 1):
tg = [list(ts) for ts in tags]
tg[s][i] = t
joint.append(marginal(words, tg, k, W, alpha, beta))
zp = sum(p[1:])
zj = sum(joint)
for t in range(1, k + 1):
assert p[t] / zp == joint[t - 1] / zj
def test_conditional_tricky_cases_same_tag_neighbours():
"""a = t = b, the case of the indicator terms, against the ratio of marginals."""
words = [[0, 0, 0]]
k, W = 2, 1
alpha, beta = Fraction(1, 3), Fraction(2, 5)
for mid in (1, 2):
tags = [[1, mid, 1]]
c, a, b = without_position(words, tags, k, W, 0, 1)
p = conditional(c, a, 0, b, alpha, beta)
m1 = marginal(words, [[1, 1, 1]], k, W, alpha, beta)
m2 = marginal(words, [[1, 2, 1]], k, W, alpha, beta)
assert p[1] / p[2] == m1 / m2
def test_marginal_sums_to_one_over_words():
"""Summing P(t, w) over all taggings and all word strings of fixed lengths gives P(lengths)."""
k, W = 2, 2
alpha, beta = Fraction(1, 2), Fraction(1, 3)
total = Fraction(0)
for w0 in range(W):
for w1 in range(W):
words = [[w0, w1]]
total += sum(marginal(words, tg, k, W, alpha, beta) for tg in all_taggings(words, k))
# The emission part sums to 1, so the total is P(the two-word length pattern) under the prior.
trans_only = Fraction(0)
for tg in all_taggings([[0, 0]], k):
c = build_counts([[0, 0]], tg, k, 1)
p = Fraction(1)
for a in range(k + 1):
for b in range(k + 1):
p *= rising(alpha, c.trans[a][b])
p /= rising((k + 1) * alpha, c.out[a])
trans_only += p
assert total == trans_only
def test_log_marginal_matches_exact():
rng = random.Random(4)
words = [[rng.randrange(3) for _ in range(4)] for _ in range(2)]
tags = [[rng.randint(1, 2) for _ in ws] for ws in words]
exact = marginal(words, tags, 2, 3, Fraction(1, 10), Fraction(1, 5))
assert abs(log_marginal(words, tags, 2, 3, 0.1, 0.2) - math.log(exact)) < 1e-9
def test_gibbs_frequencies_match_exact_posterior():
words = [[0, 1, 0], [1]]
k, W = 2, 2
alpha, beta = 0.5, 0.5
exact = exact_posterior(words, k, W, Fraction(1, 2), Fraction(1, 2))
_, samples = gibbs(words, k, W, alpha, beta, sweeps=20000, seed=12345)
freq = {}
for smp in samples[200:]:
freq[smp] = freq.get(smp, 0) + 1
n = len(samples) - 200
assert len(exact) == 16
assert sum(exact.values()) == 1
for key, p in exact.items():
assert abs(freq.get(key, 0) / n - float(p)) < 0.01
def test_gibbs_finds_planted_classes():
"""Two tags with disjoint vocabularies that alternate; sparse priors recover them."""
rng = random.Random(9)
words, gold = [], []
for _ in range(30):
ws, gs = [], []
for j in range(rng.randint(2, 6)):
if j % 2 == 0:
ws.append(rng.randrange(0, 4))
gs.append("D")
else:
ws.append(rng.randrange(4, 8))
gs.append("N")
words.append(ws)
gold.append(gs)
tags, _ = gibbs(words, 2, 8, 0.1, 0.1, sweeps=150, seed=3)
assert many_to_one_accuracy(gold, tags) == 1.0
assert log_marginal(words, tags, 2, 8, 0.1, 0.1) > log_marginal(words, [[1] * len(ws) for ws in words], 2, 8, 0.1, 0.1)
def test_counts_restored_after_sweeps():
rng = random.Random(2)
words = [[rng.randrange(5) for _ in range(rng.randint(1, 6))] for _ in range(5)]
tags, _ = gibbs(words, 3, 5, 0.3, 0.2, sweeps=5, seed=8)
c = build_counts(words, tags, 3, 5)
assert sum(c.ntag) == sum(len(ws) for ws in words)
assert c.out[0] == len(words) and sum(c.trans[a][0] for a in range(4)) == len(words)
History
Goldwater and Griffiths (2007) start from the tradition of Merialdo (1994), who trained a trigram HMM tagger by maximum likelihood on untagged text with a tag dictionary. They kept the trigram HMM but replaced the point estimate by integration under symmetric Dirichlet priors, and sampled the tags by collapsed Gibbs sampling, the technique that Griffiths and Steyvers (2004) had used for topic models. In their experiments the Bayesian model was up to 14 percentage points more accurate than the maximum likelihood HMM.
References
- Goldwater and Griffiths 2007, Section 2.2 (the trigram model with symmetric Dirichlet priors), Section 2.3 and Figure 2 (Gibbs sampling and the conditional of one tag, annealing), Table 1 (accuracy against the hyperparameters), Section 4 (hyperparameter inference)
- Stuart Geman and Donald Geman, Stochastic relaxation, Gibbs distributions, and the Bayesian restoration of images, IEEE Transactions on Pattern Analysis and Machine Intelligence 6(6), 1984, pages 721 to 741, the Gibbs sampler and annealing
- Thomas L. Griffiths and Mark Steyvers, Finding scientific topics, Proceedings of the National Academy of Sciences 101(suppl. 1), 2004, pages 5228 to 5235, collapsed Gibbs sampling with Dirichlet-multinomial count ratios, for topic models
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag FKE3K3 Edit this page History Report an error Markdown