TrOCR repeated generation
@nielsrI am using microsoft/trocr-large-printedthere is a slight issue, the model generates repeated predictions on my dataset.if you see the left is ground_truth and the right is the model predictionafter generating the right text, it does not stop and goes on repeating the same.Do you know what might be the issue?  Am I missing any param in generate functionMy decoding code looks like thisfor batch in tqdm(test_dataloader):
    # predict using generate
    pixel_values = batch["pixel_values"].to(device)
    outputs = model.generate(pixel_values, output_scores=True, return_dict_in_generate=True, max_length=22)
    
    # decode
    pred_str = processor.batch_decode(outputs.sequences, skip_special_tokens=True)thanks once again
2021-11-29T13:24:11Z
Hi,Thanks for reporting. This has been reported before (seethis).This probably has to do with the settings of thegenerate()method, which uses greedy decoding by default. Note that theoriginal implementationuses beam search.Greedy decoding usually does a lot of repetition, so for tasks like TrOCR one should consider beam-search. And to avoid repetition, one could use theno_repeat_ngram_sizeargument. One should also set the rightmax_lengthandmin_length.I’ll investigate this a bit. Feel free to experiment with the settings of the generate method.
2021-11-29T17:19:45Z
Hi,After investigation, it turns out the generate() method currently does not take into accountconfig.decoder.eos_token_id, onlyconfig.eos_token_id.You can fix it by settingmodel.config.eos_token_id = 2.We will fix this soon.
2021-11-30T15:28:40Z
awesome it worked. Thank you