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
380c62f9
Commit
380c62f9
authored
Jul 21, 2023
by
haileyschoelkopf
Browse files
handle trust_remote_code models better
parent
1e2fbe6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
lm_eval/models/huggingface.py
lm_eval/models/huggingface.py
+16
-1
No files found.
lm_eval/models/huggingface.py
View file @
380c62f9
import
torch
import
transformers
from
transformers.models.auto.modeling_auto
import
MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
from
transformers.models.auto.modeling_auto
import
(
MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
,
MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES
,
)
from
peft
import
__version__
as
PEFT_VERSION
,
PeftModel
import
copy
...
...
@@ -147,6 +150,18 @@ class HFLM(LM):
if
getattr
(
self
.
_config
,
"model_type"
)
in
MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
:
self
.
AUTO_MODEL_CLASS
=
transformers
.
AutoModelForCausalLM
elif
(
not
getattr
(
self
.
_config
,
"model_type"
)
in
MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES
):
if
not
trust_remote_code
:
eval_logger
.
warning
(
"HF model type is neither marked as CausalLM or Seq2SeqLM.
\
This is expected if your model requires `trust_remote_code=True` but may be an error otherwise."
)
# if model type is neither in HF transformers causal or seq2seq model registries
# then we default to AutoModelForCausalLM
self
.
AUTO_MODEL_CLASS
=
transformers
.
AutoModelForCausalLM
else
:
self
.
AUTO_MODEL_CLASS
=
transformers
.
AutoModelForSeq2SeqLM
...
...
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