Skip to content
Open
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
3 changes: 2 additions & 1 deletion fastchat/model/model_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion fastchat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading