Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep...

68
deep architectures for natural language processing Sergey I. Nikolenko 1,2 DataFest 4 Moscow, February 11, 2017 1 Laboratory for Internet Studies, NRU Higher School of Economics, St. Petersburg 2 Steklov Institute of Mathematics at St. Petersburg 4 Not really a footnote mark, just the way DataFests prefer to be numbered Random facts: February 11, the birthday of Thomas Alva Edison, was proclaimed in 1983 by Ronald Reagan to be the National Inventors' Day Ten years later, in 1993, Pope John Paul II proclaimed February 11 to be the World Day of the Sick, ''a special time of... offering one's suffering''

Transcript of Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep...

Page 1: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

deep architecturesfor natural language processing

Sergey I. Nikolenko1,2

DataFest4Moscow, February 11, 2017

1Laboratory for Internet Studies, NRU Higher School of Economics, St. Petersburg2Steklov Institute of Mathematics at St. Petersburg4Not really a footnote mark, just the way DataFests prefer to be numbered

Random facts:• February 11, the birthday of Thomas Alva Edison, was proclaimed in 1983 by Ronald Reaganto be the National Inventors' Day

• Ten years later, in 1993, Pope John Paul II proclaimed February 11 to be theWorld Day of the Sick, ''a special time of... offering one's suffering''

Page 2: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

plan

• The deep learning revolution has not left natural languageprocessing alone.

• DL in NLP has started with standard architectures (RNN, CNN)but then has branched out into new directions.

• You have already heard about distributed word representations;now let us see a ((very-)very) brief overview of the mostpromising directions in modern NLP based on deep learning.

• We will concentrate on NLP problems that have given rise tonew models and architectures.

2

Page 3: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

nlp problems

• NLP is a very diverse field. Types of NLP problems:• well-defined syntactic problems with semantic complications:

• part-of-speech tagging;• morphological segmentation;• stemming and lemmatization;• sentence boundary disambiguation and word segmentation;• named entity recognition;• word sense disambiguation;• syntactic parsing;• coreference resolution;

• well-defined semantic problems:• language modeling;• sentiment analysis;• relationship/fact extraction;• question answering;

• text generation problems, usually not so very well defined:• text generation per se;• automatic summarization;• machine translation;• dialog and conversational models...

3

Page 4: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

basic nn architectures

• Basic neural network architectures that have been adapted fordeep learning over the last decade:

• feedforward NNs are the basic building block;• autoencoders map a (possibly distorted) input to itself, usually forfeature engineering;

• convolutional NNs apply NNs with shared weights to certainwindows in the previous layer (or input), collecting first local andthen more and more global features;

• recurrent NNs have a hidden state and propagate it further, usedfor sequence learning;

• in particular, LSTM (long short-term memory) and GRU (gatedrecurrent unit) units fight vanishing gradients and are often usedfor NLP since they are good for longer dependencies.

4

Page 5: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

word embeddings

• Distributional hypothesis in linguistics: words with similarmeaning will occur in similar contexts.

• Distributed word representations (word2vec, Glove andvariations) map words to a Euclidean space (usually ofdimension several hundred).

• Some sample nearest neighbors:любовь синонимжизнь 0.5978 антоним 0.5459

нелюбовь 0.5957 эвфемизм 0.4642приязнь 0.5735 анаграмма 0.4145

боль 0.5547 омоним 0.4048страсть 0.5520 оксюморон 0.3930

программист программисткакомпьютерщик 0.5618 стажерка 0.4755

программер 0.4682 инопланетянка 0.4500электронщик 0.4613 американочка 0.4481автомеханик 0.4441 предпринимательница 0.4442криптограф 0.4316 студенточка 0.4368

• How do we use them? 5

Page 6: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

how to use word vectors: recurrent architectures

• Recurrent architectures on top of word vectors; this is straightfrom basic Keras tutorials:

6

Page 7: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

how to use word vectors: recurrent architectures

• Often bidirectional, providing both left and right context foreach word:

6

