This is as LatticeFasterDecoder, but does online composition between HCLG and the "difference language model", which is a deterministic FST that represents the difference between the language model you want and the language model you compiled HCLG with. More...
#include <lattice-biglm-faster-decoder.h>
Classes | |
struct | ForwardLink |
struct | Token |
struct | TokenList |
Public Types | |
typedef fst::StdArc | Arc |
typedef Arc::Label | Label |
typedef Arc::StateId | StateId |
typedef uint64 | PairId |
typedef Arc::Weight | Weight |
Public Member Functions | |
LatticeBiglmFasterDecoder (const fst::Fst< fst::StdArc > &fst, const LatticeBiglmFasterDecoderConfig &config, fst::DeterministicOnDemandFst< fst::StdArc > *lm_diff_fst) | |
void | SetOptions (const LatticeBiglmFasterDecoderConfig &config) |
LatticeBiglmFasterDecoderConfig | GetOptions () |
~LatticeBiglmFasterDecoder () | |
bool | Decode (DecodableInterface *decodable) |
bool | ReachedFinal () const |
says whether a final-state was active on the last frame. More... | |
bool | GetBestPath (fst::MutableFst< LatticeArc > *ofst, bool use_final_probs=true) const |
bool | GetRawLattice (fst::MutableFst< LatticeArc > *ofst, bool use_final_probs=true) const |
bool | GetLattice (fst::MutableFst< CompactLatticeArc > *ofst, bool use_final_probs=true) const |
Private Types | |
typedef HashList< PairId, Token * >::Elem | Elem |
Private Member Functions | |
PairId | ConstructPair (StateId fst_state, StateId lm_state) |
void | PossiblyResizeHash (size_t num_toks) |
Elem * | FindOrAddToken (PairId state_pair, int32 frame, BaseFloat tot_cost, bool emitting, bool *changed) |
void | PruneForwardLinks (int32 frame, bool *extra_costs_changed, bool *links_pruned, BaseFloat delta) |
void | PruneForwardLinksFinal (int32 frame) |
void | PruneTokensForFrame (int32 frame) |
void | PruneActiveTokens (int32 cur_frame, BaseFloat delta) |
void | PruneActiveTokensFinal (int32 cur_frame) |
BaseFloat | GetCutoff (Elem *list_head, size_t *tok_count, BaseFloat *adaptive_beam, Elem **best_elem) |
Gets the weight cutoff. Also counts the active tokens. More... | |
StateId | PropagateLm (StateId lm_state, Arc *arc) |
void | ProcessEmitting (DecodableInterface *decodable, int32 frame) |
void | ProcessNonemitting (int32 frame) |
void | DeleteElems (Elem *list) |
void | ClearActiveTokens () |
Static Private Member Functions | |
static StateId | PairToState (PairId state_pair) |
static StateId | PairToLmState (PairId state_pair) |
Private Attributes | |
HashList< PairId, Token * > | toks_ |
std::vector< TokenList > | active_toks_ |
std::vector< const Elem *> | queue_ |
std::vector< BaseFloat > | tmp_array_ |
const fst::Fst< fst::StdArc > & | fst_ |
fst::DeterministicOnDemandFst< fst::StdArc > * | lm_diff_fst_ |
LatticeBiglmFasterDecoderConfig | config_ |
bool | warned_noarc_ |
int32 | num_toks_ |
bool | warned_ |
bool | final_active_ |
std::map< Token *, BaseFloat > | final_costs_ |
This is as LatticeFasterDecoder, but does online composition between HCLG and the "difference language model", which is a deterministic FST that represents the difference between the language model you want and the language model you compiled HCLG with.
The class DeterministicOnDemandFst follows through the epsilons in G for you (assuming G is a standard backoff language model) and makes it look like a determinized FST.
Definition at line 48 of file lattice-biglm-faster-decoder.h.
typedef fst::StdArc Arc |
Definition at line 50 of file lattice-biglm-faster-decoder.h.
Definition at line 300 of file lattice-biglm-faster-decoder.h.
typedef Arc::Label Label |
Definition at line 51 of file lattice-biglm-faster-decoder.h.
typedef uint64 PairId |
Definition at line 54 of file lattice-biglm-faster-decoder.h.
typedef Arc::StateId StateId |
Definition at line 52 of file lattice-biglm-faster-decoder.h.
typedef Arc::Weight Weight |
Definition at line 55 of file lattice-biglm-faster-decoder.h.
|
inline |
Definition at line 57 of file lattice-biglm-faster-decoder.h.
References LatticeFasterDecoderConfig::Check(), KALDI_ASSERT, DeterministicOnDemandFst< Arc >::Start(), and LatticeBiglmFasterDecoder::toks_.
|
inline |
Definition at line 70 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::ClearActiveTokens(), LatticeBiglmFasterDecoder::DeleteElems(), and LatticeBiglmFasterDecoder::toks_.
|
inlineprivate |
Definition at line 867 of file lattice-biglm-faster-decoder.h.
References rnnlm::i, KALDI_ASSERT, LatticeBiglmFasterDecoder::Token::next, and LatticeBiglmFasterDecoder::ForwardLink::next_tok.
Referenced by LatticeBiglmFasterDecoder::Decode(), and LatticeBiglmFasterDecoder::~LatticeBiglmFasterDecoder().
Definition at line 229 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::Decode(), LatticeBiglmFasterDecoder::ProcessEmitting(), and LatticeBiglmFasterDecoder::ProcessNonemitting().
|
inline |
Definition at line 77 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::active_toks_, LatticeBiglmFasterDecoder::ClearActiveTokens(), LatticeBiglmFasterDecoder::config_, LatticeBiglmFasterDecoder::ConstructPair(), LatticeBiglmFasterDecoder::DeleteElems(), LatticeBiglmFasterDecoder::final_active_, LatticeBiglmFasterDecoder::final_costs_, LatticeBiglmFasterDecoder::fst_, DecodableInterface::IsLastFrame(), LatticeFasterDecoderConfig::lattice_beam, LatticeBiglmFasterDecoder::lm_diff_fst_, LatticeBiglmFasterDecoder::num_toks_, LatticeBiglmFasterDecoder::ProcessEmitting(), LatticeBiglmFasterDecoder::ProcessNonemitting(), LatticeFasterDecoderConfig::prune_interval, LatticeBiglmFasterDecoder::PruneActiveTokens(), LatticeBiglmFasterDecoder::PruneActiveTokensFinal(), DeterministicOnDemandFst< Arc >::Start(), LatticeBiglmFasterDecoder::toks_, and LatticeBiglmFasterDecoder::warned_.
Referenced by kaldi::DecodeUtterance().
|
inlineprivate |
Definition at line 859 of file lattice-biglm-faster-decoder.h.
References HashList< I, T >::Clear(), and HashList< I, T >::Delete().
Referenced by LatticeBiglmFasterDecoder::Decode(), and LatticeBiglmFasterDecoder::~LatticeBiglmFasterDecoder().
|
inlineprivate |
Definition at line 315 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::active_toks_, KALDI_ASSERT, LatticeBiglmFasterDecoder::num_toks_, LatticeBiglmFasterDecoder::toks_, LatticeBiglmFasterDecoder::Token::tot_cost, and HashList< I, T >::Elem::val.
Referenced by LatticeBiglmFasterDecoder::ProcessEmitting(), and LatticeBiglmFasterDecoder::ProcessNonemitting().
|
inline |
Definition at line 120 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::GetRawLattice().
Referenced by kaldi::DecodeUtterance().
|
inlineprivate |
Gets the weight cutoff. Also counts the active tokens.
Definition at line 616 of file lattice-biglm-faster-decoder.h.
References LatticeFasterDecoderConfig::beam, LatticeFasterDecoderConfig::beam_delta, LatticeBiglmFasterDecoder::config_, count, LatticeFasterDecoderConfig::max_active, HashList< I, T >::Elem::tail, and LatticeBiglmFasterDecoder::tmp_array_.
Referenced by LatticeBiglmFasterDecoder::ProcessEmitting().
|
inline |
Definition at line 204 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::config_, LatticeFasterDecoderConfig::det_opts, fst::DeterminizeLatticePruned(), LatticeBiglmFasterDecoder::GetRawLattice(), KALDI_WARN, LatticeFasterDecoderConfig::lattice_beam, DeterminizeLatticePrunedOptions::max_mem, and DeterminizeLatticePhonePrunedOptions::max_mem.
|
inline |
Definition at line 69 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::config_.
Referenced by kaldi::DecodeUtterance().
|
inline |
Definition at line 133 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::active_toks_, LatticeBiglmFasterDecoder::final_costs_, KALDI_ASSERT, KALDI_VLOG, KALDI_WARN, LatticeBiglmFasterDecoder::ForwardLink::next, LatticeBiglmFasterDecoder::num_toks_, and LatticeWeightTpl< BaseFloat >::One().
Referenced by kaldi::DecodeUtterance(), LatticeBiglmFasterDecoder::GetBestPath(), and LatticeBiglmFasterDecoder::GetLattice().
Definition at line 236 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::ProcessEmitting(), LatticeBiglmFasterDecoder::ProcessNonemitting(), and LatticeBiglmFasterDecoder::PruneForwardLinksFinal().
Definition at line 233 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::ProcessEmitting(), LatticeBiglmFasterDecoder::ProcessNonemitting(), and LatticeBiglmFasterDecoder::PruneForwardLinksFinal().
|
inlineprivate |
Definition at line 302 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::config_, LatticeFasterDecoderConfig::hash_ratio, and LatticeBiglmFasterDecoder::toks_.
Referenced by LatticeBiglmFasterDecoder::ProcessEmitting().
|
inlineprivate |
Definition at line 687 of file lattice-biglm-faster-decoder.h.
References LatticeFasterDecoderConfig::beam, LatticeBiglmFasterDecoder::config_, LatticeBiglmFasterDecoder::ConstructPair(), LatticeBiglmFasterDecoder::FindOrAddToken(), LatticeBiglmFasterDecoder::ForwardLink::ForwardLink(), LatticeBiglmFasterDecoder::fst_, LatticeBiglmFasterDecoder::GetCutoff(), LatticeBiglmFasterDecoder::ForwardLink::graph_cost, HashList< I, T >::Elem::key, LatticeBiglmFasterDecoder::Token::links, DecodableInterface::LogLikelihood(), LatticeBiglmFasterDecoder::PairToLmState(), LatticeBiglmFasterDecoder::PairToState(), LatticeBiglmFasterDecoder::PossiblyResizeHash(), LatticeBiglmFasterDecoder::PropagateLm(), fst::Times(), LatticeBiglmFasterDecoder::toks_, LatticeBiglmFasterDecoder::Token::tot_cost, and HashList< I, T >::Elem::val.
Referenced by LatticeBiglmFasterDecoder::Decode().
|
inlineprivate |
Definition at line 761 of file lattice-biglm-faster-decoder.h.
References LatticeFasterDecoderConfig::beam, LatticeBiglmFasterDecoder::config_, LatticeBiglmFasterDecoder::ConstructPair(), LatticeBiglmFasterDecoder::Token::DeleteForwardLinks(), LatticeBiglmFasterDecoder::FindOrAddToken(), LatticeBiglmFasterDecoder::ForwardLink::ForwardLink(), LatticeBiglmFasterDecoder::fst_, LatticeBiglmFasterDecoder::ForwardLink::graph_cost, KALDI_ASSERT, KALDI_ERR, HashList< I, T >::Elem::key, LatticeBiglmFasterDecoder::Token::links, LatticeBiglmFasterDecoder::PairToLmState(), LatticeBiglmFasterDecoder::PairToState(), LatticeBiglmFasterDecoder::PropagateLm(), LatticeBiglmFasterDecoder::queue_, LatticeBiglmFasterDecoder::toks_, LatticeBiglmFasterDecoder::Token::tot_cost, HashList< I, T >::Elem::val, and LatticeBiglmFasterDecoder::warned_.
Referenced by LatticeBiglmFasterDecoder::Decode().
Definition at line 663 of file lattice-biglm-faster-decoder.h.
References DeterministicOnDemandFst< Arc >::GetArc(), KALDI_WARN, LatticeBiglmFasterDecoder::lm_diff_fst_, fst::Times(), and LatticeBiglmFasterDecoder::warned_noarc_.
Referenced by LatticeBiglmFasterDecoder::ProcessEmitting(), and LatticeBiglmFasterDecoder::ProcessNonemitting().
Definition at line 566 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::active_toks_, KALDI_VLOG, LatticeBiglmFasterDecoder::num_toks_, LatticeBiglmFasterDecoder::PruneForwardLinks(), and LatticeBiglmFasterDecoder::PruneTokensForFrame().
Referenced by LatticeBiglmFasterDecoder::Decode().
|
inlineprivate |
Definition at line 594 of file lattice-biglm-faster-decoder.h.
References KALDI_VLOG, LatticeBiglmFasterDecoder::num_toks_, LatticeBiglmFasterDecoder::PruneForwardLinks(), LatticeBiglmFasterDecoder::PruneForwardLinksFinal(), and LatticeBiglmFasterDecoder::PruneTokensForFrame().
Referenced by LatticeBiglmFasterDecoder::Decode().
|
inlineprivate |
Definition at line 356 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::ForwardLink::acoustic_cost, LatticeBiglmFasterDecoder::active_toks_, LatticeBiglmFasterDecoder::config_, LatticeBiglmFasterDecoder::Token::extra_cost, LatticeBiglmFasterDecoder::ForwardLink::graph_cost, KALDI_ASSERT, KALDI_WARN, LatticeFasterDecoderConfig::lattice_beam, LatticeBiglmFasterDecoder::ForwardLink::next, LatticeBiglmFasterDecoder::ForwardLink::next_tok, LatticeBiglmFasterDecoder::Token::tot_cost, and LatticeBiglmFasterDecoder::warned_.
Referenced by LatticeBiglmFasterDecoder::PruneActiveTokens(), and LatticeBiglmFasterDecoder::PruneActiveTokensFinal().
|
inlineprivate |
Definition at line 431 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::ForwardLink::acoustic_cost, LatticeBiglmFasterDecoder::active_toks_, kaldi::ApproxEqual(), LatticeBiglmFasterDecoder::config_, LatticeBiglmFasterDecoder::Token::extra_cost, DeterministicOnDemandFst< Arc >::Final(), LatticeBiglmFasterDecoder::final_active_, LatticeBiglmFasterDecoder::final_costs_, LatticeBiglmFasterDecoder::fst_, LatticeBiglmFasterDecoder::ForwardLink::graph_cost, KALDI_ASSERT, KALDI_WARN, LatticeFasterDecoderConfig::lattice_beam, LatticeBiglmFasterDecoder::lm_diff_fst_, LatticeBiglmFasterDecoder::ForwardLink::next, LatticeBiglmFasterDecoder::ForwardLink::next_tok, LatticeBiglmFasterDecoder::PairToLmState(), LatticeBiglmFasterDecoder::PairToState(), LatticeBiglmFasterDecoder::toks_, and LatticeBiglmFasterDecoder::Token::tot_cost.
Referenced by LatticeBiglmFasterDecoder::PruneActiveTokensFinal().
|
inlineprivate |
Definition at line 538 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::active_toks_, LatticeBiglmFasterDecoder::Token::extra_cost, KALDI_ASSERT, KALDI_WARN, LatticeBiglmFasterDecoder::Token::next, LatticeBiglmFasterDecoder::ForwardLink::next_tok, and LatticeBiglmFasterDecoder::num_toks_.
Referenced by LatticeBiglmFasterDecoder::PruneActiveTokens(), and LatticeBiglmFasterDecoder::PruneActiveTokensFinal().
|
inline |
says whether a final-state was active on the last frame.
If it was not, the lattice (or traceback) will end with states that are not final-states.
Definition at line 115 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::final_active_.
Referenced by kaldi::DecodeUtterance().
|
inline |
Definition at line 68 of file lattice-biglm-faster-decoder.h.
References LatticeBiglmFasterDecoder::config_.
|
private |
Definition at line 836 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::Decode(), LatticeBiglmFasterDecoder::FindOrAddToken(), LatticeBiglmFasterDecoder::GetRawLattice(), LatticeBiglmFasterDecoder::PruneActiveTokens(), LatticeBiglmFasterDecoder::PruneForwardLinks(), LatticeBiglmFasterDecoder::PruneForwardLinksFinal(), and LatticeBiglmFasterDecoder::PruneTokensForFrame().
|
private |
Definition at line 844 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::Decode(), LatticeBiglmFasterDecoder::GetCutoff(), LatticeBiglmFasterDecoder::GetLattice(), LatticeBiglmFasterDecoder::GetOptions(), LatticeBiglmFasterDecoder::PossiblyResizeHash(), LatticeBiglmFasterDecoder::ProcessEmitting(), LatticeBiglmFasterDecoder::ProcessNonemitting(), LatticeBiglmFasterDecoder::PruneForwardLinks(), LatticeBiglmFasterDecoder::PruneForwardLinksFinal(), and LatticeBiglmFasterDecoder::SetOptions().
|
private |
Definition at line 848 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::Decode(), LatticeBiglmFasterDecoder::PruneForwardLinksFinal(), and LatticeBiglmFasterDecoder::ReachedFinal().
Definition at line 850 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::Decode(), LatticeBiglmFasterDecoder::GetRawLattice(), and LatticeBiglmFasterDecoder::PruneForwardLinksFinal().
|
private |
Definition at line 842 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::Decode(), LatticeBiglmFasterDecoder::ProcessEmitting(), LatticeBiglmFasterDecoder::ProcessNonemitting(), and LatticeBiglmFasterDecoder::PruneForwardLinksFinal().
|
private |
Definition at line 843 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::Decode(), LatticeBiglmFasterDecoder::PropagateLm(), and LatticeBiglmFasterDecoder::PruneForwardLinksFinal().
|
private |
Definition at line 846 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::Decode(), LatticeBiglmFasterDecoder::FindOrAddToken(), LatticeBiglmFasterDecoder::GetRawLattice(), LatticeBiglmFasterDecoder::PruneActiveTokens(), LatticeBiglmFasterDecoder::PruneActiveTokensFinal(), and LatticeBiglmFasterDecoder::PruneTokensForFrame().
|
private |
Definition at line 839 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::ProcessNonemitting().
|
private |
Definition at line 840 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::GetCutoff().
Definition at line 835 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::Decode(), LatticeBiglmFasterDecoder::FindOrAddToken(), LatticeBiglmFasterDecoder::LatticeBiglmFasterDecoder(), LatticeBiglmFasterDecoder::PossiblyResizeHash(), LatticeBiglmFasterDecoder::ProcessEmitting(), LatticeBiglmFasterDecoder::ProcessNonemitting(), LatticeBiglmFasterDecoder::PruneForwardLinksFinal(), and LatticeBiglmFasterDecoder::~LatticeBiglmFasterDecoder().
|
private |
Definition at line 847 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::Decode(), LatticeBiglmFasterDecoder::ProcessNonemitting(), and LatticeBiglmFasterDecoder::PruneForwardLinks().
|
private |
Definition at line 845 of file lattice-biglm-faster-decoder.h.
Referenced by LatticeBiglmFasterDecoder::PropagateLm().