-
Notifications
You must be signed in to change notification settings - Fork 299
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
ASR SEAME Recipe #1582
Open
AmirHussein96
wants to merge
5
commits into
k2-fsa:master
Choose a base branch
from
AmirHussein96:seame
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
ASR SEAME Recipe #1582
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Introduction | ||
|
||
This recipe includes ASR models (zipformer, zipformer-hat, zipformer-hat-lid) trained and evaluated on SEAME dataset. | ||
The SEAME corpora is Singaporean Codeswitched English and Mandarin. | ||
|
||
This corpus comes defined with a training split and two development splits: | ||
|
||
train -- A mix of codeswitched, Mandarin and Singaporean English | ||
dev_sge -- A set of primarily Singaporean English though there is codeswitching | ||
dev_man -- A set of primarily Mandarin though there is also some codeswitching | ||
|
||
|
||
[./RESULTS.md](./RESULTS.md) contains the latest results. | ||
|
||
# Zipformer-hat | ||
|
||
Zipformer with hybrid autoregressive transducer (HAT) loss https://arxiv.org/abs/2003.07705 | ||
see https://github.com/k2-fsa/icefall/pull/1291 | ||
|
||
# Zipformer-hat-lid | ||
|
||
Zipformer-hat with auxiliary LID encoder and blank sharing for synchronization between ASR and LID as described here (will be shared soon) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
## Results | ||
|
||
#### Zipformer | ||
|
||
| | dev | test | comment | | ||
|------------------------------------|------------|------------|------------------------------------------| | ||
| modified beam search | 21.87 | 29.04 | --epoch 25, --avg 5, --max-duration 500 | | ||
|
||
The training command: | ||
|
||
``` | ||
export CUDA_VISIBLE_DEVICES="0,1,2,3" | ||
|
||
./zipformer/train.py \ | ||
--world-size 4 \ | ||
--num-epochs 25 \ | ||
--start-epoch 1 \ | ||
--use-fp16 1 \ | ||
--exp-dir zipformer/exp-asr-seame \ | ||
--causal 0 \ | ||
--num-encoder-layers 2,2,2,2,2,2 \ | ||
--feedforward-dim 512,768,1024,1024,1024,768 \ | ||
--encoder-dim 192,256,256,256,256,256 \ | ||
--encoder-unmasked-dim 192,192,192,192,192,192 \ | ||
--prune-range 10 \ | ||
--max-duration 500 | ||
``` | ||
|
||
The decoding command: | ||
|
||
``` | ||
./zipformer/decode.py \ | ||
--epoch 25 \ | ||
--avg 5 \ | ||
--beam-size 10 | ||
--exp-dir ./zipformer/exp-asr-seame \ | ||
--max-duration 800 \ | ||
--num-encoder-layers 2,2,2,2,2,2 \ | ||
--feedforward-dim 512,768,1024,1024,1024,768 \ | ||
--encoder-dim 192,256,256,256,256,256 \ | ||
--encoder-unmasked-dim 192,192,192,192,192,192 \ | ||
--decoding-method modified_beam_search | ||
``` | ||
|
||
The pretrained model is available at: <https://huggingface.co/AmirHussein/zipformer-seame> | ||
|
||
|
||
### Zipformer-HAT | ||
|
||
| | dev | test | comment | | ||
|------------------------------------|------------|------------|------------------------------------------| | ||
| modified beam search | 22.00 | 29.92 | --epoch 20, --avg 5, --max-duration 500 | | ||
|
||
|
||
The training command for reproducing is given below: | ||
|
||
``` | ||
export CUDA_VISIBLE_DEVICES="0,1,2,3,4,5" | ||
|
||
./zipformer_hat/train.py \ | ||
--world-size 4 \ | ||
--num-epochs 25 \ | ||
--start-epoch 1 \ | ||
--base-lr 0.045 \ | ||
--lr-epochs 6 \ | ||
--use-fp16 1 \ | ||
--exp-dir zipformer_hat/exp \ | ||
--causal 0 \ | ||
--num-encoder-layers 2,2,2,2,2,2 \ | ||
--feedforward-dim 512,768,1024,1024,1024,768 \ | ||
--encoder-dim 192,256,256,256,256,256 \ | ||
--encoder-unmasked-dim 192,192,192,192,192,192 \ | ||
--prune-range 10 \ | ||
--max-duration 500 | ||
``` | ||
|
||
The decoding command is: | ||
``` | ||
## modified beam search | ||
./zipformer_hat/decode.py \ | ||
--epoch 25 --avg 5 --use-averaged-model True \ | ||
--beam-size 10 \ | ||
--causal 0 \ | ||
--exp-dir zipformer_hat/exp \ | ||
--bpe-model data_seame/lang_bpe_4000/bpe.model \ | ||
--max-duration 1000 \ | ||
--num-encoder-layers 2,2,2,2,2,2 \ | ||
--feedforward-dim 512,768,1024,1024,1024,768 \ | ||
--encoder-dim 192,256,256,256,256,256 \ | ||
--encoder-unmasked-dim 192,192,192,192,192,192 \ | ||
--decoding-method modified_beam_search | ||
``` | ||
|
||
A pre-trained model and decoding logs can be found at <https://huggingface.co/AmirHussein/zipformer-hat-seame> | ||
|
||
### Zipformer-HAT-LID | ||
|
||
| | dev | test | comment | | ||
|------------------------------------|------------|------------|------------------------------------------| | ||
| modified beam search | 20.04 | 26.91 | --epoch 15, --avg 5, --max-duration 500 | | ||
|
||
The training command for reproducing is given below: | ||
|
||
``` | ||
export CUDA_VISIBLE_DEVICES="0,1,2,3,4,5" | ||
|
||
./zipformer_hat_lid/train.py \ | ||
--world-size 4 \ | ||
--lid True \ | ||
--num-epochs 25 \ | ||
--start-epoch 1 \ | ||
--base-lr 0.045 \ | ||
--use-fp16 1 \ | ||
--lid-loss-scale 0.3 \ | ||
--exp-dir zipformer_hat_lid/exp \ | ||
--causal 0 \ | ||
--lid-output-layer 3 \ | ||
--num-encoder-layers 2,2,2,2,2,2 \ | ||
--feedforward-dim 512,768,1024,1024,1024,768 \ | ||
--encoder-dim 192,256,256,256,256,256 \ | ||
--encoder-unmasked-dim 192,192,192,192,192,192 \ | ||
--lids "<en>,<zh>" \ | ||
--prune-range 10 \ | ||
--freeze-main-model False \ | ||
--use-lid-encoder True \ | ||
--use-lid-joiner True \ | ||
--lid-num-encoder-layers 2,2,2 \ | ||
--lid-downsampling-factor 2,4,2 \ | ||
--lid-feedforward-dim 256,256,256 \ | ||
--lid-num-heads 4,4,4 \ | ||
--lid-encoder-dim 256,256,256 \ | ||
--lid-encoder-unmasked-dim 128,128,128 \ | ||
--lid-cnn-module-kernel 31,15,31 \ | ||
--max-duration 500 | ||
|
||
``` | ||
|
||
The decoding command is: | ||
``` | ||
## modified beam search | ||
python zipformer_hat_lid/decode.py \ | ||
--epoch $epoch --avg 5 --use-averaged-model True \ | ||
--beam-size 10 \ | ||
--lid False \ | ||
--lids "<en>,<zh>" \ | ||
--exp-dir zipformer_hat_lid/exp \ | ||
--bpe-model data_seame/lang_bpe_4000/bpe.model \ | ||
--max-duration 800 \ | ||
--num-encoder-layers 2,2,2,2,2,2 \ | ||
--feedforward-dim 512,768,1024,1024,1024,768 \ | ||
--encoder-dim 192,256,256,256,256,256 \ | ||
--encoder-unmasked-dim 192,192,192,192,192,192 \ | ||
--decoding-method modified_beam_search \ | ||
--lid-output-layer 3 \ | ||
--use-lid-encoder True \ | ||
--use-lid-joiner True \ | ||
--lid-num-encoder-layers 2,2,2 \ | ||
--lid-downsampling-factor 2,4,2 \ | ||
--lid-feedforward-dim 256,256,256 \ | ||
--lid-num-heads 4,4,4 \ | ||
--lid-encoder-dim 256,256,256 \ | ||
--lid-encoder-unmasked-dim 128,128,128 \ | ||
--lid-cnn-module-kernel 31,15,31 | ||
``` | ||
|
||
A pre-trained model and decoding logs can be found at <https://huggingface.co/AmirHussein/zipformer-hat-lid-seame> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python3 | ||
# Johns Hopkins University (authors: Amir Hussein) | ||
|
||
|
||
""" | ||
This file cer from icefall decoded "recogs" file: | ||
id [ref] xxx | ||
id [hyp] yxy | ||
""" | ||
|
||
import argparse | ||
|
||
import jiwer | ||
|
||
|
||
def get_args(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--dec-file", type=str, help="Decoded icefall recogs file") | ||
|
||
return parser | ||
|
||
|
||
def cer_(file): | ||
hyp = [] | ||
ref = [] | ||
cer_results = 0 | ||
ref_lens = 0 | ||
with open(file, "r", encoding="utf-8") as dec: | ||
for line in dec: | ||
id, target = line.split("\t") | ||
id = id[0:-2] | ||
target, txt = target.split("=") | ||
if target == "ref": | ||
words = txt.strip().strip("[]").split(", ") | ||
word_list = [word.strip("'") for word in words] | ||
ref.append(" ".join(word_list)) | ||
elif target == "hyp": | ||
words = txt.strip().strip("[]").split(", ") | ||
word_list = [word.strip("'") for word in words] | ||
hyp.append(" ".join(word_list)) | ||
for h, r in zip(hyp, ref): | ||
if r: | ||
cer_results += jiwer.cer(r, h) * len(r) | ||
|
||
ref_lens += len(r) | ||
print(cer_results / ref_lens) | ||
|
||
|
||
def main(): | ||
parse = get_args() | ||
args = parse.parse_args() | ||
cer_(args.dec_file) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
hi amir, thank you for your contribution!
but im wondering perhaps you want to use a separate
export.py
rather than applying modification to the one used by librispeech?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.
Since both are based on same zipformer architecture, I think they can use the same export, the difference is in the parameters. I could also create a separate one if needed.