Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
lm-evaluation-harness
Commits
682e5c44
Commit
682e5c44
authored
Dec 23, 2021
by
thomasw21
Browse files
FIX wnli
parent
134150a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
lm_eval/tasks/glue.py
lm_eval/tasks/glue.py
+6
-7
No files found.
lm_eval/tasks/glue.py
View file @
682e5c44
...
@@ -241,26 +241,25 @@ class WNLI(HFTask):
...
@@ -241,26 +241,25 @@ class WNLI(HFTask):
return
False
return
False
def
doc_to_text
(
self
,
doc
):
def
doc_to_text
(
self
,
doc
):
return
"{}
\n
Question: {} True
,
False
or Neither
?
\n
Answer:"
.
format
(
return
"{}
\n
Question: {} True
or
False?
\n
Answer:"
.
format
(
doc
[
"sentence1"
],
doc
[
"sentence1"
],
doc
[
"sentence2"
],
doc
[
"sentence2"
],
)
)
def
doc_to_target
(
self
,
doc
):
def
doc_to_target
(
self
,
doc
):
# True = entailment
# True = entailment
# False = contradiction
# False = not_entailment
# Neither = neutral
return
" {}"
.
format
({
0
:
"False"
,
1
:
"True"
}[
doc
[
"label"
]])
return
" {}"
.
format
({
0
:
"True"
,
1
:
"Neither"
,
2
:
"False"
}[
doc
[
"label"
]])
def
construct_requests
(
self
,
doc
,
ctx
):
def
construct_requests
(
self
,
doc
,
ctx
):
ll_true
,
_
=
rf
.
loglikelihood
(
ctx
,
" True"
)
ll_true
,
_
=
rf
.
loglikelihood
(
ctx
,
" True"
)
ll_neither
,
_
=
rf
.
loglikelihood
(
ctx
,
" Neither"
)
ll_false
,
_
=
rf
.
loglikelihood
(
ctx
,
" False"
)
ll_false
,
_
=
rf
.
loglikelihood
(
ctx
,
" False"
)
return
ll_true
,
ll_neither
,
ll_false
return
ll_true
,
ll_false
def
process_results
(
self
,
doc
,
results
):
def
process_results
(
self
,
doc
,
results
):
ll_true
,
ll_false
=
results
pred
=
ll_true
>
ll_false
gold
=
doc
[
"label"
]
gold
=
doc
[
"label"
]
pred
=
np
.
argmax
(
results
)
return
{
return
{
"acc"
:
pred
==
gold
"acc"
:
pred
==
gold
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment