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

GPTModelWrapper' object has no attribute 'can_generate' #177

Open
jxcomeon opened this issue Jul 13, 2023 · 1 comment
Open

GPTModelWrapper' object has no attribute 'can_generate' #177

jxcomeon opened this issue Jul 13, 2023 · 1 comment

Comments

@jxcomeon
Copy link

When i run

with torch.inference_mode():
    gpt2_model = GPTModelWrapper(config=model.config, device=model.device, inference=inference_torch)
    sample_output = gpt2_model.generate(inputs.input_ids, max_length=64)

There has an error
'GPTModelWrapper' object has no attribute 'can_generate'
how can i do?
thanks

@ostlee
Copy link

ostlee commented Sep 13, 2023

When i run

with torch.inference_mode():
    gpt2_model = GPTModelWrapper(config=model.config, device=model.device, inference=inference_torch)
    sample_output = gpt2_model.generate(inputs.input_ids, max_length=64)

There has an error 'GPTModelWrapper' object has no attribute 'can_generate' how can i do? thanks

I encountered the same problem. The reason is that the GPTModelWrapper, which inherits from the GenerationMixin, lacks the corresponding class methods and related attributes. My solution is to modify the GPTModelWrapper class according to the PreTrainedModel in transformers : 1. Add the can_generate() method 2. Add self.generation_config in init()

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