Source-linked AI summary

BERTese: Learning to Speak to BERT

Adi Haviv, Jonathan Berant, Amir Globerson

arXiv:2103.05327v2cs.CLcs.LG

TL;DR

Large language models contain factual knowledge, but extracting it with manually authored queries can leave unclear whether an error reflects missing knowledge or misunderstood wording. BERTese trains a query rewriter against a fixed BERT predictor, and the authors report that it outperforms baselines while making small wording changes that may offer insight into model knowledge.

  • Problem

    A wrong answer to a manually crafted query can reflect either missing knowledge in the language model or failure to understand the query.

    Source: §1 · p. 1
  • Method

    BERTese trains a query rewriter to optimize knowledge extraction through a fixed pretrained BERT predictor, using auxiliary losses to encourage token-like rewrites and a single [MASK].

    Source: §1 · pp. 1–2, §3 · p. 3
  • Results

    The authors report that BERTese outperforms baselines, and its rewrites are fairly small wording modifications.

    Source: §5 · p. 5
  • Takeaways & Limitations

    The small rewrites may provide insight into how knowledge is represented in language models.

    Source: §1 · p. 2, §5 · p. 5

    The empirical setting uses LAMA with a single-mask prediction; extensions to multiple masks and testing on other masked language models remain for future work.

    Source: §5 · p. 5

Abstract

from arXiv · show

Large pre-trained language models have been shown to encode large amounts of world and commonsense knowledge in their parameters, leading to substantial interest in methods for extracting that knowledge. In past work, knowledge was extracted by taking manually-authored queries and gathering paraphrases for them using a separate pipeline. In this work, we propose a method for automatically rewriting queries into "BERTese", a paraphrase query that is directly optimized towards better knowledge extraction. To encourage meaningful rewrites, we add auxiliary loss functions that encourage the query to correspond to actual language tokens. We empirically show our approach outperforms competing baselines, obviating the need for complex pipelines. Moreover, BERTese provides some insight into the type of language that helps language models perform knowledge extraction.

1 Introduction

The section frames knowledge extraction as a query-wording problem: an incorrect answer may reflect either missing knowledge or a query the model does not understand. It proposes training a rewriter to optimize queries for a fixed predictor, with results showing the potential of rewriting to improve predictions and reveal useful language changes.

1 Introduction

  • Large pre-trained language models encode substantial world knowledge, but a wrong answer to a manually crafted query can reflect either absent knowledge or misunderstood wording.For example, adding “the city of” to a query about Dante’s birthplace may elicit the correct answer.Source: §1 · p. 1
  • The paper asks how to automatically rewrite knowledge-seeking queries into forms that MLMs understand, with understanding measured by producing the correct answer.Source: §1 · p. 1
  • Unlike prior work’s two-step pipeline of collecting paraphrase templates and aggregating their answers, the proposed approach trains query rewriting directly for knowledge extraction.Source: §1 · p. 1
  • A BERT-based rewriter produces a token rewrite at each input position, which a separate, fixed pretrained BERT predictor uses to produce an answer.The predictor remains fixed, so the rewriter is trained to produce queries that make it output the correct answer.Source: Figure 1 · p. 1, §1 · p. 2
  • Auxiliary losses encourage token-like outputs and exactly one [MASK], while a selection layer uses a straight-through estimator to choose the answer position.The reported rewrites often make consistent wording changes, such as changing tense; the method is evaluated on LAMA and is described as applicable to any MLM.Source: §1 · p. 2
  • The results demonstrate the potential of rewriting inputs to language models for better predictions and possible insight into how knowledge is represented.Source: §1 · p. 2

2 Related Work

Related work covers query reformulation for factual knowledge extraction and for standard question answering. The paper builds on paraphrase-based extraction with end-to-end rewriting, alongside independent work on gradient-based prompt generation.

