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
ad792140
Commit
ad792140
authored
Oct 09, 2023
by
lintangsutawika
Browse files
removed
parent
0348ed97
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
43 deletions
+0
-43
lm_eval/filters/__init__.py
lm_eval/filters/__init__.py
+0
-1
lm_eval/filters/extraction.py
lm_eval/filters/extraction.py
+0
-42
No files found.
lm_eval/filters/__init__.py
View file @
ad792140
...
...
@@ -10,7 +10,6 @@ FILTER_REGISTRY = {
"majority_vote"
:
selection
.
MajorityVoteFilter
,
"take_first_k"
:
selection
.
TakeKFilter
,
"remove_whitespace"
:
extraction
.
WhitespaceFilter
,
"cot_filter"
:
extraction
.
CoTFilter
,
"lowercase"
:
transformation
.
LowercaseFilter
,
"uppercase"
:
transformation
.
UppercaseFilter
,
"map"
:
transformation
.
MapFilter
,
...
...
lm_eval/filters/extraction.py
View file @
ad792140
...
...
@@ -60,45 +60,3 @@ class WhitespaceFilter(Filter):
filtered_resps
=
[
filter_set
(
resp
)
for
resp
in
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
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