Page 8: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

how to use word vectors: recurrent architectures

• And you can make them deep (but not too deep):

6

Page 9: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

attention in recurrent networks

• Recent important development: attention. A small (sub)networkthat learns which parts to focus on.

• (Yang et al., 2016): Hierarchical Attention Networks; word level,then sentence level attention for classification (e.g., sentiment).

7

Page 10: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

up and down from word embeddings

• Word embeddings are the first step of most DL models in NLP.• But we can go both up and down from word embeddings.• First, a sentence is not necessarily the sum of its words.• How do we combine word vectors into “text chunk” vectors?

8

Page 11: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

up and down from word embeddings

• Word embeddings are the first step of most DL models in NLP.• But we can go both up and down from word embeddings.• First, a sentence is not necessarily the sum of its words.• How do we combine word vectors into “text chunk” vectors?• The simplest idea is to use the sum and/or mean of wordembeddings to represent a sentence/paragraph:

• a baseline in (Le and Mikolov 2014);• a reasonable method for short phrases in (Mikolov et al. 2013)• shown to be effective for document summarization in (Kagebacket al. 2014).

8

Page 12: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

sentence embeddings

• Distributed Memory Model of Paragraph Vectors (PV-DM) (Le andMikolov 2014):

• a sentence/paragraph vector is an additional vector for eachparagraph;

• acts as a “memory” to provide longer context;• also a dual version, PV-DBOW.

• A number of convolutional architectures (Ma et al., 2015;Kalchbrenner et al., 2014).

9

Page 13: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

sentence embeddings

• Recursive neural networks (Socher et al., 2012):• a neural network composes a chunk of text with another part in atree;

• works its way up from word vectors to the root of a parse tree.

9

Page 14: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

sentence embeddings

• Recursive neural networks (Socher et al., 2012):• by training this in a supervised way, one can get a very effectiveapproach to sentiment analysis (Socher et al. 2013).

9

Page 15: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

sentence embeddings

• Recursive neural networks (Socher et al., 2012):• further improvements (Irsoy, Cardie, 2014): decouple leaves andinternal nodes and make the networks deep to get hierarchicalrepresentations;

• but all this is dependent on getting parse trees (later).

9

Page 16: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

word vector extensions

• Other modifications of word embeddings add externalinformation.

• E.g., the RC-NET model (Xu et al. 2014) extends skip-grams withrelations (semantic and syntactic) and categorical knowledge(sets of synonyms, domain knowledge etc.):

𝑤Hinton − 𝑤Wimbledon ≈ 𝑟born at ≈ 𝑤Euler − 𝑤Basel

• Another important problem with both word vectors andchar-level models: homonyms. The model usually just choosesone meaning.

• We have to add latent variables for different meaning and inferthem from context: Bayesian inference with stochasticvariational inference (Bartunov et al., 2015).

10

Page 17: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

character-level models

• Word embeddings have important shortcomings:• vectors are independent but words are not; consider, in particular,morphology-rich languages like Russian;

• the same applies to out-of-vocabulary words: a word embeddingcannot be extended to new words;

• word embedding models may grow large; it’s just lookup, but thewhole vocabulary has to be stored in memory with fast access.

• E.g., “polydistributional” gets 48 results on Google, so youprobably have never seen it, and there’s very little training data:

• Do you have an idea what it means? Me too.11

Page 18: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

character-level models

• Hence, character-level representations:• began by decomposing a word into morphemes (Luong et al. 2013;Botha and Blunsom 2014; Soricut and Och 2015);

• C2W (Ling et al. 2015) is based on bidirectional LSTMs:

11

Page 19: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

character-level models

• The approach of Deep Structured Semantic Model (DSSM)(Huang et al., 2013; Gao et al., 2014a; 2014b):

• sub-word embeddings: represent a word as a bag of trigrams;• vocabulary shrinks to |𝑉 |3 (tens of thousands instead of millions),but collisions are very rare;

• the representation is robust to misspellings (very important foruser-generated texts).

11

