searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

语音系列-wenet增加语言模型流程

2024-06-17 04:09:01
7
0

试验了两种接入LM的方式

  • charater级别,CTC beam search with LM
    v2-34d6a218d6a19a8548a9b6cbe53ca90c_720w.png
  • word级别的,CTC WFST search with LM
    v2-d794012dbf69b2b729f246120553f178_720w.png

CTC beam search with LM

参考github.com/wenet-e2e/wenet/blob/main/runtime/gpu/README.md
使用的是kenlm工具统计LM
调节参数: alpha 、 beta

  1. Prepare dict
    ● units.txt :T is the model unit in E2E training
    ● corpus:根据lexicon分词
  2. Train lm :使用kenlm工具生成.apra模型
  3. Decoding with runtime(set--lm_path in the convert_start_server.sh.)

Add language model: set--lm_path in the convert_start_server.sh. Notice the path of your language model is the path in docker. There's a space between two characters.

部署方式是GPU inference with NV's Triton and TensorRT,这种方式很方便。

CTC WFST search with LM

参考 wenet/examples/aishell/s0/run.sh。
使用的是srilm工具统计LM
调节参数: acoustic_scale 、 length_penalty

  1. Prepare dict
    ● units.txt :T is the model unit in E2E training
    ● lexicon.txt :L is the lexicon
    ● corpus:根据lexicon分词
  2. Build decoding TLG.fst(tools/fst/compile_lexicon_token_fst.sh)
  3. Decoding with runtime(tools/decode.sh)
local/aishell_train_lms.sh
  # 7.3 Build decoding TLG
  tools/fst/compile_lexicon_token_fst.sh \
    data/local/dict data/local/tmp data/local/lang
  tools/fst/make_tlg.sh data/local/lm data/local/lang data/lang_test || exit 1;
  # 7.4 Decoding with runtime
  chunk_size=-1
  ./tools/decode.sh --nj 1 \
    --beam 15.0 --lattice_beam 7.5 --max_active 7000 \
    --blank_skip_thresh 0.98 --ctc_weight 0.5 --rescoring_weight 1.0 \
    --chunk_size $chunk_size \
    --fst_path data/lang_test/TLG.fst \
    --dict_path data/lang_test/words.txt \
    data/test/wav.scp data/test/text $dir/final.zip \
    data/lang_test/units.txt data/lm_with_runtime
  # Please see $dir/lm_with_runtime for wer

这种需要有个中间 lexicon 。尝试使用分词工具jieba对语料分词/使用jieba现有的词典,decode效果来看比基线有提升,但是没有第一种方式提升大。

0条评论
0 / 1000
林****玉
6文章数
0粉丝数
林****玉
6 文章 | 0 粉丝
原创

语音系列-wenet增加语言模型流程

2024-06-17 04:09:01
7
0

试验了两种接入LM的方式

  • charater级别,CTC beam search with LM
    v2-34d6a218d6a19a8548a9b6cbe53ca90c_720w.png
  • word级别的,CTC WFST search with LM
    v2-d794012dbf69b2b729f246120553f178_720w.png

CTC beam search with LM

参考github.com/wenet-e2e/wenet/blob/main/runtime/gpu/README.md
使用的是kenlm工具统计LM
调节参数: alpha 、 beta

  1. Prepare dict
    ● units.txt :T is the model unit in E2E training
    ● corpus:根据lexicon分词
  2. Train lm :使用kenlm工具生成.apra模型
  3. Decoding with runtime(set--lm_path in the convert_start_server.sh.)

Add language model: set--lm_path in the convert_start_server.sh. Notice the path of your language model is the path in docker. There's a space between two characters.

部署方式是GPU inference with NV's Triton and TensorRT,这种方式很方便。

CTC WFST search with LM

参考 wenet/examples/aishell/s0/run.sh。
使用的是srilm工具统计LM
调节参数: acoustic_scale 、 length_penalty

  1. Prepare dict
    ● units.txt :T is the model unit in E2E training
    ● lexicon.txt :L is the lexicon
    ● corpus:根据lexicon分词
  2. Build decoding TLG.fst(tools/fst/compile_lexicon_token_fst.sh)
  3. Decoding with runtime(tools/decode.sh)
local/aishell_train_lms.sh
  # 7.3 Build decoding TLG
  tools/fst/compile_lexicon_token_fst.sh \
    data/local/dict data/local/tmp data/local/lang
  tools/fst/make_tlg.sh data/local/lm data/local/lang data/lang_test || exit 1;
  # 7.4 Decoding with runtime
  chunk_size=-1
  ./tools/decode.sh --nj 1 \
    --beam 15.0 --lattice_beam 7.5 --max_active 7000 \
    --blank_skip_thresh 0.98 --ctc_weight 0.5 --rescoring_weight 1.0 \
    --chunk_size $chunk_size \
    --fst_path data/lang_test/TLG.fst \
    --dict_path data/lang_test/words.txt \
    data/test/wav.scp data/test/text $dir/final.zip \
    data/lang_test/units.txt data/lm_with_runtime
  # Please see $dir/lm_with_runtime for wer

这种需要有个中间 lexicon 。尝试使用分词工具jieba对语料分词/使用jieba现有的词典,decode效果来看比基线有提升,但是没有第一种方式提升大。

文章来自个人专栏
语音
4 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0