mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-28 22:45:50 +03:00
port beam threshold from Moses
This commit is contained in:
parent
288af6e425
commit
0f12557e19
@ -22,6 +22,8 @@ HypothesisColl::HypothesisColl(const ManagerBase &mgr) :
|
||||
m_coll(MemPoolAllocator<const HypothesisBase*>(mgr.GetPool())), m_sortedHypos(
|
||||
NULL)
|
||||
{
|
||||
m_bestScore = -std::numeric_limits<float>::infinity();
|
||||
m_worstScore = -std::numeric_limits<float>::infinity();
|
||||
}
|
||||
|
||||
const HypothesisBase *HypothesisColl::GetBestHypo() const
|
||||
@ -50,6 +52,23 @@ void HypothesisColl::Add(
|
||||
Recycler<HypothesisBase*> &hypoRecycle,
|
||||
ArcLists &arcLists)
|
||||
{
|
||||
SCORE futureScore = hypo->GetFutureScore();
|
||||
if (futureScore < m_worstScore) {
|
||||
// beam threshold
|
||||
hypoRecycle.Recycle(hypo);
|
||||
return;
|
||||
}
|
||||
|
||||
if (futureScore > m_bestScore) {
|
||||
m_bestScore = hypo->GetFutureScore();
|
||||
|
||||
// this may also affect the worst score
|
||||
SCORE beamWidth = system.options.search.beam_width;
|
||||
if ( m_bestScore + beamWidth > m_worstScore ) {
|
||||
m_worstScore = m_bestScore + beamWidth;
|
||||
}
|
||||
}
|
||||
|
||||
StackAdd added = Add(hypo);
|
||||
|
||||
size_t nbestSize = system.options.nbest.nbest_size;
|
||||
|
@ -60,6 +60,9 @@ protected:
|
||||
_HCType m_coll;
|
||||
mutable Hypotheses *m_sortedHypos;
|
||||
|
||||
SCORE m_bestScore;
|
||||
SCORE m_worstScore;
|
||||
|
||||
StackAdd Add(const HypothesisBase *hypo);
|
||||
void SortAndPruneHypos(const ManagerBase &mgr, ArcLists &arcLists) const;
|
||||
|
||||
|
@ -79,8 +79,8 @@ Parameter::Parameter()
|
||||
desc += "8=tree-to-string (SCFG-based)\n";
|
||||
desc += "9=forest-to-string";
|
||||
AddParam(search_opts, "search-algorithm", desc);
|
||||
//AddParam(search_opts, "beam-threshold", "b",
|
||||
// "threshold for threshold pruning");
|
||||
AddParam(search_opts, "beam-threshold", "b",
|
||||
"threshold for threshold pruning");
|
||||
//AddParam(search_opts, "early-discarding-threshold", "edt",
|
||||
// "threshold for constructing hypotheses based on estimate cost");
|
||||
AddParam(search_opts, "stack", "s",
|
||||
|
Loading…
Reference in New Issue
Block a user