# While finetuning w2v-bert, the WER is not decreasing

**URL:** <https://discuss.huggingface.co/t/while-finetuning-w2v-bert-the-wer-is-not-decreasing/109302>\
**Category:** Beginners\
**Created:** [September 29, 2024, 1:36pm UTC](https://discuss.huggingface.co/t/while-finetuning-w2v-bert-the-wer-is-not-decreasing/109302 "2024-09-29T13:36:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewbawitlung](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/andrewbawitlung/32/62312_2.png) [@andrewbawitlung](https://discuss.huggingface.co/u/andrewbawitlung)\
**Post date:** [September 29, 2024, 1:36pm UTC](https://discuss.huggingface.co/t/while-finetuning-w2v-bert-the-wer-is-not-decreasing/109302/1 "2024-09-29T13:36:33Z")

</div>

While finetuning w2v-bert, the WER is not decreasing. I’ve fine-tuned wav2vec2, xls-r with no problem but w2v-bert has some issune while fine tuning, can anyone help?

| Step | Training Loss | Validation Loss | Wer |
| --- | --- | --- | --- |
| 300 | 4.636700 | inf | 0.993919 |
| 600 | 18.166900 | nan | 1.000000 |
| 900 | 0.000000 | nan | 1.000000 |
| 1200 | 0.000000 | nan | 1.000000 |

Below is my collab notebook.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [September 30, 2024, 5:29am UTC](https://discuss.huggingface.co/t/while-finetuning-w2v-bert-the-wer-is-not-decreasing/109302/2 "2024-09-30T05:29:36Z")

</div>

I’m not familiar with voice model training, but something doesn’t seem right. Take a look at the following page. Maybe it means there are some environments that work well.

I’ve been modifying some Spaces recently, and it occurred to me that all of the voice-related libraries are very old. I think it is possible that some of the libraries that are not explicitly specified in the pip may be doing something wrong.

In the context of generative AI, even functions that are 6 months old may be obsolete. Even if there is no syntax error, the content may have changed, which is tricky.

> <https://github.com/huggingface/blog/blob/main/fine-tune-w2v2-bert.md#training-1>

---

<div class="post-metadata">

**Author:** ![mayank64ce](https://avatars.discourse-cdn.com/v4/letter/m/0ea827/32.png) [@mayank64ce](https://discuss.huggingface.co/u/mayank64ce)\
**Post date:** [September 30, 2024, 5:45pm UTC](https://discuss.huggingface.co/t/while-finetuning-w2v-bert-the-wer-is-not-decreasing/109302/3 "2024-09-30T17:45:53Z")

</div>

Can you manually try printing the loss and gradient norm ? With debugger maybe ?

See if the train\_loss/gradient norm is becoming infinite. In that case, your program might be suffering from gradient explosion problem.

---

<div class="post-metadata">

**Author:** ![amaniopia](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@amaniopia](https://discuss.huggingface.co/u/amaniopia)\
**Post date:** [June 6, 2025, 9:01am UTC](https://discuss.huggingface.co/t/while-finetuning-w2v-bert-the-wer-is-not-decreasing/109302/4 "2025-06-06T09:01:52Z")

</div>

Hello,  
Did you manage to fix this, I’m facing the same issue. Thanks!

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [June 6, 2025, 10:44am UTC](https://discuss.huggingface.co/t/while-finetuning-w2v-bert-the-wer-is-not-decreasing/109302/5 "2025-06-06T10:44:00Z")

</div>

I found tips?

> **[ylacombe/w2v-bert-2.0 · Loss and eval wer getting worse after a few epochs](https://huggingface.co/ylacombe/w2v-bert-2.0/discussions/12)**
>
> Hi @ ylacombe

> - For `eval_loss=NaN`, you can set `config.ctc_zero_infinity = False` (docs [here](https://huggingface.co/docs/transformers/v4.37.2/en/model_doc/wav2vec2-bert#transformers.Wav2Vec2BertConfig.ctc_zero_infinity))
> - Spanish is a much larger dataset in Common Voice than Galician or Mongolian, so you need to adapt hyper-parameters and the training config: Ideally, you would train for a much larger number of epochs on a lower learning rate.
