Skip to content

Commit

Permalink
Treat <unk> as blank
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Mar 1, 2024
1 parent 41ebcfb commit 503a4d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sherpa-ncnn/csrc/greedy-search-decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void GreedySearchDecoder::Decode(ncnn::Mat encoder_out, DecoderResult *result) {
std::max_element(joiner_out_ptr, joiner_out_ptr + joiner_out.w)));

// the blank ID is fixed to 0
if (new_token != 0) {
if (new_token != 0 && new_token != 2) {
result->tokens.push_back(new_token);
ncnn::Mat decoder_input = BuildDecoderInput(*result);
decoder_out = model_->RunDecoder(decoder_input);
Expand Down
4 changes: 2 additions & 2 deletions sherpa-ncnn/csrc/modified-beam-search-decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void ModifiedBeamSearchDecoder::Decode(ncnn::Mat encoder_out,
Hypothesis new_hyp = prev[hyp_index];

// blank id is fixed to 0
if (new_token != 0) {
if (new_token != 0 && new_token != 2) {
new_hyp.ys.push_back(new_token);
new_hyp.num_trailing_blanks = 0;
new_hyp.timestamps.push_back(t + frame_offset);
Expand Down Expand Up @@ -247,7 +247,7 @@ void ModifiedBeamSearchDecoder::Decode(ncnn::Mat encoder_out, Stream *s,
float context_score = 0;
auto context_state = new_hyp.context_state;
// blank id is fixed to 0
if (new_token != 0) {
if (new_token != 0 && new_token != 2) {
new_hyp.ys.push_back(new_token);
new_hyp.num_trailing_blanks = 0;
new_hyp.timestamps.push_back(t + frame_offset);
Expand Down

0 comments on commit 503a4d5

Please sign in to comment.