kNN-Prompt: Nearest Neighbor Zero-Shot Inference

Weijia Shi, Julian Michael, Suchin Gururangan, Luke Zettlemoyer
5/27/2022
cs.CL

Official code: swj0419/kNN_prompt (28 stars, Python, last commit 2022-11-02).

Abstract

Retrieval-augmented language models (LMs) use non-parametric memory to substantially outperform their non-retrieval counterparts on perplexity-based evaluations, but it is an open question whether they achieve similar gains in few- and zero-shot end-task accuracy. We extensively study one such model, the k-nearest neighbor LM (kNN-LM), showing that the gains marginally transfer.

Show full abstract

The main challenge is to achieve coverage of the verbalizer tokens that define the different end-task class labels. To address this challenge, we also introduce kNN-Prompt, a simple and effective kNN-LM with automatically expanded fuzzy verbalizers (e.g. to expand terrible to also include silly and other task-specific synonyms for sentiment classification). Across nine diverse end-tasks, using kNN-Prompt with GPT-2 large yields significant performance boosts over strong zero-shot baselines (13.4% absolute improvement over the base LM on average). We also show that other advantages of non-parametric augmentation hold for end tasks; kNN-Prompt is effective for domain adaptation with no further training, and gains increase with the size of the retrieval model.

View on arXivView PDF

Code Implementations(1)

swj0419/kNN_promptOfficial100%

TBC

281PythonMay 25, 20224 years ago

Similar Papers

Cite this paper

@article{shi2022knnprompt,
  title  = {kNN-Prompt: Nearest Neighbor Zero-Shot Inference},
  author = {Weijia Shi and Julian Michael and Suchin Gururangan and Luke Zettlemoyer},
  year   = {2022},
  eprint = {2205.13792},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2205.13792}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2205.13792.svg)](https://codeofpaper.com/paper/2205.13792)

Discussion