Replace this line:
full_generated_text = tokenizer.decode(output_sequences, skip_special_tokens=True)

With this:
full_generated_text = tokenizer.decode(output_sequences[0], skip_special_tokens=True)

Explanation:
model.generate() returns a tensor of shape [batch_size, sequence_length]
Since you're processing a single prompt, output_sequences has shape [1, N]
You need to select the first (and only) sequence using output_sequences[0] before decoding
This converts it to a 1D tensor that tokenizer.decode() can process

This was error in the card :

Replace this line:

full_generated_text = tokenizer.decode(output_sequences, skip_special_tokens=True)

With this:

full_generated_text = tokenizer.decode(output_sequences[0], skip_special_tokens=True)

Explanation:
model.generate() returns a tensor of shape [batch_size, sequence_length]
Since you're processing a single prompt, output_sequences has shape [1, N]
You need to select the first (and only) sequence using output_sequences[0] before decoding
This converts it to a 1D tensor that tokenizer.decode() can process

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment