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
629bcfba
Commit
629bcfba
authored
May 05, 2023
by
Benjamin Fattori
Browse files
bugfixes missed from local branch
parent
09e91431
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
13 deletions
+15
-13
lm_eval/evaluator.py
lm_eval/evaluator.py
+1
-1
lm_eval/models/gpt2.py
lm_eval/models/gpt2.py
+3
-0
main.py
main.py
+11
-12
No files found.
lm_eval/evaluator.py
View file @
629bcfba
...
@@ -200,7 +200,7 @@ def evaluate(
...
@@ -200,7 +200,7 @@ def evaluate(
# calculate values for each filter setup (TODO: make getting list of keys cleaner)
# calculate values for each filter setup (TODO: make getting list of keys cleaner)
# TODO: make it possible to use a different metric per key
# TODO: make it possible to use a different metric per key
for
key
in
task
.
instances
[
0
].
filtered_resps
.
keys
():
for
key
in
task
.
instances
[
0
].
filtered_resps
.
keys
():
for
doc_id
,
doc
in
enumerate
(
itertools
.
islice
(
task
.
test_docs
(),
0
,
limit
)
if
task
.
has_test_docs
()
else
task
.
validation_docs
()
):
for
doc_id
,
doc
in
itertools
.
islice
(
enumerate
(
task
.
test_docs
()
)
,
lm
.
rank
,
None
,
lm
.
world_size
)
if
task
.
has_test_docs
()
else
itertools
.
islice
(
enumerate
(
task
.
validation_docs
()),
lm
.
rank
,
None
,
lm
.
world_size
):
# subset instances to only this document id ; sort by idx
# subset instances to only this document id ; sort by idx
requests
=
list
(
filter
(
lambda
x
:
x
.
doc_id
==
doc_id
,
task
.
instances
))
requests
=
list
(
filter
(
lambda
x
:
x
.
doc_id
==
doc_id
,
task
.
instances
))
requests
.
sort
(
key
=
lambda
x
:
x
.
idx
)
requests
.
sort
(
key
=
lambda
x
:
x
.
idx
)
...
...
lm_eval/models/gpt2.py
View file @
629bcfba
...
@@ -45,6 +45,9 @@ class HFLM(LM):
...
@@ -45,6 +45,9 @@ class HFLM(LM):
else
torch
.
device
(
"cpu"
)
else
torch
.
device
(
"cpu"
)
)
)
else
:
self
.
_device
=
'cpu'
# TODO: update this to be less of a hack once subfolder is fixed in HF
# TODO: update this to be less of a hack once subfolder is fixed in HF
revision
=
revision
+
(
"/"
+
subfolder
if
subfolder
is
not
None
else
""
)
revision
=
revision
+
(
"/"
+
subfolder
if
subfolder
is
not
None
else
""
)
...
...
main.py
View file @
629bcfba
...
@@ -89,19 +89,18 @@ def main():
...
@@ -89,19 +89,18 @@ def main():
print
(
f
"Selected Tasks:
{
task_names
}
"
)
print
(
f
"Selected Tasks:
{
task_names
}
"
)
results
=
evaluator
.
simple_evaluate
(
model
=
args
.
model
,
model_args
=
args
.
model_args
,
tasks
=
task_names
,
num_fewshot
=
args
.
num_fewshot
,
batch_size
=
args
.
batch_size
,
device
=
args
.
device
,
limit
=
args
.
limit
,
decontamination_ngrams_path
=
args
.
decontamination_ngrams_path
,
check_integrity
=
args
.
check_integrity
,
)
if
results
is
not
None
:
if
results
is
not
None
:
results
=
evaluator
.
simple_evaluate
(
model
=
args
.
model
,
model_args
=
args
.
model_args
,
tasks
=
task_names
,
num_fewshot
=
args
.
num_fewshot
,
batch_size
=
args
.
batch_size
,
device
=
args
.
device
,
limit
=
args
.
limit
,
decontamination_ngrams_path
=
args
.
decontamination_ngrams_path
,
check_integrity
=
args
.
check_integrity
,
)
dumped
=
json
.
dumps
(
results
,
indent
=
2
)
dumped
=
json
.
dumps
(
results
,
indent
=
2
)
print
(
dumped
)
print
(
dumped
)
...
...
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