recipes/sota/2019/rescoring/README.md
Here we describe how to dump the beam candidates and perform rescoring with GCNN and Transformer LMs we did in the paper.
d80ad54: put the forward_lm.py into fairseq directory (otherwise doesn't work with fairseq import)decode*.cfgdecode*.cfg for each model:
[...]/wav2letter/build/Decoder --flagsfile path/to/necessary/decode/other/config --minloglevel=0 --logtostderr=1 --emission_dir='' --test=dev-other.lst
[...]/wav2letter/build/Decoder --flagsfile path/to/necessary/decode/other/config --minloglevel=0 --logtostderr=1 --emission_dir='' --test=test-other.lst
[...]/wav2letter/build/Decoder --flagsfile path/to/necessary/decode/clean/config --minloglevel=0 --logtostderr=1 --emission_dir='' --test=dev-clean.lst
[...]/wav2letter/build/Decoder --flagsfile path/to/necessary/decode/clean/config --minloglevel=0 --logtostderr=1 --emission_dir='' --test=test-clean.lst
Also run specific diverse beam dump for s2s Librispeech with gcnn decoding (the best one) to have diverse beam (optimization of beam search decoder is done with --beamsize=50 --beamthreshold==10 --beamsizetoken=10):
src/* to the wav2letter/src/libraries/decoder to overwrite Lexicon-free s2s decoder algorithm[...]/wav2letter/build/Decoder --flagsfile decode_transformer_s2s_gcnn_other_ls_completed_hyps.cfg --minloglevel=0 --logtostderr=1 --emission_dir='' --test=dev-other.lst
[...]/wav2letter/build/Decoder --flagsfile decode_transformer_s2s_gcnn_other_ls_completed_hyps.cfg --minloglevel=0 --logtostderr=1 --emission_dir='' --test=test_other.lst
We use word-based GCNN and word-based Transformer to rescore, so at first we generate their perplexities (actually it is loss for the sentecnce) for each candidate in the beam
cd [FAIRSEQ]
# convlm
python forward_lm.py --model [MODEL_PATH]/checkpoint_best.pt --dict [MODEL_DATA_PATH]/dict.txt --text [BEAM DUMP].lst.hyp --out convlm.ppl --model-type convlm --max-tokens 1024 --skip 1
# transformer
python forward_lm.py --model [MODEL_PATH]/checkpoint_best.pt --dict [MODEL_DATA_PATH]/dict.txt --text [BEAM DUMP].lst.hyp --out transformer.ppl --model-type transformer --max-tokens 1024 --skip 1
# for name in dev-other dev-clean
python rescore.py --hyp "[PATH_TO_$name].hyp" --list "[DATA_DST]/lists/$name.lst" --convlm="[PATH]/convlm_$name.ppl" --tr="[PATH]/transformer_$name.ppl" --in_wts=0,0,0 --search
# then eval found best weight for test-other and test-clean
python rescore.py --hyp "[PATH_TO_$name].hyp" --list "[DATA_DST]/lists/$name.lst" --convlm="[PATH]/convlm_$name.ppl" --tr="[PATH]/transformer_$name.ppl" --in_wts=w1,w2,w3
--top=large to eval 2500 beam)# for name in dev-other dev-clean
python rescore.py --hyp "[PATH_TO_$name].hyp" --list "[DATA_DST]/lists/$name.lst" --convlm="[PATH]/convlm_$name.ppl" --tr="[PATH]/transformer_$name.ppl" --in_wts=0,0,0 --search --gridsearch
# then eval found best weight for test-other and test-clean
python rescore.py --hyp "[PATH_TO_$name].hyp" --list "[DATA_DST]/lists/$name.lst" --convlm="[PATH]/convlm_$name.ppl" --tr="[PATH]/transformer_$name.ppl" --in_wts=w1,w2,w3