k2-fsa / k2

FSA/FST algorithms, differentiable, with PyTorch compatibility.
https://k2-fsa.github.io/k2
Apache License 2.0
1.1k stars 214 forks source link

When to use k2.ctc_topo with modified=True? #1224

Closed wangtiance closed 1 year ago

wangtiance commented 1 year ago

The result seems to be the same as the "compact CTC" from https://arxiv.org/abs/2110.03098, where the number of arcs is linear with the number of tokens. The paper says that in training, the input needs to be modified. What about inference? Can it be used directly?

wangtiance commented 1 year ago

I later realized it's not the same as compact CTC as state 0 has looping arcs. Still, it produces a much smaller HLG than the standard topology. Is it useful for inference though? H_mod.pdf

danpovey commented 1 year ago

I think the main saving is memory. Not 100% sure though. Can be used for inference but i think after composing with any language model the difference may be small.

wangtiance commented 1 year ago

Thanks Dan. I did some tests, for Librispeech's 3-gram it only reduced the number of arcs of HLG by less than 5%. But for my own G (with only a few keywords) the reduction is significant, like 80%.