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
5c1f194b
Commit
5c1f194b
authored
Dec 19, 2024
by
Baber
Browse files
fix metric
parent
6c7c413d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
lm_eval/tasks/ruler/sniah_1.yaml
lm_eval/tasks/ruler/sniah_1.yaml
+1
-1
lm_eval/tasks/ruler/utils.py
lm_eval/tasks/ruler/utils.py
+14
-3
No files found.
lm_eval/tasks/ruler/sniah_1.yaml
View file @
5c1f194b
...
...
@@ -7,7 +7,7 @@ output_type: generate_until
test_split
:
test
download_dataset
:
!function
utils.niah_single_1
doc_to_text
:
"
{{input}}"
doc_to_target
:
"
{{outputs
[0]
}}"
doc_to_target
:
"
{{outputs}}"
process_results
:
!function
utils.process_results
metric_list
:
...
...
lm_eval/tasks/ruler/utils.py
View file @
5c1f194b
...
...
@@ -181,16 +181,27 @@ def postprocess_pred(predict_str: str) -> str:
return
predict_str
def
string_match_all
(
preds
:
list
[
str
],
refs
:
list
[
list
[
str
]])
->
float
:
score
=
sum
(
[
sum
([
1.0
if
r
.
lower
()
in
pred
.
lower
()
else
0.0
for
r
in
ref
])
/
len
(
ref
)
for
pred
,
ref
in
zip
(
preds
,
refs
)
]
)
/
len
(
preds
)
return
score
def
process_results
(
doc
:
dict
,
results
:
list
[
str
])
->
dict
[
str
,
float
]:
# hacky: set all other lengths to -1
metrics
=
{
str
(
length
):
-
1.0
for
length
in
SEQ_LENGTHS
}
input_len
=
doc
[
"max_length"
]
acc
=
1.0
if
postprocess_pred
(
results
[
0
])
in
doc
[
"input"
]
else
0.0
metrics
[
str
(
input_len
)]
=
acc
pred
=
postprocess_pred
(
results
[
0
])
score
=
string_match_all
([
pred
],
[
doc
[
"outputs"
]])
metrics
[
str
(
input_len
)]
=
score
return
metrics
def
aggregate_metrics
(
metrics
:
list
[
in
t
])
->
float
:
def
aggregate_metrics
(
metrics
:
list
[
floa
t
])
->
float
:
res
=
[
x
for
x
in
metrics
if
x
!=
-
1
]
if
not
res
:
# we don't have any samples with this length
...
...
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