Skip to content

Commit

Permalink
add trust_remote_code argument (#2715)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangshuai09 authored Nov 26, 2023
1 parent cfba5f4 commit 96aed4c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fastchat/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
@dataclass
class ModelArguments:
model_name_or_path: Optional[str] = field(default="facebook/opt-125m")
trust_remote_code: bool = field(
default=False,
metadata={
"help": "Whether or not to allow for custom models defined on the Hub in their own modeling files"
},
)
padding_side: str = field(
default="right", metadata={"help": "The padding side in tokenizer"}
)
Expand Down Expand Up @@ -260,6 +266,7 @@ def train():
config = transformers.AutoConfig.from_pretrained(
model_args.model_name_or_path,
cache_dir=training_args.cache_dir,
trust_remote_code=model_args.trust_remote_code,
)
orig_ctx_len = getattr(config, "max_position_embeddings", None)
if orig_ctx_len and training_args.model_max_length > orig_ctx_len:
Expand All @@ -272,13 +279,15 @@ def train():
model_args.model_name_or_path,
config=config,
cache_dir=training_args.cache_dir,
trust_remote_code=model_args.trust_remote_code,
)
tokenizer = transformers.AutoTokenizer.from_pretrained(
model_args.model_name_or_path,
cache_dir=training_args.cache_dir,
model_max_length=training_args.model_max_length,
padding_side=model_args.padding_side,
use_fast=False,
trust_remote_code=model_args.trust_remote_code,
)

if tokenizer.pad_token != tokenizer.unk_token:
Expand Down

0 comments on commit 96aed4c

Please sign in to comment.