Phrase2vec in Practice - Aerin Kim
-
Upload
withthebest -
Category
Technology
-
view
71 -
download
1
Transcript of Phrase2vec in Practice - Aerin Kim
Phrase2vecinPrac-ce
AerinKim
Attheendofthistalk
Download&Install
• h;ps://drive.google.com/file/d/0B7XkCwpI5KDYNlNUTTlSS21pQmM/edit
• easy_install-Ugensim• easy_installnumpy• easy_installscipy• Pipinstallnltk
Frustra-on
• BinaryVector(discreterepresenta-on)
• Apple=[0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]AND• Fruit=[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0]
=0• Dimensionality?–verysparserepresenta-on
Solu-on
• Sta-s-calNLPèCo-occurrencematrix'buildings' 'factories' 'has' 'owns' 'Donald' 'Trump' 'many' 'hands' 'in' 'Mr.' '.' 'China' 'small' 'rela<vely'
'buildings' 0 0 0 0 0 0 1 0 0 0 1 0 0 0
'factories' 0 0 0 0 0 0 1 0 1 0 0 0 0 0
'has' 0 0 0 0 0 2 1 0 0 0 0 0 0 1
'owns' 0 0 0 0 0 1 1 0 0 0 0 0 0 0
'Donald' 0 0 0 0 0 2 0 0 0 0 0 0 0 0
'Trump' 0 0 2 1 2 0 0 0 0 1 0 0 0 0
'many' 1 1 1 1 0 0 0 0 0 0 0 0 0 0
'hands' 0 0 0 0 0 0 0 0 0 0 1 0 1 0
'in' 0 1 0 0 0 0 0 0 0 0 0 1 0 0
'Mr.' 0 0 0 0 0 1 0 0 0 0 0 0 0 0
'.' 1 0 0 0 0 0 0 1 0 0 0 1 0 0
'China' 0 0 0 0 0 0 0 0 1 0 1 0 0 0
'small' 0 0 0 0 0 0 0 1 0 0 0 0 0 1
'rela<vely' 0 0 1 0 0 0 0 0 0 0 0 0 1 0
Be;erSolu-on
• Predictsurroundingwordsofeveryword
• YoushallbejudgedbythecompanyyoukeepSinceheannouncedhiscandidacyforthepresidency,TrumphasfiledanumberoflawsuitsWouldaTrumppresidencyundotheUNclimatechangeagreement?
Thesewordswillrepresent“presidency”
WordEmbedding(Word2Vec)
• Objec-vefunc-on:
MAXIMIZEthelogprobabilityofanycontextword
giventhecurrentcenterword.
One(very)BigVectorΘ
• ΘisthesetofALLparametersinonevector
OBJfunc-onofsinglewindow
• TrumpannouncedhiscandidacyforpresidentasaRepublicanUVU
• Assumingwindowsize=1• Firstelement:Exp(UT(his)⋅V(candidacy))• Secondelement:Exp(UT(for)⋅V(candidacy))
ResultalertheOp-miza-on
• Seman-callyFamousexample:Vec(King)–Vec(man)=Vec(Queen)–Vec(woman)Vec(CSS)–Vec(Front-end)=Vec(Django)–Vec(Beck-end)
• Syntac-callyVector(apple)-vector(apples)=vector(car)-vector(cars)Vec(built)–Vec(build)=Vec(developed)–Vec(develop)
ClassifyingDataScienceKeywords
Moresophis-catedrela-onships
Let’smakethePhraseVectors!
• h;ps://bitbucket.org/yunazzang/aiwiththebest_byor