Skip to content

Commit

Permalink
Fix initial tokens to decoding (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Aug 9, 2023
1 parent aeb112d commit aa48b76
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(sherpa-onnx)

set(SHERPA_ONNX_VERSION "1.6.1")
set(SHERPA_ONNX_VERSION "1.6.2")

# Disable warning about
#
Expand Down
3 changes: 2 additions & 1 deletion sherpa-onnx/csrc/offline-transducer-greedy-search-decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ OfflineTransducerGreedySearchDecoder::Decode(Ort::Value encoder_out,

std::vector<OfflineTransducerDecoderResult> ans(batch_size);
for (auto &r : ans) {
r.tokens.resize(context_size, -1);
// 0 is the ID of the blank token
r.tokens.resize(context_size, 0);
r.tokens.back() = 0;
}

auto decoder_input = model_->BuildDecoderInput(ans, ans.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ OfflineTransducerModifiedBeamSearchDecoder::Decode(
int32_t vocab_size = model_->VocabSize();
int32_t context_size = model_->ContextSize();

std::vector<int64_t> blanks(context_size, 0);
std::vector<int64_t> blanks(context_size, -1);
blanks.back() = 0;

std::deque<Hypotheses> finalized;
std::vector<Hypotheses> cur;
Expand Down
3 changes: 2 additions & 1 deletion sherpa-onnx/csrc/online-transducer-greedy-search-decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ OnlineTransducerGreedySearchDecoder::GetEmptyResult() const {
int32_t context_size = model_->ContextSize();
int32_t blank_id = 0; // always 0
OnlineTransducerDecoderResult r;
r.tokens.resize(context_size, blank_id);
r.tokens.resize(context_size, -1);
r.tokens.back() = blank_id;

return r;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ OnlineTransducerModifiedBeamSearchDecoder::GetEmptyResult() const {
int32_t context_size = model_->ContextSize();
int32_t blank_id = 0; // always 0
OnlineTransducerDecoderResult r;
std::vector<int64_t> blanks(context_size, blank_id);
std::vector<int64_t> blanks(context_size, -1);
blanks.back() = blank_id;

Hypotheses blank_hyp({{blanks, 0}});
r.hyps = std::move(blank_hyp);
r.tokens = std::move(blanks);
Expand Down

0 comments on commit aa48b76

Please sign in to comment.