| 
    Reranker Framework (ReFr)
    
   Reranking framework for structure prediction and discriminative language modeling 
   | 
 
Model is an interface for reranking models. More...
#include <model.H>
  
 Classes | |
| class | Hook | 
| An interface for specifying a hook to be run by a Model instance.  More... | |
| class | UpdatePredicate | 
| An inner interface for a predicate that tests whether a Model needs to be updated based on the current training example.  More... | |
| class | Updater | 
| An inner interface specifying an update function for a model.  More... | |
Public Member Functions | |
| Model () | |
| Constructs a new instance with the empty string for its name and a NULL kernel function.  More... | |
| Model (const string &name) | |
| Constructs a new instance with a NULL kernel function.  More... | |
| Model (const string &name, KernelFunction *kernel_fn) | |
| Constructs a new instance with the specified kernel function.  More... | |
| Model (const string &name, KernelFunction *kernel_fn, Symbols *symbols) | |
| Constructs a new instance with the specified kernel function and symbol table.  More... | |
| virtual | ~Model () | 
| Destroys this model and its associated kernel function.  More... | |
| const string & | name () const | 
| Returns the unique name for this model instance.  More... | |
| Symbols * | symbols () const | 
| Returns the symbol table for this model.  More... | |
| const Time & | time () const | 
| Returns the current training time of this model: number of epochs, number of time steps in the current epoch and total number of time steps (which is equal to the total number of training examples seen).  More... | |
| virtual int | best_model_epoch () const =0 | 
| int | num_updates () const | 
| Returns the number of updates made by this model.  More... | |
| const vector< int > & | num_training_errors_per_epoch () | 
| Returns the number of training errors made for each epoch.  More... | |
| int | num_training_errors () const | 
| Returns the number of training errors made by this model.  More... | |
| int | min_epochs () const | 
| Returns the minimum number of epochs to train.  More... | |
| int | max_epochs () const | 
| Returns the maximum number of epochs to train.  More... | |
| const vector< double > & | loss_per_epoch () | 
| Returns the loss per epoch for epoch of training that was evaluated.  More... | |
| virtual const string & | model_spec () const =0 | 
| Returns the spec string for constructing a default instance of this model so it may be properly de-serialized by its ModelProtoReader.  More... | |
| virtual const string & | proto_reader_spec () const =0 | 
| Returns the spec string for contructing an instance of a ModelProtoReader capable of de-serializing this Model implementation.  More... | |
| virtual const string & | proto_writer_spec () const =0 | 
| Returns the spec string for contructing an instance of a ModelProtoWriter capable of serializing this Model implementation.  More... | |
| virtual shared_ptr < Candidate::Comparator >  | score_comparator () | 
| Returns a pointer to the score comparator used by this model.  More... | |
| virtual shared_ptr < Candidate::Comparator >  | gold_comparator () | 
| Returns a pointer to the gold comparator used by this model.  More... | |
| virtual bool | NeedToKeepTraining ()=0 | 
| Returns whether more training epochs are required for this model.  More... | |
| virtual void | Train (CandidateSetIterator &examples, CandidateSetIterator &development_test)=0 | 
| Trains this model on a collection of training examples, where each training example is a set of candidates, possibly with a distinguished "gold candidate" that is the reference against which other candidates are scored.  More... | |
| virtual void | NewEpoch ()=0 | 
| virtual void | EndOfEpoch ()=0 | 
| virtual void | TrainOneEpoch (CandidateSetIterator &examples)=0 | 
| Trains this model for one epoch, i.e., a single pass through the specified set of training examples.  More... | |
| virtual void | TrainOnExample (CandidateSet &example)=0 | 
| Trains this model on the specified training example.  More... | |
| virtual bool | NeedToUpdate (CandidateSet &example)=0 | 
| Indicates whether the current model needs to be updated.  More... | |
| virtual void | Update (CandidateSet &example)=0 | 
| Updates the current model based on the specified set of candidates.  More... | |
| virtual double | Evaluate (CandidateSetIterator &development_test)=0 | 
| Evaluates this model on the specified set of held-out development test data.  More... | |
| virtual void | ScoreCandidates (CandidateSet &candidates, bool training)=0 | 
| Scores the specified set of candidates according to either the raw or averaged version of this perceptron model.  More... | |
| virtual double | ScoreCandidate (Candidate &candidate, bool training)=0 | 
| Scores a candidate according to either the raw or averaged version of this perceptron model.  More... | |
| virtual void | set_min_epochs (int min_epochs) | 
| Sets the minimum number of epochs to train.  More... | |
| virtual void | set_max_epochs (int max_epochs) | 
| Sets the maximum number of epochs to train.  More... | |
| virtual void | CompactifyFeatureUids ()=0 | 
Renumbers the potentially sparse feature uid’s so that they occupy the interval [0,n-1] densely, for n non-zero features in use by this model.  More... | |
| virtual void | set_end_of_epoch_hook (Hook *end_of_epoch_hook) | 
| virtual bool | use_weighted_loss () | 
| virtual void | set_use_weighted_loss (bool use_weighted_loss) | 
| virtual void | set_symbols (Symbols *symbols) | 
| Sets the Symbols instance for this Model to be the specified instance.  More... | |
  Public Member Functions inherited from reranker::FactoryConstructible | |
