Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: set trust_remote_code to true #500

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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