Page 20: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

character-level models

• ConvNet (Zhang et al. 2015): text understanding from scratch,from the level of symbols, based on CNNs.

• Character-level models and extensions to appear to be veryimportant, especially for morphology-rich languages likeRussian.

11

Page 21: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

modern char-based language model: kim et al., 2015

12

Page 22: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

poroshki

• Of course, we could just learn the short-term dependencies bydirect language modeling, symbol by symbol. Not really a stepto understanding, but good fun.

• Here are some poroshki generated with LSTMs from a relativelysmall dataset (thanks to Artur Kadurin):

заходит к солнцу отдаётесьчто он летел а может бытьи вовсе не веду на стенкена поле пять и новый годи почему то по башкев квартире голуби и болии повзрослел и умирать

страшней всего когда ты выпилбез показания зонта

однажды я тебя не вышлои ты

я захожу в макдоналистунадену отраженный дождьпод ужин почему местамии вдруг подставил человек

ты мне привычно верил крышудо дна

я подползает под кроватьючтоб он исписанный пингвини ты мне больше никогдано мы же после русских классикбарто солдаты для любви

13

Page 23: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

text understandingwith convolutional networks

Page 24: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dssm

• A general approach to NLP based on CNNs has been extendedinto Deep Structured Semantic Model (DSSM) (Huang et al., 2013;Gao et al., 2014a; 2014b):

• one-hot target vectors for classification (speech recognition,image recognition, language modeling).

15

Page 25: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dssm

• A general approach to NLP based on CNNs has been extendedinto Deep Structured Semantic Model (DSSM) (Huang et al., 2013;Gao et al., 2014a; 2014b):

• vector-valued targets for semantic matching.

15

Page 26: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dssm

• A general approach to NLP based on CNNs has been extendedinto Deep Structured Semantic Model (DSSM) (Huang et al., 2013;Gao et al., 2014a; 2014b):

• can capture different targets (one-hot, vector);• to train with vector targets – reflection: bring source and targetvectors closer (this is DSSM).

15

Page 27: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dssm

• A general approach to NLP based on CNNs has been extendedinto Deep Structured Semantic Model (DSSM) (Huang et al., 2013;Gao et al., 2014a; 2014b):

• This approach can be applied in a number of different contextswhen we can specify a supervised dataset:

• semantic word embeddings: word by context;• web search: web documents by query;• question answering: knowledge base relation/entity by pattern;• recommendations: interesting documents by read/likeddocuments;

• translation: target sentence by source sentence;• text/image: labels by images or vice versa.

• Basically, this is an example of a general architecture that canbe trained to do almost anything.

15

Page 28: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dssm

• A general approach to NLP based on CNNs has been extendedinto Deep Structured Semantic Model (DSSM) (Huang et al., 2013;Gao et al., 2014a; 2014b):

• Deep Structured Semantic Models (DSSM) (Huang et al., 2013;Gao et al., 2014a; 2014b): a deep convolutional architecturetrained on similar text pairs.

• Can be used for information retrieval: model relevance bybringing relevant documents closer to their queries (bothdocument and query go through the same convolutionalarchitecture).

• November 2, 2016: a post by Yandex saying that they use(modified) DSSM in their new Palekh search algorithm (probablythe audience can clarify this better than myself).

15

Page 29: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

attention for text similarity

• (Parikh et al., 2016): Attend-Compare-Aggregate withparallelizable attention for natural language inference.

• Very lightweight approach: attention network aligns text withquery, then we compare embeddings of aligned subphrases andaggregate comparisons into the response.

16

Page 30: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dependency parsing

Page 31: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dependency parsing

• We mentioned parse trees; but how do we construct them?• Current state of the art – continuous-state parsing: current stateis encoded in ℝ𝑑.

• Stack LSTMs (Dyer et al., 2015) – the parser manipulates threebasic data structures:(1) a buffer 𝐵 that contains the sequence of words, with state 𝑏𝑡;(2) a stack 𝑆 that stores partially constructed parses, with state 𝑠𝑡;(3) a list 𝐴 of actions already taken by the parser, with state 𝑎𝑡.