| virtual | ~FactoryConstructible () | 
| virtual void | RegisterInitializers (Initializers &initializers) | 
| virtual void | Init (const Environment *env, const string &arg) | 
Protected Member Functions | |
| void | set_name (const string &name) | 
| Sets the name of this Model instance.  More... | |
| void | set_kernel_fn (KernelFunction *kernel_fn) | 
| Sets the kernel function for this model.  More... | |
| void | set_score_comparator (shared_ptr< Candidate::Comparator > score_comparator) | 
| void | set_gold_comparator (shared_ptr< Candidate::Comparator > gold_comparator) | 
| void | SetDefaultObjects () | 
| void | SetDefaultComparators () | 
| void | SetDefaultCandidateSetScorer () | 
| shared_ptr< Candidate::Comparator > | GetComparator (const string &spec) const | 
| shared_ptr< CandidateSet::Scorer > | GetCandidateSetScorer (const string &spec) const | 
| shared_ptr< UpdatePredicate > | GetUpdatePredicate (const string &spec) const | 
| shared_ptr< Updater > | GetUpdater (const string &spec) const | 
| virtual void | CheckNumberOfTokens (const string &arg, const vector< string > &tokens, size_t min_expected_number, size_t max_expected_number, const string &class_name) const | 
| A helper method for implementing the Init method: throws a std::runtime_error if the number of tokens in the argument string is not the expected number.  More... | |
Protected Attributes | |
| string | name_ | 
| This model’s unique name.  More... | |
| Time | time_ | 
| The tiny object that holds the "training time" for this model (epoch, index and absolute time index).  More... | |
| KernelFunction * | kernel_fn_ | 
| Yes, this is an interface, but we add the kernel function as a data member.  More... | |
| Symbols * | symbols_ | 
| The symbol table for this model (may be NULL).  More... | |
| shared_ptr< Candidate::Comparator > | score_comparator_ | 
| A comparator to provide an ordering for candidates based on score when scoring all candidates in a set.  More... | |
| shared_ptr< Candidate::Comparator > | gold_comparator_ | 
| A comparator to provide an ordering for candidates to find the gold candidate in a set.  More... | |
| shared_ptr< CandidateSet::Scorer > | candidate_set_scorer_ | 
| A scorer for CandidateSet instances.  More... | |
| shared_ptr< UpdatePredicate > | update_predicate_ | 
| The update predicate for this model.  More... | |
| shared_ptr< Updater > | updater_ | 
| The updater for this model.  More... | |
| vector< double > | loss_per_epoch_ | 
| The average loss per epoch.  More... | |
| vector< int > | num_testing_errors_per_epoch_ | 
| The number of testing errors made on held-out development test data for each epoch.  More... | |
| vector< int > | num_training_errors_per_epoch_ | 
| The number of errors made on training examples during each epoch.  More... | |
| int | num_training_errors_ | 
| The number of errors made on training examples.  More... | |
| int | num_updates_ | 
| The number of times an update was performed on this model during training.  More... | |
| int | min_epochs_ | 
| The minimum number of training epochs to execute.  More... | |
| int | max_epochs_ | 
| The maximum number of training epochs to execute.  More... | |
| Hook * | end_of_epoch_hook_ | 
| A hook to be performed at the end of every epoch.  More... | |
| bool | use_weighted_loss_ | 
| Indicates whether this model should weight each candidate’s loss by the value returned by CandidateSet::loss_weight.  More... | |
Model is an interface for reranking models.
TODO(dbikel): Add factory for kernel functions. Remove all constructors but the zero-arg constructor from both Model and PerceptronModel.
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  inline | 
Constructs a new instance with the specified kernel function and symbol table.
      
  | 
  inlinevirtual | 
      
  | 
  pure virtual | 
Implemented in reranker::PerceptronModel.
      
  | 
  protectedvirtual | 
A helper method for implementing the Init method: throws a std::runtime_error if the number of tokens in the argument string is not the expected number.
| arg | the arg that was tokenized (for error reporting) | 
| tokens | the tokens array to inspect for correct size | 
| min_expected_number | the minimum expected number of tokens | 
| max_expected_number | the maximum expected number of tokens | 
| class_name | the name of the class invoking this method (for error reporting) | 
      
  | 
  pure virtual | 
Renumbers the potentially sparse feature uid’s so that they occupy the interval [0,n-1] densely, for n non-zero features in use by this model. 
If the internal Symbols instance is non-NULL, then this method also adjusts it to reflect the new set of feature uid’s. 
Implemented in reranker::PerceptronModel.
      
  | 
  pure virtual | 
Implemented in reranker::PerceptronModel.
      
  | 
  pure virtual | 
Evaluates this model on the specified set of held-out development test data.
| development_test | a held-out set of examples to use for evaluation of this model (during training, this method is typically invoked after each epoch to determine when to stop) | 
Implemented in reranker::PerceptronModel.
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  inlinevirtual | 
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  pure virtual | 
Returns the spec string for constructing a default instance of this model so it may be properly de-serialized by its ModelProtoReader.
Implemented in reranker::PerceptronModel.
      
  | 
  inline | 
      
  | 
  pure virtual | 
Returns whether more training epochs are required for this model.
Implemented in reranker::PerceptronModel.
      
  | 
  pure virtual | 
Indicates whether the current model needs to be updated.
For perceptron-style models, this is usually based on having scored the candidates and finding that the best-scoring candidate is not equal to the gold or reference candidate.
| example | the current training example | 
Implemented in reranker::PerceptronModel.
      
  | 
  pure virtual | 
Implemented in reranker::PerceptronModel.
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  pure virtual | 
Returns the spec string for contructing an instance of a ModelProtoReader capable of de-serializing this Model implementation.
Implemented in reranker::PerceptronModel.
      
  | 
  pure virtual | 
Returns the spec string for contructing an instance of a ModelProtoWriter capable of serializing this Model implementation.
Implemented in reranker::PerceptronModel.
      
  | 
  inlinevirtual | 
      
  | 
  pure virtual | 
Scores a candidate according to either the raw or averaged version of this perceptron model.
The specified candidate's score may be modified.
| [in,out] | candidate | the candidate to be scored by this model | 
| training | whether this is being called during training or evaluation of a model | 
Implemented in reranker::PerceptronModel.
      
  | 
  pure virtual | 
Scores the specified set of candidates according to either the raw or averaged version of this perceptron model.
The scores of the specified set of candidates may be modified.
| [in,out] | candidates | the set of candidates to be scored | 
| training | whether this is being called during training or evaluation of a model | 
Implemented in reranker::PerceptronModel.
      
  | 
  inlinevirtual | 
      
  | 
  inlineprotected | 
      
  | 
  inlineprotected | 
      
  | 
  inlinevirtual | 
      
  | 
  inlinevirtual | 
      
  | 
  inlineprotected | 
      
  | 
  inlineprotected | 
      
  | 
  inlinevirtual | 
      
  | 
  inlinevirtual | 
      
  | 
  inlineprotected | 
      
  | 
  inlineprotected | 
      
  | 
  inline | 
      
  | 
  inline | 
      
  | 
  pure virtual | 
Trains this model on a collection of training examples, where each training example is a set of candidates, possibly with a distinguished "gold candidate" that is the reference against which other candidates are scored.
Typically, invoking this method indicates to train a model until convergence.
| examples | the set of training examples on which to train this model | 
| development_test | the set of held-out examples to use to evaluate the model after each epoch | 
Implemented in reranker::PerceptronModel.
      
  | 
  pure virtual | 
Trains this model for one epoch, i.e., a single pass through the specified set of training examples.
Typically the Train method will be implemented in terms of this method.
| examples | the set of training examples on which to train this model | 
Implemented in reranker::PerceptronModel.
      
  | 
  pure virtual | 
Trains this model on the specified training example.
Typically, the TrainOneEpoch method will be implemented in terms of this method.
| example | the example on which to train | 
Implemented in reranker::PerceptronModel.
      
  | 
  pure virtual | 
Updates the current model based on the specified set of candidates.
TrainOnExample will be implemented in terms of this method.
| example | the current training example | 
Implemented in reranker::PerceptronModel.
      
  | 
  inlinevirtual | 
      
  | 
  protected | 
A scorer for CandidateSet instances.
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
      
  | 
  protected | 
Indicates whether this model should weight each candidate’s loss by the value returned by CandidateSet::loss_weight.
 1.8.6