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
2ae642d8
Commit
2ae642d8
authored
Jul 18, 2025
by
Baber
Browse files
refactor build_filter_ensemble to simplify filter creation
parent
b6f38ac8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
lm_eval/filters/__init__.py
lm_eval/filters/__init__.py
+10
-12
No files found.
lm_eval/filters/__init__.py
View file @
2ae642d8
from
functools
import
partial
from
typing
import
Iterable
,
List
,
Optional
,
Union
from
typing
import
Optional
,
Union
from
lm_eval.api.filter
import
FilterEnsemble
from
lm_eval.api.registry
import
get_filter
...
...
@@ -8,18 +8,16 @@ from . import custom, extraction, selection, transformation
def
build_filter_ensemble
(
filter_name
:
str
,
components
:
list
[
tuple
[
str
,
Optional
[
dict
]]]
filter_name
:
str
,
components
:
list
[
tuple
[
str
,
Optional
[
dict
[
str
,
Union
[
str
,
int
,
float
]]]]],
)
->
FilterEnsemble
:
"""
Create a filtering pipeline.
"""
filters
=
[]
for
function
,
kwargs
in
components
:
if
kwargs
is
None
:
kwargs
=
{}
# create a filter given its name in the registry
f
=
partial
(
get_filter
(
function
),
**
kwargs
)
# add the filter as a pipeline step
filters
.
append
(
f
)
return
FilterEnsemble
(
name
=
filter_name
,
filters
=
filters
)
# create filters given its name in the registry, and add each as a pipeline step
return
FilterEnsemble
(
name
=
filter_name
,
filters
=
[
partial
(
get_filter
(
func
),
**
(
kwargs
or
{}))
for
func
,
kwargs
in
components
],
)
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