Pseudo-OOD training for robust language models Dhanasekar Sundararaman1 Nikhil Mehta1 Lawrence Carin1 1Duke University

2025-05-02 0 0 482.33KB 8 页 10玖币
侵权投诉
Pseudo-OOD training for robust language models
Dhanasekar Sundararaman1, Nikhil Mehta1, Lawrence Carin1
1Duke University
{ds448,nm208}@duke.edu
Abstract
While pre-trained large-scale deep models
have garnered attention as an important topic
for many downstream natural language pro-
cessing (NLP) tasks, such models often make
unreliable predictions on out-of-distribution
(OOD) inputs. As such, OOD detection is
a key component of a reliable machine learn-
ing model for any industry-scale application.
Common approaches often assume access to
additional OOD samples during the training
stage, however, outlier distribution is often un-
known in advance. Instead, we propose a
post hoc framework called POORE - POsthoc
pseudo Ood REgularization, that generates
pseudo-OOD samples using in-distribution
(IND) data. The model is fine-tuned by in-
troducing a new regularization loss that sepa-
rates the embeddings of IND and OOD data,
which leads to significant gains on the OOD
prediction task during testing. We extensively
evaluate our framework on three real-world di-
alogue systems, achieving new state-of-the-art
in OOD detection.
1 Introduction
Detecting Out-of-Distribution (
OOD
) (Goodfel-
low et al.,2014;Hendrycks and Gimpel,2016;
Yang et al.,2021) samples is vital for develop-
ing reliable machine learning systems for various
industry-scale applications of natural language un-
derstanding (NLP) (Shen et al.,2019;Sundarara-
man et al.,2020) including intent understanding
in conversational dialogues (Zheng et al.,2020;
Li et al.,2017), language translation (Denkowski
and Lavie,2011;Sundararaman et al.,2019), and
text classification (Aggarwal and Zhai,2012;Sun-
dararaman et al.,2022). For instance, a language
understanding model deployed to support a chat
system for medical inquiries should reliably de-
tect if the symptoms reported in a conversation
The authors contributed equally to this work
constitute an
OOD
query so that the model may
abstain from making incorrect diagnosis (Sied-
likowski et al.,2021).
Although
OOD
detection has attracted a great
deal of interest from the research commu-
nity (Goodfellow et al.,2014;Hendrycks and Gim-
pel,2017;Lee et al.,2018), these approaches are
not specifically designed to leverage the structure
of textual inputs. Consequently, commonly used
OOD
approaches often have limited success in real-
world NLP applications. Most prior
OOD
methods
for NLP systems (Larson et al.,2019;Chen and Yu,
2021;Kamath et al.,2020) typically assume addi-
tional
OOD
data for outlier exposure (Hendrycks
et al.,2018). However, such methods risk over-
fitting to the chosen OOD set, while making the
assumption that a relevant OOD set is available dur-
ing the training stage. Other methods (Gangal et al.,
2020;Li et al.,2021;Kamath et al.,2020) assume
training a calibration model, in addition to the clas-
sifier, for detecting
OOD
inputs. These methods
are computationally expensive as they often require
re-training the model on the downstream task.
Motivated by the above limitations, we propose
a framework called POsthoc pseudo Ood REgular-
ization (
POORE
) that generates pseudo-OOD data
using the trained classifier and the In-Distribution
(
IND
) samples. As opposed to methods that use
outlier exposure, our framework doesn’t rely on any
external OOD set. Moreover,
POORE
can be eas-
ily applied to already deployed large-scale models
trained on a classification task, without requiring
to re-train the classifier from scratch. In summary,
we make the following contributions:
1.
We propose a Mahalanobis-based context
masking scheme for generating pseudo-OOD
samples that can be used during the fine-
tuning.
2.
We introduce a new Pseudo Ood Regular-
ization (
POR
) loss that maximizes the dis-
arXiv:2210.09132v1 [cs.CL] 17 Oct 2022
tance between IND and generated pseudo-
OOD samples to improve the OOD detection.
3.
Though extensive experiments on the three
benchmarks, we show that our approach per-
forms significantly better than existing base-
lines.
2 Related Works
OOD Detection
. It is a binary classification
problem that seeks to identify unfamiliar inputs
during inference from in-distribution (
IND
)
data observed during training. Standard
OOD
methods can be divided into two categories. The
first category (Lee et al.,2018;Podolskiy et al.,
2021;Nalisnick et al.,2019;Ren et al.,2019)
corresponds to approximating a density
pI N D (x)
,
where density is used as a confidence estimate
for binary classification. The second category of
approaches (Hendrycks and Gimpel,2016,2017;
Li et al.,2017;Gal and Ghahramani,2016) use the
predictive probability to estimate the confidence
scores. In our experiments, we compare against
approaches from both the categories.
OOD Detection in NLP.
There have been several
methods developed for
OOD
detection in NLP. Li
et al. (2021) proposed using
k
sub models, where
each model is trained with different masked inputs.
Kamath et al. (2020) uses an external
OOD
set
to train an additional calibration model for
OOD
detection. Most related to our proposed frame-
work is MASKER (Moon et al.,2021) that lever-
ages
IND
data to generate pseudo-
OOD
samples,
and uses self-supervision loss inspired from Devlin
et al. (2018) and predictive entropy regularization
for pseudo-
OOD
inputs. We also use BERT self-
supervision inspired keyword masking, however,
we propose a novel keyword selection criterion.
Moreover, we also introduce a novel model regu-
larization loss that directly increases the distance
of IND and pseudo-OOD samples.
3 Preliminaries and Notations
We consider a deep learning model
gf(x)
composed of an encoder
f:X → F
and a
classifier
g
that maps
f(x)
to the output space,
where
x∈ X
corresponds to natural sentences
composed of a sequence of tokens
vi∈ V
,
i.e.
x= [v1, . . . , vT]
,
T
is the length of the sequence,
and
V
is the token vocabulary. For a downstream
classification task, the class prediction is defined
as p(y|x) = softmax (g(f((x))).
Architecture.
In this work, we construct
f
using the bi-directional Transformer architecture
(Vaswani et al.,2017). Specifically, we use the en-
coder architecture proposed in Devlin et al. (2018)
such that
f(x)
is the final hidden representation
of the CLS token. We use a two-layer multi-layer
perceptron (MLP) as the classifier g.
Mahalanobis OOD Scoring. OOD
methods typ-
ically learn a confidence estimator that outputs
a score
s(x)R
such that
s(xind)> s(xood)
,
where
xind
and
xood
are sampled from
IND
dis-
tribution (
DI N D
) and
OOD
distribution (
DOOD
)
respectively. Lee et al. (2018) proposed using Ma-
halanobis distance estimator for OOD detection
that uses pre-trained features of the softmax neural
classifier. Namely, given feature of a test sample
φ(x)
, the mahalanobis score
sM(x)
is computed
as follows
d(x, c) = (φ(x)ˆµc)Tˆ
Σ1(φ(x)ˆµc)(1)
sM(x) = min
cd(x, c)(2)
where
φ
is an intermediate layer of the neural clas-
sifier and
c
denotes the class. The parameters of
the estimator {ˆµc,ˆ
Σ}denote the class-conditional
mean and the tied covariance of the IND features.
4 Post hoc Pseudo-OOD Regularization
In this section, we describe our framework called
POsthoc pseudo Ood REgularization (
POORE
),
which uses pseudo-OOD samples for fine-tuning
a pre-trained classifier. We first describe our
masking-based approach to generate pseudo-OOD
samples from the
IND
samples available during
training. These generated pseudo-OOD samples
are used to regularize the encoder during post-hoc
training of a pre-trained classifier, which leads to
improved robustness of the model towards
OOD
samples.
4.1 Masking for Pseudo-OOD Generation
We perform context masking of
IND
samples for
generating pseudo OOD samples. To generate
context-masked pseudo
OOD
samples, we first
identify a set of tokens
v∈ K ⊂ V
that have
high attention scores and consequently, a higher
influence in model predictions. Given the set
of keywords, we perform random masking of
non-keywords in a given IND sample
x
to generate
摘要:

Pseudo-OODtrainingforrobustlanguagemodelsDhanasekarSundararaman1,NikhilMehta1,LawrenceCarin11DukeUniversity{ds448,nm208}@duke.eduAbstractWhilepre-trainedlarge-scaledeepmodelshavegarneredattentionasanimportanttopicformanydownstreamnaturallanguagepro-cessing(NLP)tasks,suchmodelsoftenmakeunreliablepr...

展开>> 收起<<
Pseudo-OOD training for robust language models Dhanasekar Sundararaman1 Nikhil Mehta1 Lawrence Carin1 1Duke University.pdf

共8页,预览2页

还剩页未读, 继续阅读

声明:本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。玖贝云文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知玖贝云文库,我们立即给予删除!
分类:图书资源 价格:10玖币 属性:8 页 大小:482.33KB 格式:PDF 时间:2025-05-02

开通VIP享超值会员特权

  • 多端同步记录
  • 高速下载文档
  • 免费文档工具
  • 分享文档赚钱
  • 每日登录抽奖
  • 优质衍生服务
/ 8
客服
关注