• 𝑏𝑡, 𝑠𝑡, and 𝑎𝑡 are hidden states of stack LSTMs, LSTMs that have astack pointer: new inputs are added from the right, but thecurrent location of the stack pointer shows which cell’s state isused to compute new memory cell contents.

18

Page 32: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dependency parsing with morphology

• Important extension – (Ballesteros et al., 2015):• in morphologically rich natural languages, we have to take intoaccount morphology;

• so they represent the words by bidirectional character-level LSTMs;• report improved results in Arabic, Basque, French, German,Hebrew, Hungarian, Korean, Polish, Swedish, and Turkish;

• this direction probably can be further improved (and where’sRussian in the list above?..).

19

Page 33: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

still hard

• Syntactic parsing is still not easy because it relies on semanticsand common sense.

20

Page 34: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dialog and conversation

Page 35: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dialog and conversational models

• Dialog models attempt to model and predict dialogue;conversational models actively talk to a human.

• First interesting problem: how to evaluate?• (Liu et al., 2017) — a survey of unsupervised evaluation metrics:

• based on word overlap: BLEU, METEOR, ROUGE;• based on word embeddings (word2vec matching/averaging);• they compare these metrics against human judgement...

• ...aaaaaand they all don’t work at all. We need something new.22

Page 36: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dialog and conversational models

• As for the models themselves, Vinyals and Le (2015) use seq2seq(Sutskever et al. 2014):

• feed previous sentences ABC as context to the RNN;• predict the next word of reply WXYZ based on the previous wordand hidden state.

• They get a reasonable conversational model, both general(MovieSubtitles) and in a specific domain (IT helpdesk).

22

Page 37: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dialog and conversational models

• Hierarchical recurrent encoder decoder architecture (HRED); firstproposed for query suggestion in IR (Sordoni et al. 2015), usedfor dialog systems in (Serban et al. 2015).

• The dialogue as a two-level system: a sequence of utterances,each of which is in turn a sequence of words. To model thistwo-level system, HRED trains:(1) encoder RNN that maps each utterance in a dialogue into a single

utterance vector;(2) context RNN that processes all previous utterance vectors and

combines them into the current context vector;(3) decoder RNN that predicts the tokens in the next utterance, one at

a time, conditional on the context RNN.

22

Page 38: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dialog and conversational models

• HRED architecture:

• (Serban et al. 2015) report promising results in terms of bothlanguage models (perplexity) and expert evaluation.

22

Page 39: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dialog and conversational models

• This line of work continued in (Serban et al., 2016), whichdevelops a variational lower bound for the hierarchical modeland optimizes it: Variational Hierarchical RecurrentEncoder-Decoder (VHRED).

• A very recent work (Serban et al., Dec. 2016) extends this todifferent forms of priors (piecewise constant), which leads tomultimodal document modeling, generating responses to thetimes and events specified in the original query.

22

Page 40: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dialog and conversational models

• Some recent developments:• (Yao et al., 2015): “attention with intention”, a separate network tomodel the intention process;

• (Wen et al., 2016) use snapshot learning, adding some weaksupervision in the form of particular events occurring in theoutput sequence (whether we still want to say something or havealready said it);

• (Su et al., 2016) improve dialogue systems with online activereward learning, a tool from reinforcement learning;

• (Xie et al., 2016) recommend emojis to add to (existing) dialogueentries, with a HRED-like architecture;

• (Gu et al., 2016) add an explicit copying mechanism to seq2seq: weoften need to copy some part of the query in the response;implemented with state changes and attention.

22

Page 41: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dialog and conversational models

• Some recent developments:• (Li et al., 2016a) apply reinforcement learning (DQN) to improvedialogue generation;

• (Li et al., 2016b) add personas with latent variables, so dialoguecan be more consistent;

• in a similar vein, (Zhang et al., 2017) learn the conversational styleof humans and model it: neural personalized response generation;

