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
e4e9228e
Commit
e4e9228e
authored
Feb 13, 2021
by
Jason Phang
Browse files
ReCoRD fix
parent
487b5313
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
11 deletions
+7
-11
lm_eval/tasks/__init__.py
lm_eval/tasks/__init__.py
+1
-1
lm_eval/tasks/superglue.py
lm_eval/tasks/superglue.py
+6
-10
No files found.
lm_eval/tasks/__init__.py
View file @
e4e9228e
...
@@ -44,7 +44,7 @@ TASK_REGISTRY = {
...
@@ -44,7 +44,7 @@ TASK_REGISTRY = {
"cb"
:
superglue
.
CommitmentBank
,
"cb"
:
superglue
.
CommitmentBank
,
"copa"
:
superglue
.
Copa
,
"copa"
:
superglue
.
Copa
,
"multirc"
:
superglue
.
MultiRC
,
"multirc"
:
superglue
.
MultiRC
,
#
"record": superglue.ReCoRD,
"record"
:
superglue
.
ReCoRD
,
"wic"
:
superglue
.
WordsInContext
,
"wic"
:
superglue
.
WordsInContext
,
"wsc"
:
superglue
.
SGWinogradSchemaChallenge
,
"wsc"
:
superglue
.
SGWinogradSchemaChallenge
,
...
...
lm_eval/tasks/superglue.py
View file @
e4e9228e
...
@@ -272,7 +272,7 @@ class ReCoRD(HFTask):
...
@@ -272,7 +272,7 @@ class ReCoRD(HFTask):
def
training_docs
(
self
):
def
training_docs
(
self
):
# In ReCoRD, each doc manifests multiple "examples" in the context of few shot example packing.
# In ReCoRD, each doc manifests multiple "examples" in the context of few shot example packing.
# Each doc consists of multiple answer candidates, each of which is scored yes/no.
# Each doc consists of multiple answer candidates, each of which is scored yes/no.
# Hence, we one "doc" for each (context + passage, answer) pair.
# Hence, we
create
one "doc" for each (context + passage, answer) pair.
# Moreover, we only use the correct answers for context packing
# Moreover, we only use the correct answers for context packing
# (This is not an issue for evaluation, where we can directly score multiple candidates at once).
# (This is not an issue for evaluation, where we can directly score multiple candidates at once).
if
self
.
_training_docs
is
None
:
if
self
.
_training_docs
is
None
:
...
@@ -288,14 +288,10 @@ class ReCoRD(HFTask):
...
@@ -288,14 +288,10 @@ class ReCoRD(HFTask):
return
self
.
_training_docs
return
self
.
_training_docs
def
validation_docs
(
self
):
def
validation_docs
(
self
):
for
doc
in
self
.
data
[
"validation"
]:
# Following from .trianing_docs, for validation_docs, each document corresponds to
for
entity
in
list
(
set
(
doc
[
"entities"
])):
# the original doc from the dataset, i.e. comprises of lists of entities, and which
yield
{
# entities are correct (potentially multiple)
"passage"
:
doc
[
"passage"
],
yield
from
self
.
data
[
"validation"
]
"query"
:
doc
[
"query"
],
"entity"
:
entity
,
"label"
:
entity
in
doc
[
"answers"
],
}
def
doc_to_text
(
self
,
doc
):
def
doc_to_text
(
self
,
doc
):
initial_text
,
*
highlights
=
doc
[
"passage"
].
strip
().
split
(
"
\n
@highlight
\n
"
)
initial_text
,
*
highlights
=
doc
[
"passage"
].
strip
().
split
(
"
\n
@highlight
\n
"
)
...
@@ -314,7 +310,7 @@ class ReCoRD(HFTask):
...
@@ -314,7 +310,7 @@ class ReCoRD(HFTask):
def
construct_requests
(
self
,
doc
,
ctx
):
def
construct_requests
(
self
,
doc
,
ctx
):
requests
=
[
requests
=
[
rf
.
loglikelihood
(
ctx
,
self
.
format_answer
(
query
=
doc
[
"query"
],
entity
=
entity
))
rf
.
loglikelihood
(
ctx
,
self
.
format_answer
(
query
=
doc
[
"query"
],
entity
=
entity
))
for
entity
in
doc
[
"entit
y
"
]
for
entity
in
doc
[
"entit
ies
"
]
]
]
return
requests
return
requests
...
...
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