-
Notifications
You must be signed in to change notification settings - Fork 295
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
[Ready to merge] Pruned Transducer Stateless2 for WenetSpeech (char-based) #349
Changes from all commits
0eff3de
cdb6591
c3b2a52
1b51f18
da78063
7fb31c1
34f859f
3925eae
afdda05
0d8fa6a
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
# Introduction | ||
|
||
This recipe includes some different ASR models trained with WenetSpeech. | ||
|
||
[./RESULTS.md](./RESULTS.md) contains the latest results. | ||
|
||
# Transducers | ||
|
||
There are various folders containing the name `transducer` in this folder. | ||
The following table lists the differences among them. | ||
|
||
| | Encoder | Decoder | Comment | | ||
|---------------------------------------|---------------------|--------------------|-----------------------------| | ||
| `pruned_transducer_stateless2` | Conformer(modified) | Embedding + Conv1d | Using k2 pruned RNN-T loss | | | ||
|
||
The decoder in `transducer_stateless` is modified from the paper | ||
[Rnn-Transducer with Stateless Prediction Network](https://ieeexplore.ieee.org/document/9054419/). | ||
We place an additional Conv1d layer right after the input embedding layer. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
## Results | ||
|
||
### WenetSpeech char-based training results (Pruned Transducer 2) | ||
|
||
#### 2022-05-19 | ||
|
||
Using the codes from this PR https://github.com/k2-fsa/icefall/pull/349. | ||
|
||
When training with the L subset, the WERs are | ||
|
||
| | dev | test-net | test-meeting | comment | | ||
|------------------------------------|-------|----------|--------------|------------------------------------------| | ||
| greedy search | 7.80 | 8.75 | 13.49 | --epoch 10, --avg 2, --max-duration 100 | | ||
| modified beam search (beam size 4) | 7.76 | 8.71 | 13.41 | --epoch 10, --avg 2, --max-duration 100 | | ||
| fast beam search (set as default) | 7.94 | 8.74 | 13.80 | --epoch 10, --avg 2, --max-duration 1500 | | ||
|
||
The training command for reproducing is given below: | ||
|
||
``` | ||
export CUDA_VISIBLE_DEVICES="0,1,2,3,4,5,6,7" | ||
|
||
./pruned_transducer_stateless2/train.py \ | ||
--lang-dir data/lang_char \ | ||
--exp-dir pruned_transducer_stateless2/exp \ | ||
--world-size 8 \ | ||
--num-epochs 15 \ | ||
--start-epoch 0 \ | ||
--max-duration 180 \ | ||
--valid-interval 3000 \ | ||
--model-warm-step 3000 \ | ||
--save-every-n 8000 \ | ||
--training-subset L | ||
``` | ||
|
||
The tensorboard training log can be found at | ||
https://tensorboard.dev/experiment/wM4ZUNtASRavJx79EOYYcg/#scalars | ||
|
||
The decoding command is: | ||
``` | ||
epoch=10 | ||
avg=2 | ||
|
||
## greedy search | ||
./pruned_transducer_stateless2/decode.py \ | ||
--epoch $epoch \ | ||
--avg $avg \ | ||
--exp-dir ./pruned_transducer_stateless2/exp \ | ||
--lang-dir data/lang_char \ | ||
--max-duration 100 \ | ||
--decoding-method greedy_search | ||
|
||
## modified beam search | ||
./pruned_transducer_stateless2/decode.py \ | ||
--epoch $epoch \ | ||
--avg $avg \ | ||
--exp-dir ./pruned_transducer_stateless2/exp \ | ||
--lang-dir data/lang_char \ | ||
--max-duration 100 \ | ||
--decoding-method modified_beam_search \ | ||
--beam-size 4 | ||
|
||
## fast beam search | ||
./pruned_transducer_stateless2/decode.py \ | ||
--epoch $epoch \ | ||
--avg $avg \ | ||
--exp-dir ./pruned_transducer_stateless2/exp \ | ||
--lang-dir data/lang_char \ | ||
--max-duration 1500 \ | ||
--decoding-method fast_beam_search \ | ||
--beam 4 \ | ||
--max-contexts 4 \ | ||
--max-states 8 | ||
``` | ||
|
||
When training with the M subset, the WERs are | ||
|
||
| | dev | test-net | test-meeting | comment | | ||
|------------------------------------|--------|-----------|---------------|-------------------------------------------| | ||
| greedy search | 10.40 | 11.31 | 19.64 | --epoch 29, --avg 11, --max-duration 100 | | ||
| modified beam search (beam size 4) | 9.85 | 11.04 | 18.20 | --epoch 29, --avg 11, --max-duration 100 | | ||
| fast beam search (set as default) | 10.18 | 11.10 | 19.32 | --epoch 29, --avg 11, --max-duration 1500 | | ||
|
||
|
||
When training with the S subset, the WERs are | ||
|
||
| | dev | test-net | test-meeting | comment | | ||
|------------------------------------|--------|-----------|---------------|-------------------------------------------| | ||
| greedy search | 19.92 | 25.20 | 35.35 | --epoch 29, --avg 24, --max-duration 100 | | ||
| modified beam search (beam size 4) | 18.62 | 23.88 | 33.80 | --epoch 29, --avg 24, --max-duration 100 | | ||
| fast beam search (set as default) | 19.31 | 24.41 | 34.87 | --epoch 29, --avg 24, --max-duration 1500 | | ||
|
||
|
||
A pre-trained model and decoding logs can be found at <https://huggingface.co/luomingshuang/icefall_asr_wenetspeech_pruned_transducer_stateless2> | ||
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. Could you also add the pretrained models and decoding results for the Also, could you upload the training logs to huggingface? 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. OK, no problem. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../librispeech/ASR/local/compute_fbank_musan.py |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2021 Johns Hopkins University (Piotr Żelasko) | ||
# Copyright 2021 Xiaomi Corp. (Fangjun Kuang) | ||
# | ||
# See ../../../../LICENSE for clarification regarding multiple authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import logging | ||
from pathlib import Path | ||
|
||
import torch | ||
from lhotse import ( | ||
CutSet, | ||
KaldifeatFbank, | ||
KaldifeatFbankConfig, | ||
LilcomHdf5Writer, | ||
) | ||
|
||
# Torch's multithreaded behavior needs to be disabled or | ||
# it wastes a lot of CPU and slow things down. | ||
# Do this outside of main() in case it needs to take effect | ||
# even when we are not invoking the main (e.g. when spawning subprocesses). | ||
torch.set_num_threads(1) | ||
torch.set_num_interop_threads(1) | ||
|
||
|
||
def compute_fbank_wenetspeech_dev_test(): | ||
in_out_dir = Path("data/fbank") | ||
# number of workers in dataloader | ||
num_workers = 42 | ||
|
||
# number of seconds in a batch | ||
batch_duration = 600 | ||
|
||
subsets = ("S", "M", "DEV", "TEST_NET", "TEST_MEETING") | ||
|
||
device = torch.device("cpu") | ||
if torch.cuda.is_available(): | ||
device = torch.device("cuda", 0) | ||
extractor = KaldifeatFbank(KaldifeatFbankConfig(device=device)) | ||
|
||
logging.info(f"device: {device}") | ||
|
||
for partition in subsets: | ||
cuts_path = in_out_dir / f"cuts_{partition}.jsonl.gz" | ||
if cuts_path.is_file(): | ||
logging.info(f"{cuts_path} exists - skipping") | ||
continue | ||
|
||
raw_cuts_path = in_out_dir / f"cuts_{partition}_raw.jsonl.gz" | ||
|
||
logging.info(f"Loading {raw_cuts_path}") | ||
cut_set = CutSet.from_file(raw_cuts_path) | ||
|
||
logging.info("Computing features") | ||
|
||
cut_set = cut_set.compute_and_store_features_batch( | ||
extractor=extractor, | ||
storage_path=f"{in_out_dir}/feats_{partition}", | ||
num_workers=num_workers, | ||
batch_duration=batch_duration, | ||
storage_type=LilcomHdf5Writer, | ||
) | ||
cut_set = cut_set.trim_to_supervisions( | ||
keep_overlapping=False, min_duration=None | ||
) | ||
|
||
logging.info(f"Saving to {cuts_path}") | ||
cut_set.to_file(cuts_path) | ||
|
||
|
||
def main(): | ||
formatter = ( | ||
"%(asctime)s %(levelname)s [%(filename)s:%(lineno)d] %(message)s" | ||
) | ||
logging.basicConfig(format=formatter, level=logging.INFO) | ||
|
||
compute_fbank_wenetspeech_dev_test() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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.
You can find the tensorboard log here. And according to this log, it takes about 21 days 16 hours and a half for 17 epochs. According to my results, I think it can be stopped when training for 11 epochs.
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.
https://tensorboard.dev/experiment/wM4ZUNtASRavJx79EOYYcg/#scalars