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
489edf2c
Commit
489edf2c
authored
Aug 09, 2023
by
lintangsutawika
Browse files
added new filter to remove whitespace in the front of a prediction
parent
c2990e29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
lm_eval/filters/__init__.py
lm_eval/filters/__init__.py
+1
-0
lm_eval/filters/extraction.py
lm_eval/filters/extraction.py
+24
-0
No files found.
lm_eval/filters/__init__.py
View file @
489edf2c
...
...
@@ -8,6 +8,7 @@ FILTER_REGISTRY = {
"regex"
:
extraction
.
RegexFilter
,
"majority_vote"
:
selection
.
MajorityVoteFilter
,
"take_first_k"
:
selection
.
TakeKFilter
,
"remove_whitespace"
:
extraction
.
WhitespaceFilter
,
# 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,
# or should implement different filters for different ways of handling a reward model's inference.
...
...
lm_eval/filters/extraction.py
View file @
489edf2c
...
...
@@ -36,3 +36,27 @@ class RegexFilter(Filter):
# print(filtered_resps)
return
filtered_resps
class
WhitespaceFilter
(
Filter
):
""" """
def
__init__
(
self
):
pass
def
apply
(
self
,
resps
):
def
filter_set
(
inst
):
filtered_resp
=
[]
for
resp
in
inst
:
if
resp
.
startswith
(
" "
):
resp
=
resp
[
1
:]
filtered_resp
.
append
(
resp
)
return
filtered_resp
filtered_resps
=
[
filter_set
(
resp
)
for
resp
in
resps
]
return
filtered_resps
\ No newline at end of file
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