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
07bd7e23
Unverified
Commit
07bd7e23
authored
Mar 11, 2025
by
Baber Abbasi
Committed by
GitHub
Mar 11, 2025
Browse files
initialize tokenizer with bos_token (#2781)
parent
ebb498e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
0 deletions
+6
-0
lm_eval/models/huggingface.py
lm_eval/models/huggingface.py
+5
-0
lm_eval/models/vllm_causallms.py
lm_eval/models/vllm_causallms.py
+1
-0
No files found.
lm_eval/models/huggingface.py
View file @
07bd7e23
...
@@ -184,6 +184,7 @@ class HFLM(TemplateLM):
...
@@ -184,6 +184,7 @@ class HFLM(TemplateLM):
trust_remote_code
=
trust_remote_code
,
trust_remote_code
=
trust_remote_code
,
use_fast_tokenizer
=
use_fast_tokenizer
,
use_fast_tokenizer
=
use_fast_tokenizer
,
gguf_file
=
gguf_file
,
gguf_file
=
gguf_file
,
add_bos_token
=
add_bos_token
,
)
)
# if we passed `pretrained` as a string, initialize our model now
# if we passed `pretrained` as a string, initialize our model now
...
@@ -688,6 +689,7 @@ class HFLM(TemplateLM):
...
@@ -688,6 +689,7 @@ class HFLM(TemplateLM):
trust_remote_code
:
Optional
[
bool
]
=
False
,
trust_remote_code
:
Optional
[
bool
]
=
False
,
use_fast_tokenizer
:
Optional
[
bool
]
=
True
,
use_fast_tokenizer
:
Optional
[
bool
]
=
True
,
gguf_file
:
Optional
[
str
]
=
None
,
gguf_file
:
Optional
[
str
]
=
None
,
add_bos_token
:
Optional
[
bool
]
=
False
,
)
->
None
:
)
->
None
:
"""
"""
Helper method during initialization.
Helper method during initialization.
...
@@ -706,6 +708,9 @@ class HFLM(TemplateLM):
...
@@ -706,6 +708,9 @@ class HFLM(TemplateLM):
else
:
else
:
kwargs
[
"use_fast"
]
=
use_fast_tokenizer
kwargs
[
"use_fast"
]
=
use_fast_tokenizer
if
add_bos_token
:
kwargs
[
"add_bos_token"
]
=
True
if
tokenizer
:
if
tokenizer
:
if
isinstance
(
tokenizer
,
str
):
if
isinstance
(
tokenizer
,
str
):
self
.
tokenizer
=
transformers
.
AutoTokenizer
.
from_pretrained
(
self
.
tokenizer
=
transformers
.
AutoTokenizer
.
from_pretrained
(
...
...
lm_eval/models/vllm_causallms.py
View file @
07bd7e23
...
@@ -123,6 +123,7 @@ class VLLM(TemplateLM):
...
@@ -123,6 +123,7 @@ class VLLM(TemplateLM):
tokenizer_mode
=
tokenizer_mode
,
tokenizer_mode
=
tokenizer_mode
,
trust_remote_code
=
trust_remote_code
,
trust_remote_code
=
trust_remote_code
,
revision
=
tokenizer_revision
,
revision
=
tokenizer_revision
,
add_bos_token
=
add_bos_token
,
)
)
self
.
tokenizer
=
configure_pad_token
(
self
.
tokenizer
)
self
.
tokenizer
=
configure_pad_token
(
self
.
tokenizer
)
self
.
add_bos_token
=
add_bos_token
self
.
add_bos_token
=
add_bos_token
...
...
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