Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scripts/rnnlm/lmrescore_pruned.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ max_ngram_order=4 # Approximate the lattice-rescoring by limiting the max-ngram-
# the same ngram history and this prevents the lattice from
# exploding exponentially. Details of the n-gram approximation
# method are described in section 2.3 of the paper
# http://www.danielpovey.com/files/2018_icassp_lattice_pruning.pdm
# http://www.danielpovey.com/files/2018_icassp_lattice_pruning.pdf
max_arcs= # limit the max arcs in lattice while rescoring. E.g., 20000

acwt=0.1
Expand All @@ -26,6 +26,8 @@ normalize=false # If true, we add a normalization step to the output of the RNNL
# as in our RNNLM setup, a properly trained network would automatically
# have its normalization term close to 1. The details of this
# could be found at http://www.danielpovey.com/files/2018_icassp_rnnlm.pdf
lattice_prune_beam=4 # Beam used in pruned lattice composition
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hainan-xv, in your experience, how much difference does this make to WER results? (4 vs. 6)

# This option affects speed and how large the composed lattice may be

# End configuration section.

Expand Down Expand Up @@ -97,6 +99,7 @@ cp $indir/num_jobs $outdir

$cmd JOB=1:$nj $outdir/log/rescorelm.JOB.log \
lattice-lmrescore-kaldi-rnnlm-pruned --lm-scale=$weight $special_symbol_opts \
--lattice-compose-beam=$lattice_prune_beam \
--acoustic-scale=$acwt --max-ngram-order=$max_ngram_order $normalize_opt $max_arcs_opt \
$carpa_option $oldlm $word_embedding "$rnnlm_dir/final.raw" \
"ark:gunzip -c $indir/lat.JOB.gz|" "ark,t:|gzip -c>$outdir/lat.JOB.gz" || exit 1;
Expand Down
15 changes: 13 additions & 2 deletions src/lat/compose-lattice-pruned.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,14 @@ class PrunedCompactLatticeComposer {
// BaseFloat expected_cost_offset;
};


// This bool variable is initialized to false, and will be updated to true
// the first time a Final() function is called on the det_fst_. Then we will
// immediately call RecomputeRruningInfo() so that the output_best_cost_ is
// changed from +inf to a finite value, to be used in beam search. This is the
// only time the RecomputeRruningInfo() function is called manually; otherwise
// it always follows an automatic schedule based on the num-arcs of the output
// lattice.
bool output_reached_final_;
const ComposeLatticePrunedOptions &opts_;
const CompactLattice &clat_in_;
fst::DeterministicOnDemandFst<fst::StdArc> *det_fst_;
Expand Down Expand Up @@ -584,7 +591,7 @@ PrunedCompactLatticeComposer::PrunedCompactLatticeComposer(
const ComposeLatticePrunedOptions &opts,
const CompactLattice &clat_in,
fst::DeterministicOnDemandFst<fst::StdArc> *det_fst,
CompactLattice* composed_clat):
CompactLattice* composed_clat): output_reached_final_(false),
opts_(opts), clat_in_(clat_in), det_fst_(det_fst),
clat_out_(composed_clat),
num_arcs_out_(0),
Expand Down Expand Up @@ -697,6 +704,10 @@ void PrunedCompactLatticeComposer::ProcessQueueElement(
double final_cost = ConvertToCost(final_lat_weight);
if (final_cost < src_composed_state_info.backward_cost)
src_composed_state_info.backward_cost = final_cost;
if (!output_reached_final_) {
output_reached_final_ = true;
RecomputePruningInfo();
}
}
} else {
// It really was an arc. This code is very complicated, so we make it its
Expand Down