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
9426db16
Commit
9426db16
authored
Oct 23, 2020
by
Charles Foster
Browse files
Added natural questions. Not yet validated or tested with a call to write.
parent
302ca3d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
lm_eval/tasks/__init__.py
lm_eval/tasks/__init__.py
+2
-0
lm_eval/tasks/naturalqs.py
lm_eval/tasks/naturalqs.py
+41
-0
No files found.
lm_eval/tasks/__init__.py
View file @
9426db16
...
...
@@ -9,6 +9,7 @@ from . import quac
from
.
import
hellaswag
from
.
import
openbookqa
from
.
import
squad
from
.
import
naturalqs
TASK_REGISTRY
=
{
# GLUE
...
...
@@ -36,6 +37,7 @@ TASK_REGISTRY = {
"openbookqa"
:
openbookqa
.
OpenBookQA
,
"squad"
:
squad
.
SQuAD
,
"race"
:
race
.
RACE
,
"naturalqs"
:
naturalqs
.
NaturalQs
,
"webqs"
:
webqs
.
WebQs
,
"winogrande"
:
winogrande
.
Winogrande
,
"anli_r1"
:
anli
.
ANLIRound1
,
...
...
lm_eval/tasks/naturalqs.py
0 → 100644
View file @
9426db16
from
.
common
import
HFTask
import
apache_beam
class
NaturalQs
(
HFTask
):
DATASET_PATH
=
"natural_questions"
DATASET_NAME
=
None
def
has_training_docs
(
self
):
return
True
def
has_validation_docs
(
self
):
return
True
def
has_test_docs
(
self
):
return
False
def
fewshot_description
(
self
):
# TODO: figure out description
return
""
def
doc_to_text
(
self
,
doc
,
include_target
=
True
):
question
=
doc
[
'question'
][
'text'
]
short_answer
=
doc
[
'annotations'
][
'short_answers'
][
0
][
'text'
]
long_answer_start
=
doc
[
'annotations'
][
'long_answer'
][
0
][
'start_token'
]
long_answer_end
=
doc
[
'annotations'
][
'long_answer'
][
0
][
'end_token'
]
passage
=
" "
.
join
(
doc
[
'document'
][
'tokens'
][
'token'
][
long_answer_start
:
long_answer_end
])
text
=
'Q: '
+
question
+
'
\n\n
'
+
'A: '
if
include_target
:
# What if there is no short answer? This will be an empty string. Currently, default to the long answer otherwise.
if
short_answer
:
text
+=
short_answer
[
0
]
else
:
text
+=
long_answer
return
text
def
evaluate
(
self
,
docs
,
lm
,
provide_description
,
num_fewshot
):
# TODO: implement
raise
NotImplementedError
()
\ 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