2 Related Work

  • Prior work found that small query variations can reduce zero-shot factual recall from masked language models (Heinzerling and Inui, 2020).Source: §2 · p. 2
  • For standard QA and retrieval, query reformulation has been trained with reinforcement learning to optimize black-box system accuracy or recall (Buck et al., 2017).Minor query modifications were also reported to reduce performance across QA models and tasks.Source: §2 · p. 2
  • Jiang et al. (2020) mined queries, collected paraphrases through back-translation, and reranked them before querying BERT.Source: §2 · p. 2
  • This work instead trains end-to-end query generation to maximize MLM knowledge extraction; independent work by Shin et al. (2020) uses gradient-based prompt search and reports gains across multiple tasks.Source: §2 · p. 2

3 The BERTese Model

BERTese rewrites natural-language queries before passing them to an existing BERT predictor. Its training objective combines answer prediction with losses that encourage valid BERT-token embeddings and a single [MASK] position.

3 The BERTese Model

  • The rewriter maps an input query to discrete BERT-token neighbors, then a fixed predictor returns its answer from the masked position.The rewriter is trained to produce queries that lead the predictor to the correct answer.Source: §3 · p. 3
  • Two auxiliary losses address non-differentiable token selection and encourage the rewritten query to contain one [MASK] token.The valid-token loss pulls output vectors toward BERT embeddings; the single-[MASK] loss encourages one position to match the [MASK] embedding most closely.Source: §3 · p. 3
  • The prediction loss uses predictor outputs across positions to approximate cross-entropy at the [MASK] position, with the straight-through estimator enabling optimization.In the forward pass, the mask-position distribution is converted to a one-hot vector.Source: §3 · p. 3
  • The final training objective sums prediction, valid-token, and single-[MASK] losses, with the auxiliary terms encouraging valid tokens and one mask.The weights on the auxiliary terms are tuned using cross-validation.Source: §3 · p. 3
  • The rewriter is initialized as an identity mapping, so it initially outputs the query it receives.It is initialized from a BERT-based model fine-tuned to reproduce its input word embeddings.Source: §3 · pp. 3–4

4 Experiments

Experiments on T-REx compare BERTese with three baselines and examine its rewrites and loss components; BERTese outperforms all three baselines.

4 Experiments

  • Experiments train on separate, nonoverlapping T-REx-train and evaluate the complete T-REx dataset, comparing BERTese with zero-shot BERT, LPAQA, and fine-tuned BERT.T-REx contains 41 relations, each associated with at most 1,000 queries.Source: §4 · p. 4
  • Using both auxiliary losses further improves accuracy over using either Valid Token Loss or Single [MASK] Loss alone.Removing Single [MASK] Loss drops P@1 from 38.3 to 37.3; some resulting rewrites contain more than one [MASK].Source: Table 3 · p. 4, §4 · p. 4
  • P@1 rose from 31.1 to 38.3 versus zero-shot BERT and from 36 to 38.3 versus fine-tuned BERT; BERTese also beats BERTbase LPAQA by more than 4 points.Results are macro-averaged over relations.Source: §4 · p. 4, Table 1 · p. 5
  • Rewrites are usually semantically plausible and small, sometimes making interpretable substitutions such as airfield to airport.The examples come from T-REx test queries where the original produced a wrong answer and the rewrite produced a correct one.Source: §4 · p. 4, Table 2 · p. 5
  • More than 70% of replacements are nouns and verbs, while 15% are determiners.The passage characterizes nouns and verbs as carrying substantial semantic content and determiners as carrying little.Source: §4 · pp. 4–5, Table 4 · p. 5

5 Conclusion

The trained rewrite model improves factual extraction from BERT compared with baselines, using fairly small query modifications. The approach may extend beyond knowledge extraction, though the empirical setting is limited to LAMA's single-mask prediction.

5 Conclusion

  • The paper presents modifying BERT's input as an approach to more accurate factual extraction.Source: §5 · p. 5
  • The trained rewrite model produces more accurate factual-extraction results than baselines, despite making fairly small query modifications.The authors note that these edits highlight BERT's lack of invariance to them.Source: §5 · p. 5
  • The approach could extend to general BERT question-answering datasets and language modeling, including rewriting sentences to ease masked-word completion..Source: §5 · p. 5
  • The empirical evaluation focuses on LAMA, which requires a single mask-token prediction; extensions to multiple masks are left for future work.The authors also identify RoBERTa and ERNIE as other masked language models to test.Source: §5 · p. 5
Loading 2103.05327v2…