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
d7b8fd9c
Commit
d7b8fd9c
authored
May 30, 2024
by
Konrad
Browse files
tokenizer name property for cache_key
parent
615352c0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
2 deletions
+11
-2
lm_eval/api/model.py
lm_eval/api/model.py
+6
-0
lm_eval/api/task.py
lm_eval/api/task.py
+1
-2
lm_eval/models/huggingface.py
lm_eval/models/huggingface.py
+4
-0
No files found.
lm_eval/api/model.py
View file @
d7b8fd9c
...
@@ -183,6 +183,12 @@ class LM(abc.ABC):
...
@@ -183,6 +183,12 @@ class LM(abc.ABC):
# not support multi-device parallelism nor expect it.
# not support multi-device parallelism nor expect it.
return
self
.
_world_size
return
self
.
_world_size
@
property
def
get_tokenizer_name
(
self
)
->
str
:
raise
NotImplementedError
(
"To use this model with chat templates, please implement the 'get_tokenizer_name' property."
)
def
set_cache_hook
(
self
,
cache_hook
)
->
None
:
def
set_cache_hook
(
self
,
cache_hook
)
->
None
:
self
.
cache_hook
=
cache_hook
self
.
cache_hook
=
cache_hook
...
...
lm_eval/api/task.py
View file @
d7b8fd9c
...
@@ -391,8 +391,7 @@ class Task(abc.ABC):
...
@@ -391,8 +391,7 @@ class Task(abc.ABC):
if
system_instruction
is
not
None
if
system_instruction
is
not
None
else
""
else
""
)
)
if
lm
is
not
None
and
hasattr
(
lm
,
"tokenizer"
):
cache_key
+=
f
"-tokenizer
{
lm
.
get_tokenizer_name
}
"
if
apply_chat_template
else
""
cache_key
+=
f
"-
{
lm
.
tokenizer
.
name_or_path
.
replace
(
'/'
,
'__'
)
}
"
cached_instances
=
load_from_cache
(
file_name
=
cache_key
)
cached_instances
=
load_from_cache
(
file_name
=
cache_key
)
...
...
lm_eval/models/huggingface.py
View file @
d7b8fd9c
...
@@ -415,6 +415,10 @@ class HFLM(TemplateLM):
...
@@ -415,6 +415,10 @@ class HFLM(TemplateLM):
def
world_size
(
self
):
def
world_size
(
self
):
return
self
.
_world_size
return
self
.
_world_size
@
property
def
get_tokenizer_name
(
self
)
->
str
:
return
self
.
tokenizer
.
name_or_path
.
replace
(
"/"
,
"__"
)
def
_get_backend
(
def
_get_backend
(
self
,
self
,
config
:
Union
[
transformers
.
PretrainedConfig
,
transformers
.
AutoConfig
],
config
:
Union
[
transformers
.
PretrainedConfig
,
transformers
.
AutoConfig
],
...
...
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