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
a2871d9c
Commit
a2871d9c
authored
Sep 06, 2020
by
Anish Thite
Browse files
add generate docs and generate text for coqa
parent
345f5fef
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
128 deletions
+53
-128
coqa.py
coqa.py
+53
-0
datasets/coqa/testcoquaextraction.ipynb
datasets/coqa/testcoquaextraction.ipynb
+0
-128
evaluate-v1.0.py
evaluate-v1.0.py
+0
-0
No files found.
datasets/coqa/evaluateCoQA
.py
→
coqa
.py
View file @
a2871d9c
from
...
base
import
Dataset
from
base
import
Dataset
import
os
import
json
import
random
class
CoQA
(
Dataset
):
def
has_training_docs
(
self
):
return
True
def
has_validation_docs
(
self
):
return
False
def
training_docs
(
self
):
pass
myjson
=
json
.
load
(
open
(
'data/coqa/coqa-train-v1.0.json'
))[
'data'
]
return
self
.
load_doc
(
myjson
)
def
validation_docs
(
self
):
pass
def
test_docs
(
self
):
pass
myjson
=
json
.
load
(
open
(
'data/coqa/coqa-dev-v1.0.json'
))[
'data'
]
return
self
.
load_doc
(
myjson
)
def
fewshot_examples
(
self
,
k
):
traindocs
=
list
(
self
.
training_docs
())
...
...
@@ -22,8 +32,22 @@ class CoQA(Dataset):
def
fewshot_description
(
self
):
pass
def
load_doc
(
self
,
myjson
):
docs
=
[]
for
item
in
myjson
:
new_instance
=
[
item
[
'story'
]]
qa_pairs
=
zip
(
item
[
'questions'
],
item
[
'answers'
])
for
pair
in
qa_pairs
:
new_instance
.
append
(
'
\n
'
)
new_instance
.
append
(
''
.
join
([
'Q: '
,
pair
[
0
][
'input_text'
]]))
new_instance
.
append
(
''
.
join
([
'A: '
,
pair
[
1
][
'input_text'
]]))
docs
.
append
(
new_instance
)
return
docs
def
doc_to_text
(
self
,
doc
,
include_target
=
True
):
json
.
load
(
open
(
doc
))
text
=
'
\n
<|endoftext|>
\n
'
.
join
([
'
\n
'
.
join
(
instance
)
for
instance
in
doc
])
text
=
text
+
'
\n
<|endoftext|>'
return
text
def
evaluate
(
self
,
docs
,
lm
):
pass
datasets/coqa/testcoquaextraction.ipynb
deleted
100644 → 0
View file @
345f5fef
This diff is collapsed.
Click to expand it.
datasets/coqa/
evaluate-v1.0.py
→
evaluate-v1.0.py
View file @
a2871d9c
File moved
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