TypeError: The current model class (Wav2Vec2ForCTC) is not compatible with `.generate()`, as it doesn't have a language model head.
Author: LYPinASR
Pull request: no

### System Info

- `transformers` version: 4.38.0
- Platform: Linux-5.4.0-99-generic-x86_64-with-glibc2.17
- Python version: 3.8.10
- Huggingface_hub version: 0.21.3
- Safetensors version: 0.4.2
- Accelerate version: 0.27.2
- Accelerate config:    not found
- PyTorch version (GPU?): 2.0.0+cu117 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help?

@sanchit-gandhi


### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

from transformers import Seq2SeqTrainingArguments

training_args = Seq2SeqTrainingArguments(
    output_dir="results/ft",  # change to a repo name of your choice
    per_device_train_batch_size=16,
    gradient_accumulation_steps=2,  # increase by 2x for every 2x decrease in batch size
    learning_rate=1e-3,
    num_train_epochs=50,
    warmup_ratio=0.1,
    #warmup_steps=1000,
    #max_steps=10000,
    gradient_checkpointing=True,
    fp16=True,
    save_only_model = True,
    evaluation_strategy="steps",
    per_device_eval_batch_size=16,
    predict_with_generate=True,
    generation_max_length=448,
    save_steps=100,
    eval_steps=100,
    logging_steps=20,
    report_to=["tensorboard"],
    save_total_limit=2,
    load_best_model_at_end=True,
    metric_for_best_model="wer",
    greater_is_better=False,
    push_to_hub=False,
)
from transformers import Seq2SeqTrainer

trainer = Seq2SeqTrainer(
    args=training_args,
    model=model,
    train_dataset=data['train'],
    eval_dataset=data['test'],
    data_collator=data_collator,
    compute_metrics=compute_metrics,
    tokenizer=processor.tokenizer,
)
trainer.train()

### Expected behavior

figure out

Comments:
Hey @LYPinASR - we typically reserve the GitHub issues on Transformers for bug reports or feature requests. In your case, you would likely be more successful asking for help for your question on the [Hugging Face Forum](https://discuss.huggingface.co). Wav2Vec2 is an encoder-only model. Therefore, it needs to be trained with the base [`Trainer`](https://huggingface.co/docs/transformers/main_classes/trainer#trainer) class, as demonstrated in [this blog post](https://huggingface.co/blog/fine-tune-w2v2-bert). On the other hand, Whisper is encoder-decoder (or Seq2Seq) architecture, meaning is should be used with the [`Seq2SeqTrainer`](https://huggingface.co/docs/transformers/main_classes/trainer#transformers.Seq2SeqTrainer) class.

If you follow the aforementioned blog post, you should be able to train Wav2Vec2 with the base `Trainer` class.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.