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
11be7c93
Commit
11be7c93
authored
Sep 18, 2023
by
lintangsutawika
Browse files
format
parent
d1c189ea
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
11 deletions
+15
-11
lm_eval/tasks/mutual/utils.py
lm_eval/tasks/mutual/utils.py
+1
-1
lm_eval/tasks/qasper/README.md
lm_eval/tasks/qasper/README.md
+1
-1
lm_eval/tasks/qasper/metrics.py
lm_eval/tasks/qasper/metrics.py
+5
-0
lm_eval/tasks/qasper/utils.py
lm_eval/tasks/qasper/utils.py
+8
-9
No files found.
lm_eval/tasks/mutual/utils.py
View file @
11be7c93
import
numpy
as
np
def
process_docs
(
dataset
):
def
process_docs
(
dataset
):
def
_detokenize
(
text
):
text
=
text
.
replace
(
" '"
,
"'"
)
text
=
text
.
replace
(
"
\n
"
,
"
\n
"
)
...
...
lm_eval/tasks/qasper/README.md
View file @
11be7c93
...
...
@@ -46,7 +46,7 @@ Homepage: https://allenai.org/data/qasper
#### Tasks
*
`qasper_bool`
: Multiple choice task that evaluates the task with
`answer_type="bool"`
*
`qasper_bool`
: Multiple choice task that evaluates the task with
`answer_type="bool"`
*
`qasper_freeform`
: Greedy generation task that evaluates the samples from the task with
`answer_type="free form answer"`
### Checklist
...
...
lm_eval/tasks/qasper/metrics.py
View file @
11be7c93
import
re
import
string
from
collections
import
Counter
def
normalize_answer
(
s
):
"""
Taken from the official evaluation script for v1.1 of the SQuAD dataset.
...
...
@@ -21,6 +25,7 @@ def normalize_answer(s):
return
white_space_fix
(
remove_articles
(
remove_punc
(
lower
(
s
))))
def
f1_abstractive
(
predictions
,
references
):
"""
Taken from the official evaluation script for v1.1 of the SQuAD dataset.
...
...
lm_eval/tasks/qasper/utils.py
View file @
11be7c93
from
datasets
import
Dataset
from
functools
import
partial
def
process_docs
(
dataset
,
set_answer_type
=
"bool"
):
FEATURES
=
[
"title"
,
"abstract"
,
"question"
,
"answer"
,
"answer_type"
]
FEATURES
=
[
"title"
,
"abstract"
,
"question"
,
"answer"
,
"answer_type"
]
def
_categorise_answer
(
answer_blob
):
if
answer_blob
[
"unanswerable"
]:
...
...
@@ -62,12 +57,16 @@ def process_docs(dataset, set_answer_type="bool"):
return
obs_list
dataset
=
dataset
.
map
(
_flatten
,
remove_columns
=
[
key
for
key
in
dataset
.
features
.
keys
()
if
key
not
in
FEATURES
])
dataset
=
dataset
.
map
(
_flatten
,
remove_columns
=
[
key
for
key
in
dataset
.
features
.
keys
()
if
key
not
in
FEATURES
],
)
new_dataset
=
{}
for
key
in
dataset
.
features
.
keys
():
new_dataset
[
key
]
=
[
x
for
row
in
dataset
[
key
]
for
x
in
row
]
return
Dataset
.
from_dict
(
new_dataset
)
process_docs_bool
=
partial
(
process_docs
,
set_answer_type
=
"bool"
)
process_docs_freeform
=
partial
(
process_docs
,
set_answer_type
=
"free form answer"
)
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