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
f948e989
Commit
f948e989
authored
Jun 19, 2024
by
Hojin Lee
Browse files
add custom filter
parent
bdb78d22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
lm_eval/filters/__init__.py
lm_eval/filters/__init__.py
+1
-1
lm_eval/filters/custom.py
lm_eval/filters/custom.py
+17
-0
No files found.
lm_eval/filters/__init__.py
View file @
f948e989
...
...
@@ -4,7 +4,7 @@ from typing import List
from
lm_eval.api.filter
import
FilterEnsemble
from
lm_eval.api.registry
import
get_filter
from
.
import
extraction
,
selection
,
transformation
from
.
import
custom
,
extraction
,
selection
,
transformation
def
build_filter_ensemble
(
...
...
lm_eval/filters/custom.py
0 → 100644
View file @
f948e989
from
lm_eval.api.filter
import
Filter
from
lm_eval.api.registry
import
register_filter
@
register_filter
(
"custom"
)
class
CustomFilter
(
Filter
):
"""
Custom filter that applies a custom, user-defined function to the model responses.
"""
def
__init__
(
self
,
**
kwargs
)
->
None
:
self
.
filter_fn
=
kwargs
.
pop
(
"filter_fn"
)
super
().
__init__
(
**
kwargs
)
def
apply
(
self
,
resps
,
docs
):
return
self
.
filter_fn
(
resps
,
docs
)
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