Package org.apache.solr.ltr.model
Class WrapperModel
java.lang.Object
org.apache.solr.ltr.model.LTRScoringModel
org.apache.solr.ltr.model.AdapterModel
org.apache.solr.ltr.model.WrapperModel
- All Implemented Interfaces:
org.apache.lucene.util.Accountable
- Direct Known Subclasses:
DefaultWrapperModel
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.
-
Field Summary
FieldsFields inherited from class org.apache.solr.ltr.model.AdapterModel
solrResourceLoaderFields inherited from class org.apache.solr.ltr.model.LTRScoringModel
features, name, normsFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanorg.apache.lucene.search.Explanationexplain(org.apache.lucene.index.LeafReaderContext context, int doc, float finalScore, List<org.apache.lucene.search.Explanation> featureExplanations) Similar to the score() function, except it returns an explanation of how the features were used to calculate the score.org.apache.lucene.search.ExplanationgetNormalizerExplanation(org.apache.lucene.search.Explanation e, int idx) getNorms()inthashCode()voidnormalizeFeaturesInPlace(float[] modelFeatureValues) Goes through all the stored feature values, and calculates the normalized values for all the features that will be used for scoring.longfloatscore(float[] modelFeatureValuesNormalized) Given a list of normalized values for all features a scoring algorithm cares about, calculate and return a score.toString()voidupdateModel(LTRScoringModel model) protected voidvalidate()Validate that settings make sense and throwsModelExceptionif they do not make sense.Methods inherited from class org.apache.solr.ltr.model.AdapterModel
initMethods inherited from class org.apache.solr.ltr.model.LTRScoringModel
getFeatureStoreName, getInstance, getName, getParamsMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
Field Details
-
model
-
-
Constructor Details
-
WrapperModel
-
-
Method Details
-
hashCode
public int hashCode()- Overrides:
hashCodein classLTRScoringModel
-
equals
- Overrides:
equalsin classLTRScoringModel
-
validate
Description copied from class:LTRScoringModelValidate that settings make sense and throwsModelExceptionif they do not make sense.- Overrides:
validatein classLTRScoringModel- Throws:
ModelException
-
updateModel
-
fetchModelMap
- Throws:
ModelException
-
getNorms
- Overrides:
getNormsin classLTRScoringModel- Returns:
- the norms
-
getFeatures
- Overrides:
getFeaturesin classLTRScoringModel- Returns:
- the features
-
getAllFeatures
- Overrides:
getAllFeaturesin classLTRScoringModel
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable- Overrides:
ramBytesUsedin classLTRScoringModel
-
score
public float score(float[] modelFeatureValuesNormalized) Description copied from class:LTRScoringModelGiven a list of normalized values for all features a scoring algorithm cares about, calculate and return a score.- Specified by:
scorein classLTRScoringModel- Parameters:
modelFeatureValuesNormalized- List of normalized feature values. Each feature is identified by its id, which is the index in the array- Returns:
- The final score for a document
-
explain
public org.apache.lucene.search.Explanation explain(org.apache.lucene.index.LeafReaderContext context, int doc, float finalScore, List<org.apache.lucene.search.Explanation> featureExplanations) Description copied from class:LTRScoringModelSimilar to the score() function, except it returns an explanation of how the features were used to calculate the score.- Specified by:
explainin classLTRScoringModel- Parameters:
context- Context the document is indoc- Document to explainfinalScore- Original scorefeatureExplanations- Explanations for each feature calculation- Returns:
- Explanation for the scoring of a document
-
normalizeFeaturesInPlace
public void normalizeFeaturesInPlace(float[] modelFeatureValues) Description copied from class:LTRScoringModelGoes through all the stored feature values, and calculates the normalized values for all the features that will be used for scoring.- Overrides:
normalizeFeaturesInPlacein classLTRScoringModel
-
getNormalizerExplanation
public org.apache.lucene.search.Explanation getNormalizerExplanation(org.apache.lucene.search.Explanation e, int idx) - Overrides:
getNormalizerExplanationin classLTRScoringModel
-
toString
- Overrides:
toStringin classLTRScoringModel
-