[Pytorch] Unexpected task example translation : text-generation instead of Translation in model card and Hub
Author: SoyGema
Pull request: no

### System Info

Hello there!
Thanks for making [translation example](https://github.com/huggingface/transformers/tree/main/examples/pytorch/translation) with Pytorch.
🙏🙏 The documentation is amazing and the script is very well structured! 🙏🙏


**System Info**

```
- `transformers` version: 4.32.0.dev0
- Platform: macOS-13.4.1-arm64-arm-64bit
- Python version: 3.10.10
- Huggingface_hub version: 0.16.4
- Safetensors version: 0.3.2
- Accelerate version: 0.21.0
- Accelerate config:    not found
- PyTorch version (GPU?): 2.0.1 (False)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
```

### Who can help?

@patil-suraj  

### Information

- [X] The official example scripts
- [X] My own modified scripts

### Tasks

- [x] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

#### Context 

Fine-tuning **english-hindi** Translation model with [t5-small](https://huggingface.co/SoyGema/t5-small) and [opus100](https://huggingface.co/datasets/opus100) dataset
Running the example [run_translation.py](https://github.com/huggingface/transformers/blob/main/examples/pytorch/translation/run_translation.py) from transformers repository.

[Small modification]( https://github.com/SoyGema/The-Lord-of-The-Words-The-two-frameworks/blob/de9def88f08b2cc14b39c5c74b31b60d4166cab5/src/models/Pytorch/run_translation.py#L366) for making the dataset a little bit smaller for testing end-to-end


Checked recommendations from [README.md](https://github.com/huggingface/transformers/blob/0afa5071bd84e44301750fdc594e33db102cf374/examples/pytorch/translation/README.md?plain=1#L81) when using T5 family models 

- [X] 1. Add `--source_prefix` flag 
- [X] 2. Change 3 flags accordingly `--source_lang` , `--target_lang` and `--source_prefix`

```
python run_translation.py \
    --model_name_or_path t5-small \
    --do_train \
    --do_eval \
    --source_lang en \
    --target_lang hi \
    --source_prefix "translate English to Hindi: " \
    --dataset_name opus100 \
    --dataset_config_name en-hi \
    --output_dir=/tmp/english-hindi \
    --per_device_train_batch_size=4 \
    --per_device_eval_batch_size=4 \
    --overwrite_output_dir \
    --num_train_epochs=3 \
    --push_to_hub=True \
    --predict_with_generate=True
    --report_to_all
    --do_predict
```

Model trains correctly. It is also connected to W&B
Trace of model card . Once the model is trained
```
[INFO|modelcard.py:452] 2023-09-02 23:08:32,386 >> Dropping the following result as it does not have all the necessary fields:
{'task': {'name': 'Sequence-to-sequence Language Modeling', 'type': 'text2text-generation'}, 'dataset': {'name': 'opus100', 'type': 'opus100', 'config': 'en-hi', 'split': 'validation', 'args': 'en-hi'}}
```
The model is pushed to the HUB



### Expected behavior


- Correct task recognition and inference : Somehow the task is uploaded in Hub as  **text-generation** and not as a **translation task**.
Inference shows text-generation as well, And the model card seems to point at that too.
During search , I visited/Read [forum](https://discuss.huggingface.co/t/trainer-vs-seq2seqtrainer/3145), but I think it makes reference to the BLEU generation metric and not the task (if Im understanding well ) I´ve also checked [Tasks docs](https://huggingface.co/docs/hub/models-tasks) and I think it gives you a guide on how to add a task, not change it - please let me know if I shall follow this path - and [Troubleshoot](https://huggingface.co/docs/transformers/troubleshooting) page , but couldn´t find anything. 


<img width="1308" alt="text-generation-instead-translation" src="https://github.com/SoyGema/The-Lord-of-The-Words-The-two-frameworks/assets/24204714/abdee474-3629-4f86-b669-f7b2f2e6209a">





_Tangential Note_ : 
Im aware that the Bleu Score is 0 , and I tried another languages and modifying some logic in [compute_metrics](https://github.com/SoyGema/The-Lord-of-The-Words-The-two-frameworks/blob/main/src/models/Pytorch/run_translation.py#L590) function , as well as trying with another language that computed BLEU well. However the model was also loaded as text-generation. If keeping the experimentation up can prove some hypothesis I might have about this logic and BLEU ( that impact languages with alphabets distinct from latin ones) I will let you know , but I made those experiments to test if the task issue was somehow related to the task


<img width="254" alt="Captura de pantalla 2023-09-03 a las 10 14 15" src="https://github.com/huggingface/transformers/assets/24204714/ce27020a-6565-46cd-ab50-9e69ad505104">





Any help with clarifying and poiniting to translation task would be much appreciated
And if some change in the script or docs might come from this happy to contribute
Thanks for making transformers 🤖 , for the time dedicated to this issue 🕞 and have a nice day 🤗!  

Comments:
Hi @SoyGema, thanks for raising this issue! 

If you want to change the task that a model is mapped to, you can do so by clicking on the `Edit model card` button 
 
<img width="1028" alt="Screenshot 2023-09-04 at 14 52 39" src="https://github.com/huggingface/transformers/assets/22614925/a01e4c84-b836-42b5-959f-d6e48c589321">

and then selecting the desired pipeline_tag.

<img width="1028" alt="Screenshot 2023-09-04 at 14 53 26" src="https://github.com/huggingface/transformers/assets/22614925/b1af2951-c513-4492-a965-b08af603a0e0">


Why this is automapped to text2text generation when the [task is specified in the script](https://github.com/huggingface/transformers/blob/bfb1895e3346cb8a2bf2560c75d45e70edf46a47/examples/pytorch/translation/run_translation.py#L665), I'm not sure. However, this tag isn't technically incorrect - T5 is an encoder-decoder model and this is a text generation task. cc @Narsil @muellerzr do either of you know? 

With regards to your questions about BLEU, this is a question best placed in our [forums](https://discuss.huggingface.co/). We try to reserve the github issues for feature requests and bug reports.


> Why this is automapped to text2text generation when the [task is specified in the script](https://github.com/huggingface/transformers/blob/bfb1895e3346cb8a2bf2560c75d45e70edf46a47/examples/pytorch/translation/run_translation.py#L665), I'm not sure. However, this tag isn't technically incorrect - T5 is an encoder-decoder model and this is a text generation task. cc @Narsil @muellerzr do either of you know?

The hub infers tasks automatically from the config.json@architectures when it's missing from the README.

Thanks for the support given in this issue.  I consider this complete as the main challenge has been supported and some derivative as well. With that and the fact that I tend to own the issues I open,  Im proceeding  to close it. Feel free to reopen if necessary. Thanks so much!!🥹