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
92929bd2
Unverified
Commit
92929bd2
authored
Jun 05, 2023
by
gakada
Committed by
GitHub
Jun 05, 2023
Browse files
Move spaces from context to continuation (#546)
parent
76fed776
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
+5
-7
lm_eval/base.py
lm_eval/base.py
+5
-7
No files found.
lm_eval/base.py
View file @
92929bd2
...
@@ -171,16 +171,14 @@ class BaseLM(LM):
...
@@ -171,16 +171,14 @@ class BaseLM(LM):
# TODO: enforce this somehow
# TODO: enforce this somehow
def
_encode_pair
(
self
,
context
,
continuation
):
def
_encode_pair
(
self
,
context
,
continuation
):
n_spaces
=
len
(
context
)
-
len
(
context
.
rstrip
())
if
n_spaces
>
0
:
continuation
=
context
[
-
n_spaces
:]
+
continuation
context
=
context
[:
-
n_spaces
]
whole_enc
=
self
.
tok_encode
(
context
+
continuation
)
whole_enc
=
self
.
tok_encode
(
context
+
continuation
)
whole_enc_len
=
len
(
whole_enc
)
context_enc
=
self
.
tok_encode
(
context
)
context_enc
=
self
.
tok_encode
(
context
)
context_enc_len
=
len
(
context_enc
)
context_enc_len
=
len
(
context_enc
)
if
context_enc_len
<
whole_enc_len
:
continuation_enc
=
whole_enc
[
context_enc_len
:]
continuation_enc
=
whole_enc
[
context_enc_len
:]
else
:
continuation_enc
=
self
.
tok_encode
(
continuation
)
continuation_enc_len
=
len
(
continuation_enc
)
context_enc
=
whole_enc
[:
-
continuation_enc_len
]
return
context_enc
,
continuation_enc
return
context_enc
,
continuation_enc
def
loglikelihood
(
self
,
requests
):
def
loglikelihood
(
self
,
requests
):
...
...
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