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
bf46dff4
Commit
bf46dff4
authored
Feb 06, 2025
by
Baber
Browse files
add flexible
parent
bc5c554d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
lm_eval/tasks/ai2d/ai2d.yaml
lm_eval/tasks/ai2d/ai2d.yaml
+5
-0
lm_eval/tasks/ai2d/utils.py
lm_eval/tasks/ai2d/utils.py
+17
-0
No files found.
lm_eval/tasks/ai2d/ai2d.yaml
View file @
bf46dff4
...
...
@@ -20,6 +20,11 @@ filter_list:
-
function
:
"
regex"
regex_pattern
:
"
(?:[`
\\
*_]*(?i:FINAL
ANSWER|Final
Answer|Answer)[`
\\
*_]*)[:
\\
s]*[`
\\
*_]*([A-D])[`
\\
*_]*"
-
function
:
"
take_first"
-
name
:
"
flexible-extract"
filter
:
-
function
:
"
custom"
-
filter_fn
:
!function
utils.flexible_extract
-
function
:
"
take_first"
metric_list
:
-
metric
:
exact_match
aggregation
:
mean
...
...
lm_eval/tasks/ai2d/utils.py
0 → 100644
View file @
bf46dff4
import
string
def
flexible_extract
(
resps
,
docs
):
def
filter_set
(
inst
):
filtered
=
[]
for
resp
in
inst
:
while
resp
[
-
1
]
in
string
.
punctuation
:
resp
=
resp
[:
-
1
]
if
resp
[
-
1
]
in
[
"A"
,
"B"
,
"C"
,
"D"
]:
resp
=
resp
[
-
1
]
filtered
.
append
(
resp
)
return
filtered
filtered_resps
=
list
(
map
(
lambda
x
:
filter_set
(
x
),
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