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

Rope on all Llama models for arbitrarily long inputs #2036

Closed
surak opened this issue Jul 20, 2023 · 3 comments
Closed

Rope on all Llama models for arbitrarily long inputs #2036

surak opened this issue Jul 20, 2023 · 3 comments
Labels
good first issue Good for newcomers

Comments

@surak
Copy link
Collaborator

surak commented Jul 20, 2023

As the latest transformers library is a requirement and the pull request below is in it, we can use the latest rope setting:

huggingface/transformers#24653

Here is the documentation for it: https://huggingface.co/docs/transformers/main/en/model_doc/llama#transformers.LlamaConfig.rope_scaling

@merrymercy
Copy link
Member

Transformers updated by #2011.
Please help us contribute a PR. You can start by replacing the monkey patch in longchat with the official support

def load_model(self, model_path: str, from_pretrained_kwargs: dict):
revision = from_pretrained_kwargs.get("revision", "main")
config = AutoConfig.from_pretrained(model_path, revision=revision)
# Apply monkey patch, TODO(Dacheng): Add flash attention support
from fastchat.model.llama_condense_monkey_patch import (
replace_llama_with_condense,
)
replace_llama_with_condense(config.rope_condense_ratio)
tokenizer = AutoTokenizer.from_pretrained(
model_path, use_fast=self.use_fast_tokenizer, revision=revision
)
model = AutoModelForCausalLM.from_pretrained(
model_path,
low_cpu_mem_usage=True,
**from_pretrained_kwargs,
)
return model, tokenizer

@merrymercy merrymercy added the good first issue Good for newcomers label Jul 21, 2023
@DachengLi1
Copy link
Collaborator

@surak feel free to loop me in.

@surak
Copy link
Collaborator Author

surak commented Jul 24, 2023

@DachengLi1 I have no clue how to do so :-)

@surak surak closed this as completed Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants