# Flan-T5 finetuning, predictions too short?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflan-t5-finetuning-predictions-too-short%2F36864%3E%5C
**Category:** Beginners\
**Created:** [April 17, 2023, 4:05pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflan-t5-finetuning-predictions-too-short%2F36864 "2023-04-17T16:05:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikkii22](https://avatars.discourse-cdn.com/v4/letter/n/8797f3/32.png) [@nikkii22](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnikkii22)%5C
**Post date:** [April 17, 2023, 4:05pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflan-t5-finetuning-predictions-too-short%2F36864%2F1 "2023-04-17T16:05:01Z")

</div>

hi guys, im trying to finetune a flan-t5-base modell, with following guide:

> **[A Full Guide to Finetuning T5 for Text2Text and Building a Demo with Streamlit](https://medium.com/nlplanet/a-full-guide-to-finetuning-t5-for-text2text-and-building-a-demo-with-streamlit-c72009631887)**
>
> All you need to know to build a full demo: Hugging Face Hub, Tensorboard, Streamlit, and Hugging Face Spaces

its working, but im not sure about the decoded\_preds:

```
def compute_metrics(eval_pred):
     predictions, labels = eval_pred
     labels[labels<0] = 0 

     decoded_preds = tokenizer.batch_decode(predictions, skip_special_tokens=True)
     decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=True)

      # Compute ROUGE scores
      result = metric.compute(predictions=decoded_preds, references=decoded_labels, use_stemmer=True)

      # Add mean generated length to metrics
      prediction_lens = []
      for pred in predictions:
          pred_len = len(pred)
          print("pred_len: ", pred_len)
          prediction_lens.append(pred_len)
  
      result["gen_len"] = np.mean(prediction_lens)
      print("result[gen_len]: ", result["gen_len"])

      return {k: round(v, 4) for k, v in result.items()}

```

because the output during the training seems too short, its finished too early when you compare with decoded labels.:  
**decoded\_preds:** Chatbot: 2 Hallo Frau Test, vielen Dank für die Anfrage bez  
decoded\_labels: Chatbot: 4 Hallo Frau Muster, vielen Dank für die Anfrage bezgl. Notifikation nderung E-Mailadresse\>. Wir konnten ihr Anliegen wie folgt lösen: Die E-Mailadresse wurde durch das Sekretariat im System gelöscht. Freundliche Grüsse Max Mustermann\>.  
prediction\_lens: 19  
result[gen\_len]: 19.0

im seraching the issue since days, has anyone a tipp here?  
thanks a lot…
