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
8335e43a
Commit
8335e43a
authored
Sep 17, 2024
by
Baber
Browse files
add batch_size to `get_sample_size`
parent
fb963f0f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
lm_eval/evaluator.py
lm_eval/evaluator.py
+1
-1
lm_eval/evaluator_utils.py
lm_eval/evaluator_utils.py
+11
-1
No files found.
lm_eval/evaluator.py
View file @
8335e43a
...
@@ -436,7 +436,7 @@ def evaluate(
...
@@ -436,7 +436,7 @@ def evaluate(
for
task_output
in
eval_tasks
:
for
task_output
in
eval_tasks
:
task
:
Task
=
task_output
.
task
task
:
Task
=
task_output
.
task
limit
=
get_sample_size
(
task
,
limit
)
limit
=
get_sample_size
(
task
,
limit
,
getattr
(
lm
,
"batch_size"
,
None
)
)
task
.
build_all_requests
(
task
.
build_all_requests
(
limit
=
limit
,
limit
=
limit
,
rank
=
lm
.
rank
,
rank
=
lm
.
rank
,
...
...
lm_eval/evaluator_utils.py
View file @
8335e43a
...
@@ -4,6 +4,8 @@ import pathlib
...
@@ -4,6 +4,8 @@ import pathlib
import
sys
import
sys
from
typing
import
List
,
Optional
,
Tuple
,
Union
from
typing
import
List
,
Optional
,
Tuple
,
Union
from
pandas.core.dtypes.inference
import
is_float
from
lm_eval.api.group
import
ConfigurableGroup
from
lm_eval.api.group
import
ConfigurableGroup
from
lm_eval.api.metrics
import
(
from
lm_eval.api.metrics
import
(
aggregate_subtask_metrics
,
aggregate_subtask_metrics
,
...
@@ -200,8 +202,16 @@ def print_writeout(task) -> None:
...
@@ -200,8 +202,16 @@ def print_writeout(task) -> None:
eval_logger
.
info
(
f
"Request:
{
str
(
inst
)
}
"
)
eval_logger
.
info
(
f
"Request:
{
str
(
inst
)
}
"
)
def
get_sample_size
(
task
,
limit
:
Optional
[
int
])
->
Union
[
int
,
None
]:
def
get_sample_size
(
task
,
limit
:
Optional
[
int
],
batch_size
:
Optional
[
int
]
)
->
Union
[
int
,
None
]:
if
limit
is
not
None
:
if
limit
is
not
None
:
if
batch_size
is
not
None
and
is_float
(
limit
)
and
limit
==
1.0
:
eval_logger
.
warning
(
"Limit is 1.0, adjusting the sample size to be a multiple of the batch size"
)
return
(
len
(
task
.
eval_docs
)
//
batch_size
)
*
batch_size
elif
limit
is
not
None
:
limit
=
(
limit
=
(
int
(
math
.
ceil
(
len
(
task
.
eval_docs
)
*
limit
))
if
limit
<
1.0
else
int
(
limit
)
int
(
math
.
ceil
(
len
(
task
.
eval_docs
)
*
limit
))
if
limit
<
1.0
else
int
(
limit
)
)
)
...
...
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