-
Notifications
You must be signed in to change notification settings - Fork 27.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Wav2Vec2] PyCTCDecode Integration to support language model boosted decoding #14339
Changes from 17 commits
6de1445
b68faa9
8294efa
6ec01c2
52afd82
e3b0fde
e7eb51c
ff0de09
6296938
84bfdf3
4caf406
d59b594
ead3873
682b258
6320a5a
53aaeff
7b24cdc
f3648f6
f39f02c
19a1301
88783e3
51f3dc7
ceb6ea2
e2b19af
b1ba5dd
a52f319
66dd6d8
d9cdb5e
b93b954
0fe15e1
2382b92
8e70208
b46df6b
776d152
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,7 @@ jobs: | |
- run: pip install .[sklearn,tf-cpu,torch,testing,sentencepiece,torch-speech,vision] | ||
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html | ||
- run: pip install tensorflow_probability | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
- save_cache: | ||
key: v0.4-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -151,6 +152,7 @@ jobs: | |
- run: pip install --upgrade pip | ||
- run: pip install .[sklearn,flax,torch,testing,sentencepiece,torch-speech,vision] | ||
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
- save_cache: | ||
key: v0.4-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -187,6 +189,8 @@ jobs: | |
- run: pip install --upgrade pip | ||
- run: pip install .[sklearn,flax,torch,testing,sentencepiece,torch-speech,vision] | ||
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
|
||
patrickvonplaten marked this conversation as resolved.
Show resolved
Hide resolved
patrickvonplaten marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- save_cache: | ||
key: v0.4-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -217,6 +221,7 @@ jobs: | |
- run: pip install --upgrade pip | ||
- run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm] | ||
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
- save_cache: | ||
key: v0.4-torch-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -252,6 +257,7 @@ jobs: | |
- run: pip install --upgrade pip | ||
- run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm] | ||
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
- save_cache: | ||
key: v0.4-torch-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -281,6 +287,7 @@ jobs: | |
- run: pip install --upgrade pip | ||
- run: pip install .[sklearn,tf-cpu,testing,sentencepiece,tf-speech,vision] | ||
- run: pip install tensorflow_probability | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need it in the TF tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a |
||
- save_cache: | ||
key: v0.4-tf-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -315,6 +322,7 @@ jobs: | |
- run: pip install --upgrade pip | ||
- run: pip install .[sklearn,tf-cpu,testing,sentencepiece,tf-speech,vision] | ||
- run: pip install tensorflow_probability | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
- save_cache: | ||
key: v0.4-tf-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -342,7 +350,8 @@ jobs: | |
- v0.4-flax-{{ checksum "setup.py" }} | ||
- v0.4-{{ checksum "setup.py" }} | ||
- run: pip install --upgrade pip | ||
- run: sudo pip install .[flax,testing,sentencepiece,flax-speech,vision] | ||
- run: pip install .[flax,testing,sentencepiece,flax-speech,vision] | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
patrickvonplaten marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- save_cache: | ||
key: v0.4-flax-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -375,7 +384,8 @@ jobs: | |
- v0.4-flax-{{ checksum "setup.py" }} | ||
- v0.4-{{ checksum "setup.py" }} | ||
- run: pip install --upgrade pip | ||
- run: sudo pip install .[flax,testing,sentencepiece,vision,flax-speech] | ||
- run: pip install .[flax,testing,sentencepiece,vision,flax-speech] | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
- save_cache: | ||
key: v0.4-flax-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -407,6 +417,7 @@ jobs: | |
- run: pip install --upgrade pip | ||
- run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm] | ||
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
- save_cache: | ||
key: v0.4-torch-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -443,6 +454,7 @@ jobs: | |
- run: pip install --upgrade pip | ||
- run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm] | ||
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
- save_cache: | ||
key: v0.4-torch-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -473,6 +485,7 @@ jobs: | |
- run: pip install --upgrade pip | ||
- run: pip install .[sklearn,tf-cpu,testing,sentencepiece] | ||
- run: pip install tensorflow_probability | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
- save_cache: | ||
key: v0.4-tf-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -507,6 +520,7 @@ jobs: | |
- v0.4-{{ checksum "setup.py" }} | ||
- run: pip install --upgrade pip | ||
- run: pip install .[sklearn,tf-cpu,testing,sentencepiece] | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
- run: pip install tensorflow_probability | ||
- save_cache: | ||
key: v0.4-tf-{{ checksum "setup.py" }} | ||
|
@@ -635,6 +649,7 @@ jobs: | |
git config --global user.name "ci" | ||
- run: pip install --upgrade pip | ||
- run: pip install .[torch,sentencepiece,testing] | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
- save_cache: | ||
key: v0.4-hub-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -673,6 +688,7 @@ jobs: | |
git config --global user.name "ci" | ||
- run: pip install --upgrade pip | ||
- run: pip install .[torch,sentencepiece,testing] | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
- save_cache: | ||
key: v0.4-hub-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -701,6 +717,7 @@ jobs: | |
- v0.4-{{ checksum "setup.py" }} | ||
- run: pip install --upgrade pip | ||
- run: pip install .[torch,testing,sentencepiece,onnxruntime] | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need it in the ONNX tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed it from ONNX |
||
- save_cache: | ||
key: v0.4-onnx-{{ checksum "setup.py" }} | ||
paths: | ||
|
@@ -734,6 +751,7 @@ jobs: | |
- v0.4-{{ checksum "setup.py" }} | ||
- run: pip install --upgrade pip | ||
- run: pip install .[torch,testing,sentencepiece,onnxruntime] | ||
- run: pip install https://github.com/kpu/kenlm/archive/master.zip | ||
- save_cache: | ||
key: v0.4-onnx-{{ checksum "setup.py" }} | ||
paths: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,20 +67,13 @@ Wav2Vec2Processor | |
:members: __call__, pad, from_pretrained, save_pretrained, batch_decode, decode, as_target_processor | ||
|
||
|
||
Wav2Vec2 specific outputs | ||
Wav2Vec2ProcessorWithLM | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. autoclass:: transformers.models.wav2vec2.modeling_wav2vec2.Wav2Vec2BaseModelOutput | ||
:members: | ||
|
||
.. autoclass:: transformers.models.wav2vec2.modeling_wav2vec2.Wav2Vec2ForPreTrainingOutput | ||
:members: | ||
.. autoclass:: transformers.Wav2Vec2ProcessorWithLM | ||
:members: __call__, pad, from_pretrained, save_pretrained, batch_decode, decode, as_target_processor | ||
|
||
.. autoclass:: transformers.models.wav2vec2.modeling_flax_wav2vec2.FlaxWav2Vec2BaseModelOutput | ||
:members: | ||
|
||
patrickvonplaten marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.. autoclass:: transformers.models.wav2vec2.modeling_flax_wav2vec2.FlaxWav2Vec2ForPreTrainingOutput | ||
:members: | ||
|
||
|
||
Wav2Vec2Model | ||
|
@@ -143,3 +136,19 @@ FlaxWav2Vec2ForPreTraining | |
|
||
.. autoclass:: transformers.FlaxWav2Vec2ForPreTraining | ||
:members: __call__ | ||
|
||
Wav2Vec2 specific outputs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In all other doc pages, those go before the models, so let's leave them here for now. We can decide to switch them after the model but all models together? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good - reverting this |
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. autoclass:: transformers.models.wav2vec2.modeling_wav2vec2.Wav2Vec2BaseModelOutput | ||
:members: | ||
|
||
.. autoclass:: transformers.models.wav2vec2.modeling_wav2vec2.Wav2Vec2ForPreTrainingOutput | ||
:members: | ||
|
||
.. autoclass:: transformers.models.wav2vec2.modeling_flax_wav2vec2.FlaxWav2Vec2BaseModelOutput | ||
:members: | ||
|
||
.. autoclass:: transformers.models.wav2vec2.modeling_flax_wav2vec2.FlaxWav2Vec2ForPreTrainingOutput | ||
:members: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this package? The import error indicate to do
pip install pyctcdecode
later on and do not give any instruction to install this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pyctcdecode
optionally depends on kenlm if the user would like to use akenlm
language model. In the future, there will probably be more language models that don't requirekenlm
.So IMO, it's the responsibility of the
pyctcdecode
package to throw a good error in case a user requestspyctcdecode
with akenlm
language model. However since at the moment the only language model support is based onkenlm
I can also throw a nice error message on our side.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a plan to add a realy Python package for
kenlm
? This is a bit heavy :-(There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm really not sure the
kenlm
repo doesn't seem to be super active: https://github.com/kpu/kenlm .It is however the by far most library for language model supported ASR.
Flashlight uses it: https://github.com/flashlight/flashlight/tree/main/bindings/python#dependencies among many other libraries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Espnet uses it as well: https://github.com/espnet/espnet/blob/master/espnet/nets/scorers/ngram.py