• (Li et al., 2016c) argue that the objective function should be MMIrather than likelihood of output, showing it promotes diversity andinteresting responses (yes, it’s all the same Li);

• (Song et al., 2016) add a second network (reranker) to filter and/orimprove replies generated by seq2seq, report much better results.

22

Page 42: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

dialog and conversational models

• A closely related problem: natural language understanding(NLU) to predict intent from user request and then systemaction prediction (SAP) to take action (e.g. for virtual assistantsystems like Siri/Cortana/Echo).

• (Yang et al., 2017): end-to-end joint learning of NLU and SAP:

• Resume: chatbots and virtual assistants are becomingcommonplace but it is still a long way to go before actualgeneral-purpose dialogue. 22

Page 43: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

question answering

Page 44: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

question answering

• Question answering (QA) is one of the hardest NLP challenges,close to true language understanding.

• Let us begin with evaluation:• it’s easy to find datasets for information retrieval;• these questions can be answered knowledge base approaches:map questions to logical queries over a graph of facts;

• in a multiple choice setting (Quiz Bowl), map the question andpossible answers to a semantic space and find nearest neighbors(Socher et al. 2014);

• but this is not exactly general question answering.

• (Weston et al. 2015): a dataset of simple (for humans) questionsthat do not require any special knowledge.

• But require reasoning and understanding of semanticstructure...

24

Page 45: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

question answering

• Sample questions:Task 1: Single Supporting Fact

Mary went to the bathroom.John moved to the hallway.Mary travelled to the office.Where is Mary?A: office

Task 4: Two Argument RelationsThe office is north of the bedroom.The bedroom is north of the bathroom.The kitchen is west of the garden.What is north of the bedroom? A: officeWhat is the bedroom north of? A: bathroom

Task 7: CountingDaniel picked up the football.Daniel dropped the football.Daniel got the milk.Daniel took the apple.How many objects is Daniel holding?A: two

Task 10: Indefinite KnowledgeJohn is either in the classroom or the playground.Sandra is in the garden.Is John in the classroom?A: maybeIs John in the office?A: no

Task 15: Basic DeductionSheep are afraid of wolves.Cats are afraid of dogs.Mice are afraid of cats.Gertrude is a sheep.What is Gertrude afraid of?A: wolves

Task 20: Agent’s MotivationsJohn is hungry.John goes to the kitchen.John grabbed the apple there.Daniel is hungry.Where does Daniel go? A: kitchenWhy did John go to the kitchen? A: hungry

• One problem is that we have to remember the context setthroughout the whole question... 24

Page 46: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

question answering

• ...so the current state of the art are memory networks (Weston etal. 2014).

• An array of objects (memory) and the following componentslearned during training:

I (input feature map) converts the input to the internal featurerepresentation;

G (generalization) updates old memories after receiving new input;O (output feature map) produces new output given a new input and

a memory state;R (response) converts the output of O into the output response

format (e.g., text).

24

Page 47: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

question answering

• Dynamic memory networks (Kumar et al. 2015).• Episodic memory unit that chooses which parts of the input tofocus on with an attention mechanism:

24

Page 48: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

question answering

• End-to-end memory networks (Sukhbaatar et al. 2015).• A continuous version of memory networks, with multiple hops(computational steps) per output symbol.

• Regular memory networks require supervision on each layer;end-to-end ones can be trained with input-output pairs:

24

Page 49: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

question answering

• There are plenty of other extensions; one problem is how to linkQA systems with knowledge bases to answer questions thatrequire both reasoning and knowledge.

• Google DeepMind is also working on QA (Hermann et al. 2015):• a CNN-based approach to QA, also tested on the same dataset;• perhaps more importantly, a relatively simple and straightforwardway to convert unlabeled corpora to questions;

• e.g., given a newspaper article and its summary, they construct(context, query, answer) triples that could then be used forsupervised training of text comprehension models.

• I expect a lot of exciting things to happen here.• But allow me to suggest...

24

