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
d7c08d5b
Commit
d7c08d5b
authored
Feb 04, 2021
by
Leo Gao
Browse files
Convert SAT to use MultipleChoiceTask
parent
2f5f42c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
34 deletions
+3
-34
lm_eval/tasks/sat.py
lm_eval/tasks/sat.py
+3
-34
No files found.
lm_eval/tasks/sat.py
View file @
d7c08d5b
...
@@ -61,8 +61,8 @@ class SATAnalogies(Task):
...
@@ -61,8 +61,8 @@ class SATAnalogies(Task):
doc
=
{
doc
=
{
'source'
:
source
,
'source'
:
source
,
'query'
:
query
.
split
(
' '
)[:
2
],
'query'
:
query
.
split
(
' '
)[:
2
],
'choices'
:
[
c
.
split
(
' '
)[:
2
]
for
c
in
choices
],
'choices'
:
[
" {} is to {}"
.
format
(
*
c
.
split
(
' '
)[:
2
]
)
for
c
in
choices
],
'
answer_key
'
:
[
'a'
,
'b'
,
'c'
,
'd'
,
'e'
].
index
(
answer_key
.
strip
()),
'
gold
'
:
[
'a'
,
'b'
,
'c'
,
'd'
,
'e'
].
index
(
answer_key
.
strip
()),
}
}
yield
doc
yield
doc
...
@@ -72,35 +72,4 @@ class SATAnalogies(Task):
...
@@ -72,35 +72,4 @@ class SATAnalogies(Task):
return
""
return
""
def
doc_to_text
(
self
,
doc
):
def
doc_to_text
(
self
,
doc
):
return
"{} is to {} as "
.
format
(
*
doc
[
'query'
])
return
"{} is to {} as"
.
format
(
*
doc
[
'query'
])
def
doc_to_target
(
self
,
doc
):
return
"{} is to {}"
.
format
(
*
doc
[
'choices'
][
doc
[
'answer_key'
]])
def
construct_requests
(
self
,
doc
,
ctx
):
lls
=
[
rf
.
loglikelihood
(
ctx
,
"{} is to {}"
.
format
(
*
doc
[
'choices'
][
i
]))[
0
]
for
i
in
range
(
5
)
]
return
lls
def
process_results
(
self
,
doc
,
results
):
gold
=
doc
[
"answer_key"
]
acc
=
1.
if
np
.
argmax
(
results
)
==
gold
else
0.
return
{
"acc"
:
acc
}
def
higher_is_better
(
self
):
return
{
"acc"
:
True
}
def
aggregation
(
self
):
return
{
"acc"
:
mean
}
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