In marketing terms, a multi-armed bandit solution is a ‘smarter’ or more complex version of A/B testing that uses machine learning algorithms to dynamically allocate traffic to variations that are performing well, while allocating less traffic to variations that are underperforming.
The term "multi-armed bandit" comes from a hypothetical experiment where a person must choose between multiple actions (i.e., slot machines, the "one-armed bandits"), each with an unknown payout. The goal is to determine the best or most profitable outcome through a series of choices. At the beginning of the experiment, when odds and payouts are unknown, the gambler must determine which machine to pull, in which order and how many times. This is the “multi-armed bandit problem.”
Multi-armed bandit examples
One real-world example of a multi-armed bandit problem is when a news website has to make a decision about which articles to display to a visitor. With no information about the visitor, all click outcomes are unknown. The first question is, which articles will get the most clicks? And in which order should they appear? The website’s goal is to maximize engagement, but they have many pieces of content from which to choose, and they lack data that would help them to pursue a specific strategy.
The news website has a similar problem in choosing which ads to display to its visitors. In this case, they want to maximize advertising revenue, but they may be lacking enough information about the visitor to pursue a specific advertising strategy. Similar to the issue with news articles, they typically have a large number of ads from which to choose. Which ads will drive maximum revenue for their news site?
The website needs to make a series of decisions, each with unknown outcome and ‘payout.’
Multi-armed bandit solutions
There are many different solutions that computer scientists have developed to tackle the multi-armed bandit problem. Below is a list of some of the most commonly used multi-armed bandit solutions:
1. Epsilon-greedy
This is an algorithm for continuously balancing exploration with exploitation. (In ‘greedy’ experiments, the lever with highest known payout is always pulled except when a random action is taken). A randomly chosen arm is pulled a fraction ε of the time. The other 1-ε of the time, the arm with highest known payout is pulled.
2. Upper confidence bound
This strategy is based on the Optimism in the Face of Uncertainty principle, and assumes that the unknown mean payoffs of each arm will be as high as possible, based on observable data.
3. Thompson sampling (Bayesian)
With this randomized probability matching strategy, the number of pulls for a given lever should match its actual probability of being the optimal lever.
How contextual bandits differ from standard multi-armed bandits
A contextual bandit is an advanced personalization algorithm that enhances the multi-armed bandit approach by incorporating user-specific data. While traditional multi-armed bandits help identify winning variations, contextual bandits determine which variation works best for each unique visitor.
The "context" refers to visitor-specific information like device type, location, past behavior, or purchase history. This data allows the machine learning model to make smarter decisions about which content to display to maximize conversions.
How contextual bandits work:
- Learning period: The model starts with 100% exploration, randomly assigning variations to visitors to gather diverse data for predictions.
- Balancing exploration and exploitation: Once enough visitor behavior data is collected, the model exploits (serving personalized variations). It dynamically adjusts exploration/exploitation rates as it receives more events.
- Continuous adaptation: The model maintains some exploration (maximum 95% exploitation) to ensure continuous learning and avoid missing opportunities
Instead of manually creating complex targeting rules for different user segments, contextual bandits automatically learn these relationships and serve the most relevant experience to each visitor in real time. This approach eliminates guesswork and delivers true 1:1 personalization at scale—critical in today's competitive environment where attention spans are limited and personalization expectations are high.
The key difference between contextual bandits and traditional multi-armed bandits is context. While standard multi-armed bandits seek a single winning variation across all users, contextual bandits identify the best variation for each user based on their specific attributes.
- A/B testing: Fixed traffic splits with one-size-fits-all winner selection
- Multi-armed bandits: Dynamic traffic allocation seeking one overall "best" variation
- Contextual bandits: Personalized experiences based on user context (device, location, behavior)
Multi-armed bandits vs. A/B testing
In deciding whether to use multi-armed bandits instead of A/B testing, you must weigh the tradeoff of exploitation vs. exploration (sometimes known as ‘earn or learn’.)
The key to understanding the difference between traditional A/B testing and multi-armed bandits is the concept of exploitation versus exploration:
- Exploration: Showing different variations to visitors to learn which performs best
- Exploitation: Showing the best-performing variation to maximize conversions
With A/B testing, you have a limited period of pure exploration where you allocate traffic in equal numbers to Version A and Version B. Once you declare a winner, you move into a long period of exploitation, where 100% of users go to the winning variation. One issue with this approach is that you waste resources on the losing variation while trying to gather data and learn which is the winner.
With multi-armed bandit testing, the tests are adaptive, and include periods of exploration and exploitation at the same time. They move traffic gradually towards winning variations, instead of forcing you to wait to declare a winner at the end of an experiment. This process is faster and more efficient because less time is spent on sending traffic to obviously inferior variations.
One of the main disadvantages to multi-armed bandit testing is its computational complexity. Simply put, it is just more difficult and resource-intensive to run multi-armed bandit tests.