Skip to content
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

Confidence scores with Zipformer models #490

Open
asterixvn opened this issue Dec 15, 2023 · 3 comments
Open

Confidence scores with Zipformer models #490

asterixvn opened this issue Dec 15, 2023 · 3 comments

Comments

@asterixvn
Copy link

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

@csukuangfj
Copy link
Collaborator

Yes, it is possible.

Taking the greedy search as an example,

auto y = static_cast<int32_t>(std::distance(
static_cast<const float *>(p_logit),
std::max_element(static_cast<const float *>(p_logit),
static_cast<const float *>(p_logit) + vocab_size)));

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.

@asterixvn
Copy link
Author

Thanks a lot, Fangjun. It helps!

@KarelVesely84
Copy link
Contributor

#571

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants