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
d3d1b7f1
Commit
d3d1b7f1
authored
Sep 07, 2023
by
lintangsutawika
Browse files
fixed import
parent
e0e0746d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
lm_eval/tasks/qasper/metrics.py
lm_eval/tasks/qasper/metrics.py
+8
-6
No files found.
lm_eval/tasks/qasper/metrics.py
View file @
d3d1b7f1
import
string
def
normalize_answer
(
s
):
def
normalize_answer
(
s
):
"""
"""
Taken from the official evaluation script for v1.1 of the SQuAD dataset.
Taken from the official evaluation script for v1.1 of the SQuAD dataset.
...
@@ -19,17 +21,17 @@ def normalize_answer(s):
...
@@ -19,17 +21,17 @@ def normalize_answer(s):
return
white_space_fix
(
remove_articles
(
remove_punc
(
lower
(
s
))))
return
white_space_fix
(
remove_articles
(
remove_punc
(
lower
(
s
))))
def
f1_abstractive
(
prediction
,
ground_truth
):
def
f1_abstractive
(
prediction
s
,
references
):
"""
"""
Taken from the official evaluation script for v1.1 of the SQuAD dataset.
Taken from the official evaluation script for v1.1 of the SQuAD dataset.
"""
"""
prediction_tokens
=
normalize_answer
(
prediction
).
split
()
prediction_tokens
=
normalize_answer
(
prediction
s
[
0
]
).
split
()
ground_truth
_tokens
=
normalize_answer
(
ground_truth
).
split
()
references
_tokens
=
normalize_answer
(
references
[
0
]
).
split
()
common
=
Counter
(
prediction_tokens
)
&
Counter
(
ground_truth
_tokens
)
common
=
Counter
(
prediction_tokens
)
&
Counter
(
references
_tokens
)
num_same
=
sum
(
common
.
values
())
num_same
=
sum
(
common
.
values
())
if
num_same
==
0
:
if
num_same
==
0
:
return
0
return
0
precision
=
1.0
*
num_same
/
len
(
prediction_tokens
)
precision
=
1.0
*
num_same
/
len
(
prediction_tokens
)
recall
=
1.0
*
num_same
/
len
(
ground_truth
_tokens
)
recall
=
1.0
*
num_same
/
len
(
references
_tokens
)
f1
=
(
2
*
precision
*
recall
)
/
(
precision
+
recall
)
f1
=
(
2
*
precision
*
recall
)
/
(
precision
+
recall
)
return
f1
return
f1
\ 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