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
aab23be4
Commit
aab23be4
authored
Oct 15, 2025
by
Baber
Browse files
skip duplicate bos
parent
f402411c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
lm_eval/models/huggingface.py
lm_eval/models/huggingface.py
+7
-1
lm_eval/models/utils.py
lm_eval/models/utils.py
+4
-0
No files found.
lm_eval/models/huggingface.py
View file @
aab23be4
...
...
@@ -32,6 +32,7 @@ from lm_eval.api.model import TemplateLM
from
lm_eval.api.registry
import
register_model
from
lm_eval.models.utils
import
(
Collator
,
bos_already_added
,
clear_torch_cache
,
configure_pad_token
,
get_dtype
,
...
...
@@ -901,7 +902,12 @@ class HFLM(TemplateLM):
add_special_tokens
=
{}
if
self
.
backend
==
"causal"
:
add_special_tokens
=
{
"add_special_tokens"
:
False
or
self
.
add_bos_token
}
if
bos_already_added
(
strings
[
0
],
getattr
(
self
.
tokenizer
,
"bos_token"
,
None
)
):
add_special_tokens
=
{
"add_special_tokens"
:
False
}
else
:
add_special_tokens
=
{
"add_special_tokens"
:
False
or
self
.
add_bos_token
}
encoding
=
self
.
tokenizer
(
strings
,
...
...
lm_eval/models/utils.py
View file @
aab23be4
...
...
@@ -881,3 +881,7 @@ def postprocess_generated_text(
generation
=
generation
.
split
(
think_end_token
)[
-
1
].
lstrip
()
return
generation
def
bos_already_added
(
sequence
:
str
,
bos_string
:
Optional
[
str
]):
return
sequence
[
0
]
==
bos_string
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