Page 50: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

what? where? when?

• «What? Where? When?»: a team game of answering questions.Sometimes it looks like this...

25

Page 51: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

what? where? when?

• ...but usually it looks like this:

25

Page 52: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

what? where? when?

• Teams of ≤ 6 players answer questions, whoever gets the mostcorrect answers wins.

• db.chgk.info – database of about 300K questions.• Some of them come from “Своя игра”, a Jeopardy clone butoften with less direct questions:

• Современная музыкаНа самом деле первое слово в названии ЭТОГО коллективасовпадает с фамилией шестнадцатого президента США, аисказили его для того, чтобы приобрести соответствующееназванию доменное имя.

• Россия в начале XX векаВ ЭТОМ году в России было собрано 5,3 миллиарда пудовзерновых.

• Чёрное и белоеОН постоянно меняет черное на белое и наоборот, а егососеда в этом вопросе отличает постоянство.

25

Page 53: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

what? where? when?

• Most are “Что? Где? Когда?” questions, even harder forautomated analysis:

• Ягоды черники невзрачные и довольно простецкие. Какой авторутверждал, что не случайно использовал в своей книге одно изназваний черники?

• В середине тридцатых годов в Москве выходила газета под названием«Советское метро». Какие две буквы мы заменили в предыдущемпредложении?

• Русская примета рекомендует 18 июня полоть сорняки. Согласновторой части той же приметы, этот день можно считать благоприятнымдля НЕЁ. Назовите ЕЁ словом латинского происхождения.

• Соблазнитель из венской оперетты считает, что после НЕГО женскаянеприступность уменьшается вчетверо. Назовите ЕГО одним словом.

• I believe it is a great and very challenging QA dataset.• How far in the future do you think it is? :)

25

Page 54: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

thank you!

Thank you for your attention!

26

Page 55: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

pushed out slides:machine translation

Page 56: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

evaluation for sequence-to-sequence models

• Next we will consider specific models for machine translation,dialog models, and question answering.

• But how do we evaluate NLP models that produce text?• Quality metrics for comparing with reference sentencesproduced by humans:

• BLEU (Bilingual Evaluation Understudy): reweighted precision (incl.multiple reference translations);

• METEOR: harmonic mean of unigram precision and unigram recall;• TER (Translation Edit Rate): number of edits between the outputand reference divided by the average number of reference words;

• LEPOR: combine basic factors and language metrics with tunableparameters.

• The same metrics apply to paraphrasing and, generally, allproblems where the (supervised) answer should be a free-formtext.

28

Page 57: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

machine translation

• Translation is a very convenient problem for modern NLP:• on one hand, it is very practical, obviously important;• on the other hand, it’s very high-level, virtually impossible withoutdeep understanding, so if we do well on translation, we probablydo something right about understanding;

• on the third hand (oops), it’s quantifiable (BLEU, TER etc.) and hasrelatively large available datasets (parallel corpora).

29

Page 58: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

machine translation

• Statistical machine translation (SMT): model conditionalprobability 𝑝(𝑦 ∣ 𝑥) of target 𝑦 (translation) given source 𝑥 (text).

• Classical SMT: model log 𝑝(𝑦 ∣ 𝑥) with a linear combination offeatures and then construct these features.

• NNs have been used both for reranking the best lists of possibletranslations and as part of feature functions:

29

Page 59: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

machine translation

• NNs are still used for feature engineering with state of the artresults, but here we are more interested insequence-to-sequence modeling.

• Basic idea:• RNNs can be naturally used to probabilistically model a sequence

𝑋 = (𝑥1, 𝑥2, … , 𝑥𝑇 ) as 𝑝(𝑥1), 𝑝(𝑥2 ∣ 𝑥1), …,𝑝(𝑥𝑇 ∣ 𝑥<𝑇 ) = 𝑝(𝑥𝑇 ∣ 𝑥𝑇−1, … , 𝑥1), and then the joint probability𝑝(𝑋) is just their product𝑝(𝑋) = 𝑝(𝑥1)𝑝(𝑥2 ∣ 𝑥1) … 𝑝(𝑥𝑘 ∣ 𝑥<𝑘) … 𝑝(𝑥𝑇 ∣ 𝑥<𝑇 );

• this is how RNNs are used for language modeling;• we predict next word based on the hidden state learned from allprevious parts of the sequence;

• in translation, maybe we can learn the hidden state from onesentence and apply to another.

29

Page 60: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

machine translation

• Direct application – bidirectional LSTMs (Bahdanau et al. 2014):

• But do we really translate word by word?29

Page 61: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

machine translation

• No, we first understand the whole sentence; henceencoder-decoder architectures (Cho et al. 2014):

29

Page 62: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

machine translation

• But compressing the entire sentence to a fixed-dimensionalvector is hard; quality drops dramatically with length.

• Soft attention (Luong et al. 2015a; 2015b; Jean et al. 2015):• encoder RNNs are bidirectional, so at every word we have a“focused” representation with both contexts;

• attention NN takes the state and local representation and outputsa relevance score – should we translate this word right now?

29

Page 63: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

machine translation

• Soft attention (Luong et al. 2015a; 2015b; Jean et al. 2015):• formally very simple: we compute attention weights 𝛼𝑖𝑗 andreweigh context vectors with them:

𝑒𝑖𝑗 = 𝑎(𝑠𝑖−1, 𝑗), 𝛼𝑖𝑗 = softmax(𝑒𝑖𝑗; 𝑒𝑖∗),

𝑐𝑖 =𝑗=1∑𝑇𝑥

𝛼𝑖𝑗ℎ𝑗, and now 𝑠𝑖 = 𝑓(𝑠𝑖−1, 𝑦𝑖−1, 𝑐𝑖).

29

Page 64: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

machine translation

• We get better word order in the sentence as a whole:

• Attention is an “old” idea (Larochelle, Hinton, 2010), and can beapplied to other RNN architectures, e.g., image processing andspeech recognition; in other sequence-based NLP tasks:

• syntactic parsing (Vinyals et al. 2014),• modeling pairs of sentences (Yin et al. 2015),• question answering (Hermann et al. 2015),• “Show, Attend, and Tell” (Xu et al. 2015).

29

Page 65: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

google translate

• Sep 26, 2016: Wu et al., Google’s Neural Machine TranslationSystem: Bridging the Gap between Human and MachineTranslation:

• this very recent paper shows how Google Translate actually works;• the basic architecture is the same: encoder, decoder, attention;• RNNs have to be deep enough to capture language irregularities,so 8 layers for encoder and decoder each:

30

Page 66: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

google translate

• Sep 26, 2016: Wu et al., Google’s Neural Machine TranslationSystem: Bridging the Gap between Human and MachineTranslation:

• but stacking LSTMs does not really work: 4-5 layers are OK, 8layers don’t work;

• so they add residual connections between the layers, similar to(He, 2015):

30

Page 67: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

google translate

• Sep 26, 2016: Wu et al., Google’s Neural Machine TranslationSystem: Bridging the Gap between Human and MachineTranslation:

• and it makes sense to make the bottom layer bidirectional inorder to capture as much context as possible:

30

Page 68: Deep Architectures for Natural Language Processingsergey/slides/N17_DataFest...plan • The deep learning revolution has not left natural language processing alone. • DL in NLP has

google translate

• Sep 26, 2016: Wu et al., Google’s Neural Machine TranslationSystem: Bridging the Gap between Human and MachineTranslation:

• GNMT also uses two ideas for word segmentation:• wordpiece model: break words into wordpieces (with a separatemodel); example from the paper:

Jet makers feud over seat width with big orders at stake

becomes

_J et _makers _fe ud _over _seat _width _with _big _orders _at _stake

• mixed word/character model: use word model but forout-of-vocabulary words convert them into characters (specificallymarked so that they cannot be confused); example from the paper:

Miki becomes <B>M <M>i <M>k <E>i30