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
7ba8c183
Unverified
Commit
7ba8c183
authored
Apr 10, 2021
by
Leo Gao
Committed by
GitHub
Apr 10, 2021
Browse files
Use more inheritance
parent
47382717
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
54 deletions
+2
-54
lm_eval/tasks/lambada_cloze.py
lm_eval/tasks/lambada_cloze.py
+2
-54
No files found.
lm_eval/tasks/lambada_cloze.py
View file @
7ba8c183
...
...
@@ -2,38 +2,11 @@ import json
from
lm_eval.base
import
Task
,
rf
from
lm_eval.metrics
import
mean
,
perplexity
from
lm_eval.utils
import
sh
from
lm_eval.tasks.lambada
import
LAMBADA
from
best_download
import
download_file
class
LAMBADA_cloze
(
Task
):
def
download
(
self
):
sh
(
"mkdir -p data/lambada"
)
download_file
(
"http://eaidata.bmk.sh/data/lambada_test.jsonl"
,
"data/lambada/lambada_test.jsonl"
,
"4aa8d02cd17c719165fc8a7887fddd641f43fcafa4b1c806ca8abc31fabdb226"
)
def
has_training_docs
(
self
):
return
False
def
has_validation_docs
(
self
):
return
True
def
has_test_docs
(
self
):
return
False
def
training_docs
(
self
):
pass
def
validation_docs
(
self
):
with
open
(
"data/lambada/lambada_test.jsonl"
)
as
fh
:
for
line
in
fh
:
yield
json
.
loads
(
line
)
def
test_docs
(
self
):
pass
class
LAMBADA_cloze
(
LAMBADA
):
def
doc_to_text
(
self
,
doc
):
return
doc
[
'text'
].
rsplit
(
' '
,
1
)[
0
]
+
" ____. ->"
...
...
@@ -42,28 +15,3 @@ class LAMBADA_cloze(Task):
def
fewshot_description
(
self
):
return
"Fill in blank:
\n
"
def
construct_requests
(
self
,
doc
,
ctx
):
ll
,
is_greedy
=
rf
.
loglikelihood
(
ctx
,
self
.
doc_to_target
(
doc
))
return
ll
,
is_greedy
def
process_results
(
self
,
doc
,
results
):
ll
,
is_greedy
=
results
return
{
'ppl'
:
ll
,
'acc'
:
int
(
is_greedy
)
}
def
aggregation
(
self
):
return
{
'ppl'
:
perplexity
,
'acc'
:
mean
}
def
higher_is_better
(
self
):
return
{
'ppl'
:
False
,
'acc'
:
True
}
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