From 0927f7ea0b53946a8547063b4f1594844873cd49 Mon Sep 17 00:00:00 2001 From: Joseph Mills Date: Mon, 24 Aug 2026 23:51:02 +0000 Subject: [PATCH] Populate ys_probs in the online NeMo transducer greedy search decoders --- .../csrc/online-transducer-greedy-search-nemo-decoder.cc | 6 ++++++ ...ransducer-greedy-search-nemo-parakeet-unified-decoder.cc | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/sherpa-onnx/csrc/online-transducer-greedy-search-nemo-decoder.cc b/sherpa-onnx/csrc/online-transducer-greedy-search-nemo-decoder.cc index 3594c1b7d5..8c2884f2d4 100644 --- a/sherpa-onnx/csrc/online-transducer-greedy-search-nemo-decoder.cc +++ b/sherpa-onnx/csrc/online-transducer-greedy-search-nemo-decoder.cc @@ -11,6 +11,7 @@ #include #include "sherpa-onnx/csrc/macros.h" +#include "sherpa-onnx/csrc/math.h" #include "sherpa-onnx/csrc/online-stream.h" #include "sherpa-onnx/csrc/onnx-utils.h" @@ -80,10 +81,15 @@ static void DecodeOne(const float *encoder_out, int32_t num_rows, int32_t y = MaxElementIndex(p_logit, vocab_size); + // Apply LogSoftmax and get log probability for selected token + LogSoftmax(p_logit, vocab_size); + float log_prob = p_logit[y]; + if (y != blank_id) { emitted = true; r.tokens.push_back(y); r.timestamps.push_back(t + r.frame_offset); + r.ys_probs.push_back(log_prob); r.num_trailing_blanks = 0; decoder_input = BuildDecoderInput(y, model->Allocator()); diff --git a/sherpa-onnx/csrc/online-transducer-greedy-search-nemo-parakeet-unified-decoder.cc b/sherpa-onnx/csrc/online-transducer-greedy-search-nemo-parakeet-unified-decoder.cc index 26ce2582af..96e7ebd7ae 100644 --- a/sherpa-onnx/csrc/online-transducer-greedy-search-nemo-parakeet-unified-decoder.cc +++ b/sherpa-onnx/csrc/online-transducer-greedy-search-nemo-parakeet-unified-decoder.cc @@ -10,6 +10,7 @@ #include #include "sherpa-onnx/csrc/macros.h" +#include "sherpa-onnx/csrc/math.h" #include "sherpa-onnx/csrc/online-stream.h" #include "sherpa-onnx/csrc/onnx-utils.h" @@ -74,10 +75,15 @@ static void DecodeOne(const float *encoder_out, int32_t num_rows, int32_t y = MaxElementIndex(p_logit, vocab_size); + // Apply LogSoftmax and get log probability for selected token + LogSoftmax(p_logit, vocab_size); + float log_prob = p_logit[y]; + if (y != blank_id) { emitted = true; r.tokens.push_back(y); r.timestamps.push_back(t + r.frame_offset); + r.ys_probs.push_back(log_prob); r.num_trailing_blanks = 0; decoder_input = BuildDecoderInput(y, model->Allocator());