Documentation of class/model functionality, for example: WhisperForConditionalGeneration
Author: asusdisciple
Pull request: no

### Feature request

I would urge you to give some basic explanation what a modelclass does, for example you can import 10 different kinds of Whisper models but it is not clear where the differences are.

For example:
What does WhisperForConditionalGeneration do? Where is the difference to WhisperModel? Where is difference when I load 
AutoModelForSpeechSeq2Seq.from_pretrained() withthe openai repo?

### Motivation

Just to make the usage more user friendly and easy.

### Your contribution

I lack the knowledge to give functionality explanations in term of code comments or a documentation in general.

Comments:
The documentation has already explained those things. I believe you can find the documentation for `WhisperForConditionalGeneration` [here](https://huggingface.co/docs/transformers/v4.38.2/en/model_doc/whisper#transformers.WhisperForConditionalGeneration) and that of `WhisperModel` [here](https://huggingface.co/docs/transformers/v4.38.2/en/model_doc/whisper#transformers.WhisperModel).

You should have checked out the documentation first. For the sake of clarity, let me throw more light on it:

#### Here's a basic explanation on what a ModelClass does:
It defines the architecture and functionality of different neural network models. These classes encapsulate the model's layers, parameters, and forward pass logic. Importing different Whisper models (e.g., "whisper-tiny", "whisper-base", "whisper-large") corresponds to loading different pre-trained versions of the same WhisperModel class. These versions may differ in:
- Size and Complexity: Larger models (e.g., "whisper-base") typically have more parameters and layers, leading to potentially better performance but requiring more computational resources.
- Training Data: Pre-trained models can be trained on different datasets or with different objectives, influencing their performance on specific tasks.
- Fine-tuning: Models can be further fine-tuned on task-specific data to improve performance on a specific application.

#### As for what `WhisperForConditionalGeneration` does and it's difference to `WhisperModel`:
`WhisperForConditionalGeneration` inherits from `WhisperModel` and adds additional functionalities specifically designed for speech-to-text generation. It includes a decoder network that takes the encoded audio representation from the `WhisperModel` and generates the corresponding text sequence.
By now, I'm guessing that you're understanding the difference.
The first notable difference is that `WhisperForConditionalGeneration` is a subclass of `WhisperModel`.
`WhisperModel` is the base class, it represents the core architecture. It typically deals with the audio encoding part of the model.

#### As regards your question about `AutoModelForSpeechSeq2Seq.from_pretrained()` with OpenAI Repo:
`AutoModelForSpeechSeq2Seq` is a utility function from Transformers that automatically identifies the appropriate model class based on the provided model identifier (e.g., "openai/whisper-base"). It then loads the pre-trained weights from the specified source (OpenAI's repository for instance).
The major difference when you load it with the OpenAI repo is that `AutoModelForSpeechSeq2Seq.from_pretrained()` automatically selects the appropriate model class for your task (speech-to-text generation) and efficiently loads the pre-trained weights while `WhisperForConditionalGeneration.from_pretrained()` requires you to manually specify the model class.

From Tublian, comment to @nraychaudhuri, solved, I guess the issue can be closed.

Thanks for the clarification, this helped a lot! About the documentation, I just wasn't sure where to find it since the menupoint just says "whisper", but with the subclasses as you mentioned it makes sense to look there of course.

WhisperForConditionalGeneration and WhisperModel are classes used in Hugging Face's Transformers library, which provides an easy-to-use interface for using and fine-tuning various pre-trained models for natural language processing tasks.

    WhisperForConditionalGeneration: This class is specifically designed for conditional text generation tasks. It's a variant of the GPT (Generative Pre-trained Transformer) model fine-tuned for text generation tasks where the model is conditioned on some input. For instance, you can provide a prompt, and the model will generate text conditioned on that prompt.

    WhisperModel: This is a more general class that can be used for various tasks related to natural language processing, including both generation and classification tasks. It doesn't have specific structures or parameters optimized for conditional text generation but can be used for tasks like text classification, token classification, etc.

The primary difference between WhisperForConditionalGeneration and WhisperModel lies in their intended use cases and their architectures optimized for those tasks. The former is specialized for conditional text generation, while the latter is more general-purpose.

Regarding the usage of AutoModelForSpeechSeq2Seq.from_pretrained() from the OpenAI repo, this function loads a pre-trained model for speech-to-text (STT) or text-to-speech (TTS) tasks. It's not directly related to the Whisper models.

    If you load a speech-to-text model (AutoModelForSpeechSeq2Seq.from_pretrained()), it will load a model fine-tuned for converting speech/audio input into text.
    If you load a text-to-speech model, it will load a model fine-tuned for converting text into speech/audio.

These models are typically based on architectures like Transformer or similar architectures but have been specialized and fine-tuned specifically for speech processing tasks. They operate differently from text-based models like Whisper, focusing on converting between audio and text.


Now I see - I think that both models are called "Whisper" is what got me confused. I thought WhisperForConditionalGeneration and WhisperModel are both variants of the OpenAI model and used for Speech-To-Text tasks exclusively.

 A brief explanation of the different types of models :

1. WhisperModel: This is a base class representing a generic Whisper model. It serves as the foundation for more specialized Whisper models. It provides common functionality and methods that are shared among all Whisper models.

2. WhisperForConditionalGeneration: This class specifically focuses on conditional text generation tasks. It's tailored for scenarios where you provide some input, and the model generates text based on that input. For example, you might give it a prompt, and it generates a continuation or completion of that prompt.

3. AutoModelForSpeechSeq2Seq: This is part of the Hugging Face `transformers` library, and it's used for speech-to-text or text-to-speech tasks. The "Auto" prefix indicates that this class automatically selects the appropriate model architecture based on the provided configuration or pretrained model name. In this case, `AutoModelForSpeechSeq2Seq` is designed for sequence-to-sequence tasks involving speech data.

The differences between these classes lie in their intended use cases and functionalities:

- WhisperModel is a generic base class for all Whisper models and provides common methods and attributes.
  
- WhisperForConditionalGeneration is specialized for text generation tasks where the model generates text based on provided input.

- AutoModelForSpeechSeq2Seq is specific to sequence-to-sequence tasks involving speech data, handling tasks like converting speech to text or text to speech.

When you load `AutoModelForSpeechSeq2Seq.from_pretrained()` with the OpenAI repository, it fetches a pretrained model for speech sequence-to-sequence tasks from the specified repository and initializes it for further use in your application.