lecture 3: structures and decodingnasmith/psnlp/lecture3.pdf · • general algorithm for exact map...
TRANSCRIPT
![Page 1: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/1.jpg)
Lecture3:StructuresandDecoding
![Page 2: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/2.jpg)
Outline
1. StructuresinNLP2. HMMsasBNs– ViterbialgorithmasvariableeliminaBon
3. Linearmodels
4. Fiveviewsofdecoding
![Page 3: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/3.jpg)
TwoMeaningsof“Structure”
• Yesterday:structureofagraphformodelingacollecBonofrandomvariablestogether.
• Today:linguisBcstructure.– Sequencelabelings(POS,IOBchunkings,…)– Parsetrees(phrase‐structure,dependency,…)– Alignments(word,phrase,tree,…)– Predicate‐argumentstructures– Text‐to‐text(translaBon,paraphrase,answers,…)
![Page 4: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/4.jpg)
AUsefulAbstracBon?
• Wethinkso.• BringsoutcommonaliBes:– Modelingformalisms(e.g.,linearmodelswithfeatures)
– Learningalgorithms(lectures4‐6)– Genericinferencealgorithms
• Permitssharingacrossawiderspaceofproblems.
• Disadvantage:hidesengineeringdetails.
![Page 5: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/5.jpg)
FamiliarExample:HiddenMarkovModels
![Page 6: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/6.jpg)
HiddenMarkovModel
• XandYarebothsequencesofsymbols– XisasequencefromthevocabularyΣ– YisasequencefromthestatespaceΛ
• Parameters:– TransiBonsp(y’|y)• includingp(stop |y),p(y|start)
– Emissionsp(x|y)
![Page 7: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/7.jpg)
HiddenMarkovModel
• Thejointmodel’sindependenceassumpBonsareeasytocapturewithaBayesiannetwork.
Y1
X1
Y0 Y2
X2
Y3
X3
Yn
Xn
stop …
![Page 8: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/8.jpg)
HiddenMarkovModel
• ThejointmodelinstanBatesdynamicBayesiannetworks.
Yi
Xi
Yi‐1Y0 templatethatgetscopiedasmanyBmesasneeded
![Page 9: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/9.jpg)
HiddenMarkovModel
• GivenX’svalueasevidence,thedynamicpartbecomesunnecessary,sinceweknown.
Y1
X1=x1
Y0 Y2
X2=x2
Y3
X3=x3
Yn
Xn=xn
stop …
![Page 10: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/10.jpg)
HiddenMarkovModel
• TheusualinferenceproblemistofindthemostprobablevalueofYgivenX=x.
Y1
X1=x1
Y0 Y2
X2=x2
Y3
X3=x3
Yn
Xn=xn
stop …
![Page 11: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/11.jpg)
HiddenMarkovModel
• TheusualinferenceproblemistofindthemostprobablevalueofYgivenX=x.
• Factorgraph:
Y1
X1=x1
Y0 Y2
X2=x2
Y3
X3=x3
Yn
Xn=xn
stop …
![Page 12: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/12.jpg)
HiddenMarkovModel
• TheusualinferenceproblemistofindthemostprobablevalueofYgivenX=x.
• Factorgraphaferreducingfactorstorespectevidence:
Y1 Y2 Y3 Yn…
![Page 13: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/13.jpg)
HiddenMarkovModel
• TheusualinferenceproblemistofindthemostprobablevalueofYgivenX=x.
• Cleverorderingshouldbeapparent!
Y1 Y2 Y3 Yn…
![Page 14: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/14.jpg)
HiddenMarkovModel
• WhenweeliminateY1,wetakeaproductofthreerelevantfactors.• p(Y1|start)• η(Y1)=reducedp(x1|Y1)• p(Y2|Y1)
Y1 Y2 Y3 Yn…
![Page 15: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/15.jpg)
HiddenMarkovModel
• WhenweeliminateY1,wefirsttakeaproductoftwofactorsthatonlyinvolveY1.
Y1 Y2 Y3 Yn…
y1y2…
y|Λ|y1y2…
y|Λ|η(Y1)=reducedp(x1|Y1)
p(Y1|start)
![Page 16: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/16.jpg)
HiddenMarkovModel
• WhenweeliminateY1,wefirsttakeaproductoftwofactorsthatonlyinvolveY1.
• ThisistheViterbiprobabilityvectorforY1.
Y1 Y2 Y3 Yn…y1y2…
y|Λ|φ1(Y1)
![Page 17: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/17.jpg)
HiddenMarkovModel
• WhenweeliminateY1,wefirsttakeaproductoftwofactorsthatonlyinvolveY1.
• ThisistheViterbiprobabilityvectorforY1.• EliminaBngY1equatestosolvingtheViterbiprobabiliBesforY2.
Y1 Y2 Y3 Yn…y1y2…
y|Λ|φ1(Y1)
y1
y2
…
y|Λ|p(Y2|Y1)
![Page 18: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/18.jpg)
HiddenMarkovModel
• ProductofallfactorsinvolvingY1,thenreduce.• φ2(Y2)=maxy∈Val(Y1)(φ1(y)⨉p(Y2|y))
• ThisfactorholdsViterbiprobabiliiesyforY2.
Y2 Y3 Yn…
![Page 19: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/19.jpg)
Y2
HiddenMarkovModel
• WhenweeliminateY2,wetakeaproductoftheanalogoustworelevantfactors.
• Thenreduce.• φ3(Y3)=maxy∈Val(Y2)(φ2(y)⨉p(Y3|y))
Y3 Yn…
![Page 20: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/20.jpg)
Yn
HiddenMarkovModel
• Attheend,wehaveonefinalfactorwithonerow,φn+1.
• Thisisthescoreofthebestsequence.• Usebacktracetorecovervalues.
![Page 21: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/21.jpg)
WhyThinkThisWay?
• EasytoseehowtogeneralizeHMMs.– Moreevidence– Morefactors– Morehiddenstructure– Moredependencies
• ProbabilisBcinterpretaBonoffactorsisnot centraltofindingthe“best”Y…– ManyfactorsarenotcondiBonalprobabilitytables.
![Page 22: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/22.jpg)
GeneralizaBonExample1
• Eachwordalsodependsonpreviousstate.
Y1
X1 X2 X3 X4 X5
Y2 Y3 Y4 Y5
![Page 23: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/23.jpg)
GeneralizaBonExample2
• “Trigram”HMM
Y1
X1 X2 X3 X4 X5
Y2 Y3 Y4 Y5
![Page 24: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/24.jpg)
GeneralizaBonExample3
• Aggregatebigrammodel(SaulandPereira,1997)
Y1
X1 X2 X3 X4 X5
Y2 Y3 Y4 Y5
![Page 25: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/25.jpg)
GeneralDecodingProblem
• Twostructuredrandomvariables,XandY.– SomeBmesdescribedascollec,onsofrandomvariables.
• “Decode”observedvalueX=xintosomevalueofY.
• Usually,weseektomaximizesomescore.– E.g.,MAPinferencefromyesterday.
![Page 26: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/26.jpg)
LinearModels
• DefineafeaturevectorfuncBongthatmaps(x,y)pairsintod‐dimensionalrealspace.
• Scoreislinearing(x,y).
• Results:– decodingseeksytomaximizethescore.– learningseekswto…dosomethingwe’lltalkaboutlater.
• Extremelygeneral!
![Page 27: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/27.jpg)
GenericNoisyChannelasLinearModel
• Ofcourse,thetwoprobabilitytermsaretypicallycomposedof“smaller”factors;eachcanbeunderstoodasanexponenBatedweight.
![Page 28: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/28.jpg)
MaxEntModelsasLinearModels
![Page 29: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/29.jpg)
HMMsasLinearModels
![Page 30: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/30.jpg)
RunningExample
• IOBsequencelabeling,hereappliedtoNER• OfensolvedwithHMMs,CRFs,M3Ns…
![Page 31: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/31.jpg)
![Page 32: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/32.jpg)
(WhatisNotALinearModel?)
• Modelswithhiddenvariables
• Modelsbasedonnon‐linearkernels
![Page 33: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/33.jpg)
Decoding
• ForHMMs,thedecodingalgorithmweusuallythinkoffirstistheViterbialgorithm.– Thisisjustoneexample.
• Wewillviewdecodinginfivedifferentways.– Sequencemodelsasarunningexample.– TheseviewsarenotjustforHMMs.– SomeBmestheywillleadusbacktoViterbi!
![Page 34: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/34.jpg)
FiveViewsofDecoding
![Page 35: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/35.jpg)
1.ProbabilisBcGraphicalModels
• ViewthelinguisBcstructureasacollecBonofrandomvariablesthatareinterdependent.
• Representinterdependenciesasadirectedorundirectedgraphicalmodel.
• CondiBonalprobabilitytables(BNs)orfactors(MNs)encodetheprobabilitydistribuBon.
![Page 36: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/36.jpg)
InferenceinGraphicalModels
• GeneralalgorithmforexactMAPinference:variableeliminaBon.– IteraBvelysolveforthebestvaluesofeachvariablecondiBonedonvaluesof“preceding”neighbors.
– Thentraceback.
TheViterbialgorithmisaninstanceofmax‐productvariableeliminaBon!
![Page 37: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/37.jpg)
MAPisLinearDecoding
• Bayesiannetwork:
• Markovnetwork:
• ThisonlyworksifeveryvariableisinXorY.
![Page 38: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/38.jpg)
InferenceinGraphicalModels
• Remember:moreedgesmakeinferencemoreexpensive.– Feweredgesmeansstrongerindependence.
• Reallypleasant:
![Page 39: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/39.jpg)
InferenceinGraphicalModels
• Remember:moreedgesmakeinferencemoreexpensive.– Feweredgesmeansstrongerindependence.
• Reallyunpleasant:
![Page 40: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/40.jpg)
2.Polytopes
![Page 41: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/41.jpg)
“Parts”
• AssumethatfeaturefuncBongbreaksdownintolocalparts.
• Eachparthasanalphabetofpossiblevalues.– Decodingischoosingvaluesforallparts,withconsistencyconstraints.
– (Inthegraphicalmodelsview,apartisaclique.)
![Page 42: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/42.jpg)
Example
• Onepartperword,eachisin{B,I,O}• NofeatureslookatmulBpleparts– Fastinference– Notveryexpressive
![Page 43: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/43.jpg)
Example
• Onepartperbigram,eachisin{BB,BI,BO,IB,II,IO,OB,OO}
• Featuresandconstraintscanlookatpairs– Slowerinference– Abitmoreexpressive
![Page 44: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/44.jpg)
GeometricView
• Letzi,πbe1ifpartitakesvalueπand0otherwise.
• zisavectorin{0,1}N– N =totalnumberoflocalizedpartvalues– Eachzisavertexoftheunitcube
![Page 45: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/45.jpg)
ScoreisLinearinz
notreallyequal;needtotransformbacktogety
![Page 46: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/46.jpg)
Polyhedra
• NotallverBcesoftheN‐dimensionalunitcubesaBsfytheconstraints.– E.g.,can’thavez1,BI=1 andz2,BI=1
• SomeBmeswecanwritedownasmall(polynomialnumber)oflinearconstraintsonz.
• Result:linearobjecBve,linearconstraints,integerconstraints…
![Page 47: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/47.jpg)
![Page 48: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/48.jpg)
IntegerLinearProgramming
• Veryeasytoaddnewconstraintsandnon‐localfeatures.
• ManydecodingproblemshavebeenmappedtoILP(sequencelabeling,parsing,…),butit’snot alwaystrivial.
• NP‐hardingeneral.– ButtherearepackagesthatofenworkwellinpracBce(e.g.,CPLEX)
– Specializedalgorithmsinsomecases– LPrelaxaBonforapproximatesoluBons
![Page 49: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/49.jpg)
![Page 50: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/50.jpg)
Remark
• GraphicalmodelsassumedaprobabilisBcinterpretaBon– ThoughtheyarenotalwayslearnedusingaprobabilisBcinterpretaBon!
• ThepolytopeviewisagnosBcabouthowyouinterprettheweights.– ItonlysaysthatthedecodingproblemisanILP.
![Page 51: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/51.jpg)
3.WeightedParsing
![Page 52: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/52.jpg)
Grammars
• Grammarsareofenassociatedwithnaturallanguageparsing,buttheyareextremelypowerfulforimposingconstraints.
• Wecanaddweightstothem.– HMMsareakindofweightedregulargrammar(closelyconnectedtoWFSAs)
– PCFGsareakindofweightedCFG– Many,manymore.
• Weightedparsing:findthemaximum‐weightedderivaBonforastringx.
![Page 53: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/53.jpg)
DecodingasWeightedParsing
• EveryvalidyisagrammaBcalderivaBon(parse)forx.– HMM:sequenceof“grammaBcal”statesisoneallowedbythetransiBontable.
• Augmentparsingalgorithmswithweightsandfindthebestparse.
TheViterbialgorithmisaninstanceofrecogniBonbyaweightedgrammar!
![Page 54: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/54.jpg)
BIOTaggingasaCFG
• Weighted(orprobabilisBc)CKYisadynamicprogrammingalgorithmverysimilarinstructuretoclassicalCKY.
![Page 55: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/55.jpg)
4.PathsandHyperpaths
![Page 56: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/56.jpg)
BestPath
• Generalidea:takexandbuildagraph.• Scoreofapathfactorsintotheedges.
• Decodingisfindingthebest path.
TheViterbialgorithmisaninstanceoffindingabestpath!
![Page 57: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/57.jpg)
“Lavce”ViewofViterbi
![Page 58: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/58.jpg)
MinimumCostHyperpath
• Generalidea:takexandbuildahypergraph.• Scoreofahyperpathfactorsintothehyperedges.
• Decodingisfindingthebesthyperpath.
• ThisconnecBonwaselucidatedbyKleinandManning(2002).
![Page 59: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/59.jpg)
ParsingasaHypergraph
![Page 60: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/60.jpg)
ParsingasaHypergraph
cf. “Dean for democracy”
![Page 61: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/61.jpg)
ParsingasaHypergraph
Forced to work on his thesis, sunshine streaming in the window, Mike experienced a …
![Page 62: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/62.jpg)
ParsingasaHypergraph
Forced to work on his thesis, sunshine streaming in the window, Mike began to …
![Page 63: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/63.jpg)
WhyHypergraphs?
• Useful,compactencodingofthehypothesisspace.– Buildhypothesisspaceusinglocalfeatures,maybedosomefiltering.
– Passitofftoanothermoduleformorefine‐grainedscoringwithricherormoreexpensivefeatures.
![Page 64: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/64.jpg)
5.WeightedLogicProgramming
![Page 65: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/65.jpg)
LogicProgramming
• Startwithasetofaxiomsandasetofinferencerules.
• Thegoalistoproveaspecifictheorem,goal.• Manyapproaches,butweassumeadeduc,veapproach.– Startwithaxioms,iteraBvelyproducemoretheorems.
![Page 66: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/66.jpg)
![Page 67: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/67.jpg)
WeightedLogicProgramming
• Twist:axiomshaveweights.• Wanttheproofofgoal withthebestscore:
• Notethataxiomscanbeusedmorethanonceinaproof(y).
![Page 68: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/68.jpg)
WhenceWLP?
• Shieber,Schabes,andPereira(1995):manyparsingalgorithmscanbeunderstoodinthesamededucBvelogicframework.
• Goodman(1999):addweights,getmanyusefulNLPalgorithms.
• Eisner,Goldlust,andSmith(2004,2005):semiring‐genericalgorithms,Dyna.
![Page 69: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/69.jpg)
DynamicProgramming
• Mostviews(excepBonispolytopes)canbeunderstoodasDPalgorithms.– Thelow‐levelprocedures weuseareofenDP.– EvenDPistoohigh‐leveltoknowthebestwaytoimplement.
• DPdoesnot implypolynomialBmeandspace!– MostcommonapproximaBonswhenthedesiredstatespaceistoobig:beamsearch,cubepruning,agendaswithearlystopping,...
– Otherviewssuggestothers.
![Page 70: Lecture 3: Structures and Decodingnasmith/psnlp/lecture3.pdf · • General algorithm for exact MAP inference: variable eliminaon . – Iteravely solve for the best values of each](https://reader033.vdocuments.mx/reader033/viewer/2022041923/5e6cca562153037f05685550/html5/thumbnails/70.jpg)
Summary
• Decodingisthegeneralproblemofchoosingacomplexstructure.– LinguisBcanalysis,machinetranslaBon,speechrecogniBon,…
– StaBsBcalmodelsareusuallyinvolved(notnecessarilyprobabilisBc).
• Noperfectgeneralview,butmuchcanbegainedthroughacombinaBonofviews.