Hide table of contents

Epistemic status: I wrote this on the same day I learnt about Shapley values, and built the example for my own understanding.

When a group of players collaborate, with players making unequal contributions, it is not clear how much of the total gain to attribute to each player. Shapley values provide one way of doing this. There is no mathematically “correct” way of assigning credit, but Shapley values have a number of common-sense desirable properties[1].

As the EA Forum page on Shapley values puts it,

In the context of EA, Shapley values are a method for assigning credit for the impact of an intervention to each of a set of actors collaborating to make it happen. The concept of a Shapley value comes from cooperative game theory, where it is a general solution to the problem of distributing gains from cooperation. In impact assessment, it is often compared to the calculation of the raw counterfactual impact of an intervention.

Loosely, each Shapley value (each associated with a specific actor) corresponds to the average of the counterfactual impact produced by the actor, considering each possible way in which the agents could have assembled themselves to cooperate.

The formula for Shapley values is quite confusing, and can be hard to internalize without a friendly example. This post aims to provide a such an example.

A simple example

Imagine a game where teams join to build a collective hand of cards. The types of card are "Q" and "K".

The value of the hand is determined by the number of pairs, three-of-a-kind and four-of-a-kind tricks, as follows:

Trick

Example

Value

PairK K50
Three-of-a-kindQ Q Q100
Four-of-a-kindK K K K200

Suppose players A, B, C each hold cards as follows:

A: Q Q K

B: Q K K

C: Q

What is the relative contribution of each player to the value of their collective hand? Or, in other words, what would be the fairest amount to pay each player for their contribution?

Together, they have Q Q Q Q K K K, for a total value of 200 + 100 = 300.

To understand the value of each player's individual contribution, we can check how much this value changes when we remove one player's contribution. The larger the drop in value, the larger that player's contribution.

The table below shows how much the value of the team's hand decreases when we remove each player’s cards.

Coalition

Hand

Value of hand

Missing player

Counterfactual contribution of missing player

{A,B,C}Q Q Q Q K K K300  
{A,B}Q Q Q K K K200C100
{A,C}Q Q Q K100B200
{B,C}Q Q K K100A200


Under this interpretation, C is contributing less than the other players, and B is contributing the same as A. 

However, the sum of the individual contributions is 500, which is more than the value of the hand that {A,B,C} hold. If players expected fair payment for taking part, we could not simply give each player their counterfactual contribution: there is not enough money to go around.

Shapley values are one way of determining the payment, or credit, due to each player. They take a weighted average of the contributions of each player under each possible combination (or “permutation”) of players. This includes all combinations with one, two or three players. 

The full mathematical formula can be found on the Wikipedia page, but let’s see what it looks like in the example.

The table below calculates each player’s counterfactual contribution in each possible combination of players.

The Shapley value of a player is the weighted mean of these contributions.

In this example there are three possible players. One-third of the weight comes from coalitions of three players, one-third from coalitions of two players, and one-third from coalitions of one player[2].


 

Coalition


 

Hand


 

Value

Counterfactual contribution: how much would the value of the hand decrease if this player's cards were removed?


 

Weight

ABC
{A,B,C}Q Q Q Q K K K300200200100
{A,B}Q Q Q K K K200150150-
{A,C}Q Q Q K100100-50
{B,C}Q Q K K100-10050
{A}Q Q K5050--
{B}Q K K50-50-
{C}Q0--0


 So player A’s Shapley value is

 

Player B’s Shapley value is 

 

Player C’s Shapley value is

 

 

This tracks with our intuition that player C - who only had a single Q  - made the smallest contribution. Even though players A and B had different cards, their contributions to point scores were the same, and so they have the same Shapley values.

Notice that the Shapley values sum to 300, the total value of the team's hand. The values could be used to share out the group winnings.

This has been a simple example to illustrate how Shapley values are calculated in a three-player scenario. Shapley values could be a better way of thinking about counterfactual impact. Most importantly, since the values add up to the total value of the team effort, they help us avoid double-counting.

Photo: Peter Shapley

  1. ^

    See the Wikipedia page for a list of desirable properties, or Shapley values: Better than counterfactuals

  2. ^

    This generalizes so that in n-player situations, 1/n of the weight comes from coalitions of each size from 1 to n. See the Wikipedia page for a fuller mathematical formulation.

Comments


No comments on this post yet.
Be the first to respond.
Curated and popular this week
 ·  · 38m read
 · 
