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

The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. #25

Open
zhengbiqing opened this issue Sep 12, 2023 · 3 comments

Comments

@zhengbiqing
Copy link

I run the "Example Usage":

import torch

from transformers import GPT2LMHeadModel, GPT2Tokenizer

device = torch.device("cuda")

tokenizer = GPT2Tokenizer.from_pretrained("stanford-crfm/BioMedLM")

model = GPT2LMHeadModel.from_pretrained("stanford-crfm/BioMedLM").to(device)

input_ids = tokenizer.encode(
"Photosynthesis is ", return_tensors="pt"
).to(device)

sample_output = model.generate(input_ids, do_sample=True, max_length=50, top_k=50)

print("Output:\n" + 100 * "-")
print(tokenizer.decode(sample_output[0], skip_special_tokens=True))

@zhengbiqing
Copy link
Author

I got the result:

The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's attention_mask to obtain reliable results.
Setting pad_token_id to eos_token_id:28895 for open-end generation.
Output:

Photosynthesis is [photosynthetic activity]... [that] is one of the fundamental capabilities of plants on Earth. I would never be thinking about that in light of a world without oxygen. There are still oxygen

what‘s the problem? Anyone can help?

@zhengbiqing
Copy link
Author

The "stanford-crfm/BioMedLM" in code is replaced by "/root/siton-glusterfs-eaxtsxdfs/xts/data/BioMedLM" where I download the model.

@Mehrdadghassabi
Copy link

I have same problem dude,
did you find any 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