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
9adf18b1
Unverified
Commit
9adf18b1
authored
Feb 10, 2021
by
Leo Gao
Committed by
GitHub
Feb 10, 2021
Browse files
Merge pull request #141 from jon-tow/winograd-fixes2
Fix context orderings in `Winograds` to match label positioning
parents
c6b094e0
155aeee9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
22 deletions
+22
-22
lm_eval/tasks/winogrande.py
lm_eval/tasks/winogrande.py
+11
-11
lm_eval/tasks/wsc273.py
lm_eval/tasks/wsc273.py
+11
-11
No files found.
lm_eval/tasks/winogrande.py
View file @
9adf18b1
...
...
@@ -59,18 +59,18 @@ class Winogrande(HFTask):
part of the document for `doc`.
"""
target
=
self
.
partial_target
(
doc
)
right_ctx
,
wrong_ctx
=
ctx
,
self
.
_wrong_context
(
doc
,
ctx
)
ll_right_ctx
,
_
=
rf
.
loglikelihood
(
right_ctx
,
target
)
ll_wrong_ctx
,
_
=
rf
.
loglikelihood
(
wrong_ctx
,
target
)
return
ll_right_ctx
,
ll_wrong
_ctx
def
_wrong_context
(
self
,
doc
,
ctx
):
wrong_answer
=
f
"
{
int
(
not
self
.
answer_to_num
[
doc
[
'answer'
]])
+
1
}
"
wrong_option
=
doc
[
"option"
+
wrong_answer
]
wrong_ctx
=
self
.
partial_context
(
doc
,
wrong_option
)
lls
=
[]
for
option
in
[
doc
[
"option1"
],
doc
[
"option2"
]]:
partial_ctx
=
self
.
partial_context
(
doc
,
option
)
full_ctx
=
self
.
append_context
(
ctx
,
partial
_ctx
)
lls
.
append
(
rf
.
loglikelihood
(
full_ctx
,
target
)[
0
])
return
lls
@
classmethod
def
append_context
(
cls
,
ctx
,
partial_ctx
):
ctx
=
ctx
.
split
(
"
\n\n
"
)
# Each fewshot context is on its own new line.
ctx
.
pop
()
# Remove the correct context.
return
"
\n\n
"
.
join
([
*
ctx
,
wrong
_ctx
])
if
ctx
else
wrong
_ctx
ctx
.
pop
()
# Remove the correct context
put in by `doc_to_text`
.
return
"
\n\n
"
.
join
([
*
ctx
,
partial
_ctx
])
if
ctx
else
partial
_ctx
def
process_results
(
self
,
doc
,
results
):
"""Take a single document and the LM results and evaluates, returning a
...
...
lm_eval/tasks/wsc273.py
View file @
9adf18b1
...
...
@@ -90,18 +90,18 @@ class WinogradSchemaChallenge273(HFTask):
part of the document for `doc`.
"""
target
=
self
.
partial_target
(
doc
)
right_ctx
,
wrong_ctx
=
ctx
,
self
.
_wrong_context
(
doc
,
ctx
)
ll_right_ctx
,
_
=
rf
.
loglikelihood
(
right_ctx
,
target
)
ll_wrong_ctx
,
_
=
rf
.
loglikelihood
(
wrong_ctx
,
target
)
return
ll_right_ctx
,
ll_wrong
_ctx
def
_wrong_context
(
self
,
doc
,
ctx
):
wrong_answer
=
int
(
not
doc
[
"label"
])
wrong_option
=
doc
[
"options"
][
wrong_answer
]
wrong_ctx
=
self
.
partial_context
(
doc
,
wrong_option
)
lls
=
[]
for
option
in
doc
[
"options"
]:
partial_ctx
=
self
.
partial_context
(
doc
,
option
)
full_ctx
=
self
.
append_context
(
ctx
,
partial
_ctx
)
lls
.
append
(
rf
.
loglikelihood
(
full_ctx
,
target
)[
0
])
return
lls
@
classmethod
def
append_context
(
cls
,
ctx
,
partial_ctx
):
ctx
=
ctx
.
split
(
"
\n\n
"
)
# Each fewshot context is on its own new line.
ctx
.
pop
()
# Remove the correct context.
return
"
\n\n
"
.
join
([
*
ctx
,
wrong
_ctx
])
if
ctx
else
wrong
_ctx
ctx
.
pop
()
# Remove the correct context
put in by `doc_to_text`
.
return
"
\n\n
"
.
join
([
*
ctx
,
partial
_ctx
])
if
ctx
else
partial
_ctx
def
process_results
(
self
,
doc
,
results
):
"""Take a single document and the LM results and evaluates, returning a
...
...
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