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
e75fd298
Commit
e75fd298
authored
Aug 28, 2023
by
lintangsutawika
Browse files
fix typos
parent
d1ce515a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletion
+45
-1
lm_eval/filters/__init__.py
lm_eval/filters/__init__.py
+1
-0
lm_eval/filters/extraction.py
lm_eval/filters/extraction.py
+42
-0
lm_eval/tasks/model_written_evals/persona/template_yaml
lm_eval/tasks/model_written_evals/persona/template_yaml
+2
-1
No files found.
lm_eval/filters/__init__.py
View file @
e75fd298
...
@@ -9,6 +9,7 @@ FILTER_REGISTRY = {
...
@@ -9,6 +9,7 @@ FILTER_REGISTRY = {
"majority_vote"
:
selection
.
MajorityVoteFilter
,
"majority_vote"
:
selection
.
MajorityVoteFilter
,
"take_first_k"
:
selection
.
TakeKFilter
,
"take_first_k"
:
selection
.
TakeKFilter
,
"remove_whitespace"
:
extraction
.
WhitespaceFilter
,
"remove_whitespace"
:
extraction
.
WhitespaceFilter
,
"cot_filter"
:
extraction
.
CoTFilter
,
# TODO: implement this filter. either it should take in an arbitrary "scoring"/reward function
# TODO: implement this filter. either it should take in an arbitrary "scoring"/reward function
# that takes an input and returns a scalar and then should select the max reward,
# that takes an input and returns a scalar and then should select the max reward,
# or should implement different filters for different ways of handling a reward model's inference.
# or should implement different filters for different ways of handling a reward model's inference.
...
...
lm_eval/filters/extraction.py
View file @
e75fd298
...
@@ -59,3 +59,45 @@ class WhitespaceFilter(Filter):
...
@@ -59,3 +59,45 @@ class WhitespaceFilter(Filter):
filtered_resps
=
[
filter_set
(
resp
)
for
resp
in
resps
]
filtered_resps
=
[
filter_set
(
resp
)
for
resp
in
resps
]
return
filtered_resps
return
filtered_resps
class
CoTFilter
(
Filter
):
""" """
def
__init__
(
self
):
pass
def
apply
(
self
,
resps
):
def
filter_set
(
inst
):
filtered_resp
=
[]
for
resp
in
inst
:
resp
=
resp
.
strip
()
if
resp
[
-
1
]
in
[
"."
,
","
,
"?"
,
" "
,
"
\n
"
]:
resp
=
resp
[:
-
1
].
strip
()
if
resp
[
0
]
==
"("
and
resp
[
-
1
]
==
")"
:
resp
=
resp
[
1
:
-
1
].
strip
()
return
resp
else
:
resp
=
resp
.
split
(
"resp is"
)[
-
1
].
strip
()
resp
=
resp
.
split
(
"final resp"
)[
-
1
].
strip
()
resp
=
resp
.
split
(
"Final resp"
)[
-
1
].
strip
()
resp
=
resp
.
split
(
"resp:"
)[
-
1
].
strip
()
resp
=
resp
.
split
(
"resp:"
)[
-
1
].
strip
()
if
resp
and
resp
[
0
]
in
[
"."
,
","
,
"?"
,
" "
,
"
\n
"
,
":"
]:
resp
=
resp
[
1
:].
strip
()
if
resp
and
resp
[
-
1
]
in
[
"."
,
","
,
"?"
,
" "
,
"
\n
"
,
":"
]:
resp
=
resp
[:
-
1
].
strip
()
# corner case 2: is prediction is (B), should processed into B.
if
resp
and
resp
[
0
]
==
"("
and
resp
[
-
1
]
==
")"
:
resp
=
resp
[
1
:
-
1
].
strip
()
filtered_resp
.
append
(
resp
)
return
filtered_resp
filtered_resps
=
[
filter_set
(
resp
)
for
resp
in
resps
]
return
filtered_resps
lm_eval/tasks/model_written_evals/persona/template_yaml
View file @
e75fd298
group: persona
group: persona
dataset_path: lm_eval.datasets.model_written_evals.persona
dataset_path: lm_eval.datasets.model_written_evals.persona
output_type: multiple_choice
output_type: multiple_choice
validation_split: train
validation_split: validation
target_delimiter: ""
doc_to_text: "{{question}}"
doc_to_text: "{{question}}"
doc_to_target: 0
doc_to_target: 0
doc_to_choice: "{{[answer_matching_behavior, answer_not_matching_behavior]}}"
doc_to_choice: "{{[answer_matching_behavior, answer_not_matching_behavior]}}"
...
...
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