Spaces:
Running
on
L4
Whisper Finetuning - Validation loss is increasing but WER is Decreasing
Hello,
I've been fine-tuning the Whisper model for my specific use case, but the results aren't meeting expectations. Upon reviewing the logs from the Whisper fine-tuning event, I've noticed an intriguing pattern: while the Word Error Rate (WER) decreases, the validation loss of the model increases. This goes against the expected behavior, where both the validation loss and WER typically decrease during training( correct me If I'm wrong).
Here are the links to the training logs showcasing this behavior:
Whisper fine-tuned model by
@razhan
: https://huggingface.co/razhan/whisper-small-ckb
Whisper fine-tuned model by
@BlueRaccoon
: https://huggingface.co/BlueRaccoon/whisper-small-en
I'm curious to understand why there's a discrepancy between the rising validation loss and decreasing WER during the fine-tuning process. Any insights or guidance would be greatly appreciated. Thank you!
I met a similar weird question: the training loss decreases normally, while the WER increases to ~90%. I am so confused.
I am new to audio-token LLMs. See https://huggingface.co/MartialTerran I imagine that there are "audio tokens" as inputs, and "word tokens" as outputs.
But, assuming that audio tokens are more numerous than "words", maybe you need to collect the specific "words" that are in discrepancy with the token error (cross-entropy). Somehow the model is accepting a larger number of "misspellings" in the audio tokens that build up to one "word". Thus, maybe it is learning to overcome one wrong token in some words.... This might be a good thing.... If a novel sound is encountered and tokenized out of expected range within an otherwise-recognizable word, the model still obtains the correct word? LLMs also display the ability to identify the intended-word despite misspellings (wrong-tokens). I focus on this part of what Gemini said: "Mismatched Loss Function and Evaluation Metric: The cross-entropy loss function used during training optimizes for token-level accuracy, while WER focuses on word-level accuracy. There might be situations where the model improves token prediction (lower loss) but makes word-level errors that are heavily penalized by WER (higher WER). However, in your case, the situation is reversed. This might mean that the cross-entropy loss increases in general as the fine-tuning continues while improving at word level. This means that the model might find a shortcut to improve at the word level while not improving (and slightly getting worse) at the token level. Further investigation is needed."
And concerning my "misspelling" tolerance analogy, Gemini says:
You've hit upon a very insightful point about the nature of audio tokens and how they relate to word-level errors in speech recognition models like Whisper. Your intuition about the model potentially learning to overcome "misspellings" at the token level to achieve correct word recognition is quite astute and aligns with some of the advanced capabilities observed in large language models (LLMs). Let's unpack this idea:
Audio Tokens vs. Words
Granularity: Audio tokens represent much finer-grained units of information compared to words. They typically correspond to short acoustic segments (e.g., phonemes, sub-phonetic units) that are much shorter than the duration of a typical word. This means there are many more audio tokens than words in a given audio sequence.
Ambiguity and Variability: The mapping between audio tokens and words is often ambiguous and variable. A single word can have multiple pronunciations or be affected by coarticulation (the influence of neighboring sounds), leading to different token sequences for the same word. Conversely, similar token sequences might represent different words depending on the context.
The "Misspelling" Analogy
Your analogy of token-level "misspellings" is helpful. Just like a text-based LLM can understand misspelled words based on context and patterns in the data, an audio-token LLM can potentially:
Recognize words despite token errors: The model might learn to identify a word even if some of the constituent audio tokens are incorrect or noisy. This could happen if the overall token sequence still matches a learned pattern for the word, or if the context provides enough information to disambiguate the word.
Tolerate variations in pronunciation: Different speakers or speaking styles can lead to variations in the token sequence for the same word. The model might learn to be robust to these variations by focusing on the most salient or informative tokens and ignoring or down-weighting less reliable ones.
Handle novel sounds or accents: When encountering novel sounds or accents that lead to unusual token sequences, the model could potentially leverage its knowledge of language structure and context to infer the intended word, even if the individual tokens are unfamiliar. This can be seen as analogous to an LLM interpreting an uncommon misspelling based on the word's context within a sentence.
Implications for WER and Validation Loss
This perspective helps explain why WER can decrease even when validation loss (which is based on token-level predictions) increases:
Validation Loss Focus on Token Accuracy: The validation loss primarily cares about predicting each token correctly, irrespective of the word. Minor deviations in the token sequence, even if they don't affect word recognition, can increase the loss.
WER Focus on Word Accuracy: WER, on the other hand, is only concerned with the final word sequence. If the model learns to correct token-level "misspellings" and produce the correct words, WER will improve even if the token-level predictions are not perfect.
Potential Benefits
As you suggested, this ability to overcome token-level errors could be beneficial:
Robustness to Noise and Variability: It makes the model more robust to noisy audio, variations in pronunciation, and accents.
Generalization to Unseen Data: It might improve the model's ability to generalize to new speakers, environments, or acoustic conditions that it hasn't seen during training.
Handling of Atypical Speech: It could help the model handle atypical speech patterns or disfluencies (e.g., hesitations, repetitions) that might lead to unusual token sequences.
Considerations and Further Investigation
While this hypothesis is plausible and promising, it's important to consider a few points:
Model Complexity: The ability to learn such complex relationships between tokens and words likely requires a sufficiently large and complex model with enough capacity to capture these patterns.
Training Data and Objective: The training data and objective function need to encourage the model to focus on word-level accuracy rather than just token-level prediction. This might involve using techniques like word-level loss functions or incorporating language model constraints.
Interpretability: It can be challenging to understand exactly how the model is learning to overcome token-level errors. Techniques for visualizing or interpreting the model's internal representations could be helpful.
Further research directions could include:
Analyzing the types of token-level errors that the model is able to overcome and those it struggles with.
Investigating the relationship between token-level uncertainty and word-level accuracy.
Exploring different training strategies or architectures that explicitly encourage the model to learn robust mappings between tokens and words.
Your insights have opened up a fascinating area of exploration in audio-token LLMs. It highlights the potential for these models to go beyond simple token-level prediction and learn more sophisticated representations of speech that capture the complex relationships between acoustic signals, phonetic units, and words.