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
0aa37743
Unverified
Commit
0aa37743
authored
Sep 22, 2023
by
Hailey Schoelkopf
Committed by
GitHub
Sep 22, 2023
Browse files
Merge pull request #880 from EleutherAI/hotfixes
[Refactor] Hotfixes to big-refactor
parents
265a7cde
d98159b2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
3 deletions
+22
-3
lm_eval/api/task.py
lm_eval/api/task.py
+2
-0
lm_eval/tasks/minerva_math/utils.py
lm_eval/tasks/minerva_math/utils.py
+9
-2
lm_eval/utils.py
lm_eval/utils.py
+11
-1
No files found.
lm_eval/api/task.py
View file @
0aa37743
...
@@ -632,6 +632,8 @@ class ConfigurableTask(Task):
...
@@ -632,6 +632,8 @@ class ConfigurableTask(Task):
if
self
.
fewshot_docs
()
is
not
None
:
if
self
.
fewshot_docs
()
is
not
None
:
self
.
sampler
=
samplers
.
get_sampler
(
self
.
sampler
=
samplers
.
get_sampler
(
self
.
config
.
fewshot_config
.
get
(
"sampler"
,
"default"
)
self
.
config
.
fewshot_config
.
get
(
"sampler"
,
"default"
)
if
self
.
config
.
fewshot_config
else
"default"
)(
list
(
self
.
fewshot_docs
()),
self
,
rnd
=
random
.
Random
(
1234
))
)(
list
(
self
.
fewshot_docs
()),
self
,
rnd
=
random
.
Random
(
1234
))
if
self
.
has_test_docs
():
if
self
.
has_test_docs
():
...
...
lm_eval/tasks/minerva_math/utils.py
View file @
0aa37743
import
datasets
import
datasets
import
re
import
re
import
sympy
from
sympy.parsing.latex
import
parse_latex
import
signal
import
signal
from
lm_eval.logger
import
eval_logger
from
lm_eval.logger
import
eval_logger
from
typing
import
Optional
,
List
,
Dict
from
typing
import
Optional
,
List
,
Dict
try
:
import
sympy
from
sympy.parsing.latex
import
parse_latex
except
ModuleNotFoundError
:
raise
Exception
(
"`sympy` is required for generating translation task prompt templates.
\
please install sympy via pip install lm-eval[math] or pip install -e .[math]"
,
)
# taken from
# taken from
# https://github.com/wellecks/lm-evaluation-harness/blob/master/lm_eval/tasks/minerva_math.py
# https://github.com/wellecks/lm-evaluation-harness/blob/master/lm_eval/tasks/minerva_math.py
...
...
lm_eval/utils.py
View file @
0aa37743
...
@@ -45,6 +45,14 @@ def escaped_split(text, sep_char, maxsplit=-1):
...
@@ -45,6 +45,14 @@ def escaped_split(text, sep_char, maxsplit=-1):
return
re
.
split
(
r
"(?<!\\)"
+
sep_char
,
text
,
maxsplit
)
return
re
.
split
(
r
"(?<!\\)"
+
sep_char
,
text
,
maxsplit
)
def
handle_arg_string
(
arg
):
if
arg
.
lower
()
==
"true"
:
return
True
elif
arg
.
lower
()
==
"false"
:
return
False
return
arg
def
simple_parse_args_string
(
args_string
):
def
simple_parse_args_string
(
args_string
):
"""
"""
Parses something like
Parses something like
...
@@ -55,7 +63,9 @@ def simple_parse_args_string(args_string):
...
@@ -55,7 +63,9 @@ def simple_parse_args_string(args_string):
if
not
args_string
:
if
not
args_string
:
return
{}
return
{}
arg_list
=
[
arg
for
arg
in
args_string
.
split
(
","
)
if
arg
]
arg_list
=
[
arg
for
arg
in
args_string
.
split
(
","
)
if
arg
]
args_dict
=
{
k
:
v
for
k
,
v
in
[
arg
.
split
(
"="
)
for
arg
in
arg_list
]}
args_dict
=
{
k
:
handle_arg_string
(
v
)
for
k
,
v
in
[
arg
.
split
(
"="
)
for
arg
in
arg_list
]
}
return
args_dict
return
args_dict
...
...
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