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
624c038e
Commit
624c038e
authored
Feb 14, 2021
by
Leo Gao
Browse files
Shuffle order of docs in evaluator
parent
ea08242e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
lm_eval/evaluator.py
lm_eval/evaluator.py
+9
-2
No files found.
lm_eval/evaluator.py
View file @
624c038e
import
collections
import
itertools
import
random
def
evaluate
(
lm
,
task_dict
,
provide_description
,
num_fewshot
,
limit
):
...
...
@@ -29,7 +30,13 @@ def evaluate(lm, task_dict, provide_description, num_fewshot, limit):
elif
task
.
has_test_docs
():
task_doc_func
=
task
.
test_docs
for
doc_id
,
doc
in
enumerate
(
itertools
.
islice
(
task_doc_func
(),
0
,
limit
)):
# deterministically shuffle docs and chop off the first `limit` because sometimes docs are in some kind of order
task_docs
=
list
(
task_doc_func
())
rnd
=
random
.
Random
()
rnd
.
seed
(
42
)
rnd
.
shuffle
(
docs
)
for
doc_id
,
doc
in
enumerate
(
itertools
.
islice
(
task_docs
,
0
,
limit
)):
docs
[(
task_name
,
doc_id
)]
=
doc
ctx
=
task
.
fewshot_context
(
...
...
@@ -40,7 +47,7 @@ def evaluate(lm, task_dict, provide_description, num_fewshot, limit):
reqs
=
task
.
construct_requests
(
doc
,
ctx
)
if
not
isinstance
(
reqs
,
(
list
,
tuple
)):
reqs
=
[
reqs
]
for
i
,
req
in
enumerate
(
reqs
):
requests
[
req
.
type
].
append
(
req
)
# i: index in requests for a single task instance
...
...
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