Knowledge Prompts: Injecting World Knowledge into
Language Models through Soft Prompts
Cicero Nogueira dos Santos, Zhe Dong, Daniel Cer, John Nham,
Siamak Shakeri, Jianmo Ni, Yun-hsuan Sung
Google Research
{cicerons, zhedong, cer, jnham, siamaks, jianmon, yhsung}@google.com
Abstract
Soft prompts have been recently proposed as
a tool for adapting large frozen language mod-
els (LMs) to new tasks. In this work, we repur-
pose soft prompts to the task of injecting world
knowledge into LMs. We introduce a method
to train soft prompts via self-supervised learn-
ing on data from knowledge bases. The result-
ing soft knowledge prompts (KPs) are task in-
dependent and work as an external memory of
the LMs. We perform qualitative and quanti-
tative experiments and demonstrate that: (1)
KPs can effectively model the structure of the
training data; (2) KPs can be used to improve
the performance of LMs in different knowl-
edge intensive tasks.
1 Introduction
Very large neural language models (LMs) are
known to perform well on knowledge intensive
natural language understanding (NLU) tasks, be-
cause they memorize a significant amount of world
knowledge from the training data. The larger the
LM, the more facts it can memorize at the training
time, and the better the results at the inference time
(Roberts et al.,2020). Despite their success, these
models also present some important drawbacks
such as: the parametric memory of these models
have a fixed size and cannot grow (or shrink) over
time without fully retraining the model; there is
no control in terms of which part of the memory
stores data about what; facts that do not co-occur
frequently in the training data are not well repre-
sented in the model; very large models are needed
to memorize enough data in order to perform well
on knowledge intensive tasks such as generative
question answering; and at last, but not the least,
the memorized knowledge gets obsolete overtime,
and requires re-training the model for refreshness.
In this work, we employ soft prompts to over-
come some of these issues of LMs. Soft prompts
(Lester et al.,2021;Li and Liang,2021;Ham-
bardzumyan et al.,2021) have been recently pro-
posed as a tool for adapting large frozen LMs
to new tasks. Nevertheless, we repurpose soft
prompts to the task of injecting world knowledge
into LMs. The goal is to train an external memory
that is composed of a large set of soft prompts
that encode world knowledge. We introduce a
method to train knowledge driven soft prompts via
self-supervised learning on data from knowledge
bases. The resulting soft prompts, which we call
knowledge prompts (KPs), function as an auxiliary
memory of the LMs that is activated when solving
knowledge intensive tasks. Different from regu-
lar applications of soft prompts that concatenate a
fixed small set of embeddings to every input, our
approach learns a very large set of KPs, which are
sparsely activated depending on the input.
We focus on entity-centric KPs, which means
that each prompt primarily encodes information
about one entity from a knowledge base. We use
Wikidata (Vrandeˇ
ci´
c and Krötzsch,2014) triples
as our training data and train KPs for the top 1.1M
entities, based on the number of triples. We present
a qualitative analysis of KPs using t-SNE plots
and k-nearest neighbors approaches. In terms of
quantitative analysis, we show experimental results
for three knowledge intensive tasks: question an-
swering, fact checking and relation classification.
For all datasets, the use of KPs improves the per-
formance of the T5 baseline. Our experimental
results demonstrate that KPs are an effective way
to expand the memory of frozen LMs.
The main contributions of this work are the fol-
lowing:
•
we propose a self-supervised approach to train
knowledge driven soft prompts that can be
used to inject world knowledge into LMs.
•
we demonstrate that knowledge prompts can
effectively model the structure of the training
data and can also improve the performance of
arXiv:2210.04726v1 [cs.CL] 10 Oct 2022