LeveredDocs
Concepts

Models

How the model of an optimization is trained, how it selects variants, and which states and metrics it has.

Each optimization has a model. The model learns from exposures and rewards which variants produce the highest reward, and it selects the variant for each request.

One model for all optimizations

Levered uses the same model for every optimization: a Bayesian factorization machine. It belongs to the family of contextual multi-armed bandits (CMAB). There is no model type to select. See Inference for the statistical details.

The model learns from the factors that are defined on the optimization:

Optimization hasThe model learns
Design factorsThe reward of each variant across all users.
Design factors and context factorsThe reward of each variant for each combination of context values.

Example: an optimization has the context factors country and device_type. The model can learn that mobile users from Germany convert best with a short headline and a "Get started" button, and that desktop users from the US convert best with a longer headline and social proof. Without context factors, the model selects the variant that performs best across all users.

Context factors increase the amount of data that the model needs. With country (4 levels) and device_type (3 levels), the model learns across 12 user segments, and each segment needs enough observations.

How training works

The model uses Bayesian inference to learn from observations. It estimates a probability distribution over the reward rate of each variant instead of a single value.

Training has three steps:

  1. Collect observations. Levered queries the warehouse and joins exposures with rewards.
  2. Run inference. The model estimates the posterior distributions of the reward parameters with MCMC (Markov Chain Monte Carlo).
  3. Produce posteriors. The result is one distribution for each variant, or for each combination of variant and context values if the optimization has context factors. The distribution describes the estimate of the true reward rate, given the data so far.

The distribution contains the uncertainty of the estimate. A variant with 5 conversions out of 10 exposures and a variant with 500 conversions out of 1,000 exposures both have a rate of 50%. The estimate for the first variant is much less certain, and its distribution is wider. Variant selection uses this uncertainty.

Thompson Sampling

Levered selects the variant for each request with Thompson Sampling:

  1. For each variant, the model draws a random sample from the posterior distribution of the variant.
  2. The model selects the variant with the highest sample.
  3. Levered serves this variant to the user.

This procedure has the following effects:

  • Variants with a high expected reward are served more often, because their distributions are centered on higher values.
  • Uncertain variants are still served sometimes (exploration), because a wide distribution sometimes produces a high sample.
  • The share of the best variant grows with the amount of data. The posteriors become narrower, and the best variant has the highest sample in most requests.
  • A change in user behavior changes the allocation. If a variant starts to perform better, new data shifts its distribution, and the model serves it more often.

If the optimization has context factors, the model draws the samples from the distributions for the context values of the request. Users with different context values can therefore receive different variants.

Model lifecycle

A model has one of these states:

StateDescription
createdThe model exists and has not been trained. No observations are available, or training has not started.
trainingInference is running. The model processes observations and fits the posterior distributions.
trainedTraining is complete. The model has posterior distributions and can serve variants with Thompson Sampling.
failedThe last training run did not complete. The model can train again in a later cycle.

After the model reaches trained, Levered retrains it as new data arrives in the warehouse. Each retraining includes the latest observations and updates the posterior distributions. The model changes to training and back to trained in each cycle.

During retraining, the previous trained version continues to serve variants.

In-sample metrics

Every training run publishes a new version of the optimization's posterior, and every model figure is computed from it. Lifts are measured against the reference: the baseline variant, or an even split over the variants when there is none.

  • Expected reward per variant. The reward each variant earns when served to all traffic.
  • Lift (now). What the current policy earns over the reference.
  • Lift (best variant). What serving each segment its best variant would earn over the reference, shrunk halfway toward Lift (now), since a best-of figure runs optimistic.
  • P(beats reference) and progress to best. The probability that the current policy beats the reference, and how much of the gap between the reference and the best variant the policy has closed.
  • Traffic share. Each variant's share of optimized traffic, which is also its probability of being the best variant.
  • Factor and level effects, factor importance, context importance. What each design factor and level is worth, how much of the current lift each design factor accounts for (and how much only combinations of factors explain), and how much of what personalizing adds each context factor accounts for. See standard figures.

These figures are Bayesian, not frequentist. Each comes as the median of the posterior with a central credible interval: the true value lies within the interval with the stated probability, given the observed data and the prior. This is a direct probability statement, unlike frequentist confidence intervals.

Models