Skip to content

Conversation

@sanchit-gandhi
Copy link
Contributor

@sanchit-gandhi sanchit-gandhi commented Oct 12, 2022

What does this PR do?

Generalises run_speech_recognition_seq2seq.py to handle Whisper.

To train the "tiny.en" model on LibriSpeech dummy:

Bash script
#!/usr/bin/env bash
CUDA_VISIBLE_DEVICES=0 python run_speech_recognition_seq2seq.py \
        --dataset_name="hf-internal-testing/librispeech_asr_dummy" \
        --model_name_or_path="openai/whisper-tiny.en" \
        --dataset_config_name="clean" \
        --train_split_name="validation" \
        --eval_split_name="validation" \
        --output_dir="./" \
        --preprocessing_num_workers="1" \
        --length_column_name="input_length" \
        --overwrite_output_dir \
        --num_train_epochs="1" \
        --per_device_train_batch_size="8" \
        --per_device_eval_batch_size="8" \
        --learning_rate="3e-4" \
        --warmup_steps="500" \
        --evaluation_strategy="steps" \
        --text_column_name="text" \
        --save_strategy="no" \
        --evaluation_strategy="epoch" \
        --logging_steps="10" \
        --save_total_limit="1" \
        --generation_max_length="40" \
        --generation_num_beams="1" \
        --fp16 \
        --gradient_checkpointing \
        --group_by_length \
        --predict_with_generate \
        --do_train --do_eval \
        --do_lower_case

To train the "medium.en" model on LibriSpeech 960h:

Bash script
#!/usr/bin/env bash
CUDA_VISIBLE_DEVICES=0 python run_speech_recognition_seq2seq.py \
    --model_name_or_path="openai/whisper-medium.en" \
    --dataset_name="librispeech_asr" \
    --dataset_config_name="all" \
    --train_split_name="train.clean.100+train.clean.360+train.other.500" \
    --eval_split_name="validation.clean" \
    --max_steps="5000" \
    --output_dir="./" \
    --run_name="whisper-librispeech" \
    --per_device_train_batch_size="64" \
    --per_device_eval_batch_size="16" \
    --logging_steps="25" \
    --learning_rate="1e-4" \
    --warmup_steps="500" \
    --report_to="wandb" \
    --preprocessing_num_workers="16" \
    --evaluation_strategy="steps" \
    --eval_steps="1000" \
    --save_strategy="steps" \
    --save_steps="1000" \
    --generation_max_length="224" \
    --generation_num_beams="1" \
    --length_column_name="input_length" \
    --gradient_checkpointing \
    --group_by_length \
    --freeze_encoder \
    --fp16 \
    --overwrite_output_dir \
    --do_train \
    --do_eval \
    --predict_with_generate \
    --use_auth_token

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for iterating here!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@sanchit-gandhi
Copy link
Contributor Author

@sgugger this one's ready to go! Just an FYI in-case you wanted to take a look :)

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

@sanchit-gandhi sanchit-gandhi merged commit af1a7c8 into huggingface:main Nov 14, 2022
@sanchit-gandhi sanchit-gandhi deleted the whisper-fine-tuning branch November 14, 2022 17:45
mpierrau pushed a commit to mpierrau/transformers that referenced this pull request Dec 15, 2022
* merge conflicts

* bos and eos in datacollator

* (temp) hardcode removal of attention mask

* freeze encoder

* actually freeze encoder

* set max length / num beams according to gen kwargs

* (temp) fix tests

* don't pop attn mask

* override return attention mask config from Hub

* Hub configs updated 🤗

* final fixes

* update type annotations

* backward comp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants