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
5a973941
Commit
5a973941
authored
Aug 16, 2023
by
lintangsutawika
Browse files
reformat
parent
9e9327bc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
29 deletions
+33
-29
lm_eval/api/task.py
lm_eval/api/task.py
+1
-1
lm_eval/tasks/mgsm/README.md
lm_eval/tasks/mgsm/README.md
+1
-1
lm_eval/tasks/mgsm/utils.py
lm_eval/tasks/mgsm/utils.py
+31
-27
No files found.
lm_eval/api/task.py
View file @
5a973941
...
@@ -1010,7 +1010,7 @@ class ConfigurableTask(Task):
...
@@ -1010,7 +1010,7 @@ class ConfigurableTask(Task):
gold
=
self
.
doc_to_target
(
doc
)
gold
=
self
.
doc_to_target
(
doc
)
if
self
.
_config
.
doc_to_choice
is
not
None
:
if
self
.
_config
.
doc_to_choice
is
not
None
:
# If you set doc_to_choice,
# If you set doc_to_choice,
# it assumes that doc_to_target returns a number.
# it assumes that doc_to_target returns a number.
choices
=
self
.
doc_to_choice
(
doc
)
choices
=
self
.
doc_to_choice
(
doc
)
gold
=
choices
[
gold
]
gold
=
choices
[
gold
]
...
...
lm_eval/tasks/mgsm/README.md
View file @
5a973941
...
@@ -71,4 +71,4 @@ For adding novel benchmarks/datasets to the library:
...
@@ -71,4 +71,4 @@ For adding novel benchmarks/datasets to the library:
If other tasks on this dataset are already supported:
If other tasks on this dataset are already supported:
*
[ ] Is the "Main" variant of this task clearly denoted?
*
[ ] Is the "Main" variant of this task clearly denoted?
*
[ ] Have you provided a short sentence in a README on what each new variant adds / evaluates?
*
[ ] Have you provided a short sentence in a README on what each new variant adds / evaluates?
*
[ ] Have you noted which, if any, published evaluation setups are matched by this variant?
*
[ ] Have you noted which, if any, published evaluation setups are matched by this variant?
\ No newline at end of file
lm_eval/tasks/mgsm/utils.py
View file @
5a973941
...
@@ -71,26 +71,27 @@ LANGUAGES = {
...
@@ -71,26 +71,27 @@ LANGUAGES = {
},
},
}
}
def
add_regex_pattern
(
regex_pattern
):
def
add_regex_pattern
(
regex_pattern
):
if
regex_pattern
is
None
:
if
regex_pattern
is
None
:
return
{}
return
{}
return
{
return
{
"filter_list"
:
[
"filter_list"
:
[
{
{
"name"
:
"get-answer"
,
"name"
:
"get-answer"
,
},
},
],
],
"filter"
:
[
"filter"
:
[
{
{
"function"
:
"regex"
,
"function"
:
"regex"
,
"regex_pattern"
:
regex_pattern
,
"regex_pattern"
:
regex_pattern
,
},
},
{
{
"function"
:
"take_first"
,
"function"
:
"take_first"
,
},
},
],
],
}
}
def
gen_lang_yamls
(
output_dir
:
str
,
overwrite
:
bool
,
mode
:
str
)
->
None
:
def
gen_lang_yamls
(
output_dir
:
str
,
overwrite
:
bool
,
mode
:
str
)
->
None
:
...
@@ -132,17 +133,17 @@ def gen_lang_yamls(output_dir: str, overwrite: bool, mode: str) -> None:
...
@@ -132,17 +133,17 @@ def gen_lang_yamls(output_dir: str, overwrite: bool, mode: str) -> None:
"include"
:
yaml_template
,
"include"
:
yaml_template
,
"dataset_name"
:
lang
,
"dataset_name"
:
lang
,
"task"
:
f
"mgsm_
{
lang
}
_direct"
,
"task"
:
f
"mgsm_
{
lang
}
_direct"
,
"doc_to_text"
:
f
"""{{% if answer is not none %}}"""
\
"doc_to_text"
:
f
"""{{% if answer is not none %}}"""
f
"""{{{{question+"
\\
n
{
ANSWER
}
"}}}}"""
\
f
"""{{{{question+"
\\
n
{
ANSWER
}
"}}}}"""
f
"""{{% else %}}"""
\
f
"""{{% else %}}"""
f
"""{{{{"
{
QUESTION
}
"+question+"
\\
n
{
ANSWER
}
"}}}}"""
\
f
"""{{{{"
{
QUESTION
}
"+question+"
\\
n
{
ANSWER
}
"}}}}"""
f
"""{{% endif %}}"""
,
f
"""{{% endif %}}"""
,
"doc_to_target"
:
f
"""{{% if answer is not none %}}"""
\
"doc_to_target"
:
f
"""{{% if answer is not none %}}"""
f
"""{{{{answer[
{
len
(
ANSWER
)
}
+1]}}}}"""
\
f
"""{{{{answer[
{
len
(
ANSWER
)
}
+1]}}}}"""
f
"""{{% else %}}"""
\
f
"""{{% else %}}"""
f
"""{{{{answer_number|string}}}}"""
\
f
"""{{{{answer_number|string}}}}"""
f
"""{{% endif %}}"""
,
f
"""{{% endif %}}"""
,
**
filter_list
**
filter_list
,
},
},
f
,
f
,
allow_unicode
=
True
,
allow_unicode
=
True
,
...
@@ -170,7 +171,10 @@ def main() -> None:
...
@@ -170,7 +171,10 @@ def main() -> None:
"--output-dir"
,
default
=
"."
,
help
=
"Directory to write yaml files to"
"--output-dir"
,
default
=
"."
,
help
=
"Directory to write yaml files to"
)
)
parser
.
add_argument
(
parser
.
add_argument
(
"--mode"
,
default
=
"native-cot"
,
choices
=
[
"direct"
,
"native-cot"
,
"en-cot"
],
help
=
"Mode of chain-of-thought"
"--mode"
,
default
=
"native-cot"
,
choices
=
[
"direct"
,
"native-cot"
,
"en-cot"
],
help
=
"Mode of chain-of-thought"
,
)
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
...
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