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
22197e78
Commit
22197e78
authored
Oct 15, 2025
by
Baber
Browse files
fix params
parent
d5c234ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
lm_eval/api/model.py
lm_eval/api/model.py
+5
-2
lm_eval/models/utils.py
lm_eval/models/utils.py
+1
-1
No files found.
lm_eval/api/model.py
View file @
22197e78
...
@@ -336,7 +336,7 @@ class TemplateLM(LM):
...
@@ -336,7 +336,7 @@ class TemplateLM(LM):
return
self
.
eot_token_id
return
self
.
eot_token_id
@
abc
.
abstractmethod
@
abc
.
abstractmethod
def
tok_encode
(
self
,
string
:
str
,
**
kwargs
)
->
list
[
int
]:
def
tok_encode
(
self
,
string
:
str
,
add_special_tokens
=
False
,
**
kwargs
)
->
list
[
int
]:
"""
"""
Tokenize a string using the model's tokenizer and return a list of token IDs.
Tokenize a string using the model's tokenizer and return a list of token IDs.
"""
"""
...
@@ -377,6 +377,7 @@ class TemplateLM(LM):
...
@@ -377,6 +377,7 @@ class TemplateLM(LM):
This method does NOT handle empty context. The caller should
This method does NOT handle empty context. The caller should
handle empty context (see loglikelihood method).
handle empty context (see loglikelihood method).
"""
"""
assert
context
,
"Context cannot be empty!"
import
transformers
import
transformers
n_spaces
=
len
(
context
)
-
len
(
context
.
rstrip
())
n_spaces
=
len
(
context
)
-
len
(
context
.
rstrip
())
...
@@ -429,7 +430,9 @@ class TemplateLM(LM):
...
@@ -429,7 +430,9 @@ class TemplateLM(LM):
new_reqs
=
[]
new_reqs
=
[]
for
context
,
continuation
in
[
req
.
args
for
req
in
requests
]:
for
context
,
continuation
in
[
req
.
args
for
req
in
requests
]:
if
context
==
""
:
if
context
==
""
:
continuation_enc
=
self
.
tok_encode
(
continuation
)
continuation_enc
=
self
.
tok_encode
(
continuation
,
add_special_tokens
=
False
)
# BOS or EOS as context
# BOS or EOS as context
context_enc
,
continuation_enc
=
(
context_enc
,
continuation_enc
=
(
([
self
.
prefix_token_id
],
continuation_enc
)
([
self
.
prefix_token_id
],
continuation_enc
)
...
...
lm_eval/models/utils.py
View file @
22197e78
...
@@ -150,7 +150,7 @@ class Grouper:
...
@@ -150,7 +150,7 @@ class Grouper:
def
pad_and_concat
(
def
pad_and_concat
(
max_length
:
int
,
max_length
:
int
,
tensors
:
L
ist
[
torch
.
Tensor
],
tensors
:
l
ist
[
torch
.
Tensor
],
padding_side
:
Literal
[
"right"
,
"left"
]
=
"right"
,
padding_side
:
Literal
[
"right"
,
"left"
]
=
"right"
,
):
):
"""
"""
...
...
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