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
c2fcf688
Commit
c2fcf688
authored
May 31, 2023
by
gk
Browse files
Add MultipleChoiceExactTask
parent
095d8406
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
lm_eval/base.py
lm_eval/base.py
+15
-1
No files found.
lm_eval/base.py
View file @
c2fcf688
...
...
@@ -264,7 +264,7 @@ class BaseLM(LM):
_
,
context_enc
,
continuation_enc
=
re_ord
.
get_reordered
()[
0
]
max_context
=
len
((
context_enc
+
continuation_enc
)[
-
(
self
.
max_length
+
1
)
:][:
-
1
])
if
(
self
.
batch_size
==
'auto'
):
if
override_bs
is
None
:
print
(
'Passed argument batch_size = auto. Detecting largest batch size'
)
@
find_executable_batch_size
(
starting_batch_size
=
512
)
# if OOM, then halves batch_size and tries again
...
...
@@ -734,6 +734,20 @@ class MultipleChoiceTask(Task):
}
class
MultipleChoiceExactTask
(
MultipleChoiceTask
):
def
construct_requests
(
self
,
doc
,
ctx
):
return
rf
.
loglikelihood
(
ctx
,
self
.
doc_to_target
(
doc
))[
1
]
def
process_results
(
self
,
doc
,
results
):
return
{
"acc"
:
1.0
if
results
[
0
]
else
0.0
}
def
higher_is_better
(
self
):
return
{
"acc"
:
True
}
def
aggregation
(
self
):
return
{
"acc"
:
mean
}
class
PerplexityTask
(
Task
,
abc
.
ABC
):
def
should_decontaminate
(
self
):
"""Whether this task supports decontamination against model training set."""
...
...
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