Detecting out-of-distribution (OOD) inputs is crucial for the safe deployment of natural language processing (NLP) models. Though existing methods, especially those based on the statistics in the feature space of fine-tuned pre-trained language models (PLMs), are claimed to be effective, their effectiveness on different types of distribution shifts remains underexplored. In this work, we take the first step to comprehensively evaluate the mainstream textual OOD detection methods for detecting semantic and non-semantic shifts. We find that: (1) no existing method behaves well in both settings; (2) fine-tuning PLMs on in-distribution data benefits detecting semantic shifts but severely deteriorates detecting non-semantic shifts, which can be attributed to the distortion of task-agnostic features. To alleviate the issue, we present a simple yet effective general OOD score named GNOME that integrates the confidence scores derived from the task-agnostic and task-specific representations. Experiments show that GNOME works well in both semantic and non-semantic shift scenarios, and further brings significant improvement on two cross-task benchmarks where both kinds of shifts simultaneously take place. Our code is available at https://github.com/lancopku/GNOME.
翻译:虽然现有方法,特别是那些基于经微调的预先培训语言模型特征空间统计数据的方法,据称是有效的,但对于不同类型分配转移的有效性仍未得到充分探讨。在这项工作中,我们迈出第一步,全面评估用于检测语义和非语义变化的主流文本 OOD 检测方法。我们发现:(1) 在两种情况下,现有方法都没有很好地运行;(2) 微调关于分配数据效益的PLMS, 检测语义变化,但严重恶化检测非语义变化,这可以归因于任务-语义特征的扭曲。为了缓解这一问题,我们提出了一个简单而有效的OOD 通用分数,名为GNOME,它综合了从任务-语义和非语义变化中得出的信任分数。实验表明,GNOME在语义和非语义变化情景中都运作良好,并且进一步大大改进了两个跨语义变化的基准,这里既有的是任务-语义/语义变化规则。