Skip to content

Commit

Permalink
ENH: set trust_remote_code to true (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
UranusSeven authored Sep 27, 2023
1 parent 614552b commit 3a5082f
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion xinference/deploy/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def list_model_registrations(
)
@click.option(
"--trust-remote-code",
default=False,
default=True,
type=bool,
help="Whether or not to allow for custom models defined on the Hub in their own modeling files.",
)
Expand Down
3 changes: 1 addition & 2 deletions xinference/model/llm/pytorch/baichuan.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ def _load_model(self, kwargs: dict):
tokenizer = AutoTokenizer.from_pretrained(
self.model_path,
use_fast=self._use_fast_tokenizer,
trust_remote_code=True,
trust_remote_code=kwargs["trust_remote_code"],
revision=kwargs["revision"],
)
model = AutoModelForCausalLM.from_pretrained(
self.model_path,
trust_remote_code=True,
**kwargs,
)
model.generation_config = GenerationConfig.from_pretrained(self.model_path)
Expand Down
3 changes: 1 addition & 2 deletions xinference/model/llm/pytorch/chatglm.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ def _load_model(self, kwargs: dict):

tokenizer = AutoTokenizer.from_pretrained(
self.model_path,
trust_remote_code=True,
trust_remote_code=kwargs["trust_remote_code"],
revision=kwargs["revision"],
)
model = AutoModel.from_pretrained(
self.model_path,
trust_remote_code=True,
**kwargs,
)
return model, tokenizer
Expand Down
2 changes: 1 addition & 1 deletion xinference/model/llm/pytorch/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _sanitize_model_config(
pytorch_model_config.setdefault("gptq_groupsize", -1)
pytorch_model_config.setdefault("gptq_act_order", False)
pytorch_model_config.setdefault("device", "auto")
pytorch_model_config.setdefault("trust_remote_code", False)
pytorch_model_config.setdefault("trust_remote_code", True)
return pytorch_model_config

def _sanitize_generate_config(
Expand Down
2 changes: 1 addition & 1 deletion xinference/model/llm/pytorch/falcon.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def _load_model(self, kwargs: dict):

tokenizer = AutoTokenizer.from_pretrained(
self.model_path,
trust_remote_code=kwargs["trust_remote_code"],
revision=kwargs["revision"],
)
model = AutoModelForCausalLM.from_pretrained(
self.model_path,
low_cpu_mem_usage=True,
trust_remote_code=True,
**kwargs,
)
tokenizer.pad_token_id = 9
Expand Down
2 changes: 1 addition & 1 deletion xinference/model/llm/vllm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _sanitize_model_config(
cuda_count = self._get_cuda_count()

model_config.setdefault("tokenizer_mode", "auto")
model_config.setdefault("trust_remote_code", False)
model_config.setdefault("trust_remote_code", True)
model_config.setdefault("tensor_parallel_size", cuda_count)
model_config.setdefault("block_size", 16)
model_config.setdefault("swap_space", 4)
Expand Down

0 comments on commit 3a5082f

Please sign in to comment.