FSTs, HMMs & POS tagging
CMSC 723 / LING 723 / INST 725 MARINE CARPUAT
marine@cs.umd.edu
FSTs, HMMs & POS tagging CMSC 723 / LING 723 / INST 725 M ARINE - - PowerPoint PPT Presentation
FSTs, HMMs & POS tagging CMSC 723 / LING 723 / INST 725 M ARINE C ARPUAT marine@cs.umd.edu Complete Morphological Parser Practical NLP Applications In practice, it is almost never necessary to write FSTs by hand Typically, one
CMSC 723 / LING 723 / INST 725 MARINE CARPUAT
marine@cs.umd.edu
hand…
– Chomsky and Halle Notation: a → b / c__d = rewrite a as b when occurs between c and d – E-Insertion rule
ε → e / x s z ^ __ s #
– union +ize +able – un+ ion +ize +able
he saw me he ran home she talked
accepts
– But not necessary – Strings that are not accepted are said to have probability zero
weighted finite state automata
transducers
– Generates pairs of strings and assigns a weight to each pair – Weight can often be interpreted as conditional probability P(output-string | input-string)
– Weighted Finite State Automata/Transducers – Hidden Markov Models
WH WHAT A T ARE PAR ARTS TS OF OF S SPE PEECH ECH?
– “Categories” or “types” of words
– Dionysius Thrax of Alexandria (c. 100 BC) – 8 parts of speech: noun, verb, pronoun, preposition, adverb, conjunction, participle, article – Remarkably enduring list!
1 1
– Verbs are actions – Adjectives are properties – Nouns are things
– What occurs nearby? – What does it act as?
– What affixes does it take?
– Impossible to completely enumerate – New words continuously being invented, borrowed, etc.
– Closed, fixed membership – Reasonably easy to enumerate – Generally, short function words that “structure” sentences
– Nouns – Verbs – Adjectives – Adverbs
may not have the other two
– New inventions all the time: muggle, webinar, ...
– Generally, words for people, places, things – But not always (bandwidth, energy, ...)
– Occurring with determiners – Pluralizable, possessivizable
– Mass vs. count nouns
– New inventions all the time: google, tweet, ...
– Generally, denote actions, processes, etc.
– E.g., Intransitive, transitive
– Main vs. auxiliary verbs – Gerunds (verbs behaving like nouns) – Participles (verbs behaving like adjectives)
– Generally modify nouns, e.g., tall girl
– A semantic and formal hodge-podge… – Sometimes modify verbs, e.g., sang beautifully – Sometimes modify adjectives, e.g., extremely hot
– In English, occurring before noun phrases – Specifying some type of relation (spatial, temporal, …) – Examples: on the shelf, before noon
– Resembles a preposition, but used with a verb (“phrasal verbs”) – Examples: find out, turn over, go on
He came by the office in a hurry He came by his fortune honestly We ran up the phone bill We ran up the small hill He lived down the block He never lived down the nicknames (by = preposition) (by = particle) (up = particle) (up = preposition) (down = preposition) (down = particle)
– Establish reference for a noun – Examples: a, an, the (articles), that, this, many, such, …
– Refer to person or entities: he, she, it – Possessive pronouns: his, her, its – Wh-pronouns: what, who
– Join two elements of “equal status” – Examples: cats and dogs, salad or soup
– Join two elements of “unequal status” – Examples: We’ll leave after you finish eating. While I was waiting in line, I saw my friend. – Complementizers are a special case: I think that you should finish your assignment
Chinese
No verb/adjective distinction! Riau Indonesian/Malay No Articles No Tense Marking 3rd person pronouns neutral to both gender and number No features distinguishing verbs from nouns 漂亮: beautiful/to be beautiful
Ayam (chicken) Makan (eat) The chicken is eating The chicken ate The chicken will eat The chicken is being eaten Where the chicken is eating How the chicken is eating Somebody is eating the chicken The chicken that is eating
PO POS TAGG GGING NG
– Coarse grained: noun, verb, adjective, adverb, … – Fine grained: {proper, common} noun – Even finer-grained: {proper, common} noun animate
– Choice of tags encodes certain distinctions/non-distinctions – Tagsets will differ across languages!
– The/DT grand/JJ jury/NN commmented/VBD on/IN a/DT number/NN of/IN other/JJ topics/NNS ./.
– Prepositions and subordinating conjunctions are tagged “IN” (“Although/IN I/PRP ..”) – Except the preposition/complementizer “to” is tagged “TO”
– Nicely illustrates principles of statistical NLP
– Needed for syntactic analysis – Needed for semantic analysis
– Machine translation – Information extraction – Lots more…
– Ambiguity in English
build a system that can POS tag new text?
word type
– 90% accuracy if train+test sets are drawn from Penn Treebank
HO HOW W TO O SOL OLVE VE PO POS TAGG GGING NG?
– What is x? What is y?
– Models sequences of predictions
transitions
– next state only depends on the current state and independent of previous history
– e.g., word sequences
– underlying set of hidden (unobserved) states in which the model can be (e.g., POS) – probabilistic transitions between states over time (e.g., from POS to POS in order) – probabilistic generation of (observed) tokens from states (e.g., words generate for each POS)
Credit: Jordan Boyd Graber
Credit: Jordan Boyd Graber
– Q = {q0, q1, q2, q3, …}
– aij = P(qj|qi), Σ aij = 1 I
– Each drawn from a given set of symbols (vocabulary V)
– bit = bi(ot) = P(ot|qi), Σ bit = 1 i
– An explicit start state q0 or alternatively, a prior distribution over start states: {π1, π2, π3, …}, Σ πi = 1 – The set of final states: qF
1 2 3 4 5 6 Day: ↑ ↓ ↔ ↑ ↓ ↔
↑: Market is up ↓: Market is down ↔: Market hasn’t changed
BullBearSBear Bull S
Bull: Bull Market Bear: Bear Market S: Static Market Not observable ! Here’s what you actually observe:
Credit: Jimmy Lin
States? ✓ Transitions? Vocabulary? Emissions? Priors?
States? ✓ Transitions? ✓ Vocabulary? Emissions? Priors?
States? ✓ Transitions? ✓ Vocabulary? ✓ Emissions? Priors?
States? ✓ Transitions? ✓ Vocabulary? ✓ Emissions? Priors? ✓
π1=0.5 π2=0.2 π3=0.3
States? ✓ Transitions? ✓ Vocabulary? ✓ Emissions? Priors? ✓ ✓
the number of observations (T)
sequence of observed events O, find P(O|λ)
(hidden) state sequence
and the set of states Q in λ, compute the parameters A and B
HMM Problem #1: Likelihood
1 2 3 4 5 6 t: ↑ ↓ ↔ ↑ ↓ ↔ O: λstock
Assuming λstock models the stock market, how likely are we to observe the sequence of outputs?
π1=0.5 π2=0.2 π3=0.3
– Sum over all possible ways in which we could generate O from λ – What’s the problem?
Takes O(NT) time to compute!
– State sequences may have a lot of overlap… – We’re recomputing the shared subsequences every time – Let’s store intermediate results and reuse them! – Can we do this?
– = P(being in state j after seeing t observations) – = P(o1, o2, ... ot, qt=j)
αt(j) = ∑i αt-1(i) aij bj(ot)
– αt-1(i): forward path probability until (t-1) – aij: transition probability of going from state i to j – bj(ot): probability of emitting symbol ot in state j
↑ ↓ ↑ O = find P(O|λstock)
time
↑ ↓ ↑
t=1 t=2 t=3
Bear Bull Static
states
α1(Bull) α1(Bear) α1(Static)
time
↑ ↓ ↑
t=1 t=2 t=3
0.20.7=0 .14 0.50.1 =0.05 0.30.3 =0.09
Bear Bull Static
states
0.140.60.1=0.0084
∑
α1(Bull)aBullBullbBull(↓)
.... and so on
time
↑ ↓ ↑
t=1 t=2 t=3
0.20.7=0 .14 0.50.1 =0.05 0.30.3 =0.09 0.0145
Bear Bull Static
states
time
↑ ↓ ↑
t=1 t=2 t=3
0.20.7=0 .14 0.50.1 =0.05 0.30.3 =0.09 0.0145 ? ? ? ? ?
Bear Bull Static
states
Work through the rest of these numbers… What’s the asymptotic complexity of this algorithm?
sequence of observed events O, find P(O|λ)
(hidden) state sequence
and the set of states Q in λ, compute the parameters A and B
– Weighted Finite State Automata/Transducers – Hidden Markov Models