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

Help with loading model #1499

Open
Axel-At-Apollo opened this issue Jan 3, 2025 · 1 comment
Open

Help with loading model #1499

Axel-At-Apollo opened this issue Jan 3, 2025 · 1 comment

Comments

@Axel-At-Apollo
Copy link

Axel-At-Apollo commented Jan 3, 2025

See #1410, has not been resolved as of yet.

@KareemMusleh
Copy link

I got your code to work like this

modeling_llama = importlib.reload(transformers.models.llama.modeling_llama)

model = modeling_llama.LlamaForCausalLM.from_pretrained(checkpoint_path)
tokenizer = transformers.AutoTokenizer.from_pretrained(checkpoint_path)

# Add text generation
prompt = "Write a short story about a robot learning to paint:"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
    inputs.input_ids,
    max_length=200,
    num_return_sequences=1,
    temperature=0.7,
    do_sample=True,
    pad_token_id=tokenizer.eos_token_id,
)
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
print("\nGenerated text:")
print(generated_text)

I will try to find a more general solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants