Parametric and semi-parametric methods for knowledge acquisition from text
Yury Zemlyanskiy
December 9, 2021
1
Motivation
Knowledge acquisition = (extract + store + retrieve) knowledge
2
processing
extract
retrieve
Information�flow
store
Motivation
Modern NLP neural models do not have a separate memory and store knowledge in the parameters ⟹ unreliable (Cao et al., 2021) and require retraining to incorporate new information
3
processing
Textual data
Neural NLP model
Cao et al., Knowledgeable or educated guess? revisiting language models as knowledge bases. ACL/IJCNLP 2021
Key insight: Memory
Key hypothesis of this thesis: we can improve model’s knowledge acquisition abilities by adding a dedicated memory component.
4
Memory
The exact kind of memory depends on a task at hand.
processing
Textual data
Neural NLP model
What kind of memory?
Task: Knowledge base completion for a fixed set of entities based on relevant documents.
Parametric memory for aggregated information on each entity to reliably extract knowledge about the entity
5
Memory of�“Seven Samurai”
Do people generally like this movie?�
Is it “surreal”?�
Are there “multiple storylines”?
Review #1: This movie develops its power best if you don’t try to look out for the “real” and “true” events behind the four versions of the narration... shown in a very intelligent and artistic way, no silly …
Review #2: Just rented this, and at first I didn’t like very much, but then it starts to sink in for how good it is, the acting is great especially Toshiro Mifune, it was shot very good for an older movie... it’s #62 on the top 250
compress
What kind of memory?
Task: Question-answering over books or entire Wikipedia (open-domain)
Semi-parametric memory for individual entity-centric facts from text,
amendable without re-training
6
Memory
What is the nationality of the hero who killed Medusa?
compress
Neural network model
or
Greek
What kind of memory?
Task: Structured prediction (semantic parsing or machine translation) in low resource scenario
Set reminder to send happy b-day text to Clark on Friday
SetReminder(
Message(� text= happy b-day,
whom= Clark),
time= on Friday)
Semi-parametric memory of the individual training samples
Add another reminder for next week’s exam.
SetReminder(GetTodo(time= for next week, what=exam))
Send a happy birthday message to dad
Message(whom= dad, text= happy birthday)
7
Neural net
compress
Memory of
training sample #1
Memory ∈ Rd of
training sample #2
Outline
8
9
Parametric entity memory
10
Motivation
Task: Predict movie attributes based on information in movies reviews.
11
Entity embedding of�“Seven Samurai”
Review #1: This movie develops its power best if you don’t try to look out for the “real” and “true” events behind the four versions of the narration... shown in a very intelligent and artistic way, no silly …
Review #2: Just rented this, and at first I didn’t like very much, but then it starts to sink in for how good it is, the acting is great especially Toshiro Mifune, it was shot very good for an older movie... it’s #62 on the top 250
Train
MovieLens tag
nonlinear
multiple storylines
Japan
imdb top 250
surreal
cerebral
Fine-tune
Contributions
12
Semi-parametric entity memory
13
Intro: memory�
14
Text as a virtual knowledge base
What is known about Perseus?
[Perseus] was the son of Zeus and Danaë, ...
… after [Perseus] married Andromeda founded a city and called it Amandra …
[Perseus] was a Greek hero who killed Medusa ...
Heracles was 4 generations later than [Perseus] ...
text as a virtual knowledge base�(Dhingra et al., 2020)
regular knowledge base
15
property name | property value |
parents | Zeus, Danaë |
wife | Andromeda |
position held | king of Mycenae, Argos |
... | ... |
Mention Encodings
MentionEncoder(“[Perseus] was a Greek hero who bravely killed Medusa.”) ∈ Rd
16
Memory based on mentions
Collect mention encodings from the entire document into a Memory Table.
17
[Perseus] was a Greek hero who bravely ...�Perseus was a [Greek] hero who bravely ...�...�[H. Simpson] is a character from US sitcom�H. Simpson is a character from [US] sitcom
...
MentionEncoder
All mentions in a document or a corpus
Memory Table:
number of mentions x d
Why memory table?
Memory table as knowledge representation has several advantages
18
Contributions
Both: new method to train Mention Encoder using only textual data�(and entity annotations)
Memory
Memory
ReadTwice:
MentionMemory:
Use memory to help a neural network process long documents
Use memory to capture world knowledge about entities in a format compatible with a neural network
19
Memory of large documents
20
Motivation: question answering
Task: Question Answering that require assimilating information from different sections of large inputs such as books or article collections.
Who does Aragorn take as his wife?
21
Existing methods: BERT
Goal: Output vector for every word representing word’s meaning within a sentence.
22
Frodo
couldn’t
throw
Transformer model
The
Ring
into
the
fire
Existing methods: Transfer learning
23
[MASK]
killed
Medusa
Transformer model
Perseus
Transfer
Pre-training stage:�Masked Language Model (MLM) task
Use pre-trained model as initialization
Fine-tuning stage:�Any downstream task of interest
Question Answering (QA)
Text Classification
Named Entity Recognition
...
BERT’s limitations
Inside the Sammath Naur, Frodo struggled to throw the Ring into the Cracks of Doom.
Who does Aragorn take as his wife?�BERT: Éowyn ❌
24
Motivation: long-range dependencies
Long-range dependencies are common and modeling them is crucial
Frodo couldn’t throw [MASK] into the fire ⇒ BERT ⇒ ???
but
Frodo couldn’t throw [MASK] into the fire � + The Ring slowly gained control over Frodo ⇒ BERT ⇒ The Ring
25
Motivation: long-range dependencies
Mention encodings as a way to model long range dependencies
Frodo couldn’t throw [MASK] into the fire ⇒ BERT ⇒ ???
but
Frodo couldn’t throw [MASK] into the fire � + MentionEncoding(“The Ring slowly gained control over [Frodo]”)� BERT ⇒ The Ring
26
ReadTwice method
27
ReadTwice: 1st read
Frodo couldn’t throw [MASK] into the fire
The Ring slowly gained control over Frodo
28
BERT1
BERT1
[Frodo] couldn’t throw [MASK] into the fire
[The Ring] slowly gained control over Frodo
The Ring slowly gained control over [Frodo]
ReadTwice: 1st read
Frodo couldn’t throw [MASK] into the fire
The Ring slowly gained control over Frodo
29
BERT1
BERT1
[Frodo] couldn’t throw [MASK] into the fire
[The Ring] slowly gained control over Frodo
The Ring slowly gained control over [Frodo]
Memory Table: number of mentions x 768
ReadTwice: 2nd read
Frodo couldn’t throw [MASK] into the fire
The Ring slowly gained control over Frodo
30
Memory Table
Attention Over Memory Table
BERT1
BERT1
Frodo
...
throw
The
Ring
slowly
...
over
into
the
fire
Frodo
ReadTwice: 2nd read
Frodo couldn’t throw [MASK] into the fire
The Ring slowly gained control over Frodo
31
Memory Table
Attention Over Memory Table
BERT2
BERT2
BERT1
BERT1
Frodo
...
fire
The
...
Frodo
How to encode a mention?
32
[The
Ring]
gained
BERT1
control
over
[Frodo]
Linear
Linear
[The Ring]
[Frodo]
Pre-training
The model is trained end-to-end on masked language model task
33
Evaluation: QA over books
Dataset
�
“Who does Aragorn take as his wife?”
Baselines
34
Results: NarrativeQA
ReadTwice: New state-of-the-art for NarrativeQA
35
Model | ROUGE-L | BLEU-1 | BLEU-4 | METEOR |
RoBERTa (us) | 17.4 / 18.0 | 18.2 / 18.0 | 2.4 / 2.6 | 5.4 / 5.4 |
ETC (us) | 18.3 / 18.8 | 16.1 / 17.2 | 2.4 / 2.7 | 5.4 / 5.4 |
ReadTwice (us) | 22.7 / 23.3 | 21.1 / 21.1 | 3.6 / 4.0 | 6.7 / 7.0 |
Results on dev / test sets
Insight: Inter-segment memory matters
ReadTwice: It’s important to attend memories from other segments
36
Model | NarrativeQA (dev), ROUGE-L | NarrativeQA (dev), BLEU-1 |
ReadTwice | 22.71 | 21.07 |
w/o inter-segment memory attention | 21.93 | 18.39 |
Memory of Wikipedia
37
Motivation: open domain QA
38
What is the nationality of the hero killed Medusa?�BERT: England ❌
Motivation
Goal: incorporate information from the English Wikipedia into BERT model
Existing solutions:
Proposal: Mention Memory -- retrieve and integrate mention encoding
39
TOME: Transformer over Memory
40
TOMEBlock
High-level approach: 2 training phases
41
Train Mention Encoder
Generate Mention Memory by encoding mentions in Wikipedia
Train TOME model
Pre-training mention encoder
Challenge: How to train Mention Encoder to produce useful representations?
42
Batch: Related Wiki articles
Mention Encoder
Batch-TOME
In-batch memory
Objectives
Pre-training: insights
Batch-TOME and TOME attend to relevant mentions w/o any supervision
43
How good is the Mention Encoder?
Task: Classify a mention in a passage into several categories.
Dataset: Ultra Fine Entity Typing
“[We] want to find the truth, regardless of what the truth is, ….,” chief Yemeni investigator, minister of sea and transport Said Yafaai, told the reporter … �⟹ detective, enforcement, government, authority, investigator, law_enforcement, police, agency, administration
Labels (total 10331):
44
Evaluation: Ultra Fine Entity Typing
MentionEncoder: outperforms BERT in capturing mention-level information
45
Model | Total, F1 | Coarse-grained labels only, F1 | Fine-grained labels only, F1 | Ultra fine-grained labels only, F1 |
BERT | 36.8 | 23.3 | 68.5 | 41.4 |
MentionEncoder | 39.3 | 25.9 | 70.3 | 44.7 |
Evaluation: MentionMemory + TOME
Open-domain boolean QA / claim-verification tasks: FEVER, HoVeR
46
Evaluation: open domain QA
47
Model | FEVER (test) accuracy (%) | HoVeR (test) accuracy (%) |
Entities as Experts | 63.6 | 66.6 |
REALM | 67.1 | 66.1 |
TOME-1 | 67.8 | 72.8 |
TOME-2 | 68.1 | 73.1 |
TOME-1 and TOME-2 have 1/2 TOMEBlocks (same total #parameters as BERT)
HoVer example: simple retrieval
48
Evaluation: open domain entity QA
49
Model | TriviaQA�(entity answerable only) accuracy, % | ComplexWebQuestions� accuracy, % | EntityQuestions accuracy, % |
Entities as Experts | 51.3 | 42.5 | 32.5 |
REALM | 63.4 | 46.7 | 59.0 |
TOME-1 | 60.3 | 44.9 | 62.1 |
TOME-2 | 64.8 | 47.7 | 66.0 |
Insight: memory size matters
Memory size matters
50
Insights: Mention Encoder pre-training
51
Model | FEVER (dev), accuracy (%) | HoVer (dev), accuracy (%) | TriviaQA (dev) accuracy (%) | ComplexWebQuestions (dev), accuracy (%) |
TOME-1 | 70.5 | 73.6 | 50.8 | 44.9 |
TOME-1 trained on MLM only (w/o coref. resolution loss) | 68.4 | 69.8 | 42.5 | 40.5 |
Auxiliary loss on mention encoder training is important to generate better memory
Insight: memory is amendable
52
Model | TriviaQA (dev) accuracy (%) | ComplexWebQuestions (dev), accuracy (%) |
TOME-1 | 17.4 | 16.4 |
TOME-1-unseen | 17.6 | 16.7 |
Memory can be modified on the fly without re-training.
Contributions
53
Task-specific memory
54
Motivation: Structured prediction
Semantic parsing
Machine Translation
Set reminder to send happy b-day text to Clark on Friday
Reminder(
Message(text= happy b-day, whom= Clark),
time= on Friday)
Low resource setting (<10K training samples) is common and challenging
55
Intuition
Intuition: A new input sample contains partial similarities with some train samples.
Add another reminder for next week’s exam.
SetReminder(� GetTodo(� time= for next week,� what= exam))
Send a happy birthday message to dad
Message(� whom= dad,� text= happy birthday)
Set reminder to send happy b-day text to Clark on Friday
SetReminder(� Message(� text= happy b-day,
whom= Clark),
time= on Friday)
56
Train sample
Train sample
New sample
Key hypothesis: memory
Add another reminder for next week’s exam.
SetReminder(GetTodo(time= for next week, what=exam))
Semi-parametric memory: encode training data in an explicitly decomposed way:
memories of individual samples or their parts
Send a happy birthday message to dad
Message(whom= dad, text= happy birthday)
57
MemoryEncoder
Memory of
training sample #1
Memory ∈ Rd of
training sample #2
Key hypothesis: memory
Hypothesis: Improve prediction accuracy by allowing the model to retrieve and re-combine multiple training samples from memory
58
Method
The model is similar to the TOME model.
59
Training sample #1 |
Training sample #2 |
... |
Send
...
dad
Initial Transformer model
i-th Transformer block
Decoder model
N blocks
Related work
60
Plan / Expected Contribution
61
Conclusion
62
Conclusion
We propose and study several methods for knowledge acquisition from text.
We consider several challenging knowledge-intensive tasks arising in natural language processing.
We improve the knowledge acquisition abilities of modern neural networks by adding a dedicated memory component.
63
Timeline
64
Summer 2022
Spring 2022
Defense
July/August
Step 1
Follow ups
Step 2
Acknowledgements
Many thanks to my advisor Fei Sha and my co-authors
Docent: Sudeep Gandhe, Ruining He, Bhargav Kanagal, Anirudh Ravula, Juraj Gottweis, Fei Sha, Ilya Eckstein
ReadTwice: Joshua Ainslie, Michiel de Jong, Philip Pham, Ilya Eckstein, Fei Sha
Mention Memory: Michiel de Jong, Nicholas FitzGerald, William Cohen, Fei Sha
65
Thank you!
Questions?
66
Evaluation: MovieLens tag prediction
Model | MAP | AUC |
MostPopularTags | 0.06 | 0.80 |
TF-IDF | 0.32 | 0.86 |
BERT | 0.38 | 0.91 |
RELIC | 0.39 | 0.96 |
DOCENT | 0.45 | 0.98 |
Attention over memory
Differentiable equivalent of key-value memory lookup for neural networks.
68
key1
key2
...
keyN
value1
value2
...
valueN
query
query, keyi ∈ ℝK; valuei ∈ ℝV
Attention over memory
Differentiable equivalent of key-value memory lookup for neural networks.
69
key1
key2
...
keyN
value1
value2
...
valueN
query
attn1
∑i attni·valuei
attn2
...
attnN
attni =
exp(query·keyi)
∑j exp(query·keyj)
Transformer
70
Which
hero
killed
Medusa
?
Multi-head self-attention layer
MLP
MLP
MLP
MLP
MLP
Word embeddings
Input text
“Hidden” states
2-layer neural network
Contextualized word embeddings
BERT
Goal: Output vector for every word representing word’s meaning within a sentence.
71
Astronaut
Neil
Armstrong
Transformer model
put
money
in
bank
account
BERT
Idea: train the model to produce "general" embeddings via Mask Language Model task.
72
Astronaut
[MASK]
Armstrong
Transformer model
put
[MASK]
in
bank
account
Neil
money
Motivation: question answering
Google was founded in 1998 by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University in California. Together they own about 14 percent of its shares and control 56 percent of the stockholder voting power through supervoting stock. They incorporated Google as a privately held company on September 4, 1998. An initial public offering (IPO) took place on August 19, 2004, and Google moved to its headquarters in Mountain View, California, nicknamed the Googleplex. In August 2015, Google announced plans to reorganize its various interests as a conglomerate called Alphabet Inc. Sundar Pichai was appointed CEO of Google, replacing Larry Page who became the CEO of Alphabet.
Questions based on the passage:
What is IPO?�initial public offering
Where is headquarter of Google?�Mountain View, California
Who is the current CEO?�Sundar Pichai
Challenging for modern neural networks when the document is very long (e.g., entire book).
73
Insight: Entity memory matters
Memory based on entity mentions outperforms other memories.
74
Model | TriviaQA (dev),�F1 | HotpotQA (dev), F1 | NarrativeQA (dev), ROUGE-L | NarrativeQA (dev), BLEU-1 |
ReadTwice | 80.7 | 75.9 | 22.71 | 21.07 |
ReadTwice with CLS memories | 80.6 | 75.32 | 20.89 | 17.80 |
ReadTwice with STS memories | 80.4 | 75.39 | 21.08 | 18.38 |
Evaluation: open domain entity QA
75
Model | TriviaQA (dev) accuracy (%) | TriviaQA (test) accuracy (%) | TriviaQA (E-dev) accuracy (%) | ComplexWebQuestions (dev), accuracy (%) | EntityQuestions (dev), accuracy (%) |
Entities as Experts | 42.3 | 53.4 | 51.3 | 42.5 | 32.5 |
REALM | 55.8 | 67.1 | 63.4 | 46.7 | 59.0 |
TOME-1 | 50.8 | 61.1 | 60.3 | 44.9 | 62.1 |
TOME-2 | 54.6 | 65.8 | 64.8 | 47.7 | 66.0 |
HoVer example: multiple retrieval
76
The End
77