Add script to convert HF Whisper models back to OpenAI format #26854
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR introduces a new script named
convert_hf_to_openai.pythat allows for the conversion of Hugging Face Whisper models back to the original OpenAI Whisper format. This just does the opposite of theconvert_openai_to_hf.pyscript.While Hugging Face is easier to use, for example, for fine-tuning and has many integrations, the original OpenAI Whisper library provides more fine-grained control over this specific model, facilitating the testing of new approaches and certain algorithms (at least in our case).
Doctests
I added a doctest at the beginning that passes, but it requires the
openai-whisperpackage to be installed, so I left it disabled with the double>>. Not sure how do you prefer to handle this case: leave it like that, adding the Whisper package somewhere in the CI (like.github/workflows/doctests.yml), or in any other way.Besides, even though the original
convert_openai_to_hf.pyscript did not have them, let me know if you want me to add some tests to this. I have tested it myself to work with all the Whisper model sizes, even the Large V2.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Possible candidates:
convert_openai_to_hf.pyscript creator: @ArthurZucker