Class WrapperModel

  • All Implemented Interfaces:
    Direct Known Subclasses:

    public abstract class WrapperModel
    extends AdapterModel
    A scoring model that wraps the other model.

    This model loads a model from an external resource during the initialization. The way of fetching the wrapped model is depended on the implementation of fetchModelMap().

    This model doesn't hold the actual parameters of the wrapped model, thus it can manage large models which are difficult to upload to ZooKeeper.

    Example configuration:

       "class": "...",
       "name": "myModelName",
       "params": {

    NOTE: no "features" are configured in the wrapper model because the wrapped model's features will be used instead. Also note that if a "store" is configured for the wrapper model then it must match the "store" of the wrapped model.

    • Method Detail

      • ramBytesUsed

        public long ramBytesUsed()
        Specified by:
        ramBytesUsed in interface org.apache.lucene.util.Accountable
        ramBytesUsed in class LTRScoringModel
      • score

        public float score​(float[] modelFeatureValuesNormalized)
        Description copied from class: LTRScoringModel
        Given a list of normalized values for all features a scoring algorithm cares about, calculate and return a score.
        Specified by:
        score in class LTRScoringModel
        modelFeatureValuesNormalized - List of normalized feature values. Each feature is identified by its id, which is the index in the array
        The final score for a document
      • explain

        public explain​(org.apache.lucene.index.LeafReaderContext context,
                                                            int doc,
                                                            float finalScore,
                                                            List<> featureExplanations)
        Description copied from class: LTRScoringModel
        Similar to the score() function, except it returns an explanation of how the features were used to calculate the score.
        Specified by:
        explain in class LTRScoringModel
        context - Context the document is in
        doc - Document to explain
        finalScore - Original score
        featureExplanations - Explanations for each feature calculation
        Explanation for the scoring of a document
      • normalizeFeaturesInPlace

        public void normalizeFeaturesInPlace​(float[] modelFeatureValues)
        Description copied from class: LTRScoringModel
        Goes through all the stored feature values, and calculates the normalized values for all the features that will be used for scoring.
        normalizeFeaturesInPlace in class LTRScoringModel
      • getNormalizerExplanation

        public getNormalizerExplanation​( e,
                                                                             int idx)
        getNormalizerExplanation in class LTRScoringModel