diff --git a/fastchat/model/model_adapter.py b/fastchat/model/model_adapter.py index 16cf5d2b6..cd4fd3527 100644 --- a/fastchat/model/model_adapter.py +++ b/fastchat/model/model_adapter.py @@ -781,7 +781,8 @@ def load_model(self, model_path: str, from_pretrained_kwargs: dict): # Apply monkey patch, TODO(Dacheng): Add flash attention support config = AutoConfig.from_pretrained(model_path, revision=revision) - replace_llama_with_condense(config.rope_scaling["factor"]) + rope_scaling = getattr(config, "rope_scaling", None) or {} + replace_llama_with_condense(rope_scaling.get("factor", 1)) tokenizer = AutoTokenizer.from_pretrained( model_path, use_fast=self.use_fast_tokenizer, revision=revision diff --git a/fastchat/utils.py b/fastchat/utils.py index d3531928f..1b33c79f1 100644 --- a/fastchat/utils.py +++ b/fastchat/utils.py @@ -365,7 +365,8 @@ def get_context_length(config): """Get the context length of a model from a huggingface model config.""" rope_scaling = getattr(config, "rope_scaling", None) if rope_scaling: - rope_scaling_factor = config.rope_scaling["factor"] + # Some configs (e.g. Phi-3 / Triplex) set rope_scaling without "factor". + rope_scaling_factor = rope_scaling.get("factor", 1) else: rope_scaling_factor = 1