Large language model evaluation with enhanced interpretability by k-nearest neighbor search
Abstract
Techniques for fine-tuning free evaluation of large language models with enhanced interpretability using a debiased output probability distribution of a large language model and a probability distribution of a k-Nearest Neighbor search result are provided. In one aspect, a method for performing a downstream task with a language model includes: constructing a datastore by applying the language model to a training set; applying the language model to a prompt-applied sentence from a testing set to obtain a language model feature vector; performing a k-Nearest Neighbor search of the datastore using the language model feature vector as a query vector; and interpolating a probability distribution of results from the k-Nearest Neighbor search and an output probability distribution of the language model to obtain a prediction for the downstream task.
Claims
exact text as granted — not AI-modifiedWhat is claimed is:
1 . A method for performing a downstream task with a language model, the method comprising:
obtaining a dataset for the downstream task, the dataset comprising at least a training set and a testing set; constructing a datastore by applying the language model to the training set, the datastore comprising a set of triplets with each triplet including an instance x train from the training set, a label y′, and a feature vector h train , and wherein the feature vector h train corresponds to a masked token in the sentence x train ; applying the language model to a prompt-applied sentence prompt(x) from an instance x in the testing set to predict a label y and a large language model feature vector h LLM (prompt(x)); computing an output probability distribution P LM of the language model; debiasing the output probability distribution P LM of the language model to obtain a debiased output probability distribution {circumflex over (p)} debiasedLM ; performing a k-Nearest Neighbor search of the datastore using the feature vector h LLM prompt(x)) as a query vector to find k-Nearest Neighbors N; computing a probability distribution {circumflex over (p)} kNN of results from the k-Nearest Neighbor search, wherein {circumflex over (p)} kNN is computed as:
p
^
kNN
=
1
❘
"\[LeftBracketingBar]"
𝒩
❘
"\[RightBracketingBar]"
∑
(
_
,
y
′
,
h
train
)
∈
𝒩
y
=
y
′
exp
(
-
h
train
-
h
LM
(
prompt
(
x
)
)
T
)
using
T
as a scaling hyperparameter;
interpolating the debiased output probability distribution {circumflex over (p)} debiasedLM and the probability distribution {circumflex over (p)} kNN to obtain a final prediction {circumflex over (p)}(y|prompt(x)) for the downstream task; and
outputting the results from the k-Nearest Neighbor search to explain the final prediction of the language model.
2 . The method of claim 1 , wherein parameters of the language model are frozen.
3 . The method of claim 1 , further comprising:
extracting an instance x from the testing set; and applying a prompt to the instance x to obtain the prompt-applied sentence prompt(x).
4 . The method of claim 1 , wherein the label y is predicted from a pre-defined label set Y.
5 . The method of claim 4 , wherein the output probability distribution P LM is computed over a vocabulary V as P LM (y∈V|prompt(x)).
6 . The method of claim 1 , wherein {circumflex over (p)} debiasedLM =W debias P LM (y∈V|prompt(x)), wherein W debias =diag({circumflex over (p)} cf ) −1 in which diag(v) is a function that returns a diagonal matrix of v, and wherein {circumflex over (p)} cf is computed from {circumflex over (p)} cf =1/C Σc=1 C P LM (y|prompt(context c )) by giving different input texts prompt(context c )) to the language model where context c is context-free input.
7 . The method of claim 1 , wherein k is a number of instances, and wherein k∈{0,1,4,8}.
8 . The method of claim 1 , wherein {circumflex over (p)}(y|prompt(x))=λ*{circumflex over (p)} debiasedLM + (1−λ)*{circumflex over (p)} kNN , and wherein λ∈[0,1].
9 . A computer program product for performing a downstream task with a language model, the computer program product comprising a computer readable storage medium having program instructions embodied therewith, the program instructions executable by a computer to cause the computer to perform:
obtaining a dataset for the downstream task, the dataset comprising at least a training set and a testing set; constructing a datastore by applying the language model to the training set, the datastore comprising a set of triplets with each triplet including an instance x train from the training set, a label y′, and a feature vector h train , and wherein the feature vector h train corresponds to a masked token in the sentence x train ; applying the language model to a prompt-applied sentence prompt(x) from an instance x in the testing set to predict a label y and a large language model feature vector h LLM (prompt(x)); computing an output probability distribution P LM of the language model; debiasing the output probability distribution P LM of the language model to obtain a debiased output probability distribution {circumflex over (p)} debiasedLM ; performing a k-Nearest Neighbor search of the datastore using the feature vector h LLM (prompt(x)) as a query vector to find k-Nearest Neighbors N; computing a probability distribution {circumflex over (p)} kNN of results from the k-Nearest Neighbor search, wherein {circumflex over (p)} kNN is computed as:
p
^
kNN
=
1
❘
"\[LeftBracketingBar]"
N
❘
"\[RightBracketingBar]"
∑
(
_
,
y
′
,
h
train
)
∈
N
y
=
y
′
exp
(
-
h
train
-
h
LM
(
prompt
(
x
)
)
T
)
using T as a scaling hyperparameter;
interpolating the debiased output probability distribution {circumflex over (p)} debiasedLM and the probability distribution {circumflex over (p)} kNN to obtain a final prediction {circumflex over (p)}(y|prompt(x)) for the downstream task; and
outputting the results from the k-Nearest Neighbor search to explain the final prediction of the language model.
10 . The computer program product of claim 9 , wherein parameters of the language model are frozen.
11 . A system for performing a downstream task with a language model comprising a processor, connected to a memory, operable to perform:
obtaining a dataset for the downstream task, the dataset comprising at least a training set and a testing set; constructing a datastore by applying the language model to the training set, the datastore comprising a set of triplets with each triplet including an instance x train from the training set, a label y′, and a feature vector h train , and wherein the feature vector h train corresponds to a masked token in the sentence x train ; applying the language model to a prompt-applied sentence prompt(x) from an instance x in the testing set to predict a label y and a large language model feature vector h LLM (prompt(x)); computing an output probability distribution P LM of the language model; debiasing the output probability distribution P LM of the language model to obtain a debiased output probability distribution {circumflex over (p)} debiasedLM ; performing a k-Nearest Neighbor search of the datastore using the feature vector h LLM (prompt(x)) as a query vector to find k-Nearest Neighbors N; computing a probability distribution {circumflex over (p)} kNN of results from the k-Nearest Neighbor search, wherein {circumflex over (p)} kNN is computed as:
p
^
kNN
=
1
❘
"\[LeftBracketingBar]"
N
❘
"\[RightBracketingBar]"
∑
(
_
,
y
′
,
h
train
)
∈
N
y
=
y
′
exp
(
-
h
train
-
h
LM
(
prompt
(
x
)
)
T
)
using T as a scaling hyperparameter;
interpolating the debiased output probability distribution {circumflex over (p)} debiasedLM and the probability distribution {circumflex over (p)} kNN to obtain a final prediction {circumflex over (p)}(y|prompt(x)) for the downstream task; and
outputting the results from the k-Nearest Neighbor search to explain the final prediction of the language model.
12 . The computer program product of claim 9 , further comprising:
extracting an instance x from the testing set; and applying a prompt to the instance x to obtain the prompt-applied sentence prompt(x).
13 . The computer program product of claim 9 , wherein the label y is predicted from a pre-defined label set Y.
14 . The computer program product of claim 13 , wherein the output probability distribution P LM is computed over a vocabulary V as P LM (y=V prompt(x)).
15 . The computer program product of claim 9 , wherein {circumflex over (p)} debiasedLM =W debias P LM (y∈V|prompt(x)), wherein W debias =diag({circumflex over (p)} cf ) −1 in which diag(v) is a function that returns a diagonal matrix of v, and wherein {circumflex over (p)} cf is computed from {circumflex over (p)} cf =1/C Σc=1 C P LM (y|prompt(context c )) by giving different input texts prompt(context c )) to the language model where context c is context-free input.
16 . The computer program product of claim 9 , wherein k is a number of instances, and wherein k∈{0, 1, 4, 8}.
17 . The computer program product of claim 9 , wherein {circumflex over (p)}(y|prompt(x))=λ*{circumflex over (p)} debiasedLM +(1−λ)*{circumflex over (p)} kNN , and wherein λ∈[0,1].
18 . The system of claim 11 , wherein parameters of the language model are frozen.
19 . The system of claim 11 , further comprising:
extracting an instance x from the testing set; and applying a prompt to the instance x to obtain the prompt-applied sentence prompt(x).
20 . The system of claim 11 , wherein the label y is predicted from a pre-defined label set Y.
21 . The system of claim 20 , wherein the output probability distribution P LM is computed over a vocabulary V as P LM (y∈V|prompt(x)).
22 . The system of claim 11 , wherein {circumflex over (p)} debiasedLM =W debias P LM (y∈V|prompt(x)), wherein W debias =diag ({circumflex over (p)} cf ) −1 in which diag(v) is a function that returns a diagonal matrix of v, and wherein {circumflex over (p)} cf is computed from {circumflex over (p)} cf =1/C Σc=1 C P LM (y|prompt(context c )) by giving different input texts prompt(context c ) to the language model where context c is context-free input.
23 . The system of claim 11 , wherein k is a number of instances, and wherein k∈{0,1,4,8}.
24 . The system of claim 11 , wherein {circumflex over (p)}(y|prompt(x))=λ*{circumflex over (p)} debiasedLM +(1−λ)*{circumflex over (p)} kNN , and wherein λ∈[0,1].Cited by (0)
No later patents cite this yet.
References (0)
No backward citations on record.