# Need Help for News Summary fine tuning using flan t5

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fneed-help-for-news-summary-fine-tuning-using-flan-t5%2F148979%3E%5C
**Category:** Beginners\
**Created:** [April 5, 2025, 12:42pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fneed-help-for-news-summary-fine-tuning-using-flan-t5%2F148979 "2025-04-05T12:42:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sd003](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sd003/32/44849_2.png) [@sd003](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsd003)%5C
**Post date:** [April 5, 2025, 12:42pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fneed-help-for-news-summary-fine-tuning-using-flan-t5%2F148979%2F1 "2025-04-05T12:42:05Z")

</div>

Hey everyone…I was doing a personal project on News Summarization using Flan T5 base model on gopalkalpande/bbc-news-summary hf dataset…so I’m using 95th percentile of the token length that covers 95 percent of my input and outputs … below is my training setup

```auto
from transformers import Seq2SeqTrainer,Seq2SeqTrainingArguments
from transformers.data.data_collator import default_data_collator
import time
from transformers import DataCollatorForSeq2Seq
from transformers import get_scheduler
from torch.optim import AdamW

data_collator = DataCollatorForSeq2Seq(
    tokenizer=tokenizer,
    model=model,
    label_pad_token_id=-100  
)
output_dir = f'./news-sum-training-{str(int(time.time()))}'
train_args = Seq2SeqTrainingArguments(
    output_dir=output_dir,
    num_train_epochs=10,
    eval_strategy="epoch",
    auto_find_batch_size=True,
    evaluation_strategy="epoch",
    learning_rate=1e-4,
    weight_decay=0.01,
    logging_steps=10,
    fp16=False,
    predict_with_generate=True,           
    save_strategy="epoch",
    load_best_model_at_end=True           
)

trainer=Seq2SeqTrainer(
    model=peft_model,
    args=train_args,
    train_dataset=tokenized_train_ds,
    eval_dataset=tokenized_val_ds,
    tokenizer=tokenizer,
    data_collator=data_collator,
    compute_metrics=compute_metrics
)

```

and this is my losses and rouge scores …

 ![Screenshot 2025-04-05 180846](https://us1.discourse-cdn.com/hellohellohello/original/3X/1/1/11109301504a3aeb06afa28c7c5fb223cac0b123.png)

and I’m doing LoRA fine tuning so that config is as below

```auto
from peft import LoraConfig, get_peft_model, TaskType

lora_config = LoraConfig(
    r=32,
    lora_alpha=32,
    target_modules=["q", "v"],
    lora_dropout=0.05,
    bias="none",
    task_type=TaskType.SEQ_2_SEQ_LM
)

peft_model = get_peft_model(model, lora_config)
peft_model.print_trainable_parameters()

```

now i need help to decrease the validation loss further and increase rouge scores to a acceptable level…pls anyone help me or guide what should I do in this situation…thanks in advance.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [April 5, 2025, 1:21pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fneed-help-for-news-summary-fine-tuning-using-flan-t5%2F148979%2F2 "2025-04-05T13:21:01Z")

</div>

> **[Hyperparameter search](https://huggingface.co/docs/transformers/hpo_train)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

I think it’s better to use the hyperparameter search for serious hyperparameter tuning, but there seem to be a few settings that can be tweaked before that.

Also, AdamW has been deprecated and officially discontinued a while ago, so I think it’s better to use a different optimizer.

> <https://github.com/huggingface/transformers/issues/36954>
>
> \`\`\`
> from ragatouille import RAGPretrainedModel
> RAG = RAGPretrainedModel.from\_pre…trained("colbert-ir/colbertv2.0")
> \`\`\`
> 
> \### Getting the following error when trying to run the above code:
> 
> My versions: 
> \> Python v3.12.4
> \> RAGatouille v0.0.9
> \> transformers v4.50.0
> 
> \`\`\`
> Traceback (most recent call last):
> File "\<stdin\>", line 1, in \<module\>
> File "E:\\My Documents\\Mobile Apps\\OneGo\\back-end\\venv\\Lib\\site-packages\\ragatouille\\\_\_init\_\_.py", line 2, in \<module\>
> from .RAGPretrainedModel import RAGPretrainedModel
> File "E:\\My Documents\\Mobile Apps\\OneGo\\back-end\\venv\\Lib\\site-packages\\ragatouille\\RAGPretrainedModel.py", line 14, in \<module\>
> from ragatouille.models import ColBERT, LateInteractionModel
> File "E:\\My Documents\\Mobile Apps\\OneGo\\back-end\\venv\\Lib\\site-packages\\ragatouille\\models\\\_\_init\_\_.py", line 2, in \<module\>
> from .colbert import ColBERT
> File "E:\\My Documents\\Mobile Apps\\OneGo\\back-end\\venv\\Lib\\site-packages\\ragatouille\\models\\colbert.py", line 11, in \<module\>
> from colbert import Trainer
> File "E:\\My Documents\\Mobile Apps\\OneGo\\back-end\\venv\\Lib\\site-packages\\colbert\\\_\_init\_\_.py", line 1, in \<module\>
> from .trainer import Trainer
> File "E:\\My Documents\\Mobile Apps\\OneGo\\back-end\\venv\\Lib\\site-packages\\colbert\\trainer.py", line 5, in \<module\>
> from colbert.training.training import train
> File "E:\\My Documents\\Mobile Apps\\OneGo\\back-end\\venv\\Lib\\site-packages\\colbert\\training\\training.py", line 7, in \<module\>
> from transformers import AdamW, get\_linear\_schedule\_with\_warmup
> ImportError: cannot import name 'AdamW' from 'transformers' (E:\\My Documents\\Mobile Apps\\OneGo\\back-end\\venv\\Lib\\site-packages\\transformers\\\_\_init\_\_.py)
> \`\`\`

* * *

following is by [Hugging Chat](https://huggingface.co/chat/).

To improve the performance of your news summarization model using Flan-T5, here are the key steps and considerations based on your thought process:

1. **Data Preprocessing and Tokenization:**

2. **Model Configuration:**

3. **Training Parameters:**

4. **Regularization Techniques:**

5. **Training Strategy:**

6. **Evaluation and Metrics:**

7. **Hyperparameter Tuning:**

By systematically addressing these areas, you can enhance your model’s performance, potentially leading to lower validation loss and improved ROUGE scores. Monitoring each change closely will help determine the most effective adjustments for your specific dataset and task.

---

<div class="post-metadata">

**Author:** ![sd003](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sd003/32/44849_2.png) [@sd003](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsd003)%5C
**Post date:** [April 5, 2025, 1:43pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fneed-help-for-news-summary-fine-tuning-using-flan-t5%2F148979%2F3 "2025-04-05T13:43:36Z")

</div>

```auto
def preprocess_news_example(example):
    instruction = (
        "### Instruction:\n"
        "Summarize the following news article.\n\n"
        "### Input:\n"
        f"{example['Articles']}\n\n"
        "### Response:"
    )
    return {
        "instruction": instruction,
        "output": example["Summaries"]
    }

```

this is my preprocesing fn I’m already using a prefix for instruction and in the previous snippets I just imported AdamW not used it actually…could you pls point out the data collator settings like what could I possibly modify there
