Weird output based on example code

#18
by mark100 - opened

Hi all,

I run the example code below on my end:

import torch
from transformers import pipeline

pipe = pipeline(
"text-generation",
model="google/gemma-2-2b",
device="cuda", # replace with "mps" to run on a Mac device
)

text = "Once upon a time,"
outputs = pipe(text, max_new_tokens=256)
response = outputs[0]["generated_text"]
print(response)

but got some weird output

Once upon a time, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and,

Anything wrong here? Does anyone get similar output like me?

Google org

Hi @mark100 , I tried replicating the error and did not find the issue. Could you please check by upgrading the transformers version using !pip install -U transformers and let us know if the issue still persists. Thank you.

Same problem here.

Google org

Please have a look at the below output when I tried replicating the issue in Kaggle using GPU T4*2 as well as using Colab Enterprise (T4 * 4). Also, the pre-trained model are not trained for any specific task which might cause output inconsistency. You can use Instruction tuned model instead to have better output.
Screenshot 2024-10-18 at 11.22.09 AM.png

Hi I tried the same, and following is the text generated from the system :

"Once upon a time, there was a little girl who was born with a heart condition. She was born with a hole in her heart, and she had to have surgery to fix it. The surgery was successful, and the little girl was able to live a normal life.

The little girl was very happy, and she loved to play with her friends. She was also very smart, and she loved to read books. One day, the little girl’s parents took her to the doctor for a checkup. The doctor told them that the little girl’s heart was still not working properly. The doctor said that the little girl would need to have another surgery to fix her heart. The little girl was very sad, but she knew that she had to have the surgery. The little girl’s parents were very worried, but they knew that they had to do what was best for their daughter. The little girl had the surgery, and she was able to live a normal life.

The little girl was very happy, and she loved to play with her friends. She was also very smart, and she loved to read books. One day, the little girl’s parents took her to the doctor for a checkup. The doctor told them that the little girl’s heart was still not working"

The last sentence starts repeating...

Sign up or log in to comment