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

'PromptForGeneration' object has no attribute 'can_generate' #277

Open
derek-kam opened this issue May 19, 2023 · 4 comments
Open

'PromptForGeneration' object has no attribute 'can_generate' #277

derek-kam opened this issue May 19, 2023 · 4 comments

Comments

@derek-kam
Copy link

I am trying tutorial 4.1_all_tasks_are_generation, the training run for a while, then it stopped because of the following errors, any ideas how to solve this?

Train: 2%|███▋ | 500/20000 [11:36<7:37:26, 1.41s/it, loss=45.9]Traceback (most recent call last):
File "/home/opc/gpt-dev/OpenPrompt/tutorial/4.1_all_tasks_are_generation.py", line 399, in
val_acc = evaluate(prompt_model, validation_dataloader)
File "/home/opc/gpt-dev/OpenPrompt/tutorial/4.1_all_tasks_are_generation.py", line 302, in evaluate
_, output_sentence = prompt_model.generate(inputs, **generation_arguments, verbose=False)
File "/home/opc/.local/lib/python3.9/site-packages/openprompt/pipeline_base.py", line 499, in generate
output_sequences = super().generate(**batch, **input_generation_kwargs, pad_token_id=self.tokenizer.pad_token_id, eos_token_id=self.tokenizer.eos_token_id)
File "/home/opc/.local/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/home/opc/.local/lib/python3.9/site-packages/transformers/generation/utils.py", line 1246, in generate
self._validate_model_class()
File "/home/opc/.local/lib/python3.9/site-packages/transformers/generation/utils.py", line 1101, in _validate_model_class
if not self.can_generate():
File "/home/opc/.local/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1614, in getattr
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'PromptForGeneration' object has no attribute 'can_generate'

@derek-kam
Copy link
Author

Same problem with 2.1_conditional_generation.py. Is this a bug in PromptForGeneration?

@PengZirong
Copy link

You can try to uninstall transformer and install transformer==4.19.0 then it works.

@UmerTariq1
Copy link

UmerTariq1 commented Sep 11, 2023

Faced the same error. tried with transformers 4.19.0 and it worked.
But 4.19.0 doesnt have LlamaConfig, LlamaForCausalLM or LlamaTokenizer.

Does anyone know how can i use llama2 then on openprompt and not face the can_generate error?

@milliemaoo
Copy link

Faced the same error. tried with transformers 4.19.0 and it worked. But 4.19.0 doesnt have LlamaConfig, LlamaForCausalLM or LlamaTokenizer.

Does anyone know how can i use llama2 then on openprompt and not face the can_generate error?

I think it would be great if this function would be supported.

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

4 participants