In recent months, the CEOs of leading AI companies have grown increasingly confident about rapid progress: * OpenAI's Sam Altman: Shifted from saying in November "the rate of progress continues" to declaring in January "we are now confident we know how to build AGI" * Anthropic's Dario Amodei: Stated in January "I'm more confident than I've ever been that we're close to powerful capabilities... in the next 2-3 years" * Google DeepMind's Demis Hassabis: Changed from "as soon as 10 years" in autumn to "probably three to five years away" by January. What explains the shift? Is it just hype? Or could we really have Artificial General Intelligence (AGI)[1] by 2028? In this article, I look at what's driven recent progress, estimate how far those drivers can continue, and explain why they're likely to continue for at least four more years. In particular, while in 2024 progress in LLM chatbots seemed to slow, a new approach started to work: teaching the models to reason using reinforcement learning. In just a year, this let them surpass human PhDs at answering difficult scientific reasoning questions, and achieve expert-level performance on one-hour coding tasks. We don't know how capable AGI will become, but extrapolating the recent rate of progress suggests that, by 2028, we could reach AI models with beyond-human reasoning abilities, expert-level knowledge in every domain, and that can autonomously complete multi-week projects, and progress would likely continue from there.  On this set of software engineering & computer use tasks, in 2020 AI was only able to do tasks that would typically take a human expert a couple of seconds. By 2024, that had risen to almost an hour. If the trend continues, by 2028 it'll reach several weeks.  No longer mere chatbots, these 'agent' models might soon satisfy many people's definitions of AGI — roughly, AI systems that match human performance at most knowledge work (see definition in footnote). This means that, while the compa
 ·  · 4m read
 · 
SUMMARY:  ALLFED is launching an emergency appeal on the EA Forum due to a serious funding shortfall. Without new support, ALLFED will be forced to cut half our budget in the coming months, drastically reducing our capacity to help build global food system resilience for catastrophic scenarios like nuclear winter, a severe pandemic, or infrastructure breakdown. ALLFED is seeking $800,000 over the course of 2025 to sustain its team, continue policy-relevant research, and move forward with pilot projects that could save lives in a catastrophe. As funding priorities shift toward AI safety, we believe resilient food solutions remain a highly cost-effective way to protect the future. If you’re able to support or share this appeal, please visit allfed.info/donate. Donate to ALLFED FULL ARTICLE: I (David Denkenberger) am writing alongside two of my team-mates, as ALLFED’s co-founder, to ask for your support. This is the first time in Alliance to Feed the Earth in Disaster’s (ALLFED’s) 8 year existence that we have reached out on the EA Forum with a direct funding appeal outside of Marginal Funding Week/our annual updates. I am doing so because ALLFED’s funding situation is serious, and because so much of ALLFED’s progress to date has been made possible through the support, feedback, and collaboration of the EA community.  Read our funding appeal At ALLFED, we are deeply grateful to all our supporters, including the Survival and Flourishing Fund, which has provided the majority of our funding for years. At the end of 2024, we learned we would be receiving far less support than expected due to a shift in SFF’s strategic priorities toward AI safety. Without additional funding, ALLFED will need to shrink. I believe the marginal cost effectiveness for improving the future and saving lives of resilience is competitive with AI Safety, even if timelines are short, because of potential AI-induced catastrophes. That is why we are asking people to donate to this emergency appeal
 ·  · 1m read
 · 
We’ve written a new report on the threat of AI-enabled coups.  I think this is a very serious risk – comparable in importance to AI takeover but much more neglected.  In fact, AI-enabled coups and AI takeover have pretty similar threat models. To see this, here’s a very basic threat model for AI takeover: 1. Humanity develops superhuman AI 2. Superhuman AI is misaligned and power-seeking 3. Superhuman AI seizes power for itself And now here’s a closely analogous threat model for AI-enabled coups: 1. Humanity develops superhuman AI 2. Superhuman AI is controlled by a small group 3. Superhuman AI seizes power for the small group While the report focuses on the risk that someone seizes power over a country, I think that similar dynamics could allow someone to take over the world. In fact, if someone wanted to take over the world, their best strategy might well be to first stage an AI-enabled coup in the United States (or whichever country leads on superhuman AI), and then go from there to world domination. A single person taking over the world would be really bad. I’ve previously argued that it might even be worse than AI takeover. [1] The concrete threat models for AI-enabled coups that we discuss largely translate like-for-like over to the risk of AI takeover.[2] Similarly, there’s a lot of overlap in the mitigations that help with AI-enabled coups and AI takeover risk — e.g. alignment audits to ensure no human has made AI secretly loyal to them, transparency about AI capabilities, monitoring AI activities for suspicious behaviour, and infosecurity to prevent insiders from tampering with training.  If the world won't slow down AI development based on AI takeover risk (e.g. because there’s isn’t strong evidence for misalignment), then advocating for a slow down based on the risk of AI-enabled coups might be more convincing and achieve many of the same goals.  I really want to encourage readers — especially those at labs or governments — to do something