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
9b14235d
Commit
9b14235d
authored
Feb 08, 2021
by
Leo Gao
Browse files
More task changes
parent
96157fc7
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
16 additions
and
15 deletions
+16
-15
lm_eval/tasks/anli.py
lm_eval/tasks/anli.py
+1
-1
lm_eval/tasks/arithmetic.py
lm_eval/tasks/arithmetic.py
+1
-1
lm_eval/tasks/glue.py
lm_eval/tasks/glue.py
+5
-4
lm_eval/tasks/piqa.py
lm_eval/tasks/piqa.py
+2
-2
lm_eval/tasks/pubmedqa.py
lm_eval/tasks/pubmedqa.py
+1
-1
lm_eval/tasks/race.py
lm_eval/tasks/race.py
+4
-4
lm_eval/tasks/sciq.py
lm_eval/tasks/sciq.py
+1
-1
lm_eval/tasks/webqs.py
lm_eval/tasks/webqs.py
+1
-1
No files found.
lm_eval/tasks/anli.py
View file @
9b14235d
...
...
@@ -39,7 +39,7 @@ class ANLIBase(HFTask):
# of the prompt (yes, repeating it!). also, " True, False, or Neither?" is directly
# appended onto the question, with no "Answer:" or even a newline. Do we *really*
# want to do it exactly as OA did?
return
doc
[
'premise'
]
+
'
\n
Question: '
+
doc
[
'hypothesis'
]
+
'
\n
True, False, or Neither?'
return
doc
[
'premise'
]
+
'
\n
Question: '
+
doc
[
'hypothesis'
]
+
'
True, False, or Neither?
\n
Answer:
'
def
doc_to_target
(
self
,
doc
):
# True = entailment
...
...
lm_eval/tasks/arithmetic.py
View file @
9b14235d
...
...
@@ -56,7 +56,7 @@ class Arithmetic(Task):
return
doc
.
completion
def
load_doc
(
self
,
doc_json
):
return
ArithmeticDoc
(
context
=
doc_json
[
'context'
],
completion
=
doc_json
[
'completion'
])
return
ArithmeticDoc
(
context
=
doc_json
[
'context'
]
.
strip
()
,
completion
=
doc_json
[
'completion'
]
.
strip
()
)
def
construct_requests
(
self
,
doc
,
ctx
):
ll
,
is_prediction
=
rf
.
loglikelihood
(
ctx
,
doc
.
completion
)
...
...
lm_eval/tasks/glue.py
View file @
9b14235d
...
...
@@ -22,17 +22,18 @@ class CoLA(HFTask):
return
True
def
fewshot_description
(
self
):
return
"Does this sentence make sense? (True or False)"
# TODO
return
""
def
doc_to_text
(
self
,
doc
):
return
"{}
\n
Question: Does this sentence make sense?
\n
Answer:"
.
format
(
doc
[
"sentence"
])
def
doc_to_target
(
self
,
doc
):
return
" {}"
.
format
({
1
:
"
True
"
,
0
:
"
False
"
}[
doc
[
"label"
]])
return
" {}"
.
format
({
1
:
"
yes
"
,
0
:
"
no
"
}[
doc
[
"label"
]])
def
construct_requests
(
self
,
doc
,
ctx
):
ll_true
,
_
=
rf
.
loglikelihood
(
ctx
,
"
True
"
)
ll_false
,
_
=
rf
.
loglikelihood
(
ctx
,
"
False
"
)
ll_true
,
_
=
rf
.
loglikelihood
(
ctx
,
"
yes
"
)
ll_false
,
_
=
rf
.
loglikelihood
(
ctx
,
"
no
"
)
return
ll_true
,
ll_false
def
process_results
(
self
,
doc
,
results
):
...
...
lm_eval/tasks/piqa.py
View file @
9b14235d
...
...
@@ -21,11 +21,11 @@ class PiQA(HFTask):
return
""
def
doc_to_text
(
self
,
doc
):
return
doc
[
"goal"
]
+
"
\n
"
return
"Question: "
+
doc
[
"goal"
]
+
"
\n
Answer:
"
def
doc_to_target
(
self
,
doc
):
solutions
=
[
doc
[
"sol1"
],
doc
[
"sol2"
]]
return
solutions
[
doc
[
"label"
]]
return
" "
+
solutions
[
doc
[
"label"
]]
def
construct_requests
(
self
,
doc
,
ctx
):
ll_1
,
_
=
rf
.
loglikelihood
(
ctx
,
doc
[
'sol1'
])
...
...
lm_eval/tasks/pubmedqa.py
View file @
9b14235d
...
...
@@ -30,7 +30,7 @@ class Pubmed_QA(HFTask):
def
doc_to_text
(
self
,
doc
):
ctxs
=
"
\n
"
.
join
(
doc
[
"context"
][
"contexts"
])
return
"
a
bstract: {}
\n
q
uestion: {}
\n
a
nswer:"
.
format
(
return
"
A
bstract: {}
\n
Q
uestion: {}
\n
A
nswer:"
.
format
(
ctxs
,
doc
[
"question"
],
doc
[
"final_decision"
]
...
...
lm_eval/tasks/race.py
View file @
9b14235d
...
...
@@ -82,10 +82,10 @@ class RACE(HFTask):
def
doc_to_text
(
self
,
doc
):
text
=
'Article: '
+
doc
[
'article'
]
+
'
\n\n
'
for
problem
in
doc
[
'problems'
][:
-
1
]:
question
=
'Q: '
+
problem
[
'question'
]
+
'
\n\n
'
answer
=
'A: '
+
self
.
get_answer_option
(
problem
)
+
'
\n\n
'
text
+=
question
+
answer
text
+=
'Q: '
+
self
.
last_problem
(
doc
)[
'question'
]
+
'
\n\n
'
+
'A:'
assert
problem
[
'question'
]
[
-
6
:]
==
' _ .
'
text
+=
problem
[
'question'
][
-
5
:]
+
self
.
get_answer_option
(
problem
)
+
'
\n
'
text
+=
self
.
last_problem
(
doc
)[
'question'
]
return
text
def
doc_to_target
(
self
,
doc
):
...
...
lm_eval/tasks/sciq.py
View file @
9b14235d
...
...
@@ -62,4 +62,4 @@ class SciQ(MultipleChoiceTask):
return
self
.
load_docs
(
"data/sciq/SciQ dataset-2 3/test.json"
)
def
doc_to_text
(
self
,
doc
):
return
"{}
\n
{}"
.
format
(
doc
[
"source"
],
doc
[
"query"
])
\ No newline at end of file
return
"{}
\n
Question: {}
\n
Answer:"
.
format
(
doc
[
"source"
],
doc
[
"query"
]).
strip
()
\ No newline at end of file
lm_eval/tasks/webqs.py
View file @
9b14235d
...
...
@@ -19,7 +19,7 @@ class WebQs(HFTask):
return
""
def
doc_to_text
(
self
,
doc
):
return
"Q: "
+
doc
[
'question'
]
+
'
\n
A:'
return
"Q
uestion
: "
+
doc
[
'question'
]
+
'
\n
A
nswer
:'
def
doc_to_target
(
self
,
doc
):
# this picks one answer to be the "correct" one, despite sometimes
...
...
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