# GPTSAN-japanese Summarisation

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgptsan-japanese-summarisation%2F85758%3E%5C
**Category:** 🤗 Course Projects\
**Created:** [May 8, 2024, 5:58am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgptsan-japanese-summarisation%2F85758 "2024-05-08T05:58:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![minkhantycc](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@minkhantycc](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fminkhantycc)%5C
**Post date:** [May 8, 2024, 5:58am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgptsan-japanese-summarisation%2F85758%2F1 "2024-05-08T05:58:31Z")

</div>

Hi guys,  
I am trying to fine-tune GPTSAN model for summarisation task as explained in a blog post of huggingface. Please look [here](https://huggingface.co/docs/transformers/en/tasks/summarization#summarization). The modifications I made are

1. changing model
2. re-define preprocessing step.

```auto
def preprocess_function(examples):
                    model_inputs = tokenizer(examples['text'], truncation=True, max_length=1024)
                    labels = tokenizer(examples['summary'], truncation=True, max_length=128)
                    model_inputs['labels'] = labels['input_ids']
                    return model_inputs}

```

1. I used standard training loop instead of `trainer`.

```auto
for batch in train_dataloader:
      optimzier.zero_grad()
      batch = [k: v.to(device) for k, v in batch.items()]
      pred = model(input_ids = batch['input_ids'],
                                   attention_mask = batch['attention_mask'],
                                   token_type_ids = batch['token_type_ids'],
                                   decoder_inputs_embeds = batch['decoder_input_ids'],
                                   labels = batch['label'])
       loss = pred.loss
       loss.backward()
       optimizer.step()
       scheduler.step()

```

Then I got an error message saying that the shape of `input_ids` is not the same as that of the `labels`.  
`ValueError: Expected input batch_size (1024) to match target batch_size(128)`.

**Setting those shapes equal in the preprocess function solve the error**. But I don’t know it is theoretically true or wrong.  
**So, I want to know that it is true?**

Thank you for your kind suggestion.
