From 4cf94b582ea50d2799533c3545eb16845f4795da Mon Sep 17 00:00:00 2001 From: graehl Date: Thu, 24 Jun 2010 23:35:50 +0000 Subject: prune -LM forest git-svn-id: https://ws10smt.googlecode.com/svn/trunk@25 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/cdec.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/decoder/cdec.cc b/decoder/cdec.cc index dbf32cb3..114a248d 100644 --- a/decoder/cdec.cc +++ b/decoder/cdec.cc @@ -79,6 +79,7 @@ void InitCommandLine(int argc, char** argv, po::variables_map* conf) { ("show_expected_length", "Show the expected translation length under the model") ("show_partition,z", "Compute and show the partition (inside score)") ("show_cfg_search_space", "Show the search space as a CFG") + ("prelm_beam_prune", po::value(), "Prune paths from -LM forest before LM rescoring") ("beam_prune", po::value(), "Prune paths from +LM forest") ("lexalign_use_null", "Support source-side null words in lexical translation") ("tagger_tagset,t", po::value(), "(Tagger) file containing tag set") @@ -188,7 +189,7 @@ void MaxTranslationSample(Hypergraph* hg, const int samples, const int k) { // TODO decoder output should probably be moved to another file void DumpKBest(const int sent_id, const Hypergraph& forest, const int k, const bool unique) { -cerr << "In kbest\n"; +cerr << "In kbest\n"; if (unique) { KBest::KBestDerivations, ESentenceTraversal, KBest::FilterUnique> kbest(forest, k); for (int i = 0; i < k; ++i) { @@ -407,6 +408,11 @@ int main(int argc, char** argv) { cerr << " -LM tree: " << ViterbiETree(forest) << endl;; cerr << " -LM Viterbi: " << log(vs) << endl; + if (conf.count("prelm_beam_prune")) { + forest.BeamPruneInsideOutside(1.0, false, conf["prelm_beam_prune"].as(), NULL); + cerr << " Pruned -LM forest (paths): " << forest.NumberOfPaths() << endl; + } + bool has_late_models = !late_models.empty(); if (has_late_models) { forest.Reweight(feature_weights); @@ -544,7 +550,7 @@ int main(int argc, char** argv) { acc_obj += (log_z - log_ref_z); } if (feature_expectations) { - const prob_t z = + const prob_t z = InsideOutside, EdgeFeaturesAndProbWeightFunction>(forest, &ref_exp); ref_exp /= z; acc_obj += log(z); -- cgit v1.2.3