Reranking on Item Property

It is often useful – if not necessary – to reorder recommended items following some criteria on the items’ properties. The reranking option does just that, to add some diversity or bring forth some items. It applies some pre-defined rules to calculate scores on the items recommended to rerank them. Thus it is a type of Business Rule. It may change the recommended items, given that the reranking happens before the final item selection.

Similarly to the filters option, you need to provide a property_name, the op of reranking, and possibly a positive weight to specify the importance of the rule and some more options.

Important note: reranking does not affect the models nor the training; it simply modifies the recommendations provided by a model. See Algorithms for more information about models.

Reranking Syntax

There are two equivalent ways to format a reranking: either using a JSON object or using a URL-compatible string.

JSON Object Format

The following fields form the JSON object defining a reranking rule:

  • property_name: the item-property name with which you want to rerank

  • op: the reranking ‘operator’. Available ops are defined below in Reranking Logic.

  • weight: the optional weight to apply to the reranking. Defaults at 1 and must be positive. It should generally lie between 0 and 1 but may go beyond.

  • options: the optional set of op-dependent options.

URL-Compatible Format

The equivalent syntax is also allowed, thus enabling sending the filters as URL query parameters.

For operators without weight nor options, use the syntax <PROPERTY_NAME>:<KIND>

To also use a weight: <PROPERTY_NAME>:<KIND>:<WEIGHT>

To use a both weight and options, where the option type (activation_period or default_malus) must be provided: <PROPERTY_NAME>:<KIND>:<WEIGHT>:<OPTIONS_TYPE>:<OPTION_VALUE>

To use only options. note the double ::: <PROPERTY_NAME>:<KIND>::<OPTIONS_TYPE>:<OPTION_VALUE>

Do remember to use percent-encoding when using reserved characters as values.

Reranking Logic

Diversity

Options

The diversity reranking offers the following options:

  • default_malus: when applying diversity on a repeated item-property, a positive score to attribute to items with no value. Defaults to 0.

  • activation_period: positive integer to activate the lack-of-diversity malus only every k repetitions of a property value. Combined with a large weight, this practically enforces that at most k consecutive items with the same property value can be recommended. Defaults to 1.

Examples

The following reranking rule almost enforces that the recommendations will contain a new genre every two items.

URL-string version: genres:diversity:2:activation_period:2:default_malus:0.5.

Object version:

{
  "property_name": "genres",
  "op": "diversity",
  "weight": 2,
  "options": {
    "activation_period": 2,
    "default_malus": 0.5
  }
}

Rationale

When you see that the recommendations you get are not diverse enough, you can add a diversity reranking on an item-property of interest. For example,

[
  {
    "property_name": "genres",
    "op": "diversity",
    "weight": 1,
    "options": {
      "activation_period": 2
    }
  }
]

does the following:

  • attribute a malus to each item depending on how much its genres were found in previous items among recommended items, with a default_malus of 0 for missing properties;

  • rerank the items according to their new internal score and provided weight.

The weight and the activation_period have different effects. We recommend experimenting with these two parameters as an appropriate value is database-dependent.

The weight specifies the importance we give to having a substantial diversity, compared to keeping the original ranking: weight=0 will add no diversity, weight=1 makes the diversity reasonably strong, weight=10 makes it strongly predominant,

The activation_period parameter enables groups with the same property value to be recommended consecutively. It decreases diversity, but it is often not an issue to have two or three comedy movies recommended in a row as long as all movies recommended are not comedies. A reranking rule genres:diversity:2:activation_period:3 does just that: it activates the lack-of-diversity malus only every three repetitions of a property value.

The default_malus option specifies the default score for items that have no value for the repeated item-property to apply diversity on.

Warning

Even though diversity applies to numerical properties (for example, the year a movie came out or on the price of the items), the activation_period parameter only affects categorical properties.

Bonus/Malus

(WIP, coming soon)