Issues with custom dataset in Wav2Vec2
NONE
Closed and moved to transformers.
2022-01-27T12:29:48Z
https://github.com/huggingface/datasets/issues/3640#issuecomment-1023157343
https://api.github.com/repos/huggingface/datasets/issues/3640
IC_kwDODunzps48_CRf
https://api.github.com/repos/huggingface/datasets/issues/comments/1023157343/reactions
2022-01-27T12:29:48Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1023157343
https://avatars.githubusercontent.com/u/9079808?v=4
https://api.github.com/users/peregilk/events{/privacy}
https://api.github.com/users/peregilk/followers
https://api.github.com/users/peregilk/following{/other_user}
https://api.github.com/users/peregilk/gists{/gist_id}
https://github.com/peregilk
peregilk
MDQ6VXNlcjkwNzk4MDg=
https://api.github.com/users/peregilk/orgs
https://api.github.com/users/peregilk/received_events
https://api.github.com/users/peregilk/repos
https://api.github.com/users/peregilk/starred{/owner}{/repo}
https://api.github.com/users/peregilk/subscriptions
User
https://api.github.com/users/peregilk
public
We are training Vav2Vec using the run_speech_recognition_ctc_bnb.py-script.

This is working fine with Common Voice, however using our custom dataset and data loader at [NbAiLab/NPSC]( https://huggingface.co/datasets/NbAiLab/NPSC) it crashes after roughly 1 epoch with the following stack trace:

![image](https://user-images.githubusercontent.com/9079808/151355893-6d5887cc-ca19-4b12-948a-124eb6dac372.png)


We are able to work around the issue, for instance by adding this check in line#222 in transformers/models/wav2vec2/modeling_wav2vec2.py:
```python
if input_length - (mask_length - 1) < num_masked_span:
           num_masked_span = input_length - (mask_length - 1)
```
Interestingly, these are the variable values before the adjustment:
```
input_length=10
mask_length=10
num_masked_span=2
````
After adjusting num_masked_spin to 1, the training script runs. The issue is also fixed by setting “replace=True” in the same function.

Do you have any  idea what is causing this, and how to fix this error permanently? If you do not think this is an Datasets issue, feel free to move the issue.
