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
0fa316f8
Commit
0fa316f8
authored
May 11, 2021
by
Leo Gao
Browse files
Make PerplexityTask fit the framework a bit better
parent
b691c44f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
lm_eval/base.py
lm_eval/base.py
+5
-5
No files found.
lm_eval/base.py
View file @
0fa316f8
...
@@ -315,10 +315,10 @@ class PerplexityTask(Task, abc.ABC):
...
@@ -315,10 +315,10 @@ class PerplexityTask(Task, abc.ABC):
}
}
def
doc_to_text
(
self
,
doc
):
def
doc_to_text
(
self
,
doc
):
return
doc
return
""
def
doc_to_target
(
self
,
doc
):
def
doc_to_target
(
self
,
doc
):
r
aise
NotImplementedError
()
r
eturn
doc
def
construct_requests
(
self
,
doc
,
ctx
):
def
construct_requests
(
self
,
doc
,
ctx
):
assert
not
ctx
assert
not
ctx
...
@@ -327,12 +327,12 @@ class PerplexityTask(Task, abc.ABC):
...
@@ -327,12 +327,12 @@ class PerplexityTask(Task, abc.ABC):
def
process_results
(
self
,
doc
,
results
):
def
process_results
(
self
,
doc
,
results
):
loglikelihood
,
=
results
loglikelihood
,
=
results
words
=
self
.
count_words
(
self
.
doc_to_te
x
t
(
doc
))
words
=
self
.
count_words
(
self
.
doc_to_t
arg
et
(
doc
))
bytes
=
self
.
count_bytes
(
self
.
doc_to_te
x
t
(
doc
))
bytes
=
self
.
count_bytes
(
self
.
doc_to_t
arg
et
(
doc
))
return
{
return
{
"word_perplexity"
:
(
loglikelihood
,
words
),
"word_perplexity"
:
(
loglikelihood
,
words
),
"byte_perplexity"
:
(
loglikelihood
,
bytes
),
"byte_perplexity"
:
(
loglikelihood
,
bytes
),
"bits_per_byte"
:
(
-
loglikelihood
,
self
.
count_bytes
(
self
.
doc_to_te
x
t
(
doc
)))
"bits_per_byte"
:
(
-
loglikelihood
,
self
.
count_bytes
(
self
.
doc_to_t
arg
et
(
doc
)))
}
}
def
aggregation
(
self
):
def
aggregation
(
self
):
...
...
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