Pre-trained language models have contributed significantly to relation extraction by demonstrating remarkable few-shot learning abilities. However, prompt tuning methods for relation extraction may still fail to generalize to those rare or hard patterns. Note that the previous parametric learning paradigm can be viewed as memorization regarding training data as a book and inference as the close-book test. Those long-tailed or hard patterns can hardly be memorized in parameters given few-shot instances. To this end, we regard RE as an open-book examination and propose a new semiparametric paradigm of retrieval-enhanced prompt tuning for relation extraction. We construct an open-book datastore for retrieval regarding prompt-based instance representations and corresponding relation labels as memorized key-value pairs. During inference, the model can infer relations by linearly interpolating the base output of PLM with the non-parametric nearest neighbor distribution over the datastore. In this way, our model not only infers relation through knowledge stored in the weights during training but also assists decision-making by unwinding and querying examples in the open-book datastore. Extensive experiments on benchmark datasets show that our method can achieve state-of-the-art in both standard supervised and few-shot settings. Code are available in https://github.com/zjunlp/PromptKG/tree/main/research/RetrievalRE.
翻译:预训练语言模型通过展示显著的少样本学习能力,为关系抽取做出了重要贡献。然而,针对关系抽取的提示微调方法仍难以泛化到那些罕见或复杂的模式。值得注意的是,先前的参数化学习范式可视为一种记忆过程,将训练数据看作一本书,推理视为闭卷考试。那些长尾或复杂模式在少样本实例下难以被参数化记忆。为此,我们将关系抽取视为一次开卷考试,并提出一种新的半参数化范式——用于关系抽取的检索增强提示微调。我们构建了一个用于检索的开卷数据存储库,将基于提示的实例表示及其对应的关系标签视为记忆化的键值对。在推理过程中,模型可通过线性插值预训练语言模型的基础输出与数据存储库上的非参数化最近邻分布来推断关系。通过这种方式,我们的模型不仅利用训练期间存储于权重中的知识推断关系,还能通过检索和查询开卷数据存储库中的示例辅助决策。在基准数据集上的大量实验表明,我们的方法在标准监督和少样本设置下均能达到最先进水平。代码可在 https://github.com/zjunlp/PromptKG/tree/main/research/RetrievalRE. 获取。