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
431e53de
Commit
431e53de
authored
Feb 14, 2021
by
Leo Gao
Browse files
Fix CoQA for tests
parent
8966289a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
lm_eval/tasks/coqa.py
lm_eval/tasks/coqa.py
+1
-2
tests/test_tasks.py
tests/test_tasks.py
+3
-0
No files found.
lm_eval/tasks/coqa.py
View file @
431e53de
...
@@ -53,7 +53,6 @@ class CoQA(Task):
...
@@ -53,7 +53,6 @@ class CoQA(Task):
question
=
f
"Q:
{
q
[
'input_text'
]
}
"
+
'
\n\n
'
question
=
f
"Q:
{
q
[
'input_text'
]
}
"
+
'
\n\n
'
answer
=
f
"A:
{
a
[
'input_text'
]
}
"
+
'
\n\n
'
if
a
is
not
None
else
"A:"
answer
=
f
"A:
{
a
[
'input_text'
]
}
"
+
'
\n\n
'
if
a
is
not
None
else
"A:"
doc_text
+=
question
+
answer
doc_text
+=
question
+
answer
print
(
doc_text
)
return
doc_text
return
doc_text
@
classmethod
@
classmethod
...
@@ -108,7 +107,7 @@ class CoQA(Task):
...
@@ -108,7 +107,7 @@ class CoQA(Task):
if
turnid
is
None
:
if
turnid
is
None
:
turnid
=
len
(
doc
[
"questions"
])
turnid
=
len
(
doc
[
"questions"
])
raw_text
=
doc
[
'answers'
][
turnid
-
1
][
"input_text"
]
raw_text
=
doc
[
'answers'
][
turnid
-
1
][
"input_text"
]
return
raw_text
return
" "
+
raw_text
def
construct_requests
(
self
,
doc
,
ctx
):
def
construct_requests
(
self
,
doc
,
ctx
):
""" Uses RequestFactory to construct Requests and returns an iterable of
""" Uses RequestFactory to construct Requests and returns an iterable of
...
...
tests/test_tasks.py
View file @
431e53de
...
@@ -75,6 +75,9 @@ def test_documents_and_requests(taskname, Task):
...
@@ -75,6 +75,9 @@ def test_documents_and_requests(taskname, Task):
assert
tgt
[
0
]
==
' '
or
txt
[
-
1
]
==
'
\n
'
assert
tgt
[
0
]
==
' '
or
txt
[
-
1
]
==
'
\n
'
reqs
=
task
.
construct_requests
(
doc
,
txt
)
reqs
=
task
.
construct_requests
(
doc
,
txt
)
# construct_requests can return just one request
if
not
isinstance
(
reqs
,
(
list
,
tuple
)):
reqs
=
[
reqs
]
# todo: mock lm after refactoring evaluator.py to not be a mess
# todo: mock lm after refactoring evaluator.py to not be a mess
for
req
in
reqs
:
for
req
in
reqs
:
...
...
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