Using BartForConditionalGeneration with a batch_size = 2 … all the inputs look right but when I examine the logits the shape is torch.Size([2, 1, 50264])
Great that you solved it!
If you want to compute loss on your own, perhaps you can use BartModel (does not require labels) instead of BartForConditionalGeneration
=======================
About the original question, to me, the following command gave the correct outputs & shape (I used TF). But it seems we need ‘max_length’ padding
model = TFBartForConditionalGeneration.from_pretrained('facebook/bart-large-cnn')
tokenizer = BartTokenizer.from_pretrained('facebook/bart-large-cnn')
src_texts = ['My friends are cool but they eat too many carbs. I really want them to be healthy, so I buy them vegetable.']
tgt_texts = ['I buy them vegetable.']
x = tokenizer.prepare_seq2seq_batch(src_texts, tgt_texts, return_tensors='tf',padding='max_length')
out = model(x)
Note In my case, padding has to be specified as ‘max_length’ , where in the other case, model calling failed.