47
Seq2Seq + A(en*on/Copy Wei Xu (many slides from Greg Durrett)

Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Seq2Seq+A(en*on/Copy

WeiXu(many slides from Greg Durrett)

Page 2: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

ThisWeek

‣ Sequence-to-SequenceModel

‣ A(en*onMechanism

‣ CopyMechanism

‣ TransformerArchitecture

Page 3: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Recall:CNNsvs.LSTMs

‣ BothLSTMsandconvolu*onallayerstransformtheinputusingcontext

themoviewasgood themoviewasgood

nxk

cfilters,mxkeach

O(n)xc

nxk

nx2c

BiLSTMwith hiddensizec

‣ LSTM:“globally”looksattheen*resentence(butlocalformanyproblems)

‣ CNN:localdependingonfilterwidth+numberoflayers

Page 4: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

LSTMs

xj

fg

io

hjhj-1

cj-1 cj

h(p://colah.github.io/posts/2015-08-Understanding-LSTMs/

‣ f,i,oaregatesthatcontrolinforma*onflow

‣ greflectsthemaincomputa*onofthecell

hj

Hochreiter&Schmidhuber(1997)

Page 5: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

LSTMs

‣ Gradients*lldiminishes,butinacontrolledwayandgenerallybyless—usuallyini*alizeforgetgate=1toremembereverythingtostart

<-gradientsimilargradient<-

h(p://colah.github.io/posts/2015-08-Understanding-LSTMs/

Page 6: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Encoder-Decoder‣ Encodeasequenceintoafixed-sizedvector

themoviewasgreat

‣ NowusethatvectortoproduceaseriesoftokensasoutputfromaseparateLSTMdecoder

lefilmétaitbon[STOP]

Sutskeveretal.(2014)

‣Machinetransla*on,NLG,summariza*on,dialog,andmanyothertasks(e.g.,seman*cparsing,syntac*cparsing)canbedoneusingthisframework.

Page 7: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Encoder-Decoder

‣ Isthistrue?Sortof…we’llcomebacktothislater

Page 8: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Model‣ Generatenextwordcondi*onedonpreviouswordaswellashiddenstate

themoviewasgreat <s>

‣Wsizeis|vocab|x|hiddenstate|,sopmaxoveren*revocabulary

Decoderhasseparateparametersfromencoder,sothiscanlearntobealanguagemodel(produceaplausiblenextwordgivencurrentone)

P (y|x) =nY

i=1

P (yi|x, y1, . . . , yi�1)

P (yi|x, y1, . . . , yi�1) = softmax(Wh̄)

Page 9: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Inference‣ Generatenextwordcondi*onedonpreviouswordaswellashiddenstate

themoviewasgreat

‣ Duringinference:needtocomputetheargmaxoverthewordpredic*onsandthenfeedthattothenextRNNstate

le

<s>

‣ Needtoactuallyevaluatecomputa*ongraphuptothispointtoforminputforthenextstate

‣ Decoderisadvancedonestateata*meun*l[STOP]isreached

film était bon [STOP]

Page 10: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Implemen*ngseq2seqModels

themoviewasgreat

‣ Encoder:consumessequenceoftokens,producesavector.Analogoustoencodersforclassifica*on/taggingtasks

le

<s>

‣ Decoder:separatemodule,singlecell.Takestwoinputs:hiddenstate(vectorhortuple(h,c))andprevioustoken.Outputstoken+newstate

Encoder

film

le

Decoder Decoder

Page 11: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Training

‣ Objec*ve:maximize

themoviewasgreat <s> lefilmétaitbon

le

‣ Onelosstermforeachtarget-sentenceword,feedthecorrectwordregardlessofmodel’spredic*on

[STOP]était

X

(x,y)

nX

i=1

logP (y⇤i |x, y⇤1 , . . . , y⇤i�1)

Page 12: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Training:ScheduledSampling

‣ Star*ngwithp=1anddecayingitworksbest

‣ Scheduledsampling:withprobabilityp,takethegoldasinput,elsetakethemodel’spredic*on

themoviewasgreat

lafilmétaisbon[STOP]

le film était

‣Modelneedstodotherightthingevenwithitsownpredic*ons

Bengioetal.(2015)

sample

Page 13: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Implementa*onDetails

‣ Sentencelengthsvaryforbothencoderanddecoder:

‣ Typicallypadeverythingtotherightlength

‣ Encoder:CanbeaCNN/LSTM/…

‣ Decoder:Executeonestepofcomputa*onata*me,socomputa*ongraphisformulatedastakingoneinput+hiddenstate.Un*lreach<STOP>.

‣ Beamsearch:canhelpwithlookahead.Findsthe(approximate)highestscoringsequence:

argmaxy

nY

i=1

P (yi|x, y1, . . . , yi�1)

Page 14: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Implementa*onDetails

‣ Fairseq:

Page 15: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

BeamSearch‣Maintaindecoderstate,tokenhistoryinbeam

la:0.4

<s>

la

le

les

le:0.3les:0.1

log(0.4)log(0.3)

log(0.1)

film:0.4

la

film:0.8

le

… lefilm

lafilm

log(0.3)+log(0.8)

log(0.4)+log(0.4)

‣ Keepbothfilmstates!Hiddenstatevectorsaredifferent

themoviewasgreat

Page 16: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

RegexPredic*on

‣ Canuseforotherseman*cparsing-liketasks

‣ Predictregexfromtext

‣ Problem:requiresalotofdata:10,000examplesneededtoget~60%accuracyonpre(ysimpleregexes

Locascioetal.(2016)

Page 17: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Seman*cParsingasTransla*on

JiaandLiang(2015)

‣Writedownalinearizedformoftheseman*cparse,trainseq2seqmodelstodirectlytranslateintothisrepresenta*on

‣Mightnotproducewell-formedlogicalforms,mightrequirelotsofdata

“whatstatesborderTexas”

‣ Noneedtohaveanexplicitgrammar,simplifiesalgorithms

https://www.youtube.com/watch?v=OocGXG-BY6k&t=200sSeman*cParsing/LambdaCalculus:

Page 18: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

SQLGenera*on

‣ Convertnaturallanguagedescrip*onintoaSQLqueryagainstsomeDB

‣ Howtoensurethatwell-formedSQLisgenerated?

Zhongetal.(2017)

‣ Threecomponents

‣ Howtocapturecolumnnames+constants?

‣ Pointermechanisms

Page 19: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

A(en*on

Page 20: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

ProblemswithSeq2seqModels

‣ Needsomeno*onofinputcoverageorwhatinputwordswe’vetranslated

‣ Encoder-decodermodelsliketorepeatthemselves:

AboyplaysinthesnowboyplaysboyplaysUngarçonjouedanslaneige

‣ Openabyproductoftrainingthesemodelspoorly.Inputisforgo(enbytheLSTMsoitgetsstuckina“loop”ofgenera*onthesameoutputtokensagainandagain.

Page 21: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

ProblemswithSeq2seqModels

‣ Badatlongsentences:1)afixed-sizehiddenrepresenta*ondoesn’tscale;2)LSTMss*llhaveahard*merememberingforreallylongsentences

RNNenc:themodelwe’vediscussedsofar

RNNsearch:usesa(en*on

Bahdanauetal.(2014)

Page 22: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

ProblemswithSeq2seqModels

‣ Unknownwords:

‣ Encodingtheserarewordsintoavectorspaceisreallyhard‣ Infact,wedon’twanttoencodethem,wewantawayofdirectlylookingbackattheinputandcopyingthem(Pont-de-Buis)

Jeanetal.(2015),Luongetal.(2015)

Page 23: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

AlignedInputs

<s>lefilmétaitbon

themoviewasgreat

themoviewasgreat

lefilmétaitbon

‣Muchlessburdenonthehiddenstate

‣ Supposeweknewthesourceandtargetwouldbeword-by-wordtranslated

‣ Canlookatthecorrespondinginputwordwhentransla*ng—thiscouldscale!

lefilmétaitbon[STOP]

‣ Howcanweachievethiswithouthardcodingit?

Page 24: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

A(en*on

‣ Ateachdecoderstate,computeadistribu*onoversourceinputsbasedoncurrentdecoderstatethemoviewasgreat <s> le

themovie wa

sgreatth

emovie wa

sgreat

… …

‣ Usethatinoutputlayer

Page 25: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

A(en*on

themoviewasgreat

h1 h2 h3 h4

<s>

h̄1

‣ Foreachdecoderstate,computeweightedsumofinputstates

eij = f(h̄i, hj)

ci =X

j

↵ijhj

c1

‣ Somefunc*onf(nextslide)

‣Weightedsumofinputhidden states(vector)

le

↵ij =exp(eij)Pj0 exp(eij0)

P (yi|x, y1, . . . , yi�1) = softmax(W [ci; h̄i])

P (yi|x, y1, . . . , yi�1) = softmax(Wh̄i)‣ Noa(n:

the

movie was

great

Page 26: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

A(en*on

<s>

h̄1

eij = f(h̄i, hj)

ci =X

j

↵ijhj

c1

‣ Notethatthisallusesoutputsofhiddenlayers

f(h̄i, hj) = tanh(W [h̄i, hj ])

f(h̄i, hj) = h̄i · hj

f(h̄i, hj) = h̄>i Whj

‣ Bahdanau+(2014):addi*ve

‣ Luong+(2015):dotproduct

‣ Luong+(2015):bilinear

le

↵ij =exp(eij)Pj0 exp(eij0)

Page 27: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Whatcana(en*ondo?‣ Learningtocopy—howmightthiswork?

Luongetal.(2015)

0 3 2 1

0 3 2 1

‣ LSTMcanlearntocountwiththerightweightmatrix

‣ Thisiseffec*velyposi*on-basedaddressing

Page 28: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Whatcana(en*ondo?‣ Learningtosubsampletokens

Luongetal.(2015)

0 3 2 1

3 1

‣ Needtocount(forordering)andalsodeterminewhichtokensarein/out

‣ Content-basedaddressing

Page 29: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

A(en*on

‣ Decoderhiddenstatesarenowmostlyresponsibleforselec*ngwhattoa(endto

‣ Doesn’ttakeacomplexhiddenstatetowalkmonotonicallythroughasentenceandspitoutword-by-wordtransla*ons

‣ Encoderhiddenstatescapturecontextualsourcewordiden*ty

Page 30: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

themoviewasgreat

BatchingA(en*on

Luongetal.(2015)

themoviewasgreat

tokenoutputs:batchsizexsentencelengthxdimension

sentenceoutputs:batchsizexhiddensize

<s>

hiddenstate:batchsizexhiddensize

eij = f(h̄i, hj)

↵ij =exp(eij)Pj0 exp(eij0)

a(en*onscores=batchsizexsentencelength

c=batchsizexhiddensize ci =X

j

↵ijhj

‣Makesuretensorsaretherightsize!

Page 31: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Results‣Machinetransla*on:BLEUscoreof14.0onEnglish-German->16.8witha(en*on,19.0withsmartera(en*on(constrainedtoasmallwindows)

Luongetal.(2015) Chopraetal.(2016) JiaandLiang(2016)

‣ Summariza*on/headlinegenera*on:bigramrecallfrom11%->15%

‣ Seman*cparsing:~30%accuracy->70+%accuracyonGeoquery

Page 32: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

CopyingInput/Pointers

Page 33: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

UnknownWords

Jeanetal.(2015),Luongetal.(2015)

‣Wanttobeabletocopynameden**eslikePont-de-Buis

P (yi|x, y1, . . . , yi�1) = softmax(W [ci; h̄i])

froma(en*onfromRNNhiddenstate

‣ Problem:targetwordhastobeinthevocabulary,a8enPon+RNNneedtogenerategoodembeddingtopickit

Page 34: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

PointerNetwork‣ Standarddecoder(Pvocab):sopmaxovervocabulary

P (yi|x, y1, . . . , yi�1) = softmax(W [ci; h̄i])

Le ama*n… …

‣ Pointernetwork(Ppointer):predictfromsourcewords, insteadoftargetvocabulary

por*coinPont-de-Buis <s>

…in

Pont-de-Buis

por*co

……

… …

Page 35: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

PointerGeneratorMixtureModels‣ DefinethedecodermodelasamixturemodelofPvocabandPpointer

Le ama*n

Pont-de-Buis

por*co in… …

‣ PredictP(copy)basedondecoderstate,input,etc.

v

‣Marginalizeovercopyvariableduringtrainingandinference

‣Modelwillbeabletobothgenerateandcopy,flexiblyadaptbetweenthetwo

P(copy)1-P(copy)

Gulcehreetal.(2016),Guetal.(2016)

v

Page 36: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Copying

{ {Lede

ma*n

Pont-de-Buisecotax

‣ Vocabularycontains“normal”vocabaswellaswordsininput.Normalizesoverbothofthese:

‣ Bilinearfunc*onofinputrepresenta*on+outputhiddenstate

{P (yi = w|x, y1, . . . , yi�1) /expWw[ci; h̄i]

h>j V h̄i

ifwinvocab

ifw=xj

Page 37: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

CopyinginSummariza*on

Seeetal.(2017)

Page 38: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

CopyinginSummariza*on

Seeetal.(2017)

Page 39: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

CopyinginSummariza*on

Seeetal.(2017)

Page 40: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Transformers

Page 41: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

41

SentenceEncoders

themoviewasgreat

‣ LSTMabstracPon:mapseachvectorinasentencetoanew,context-awarevector

‣ CNNsdosomethingsimilarwithfilters

‣ A8enPoncangiveusathirdwaytodothis

Vaswanietal.(2017)

themoviewasgreat

Page 42: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

42

Self-A8enPon

Vaswanietal.(2017)

Theballerinaisveryexcitedthatshewilldanceintheshow.

‣ Pronounsneedtolookatantecedents‣ Ambiguouswordsshouldlookatcontext

‣ Assumewe’reusingGloVe—whatdowewantourneuralnetworktodo?

‣Whatwordsneedtobecontextualizedhere?

‣WordsshouldlookatsyntacPcparents/children

‣ Problem:LSTMsandCNNsdon’tdothis

Page 43: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

43

Self-A8enPon

Vaswanietal.(2017)

Theballerinaisveryexcitedthatshewilldanceintheshow.

‣Want:

‣ LSTMs/CNNs:tendtolookatlocalcontext

Theballerinaisveryexcitedthatshewilldanceintheshow.

‣ Toappropriatelycontextualizeembeddings,weneedtopassinformaPonoverlongdistancesdynamicallyforeachword

Page 44: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Self-A(en*on

Vaswanietal.(2017)

themoviewasgreat

‣ Eachwordformsa“query”whichthencomputesa(en*onovereachword

‣Mul*ple“heads”analogoustodifferentconvolu*onalfilters.UseparametersWkandVktogetdifferenta(en*onvalues+transformvectors

x4

x04

scalar

vector=sumofscalar*vector

↵i,j = softmax(x>i xj)

x0i =

nX

j=1

↵i,jxj

↵k,i,j = softmax(x>i Wkxj) x0

k,i =nX

j=1

↵k,i,jVkxj

Page 45: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

�45

Whatcanself-a8enPondo?

Vaswanietal.(2017)

Theballerinaisveryexcitedthatshewilldanceintheshow.

‣WhymulPpleheads?Socmaxesendupbeingpeaked,singledistribuPoncannoteasilyputweightonmulPplethings

0.5 0.20.10.10.10 0 0 0 0 0 0

‣ ThisisademonstraPon,wewillrevisitwhatthesemodelsactuallylearnwhenwediscussBERT

‣ A8endnearby+tosemanPcallyrelatedterms

0.5 0 0.40 0.1 0 0 0 0 0 0 0

Page 46: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

�46

TransformerUses

‣ Supervised:transformercanreplaceLSTMasencoder,decoder,orboth;willrevisitthiswhenwediscussMT

‣ Unsupervised:transformersworkbe8erthanLSTMforunsupervisedpre-trainingofembeddings:predictwordgivencontextwords

‣ BERT(BidirecPonalEncoderRepresentaPonsfromTransformers):pretrainingtransformerlanguagemodelssimilartoELMo

‣ Strongerthansimilarmethods,SOTAon~11tasks(includingNER—92.8F1)

Page 47: Seq2Seq + A(en*on/Copy · 2020-04-12 · ‣ Encoder-decoder models like to repeat themselves: Un garçon joue dans la neige A boy plays in the snow boy plays boy plays ‣ Open a

Takeaways

‣ A(en*onisveryhelpfulforseq2seqmodels

‣ Usedfortasksincludingdata-to-textgenera*onandsummariza*on

‣ Explicitlycopyinginputcanbebeneficialaswell

‣ Transformersarestrongmodelswe’llcomebacktolater,if*me