sherpa-onnx icon indicating copy to clipboard operation
sherpa-onnx copied to clipboard

Confidence scores with Zipformer models

Open asterixvn opened this issue 1 year ago • 3 comments

Hi all,

I am decoding a Zipformer model with sherpa-onnx (and K2/icefall) and I am wondering if there is any way to get confidence scores for the hypothesized tokens with sherpa-onnx-offlne or other tools.

If this is not possible, can you please share any hints on where I can get this information from the source-code or how I can generate the confidence scores? Information from K2/icefall scripts and programs will be helpful also.

Many thanks. Bac

asterixvn avatar Dec 15 '23 10:12 asterixvn

Yes, it is possible.

Taking the greedy search as an example,

https://github.com/k2-fsa/sherpa-onnx/blob/03ff9db56e9ed7c0252ae036be333de5db75a746/sherpa-onnx/csrc/offline-transducer-greedy-search-decoder.cc#L52-L55

You can get the log_prob of a token from the above code.

Note that you can compute log_softmax from logit and then get the log_prob of the max token at time t.

csukuangfj avatar Dec 15 '23 10:12 csukuangfj

Thanks a lot, Fangjun. It helps!

asterixvn avatar Dec 18 '23 14:12 asterixvn

https://github.com/k2-fsa/sherpa-onnx/pull/571

KarelVesely84 avatar Feb 27 '24 08:02 KarelVesely84