KnowML

Designing People You May Know

Follow Kavya, who joins LinkedIn on her third day at a new job, from the moment she opens My Network down to the machinery that picks a few people for her out of over a billion members. We build it from a count of shared friends and fix each failure in turn.

⏱ 68 min readAssumes: recommenders (16), graph ML (18), MLOps (24), evaluation (25)
Start reading

Kavya started a new job in Bengaluru on Monday, and on Wednesday evening she finally makes a LinkedIn account. She uploads the contacts from her phone when the app offers to, fills in her new employer, and opens the My Network tab. Twelve people are already connected to her, mostly college friends whose numbers she had saved. Below them sits a short list under the heading People You May Know. There is Meghana from her old team, whom she hadn't thought to look for. There is Rohan, who sat two seats away at Monday's orientation and whom she never got round to asking for a last name. And there is a recruiter she has never met, with a very polished profile photo. She taps Connect on Rohan and on Meghana and closes the recruiter. Ten minutes later Rohan accepts, and when she pulls down to refresh, three new names have appeared, two of them from his team.

LinkedIn can't know who Kavya knows. It can see a graph, a map of which members are connected to which, and it can see what each member has written about themselves. From that it has to guess, for one person with a dozen connections, which few people out of more than a billion she would want to connect with. Behind the guess there are two more difficulties. A connection exists only when one person sends an invitation and the other accepts, so the system is trying to please two people at once, and one of them is a stranger who never opened the app. And whatever it suggests changes the graph it will learn from tomorrow. A member who gets suggested a lot collects connections, and a member with many connections gets suggested more.

Software that suggests links between members of a network is called a link recommender, and the task underneath, guessing which pairs of members will become connected, is link prediction. LinkedIn's version has been running since at least 2008 under the name People You May Know, or PYMK. So the question this chapter answers is: how does LinkedIn pick a handful of people for one new member out of a billion, when it can only see a graph, and each suggestion needs two people to say yes?

We'll build it the way an engineer would, starting from the most obvious version, "count the friends two people share", and fix each failure in turn. That takes us through why even the counting is hard at this scale, scoring that discounts celebrity connections, random walks and personalised PageRank, graph neural network embeddings, and a ranker that predicts both the invitation and the acceptance. After that we look at network effects that break ordinary A/B tests and the experiments LinkedIn built to measure them, and at the feedback loop that favours the already popular. Throughout we rely on LinkedIn's own papers, talks and engineering posts, and we say plainly where its internals are unpublished.

01What we're building, and how big

1.1 What it has to do

PYMK shows up in several places, among them the My Network tab, the feed, notifications and emails. We'll concentrate on the tab, where Kavya is, because that's where the full list gets shown and acted on. For each member the system has to produce a ranked list of people, fresh enough that someone who has just joined, or just accepted an invitation, sees the change within the same visit. Each person on the list should be someone the member would honestly want to connect with, which is a narrower thing than someone they might tap on.

In a 2018 talk at QCon San Francisco, Hema Raghavan described what LinkedIn wanted from the feature as "engaged members with high quality connections". She then proposed a metric to match, and it carries a lot of the design we'll build: count PYMK invitations that are sent and accepted, instead of invitations that are sent. Her slides show both series side by side over a month. We'll use "sent and accepted" as the target for the rest of the chapter, and section 07 turns it into a model.

Three awkward cases need sensible behaviour too. For a brand-new member like Kavya, there's almost no graph. For a very visible member, such as a recruiter or a senior executive, it must not bury them in requests. And it must respect what members have agreed to share, a constraint that shapes which data can be used at all and that we come back to in section 09.

1.2 How big is it?

LinkedIn's about page, as it stood in October 2026, lists more than 1.3 billion members, and says that more than 18,000 connections are made every minute. That is about 300 a second, or roughly 26 million a day. In its LiGNN paper (Borisyuk et al., KDD 2024), the team describes the connection graph used for people recommendation as having "up to one billion member nodes and billions of connection edges", and says it generated embeddings for 500 million members. The team page for PYMK states that the system is "responsible for building more than 50% of LinkedIn's professional graph", processes hundreds of terabytes of data a day and considers hundreds of billions of potential connections. It adds that the second-degree data grows faster than the site itself. That page isn't dated, so its figures probably come from a different year than the about page's, and the 50% figure is LinkedIn's own claim.

Predict before you read on

Say each of 500 million members has 300 connections, and each of those has 300 connections too. That's an illustrative figure, since LinkedIn doesn't publish its degree distribution. How many friend-of-friend paths start at one member, and how many in total? If each path costs a microsecond of CPU to look at, how many CPU-days is one pass over all of them?

Show the answer

One member has 300 × 300 = 90,000 two-step paths. Over 500 million members that's 4.5 × 1013 paths, which at a microsecond each is 45 million CPU-seconds, about 520 CPU-days. A thousand machines could do that in half a day.

That number is too comfortable, and the problem hides in the word "average". Connection counts are heavy-tailed, a few members have tens of thousands of connections, and the number of paths through a member grows with the square of their connections, so the real total is dominated by a few hubs and is much larger than the average suggests. LinkedIn's own figure is hundreds of billions of candidate pairs, and the volume grows faster than the membership. Section 03 puts numbers on the skew.

Latency is a separate matter, and LinkedIn hasn't published a latency budget for PYMK. We'll treat the answer as a lookup in a store that was filled ahead of time, with some work to rescore it, and reason about what a request must do without inventing figures.

02Version 1: count the friends two people share

Our first design uses one idea. If Kavya knows Meghana, and Meghana knows Rohan, then Kavya may know Rohan. Sociologists call this closing a triangle, and LinkedIn's own PYMK team page names it as the first signal the system uses: if A knows B and B knows C, then A and C may know each other. We can turn the idea into a score. For every pair of members who aren't connected, count how many connections they have in common, and show each member the pairs with the highest counts.

Formally, write for the set of members connected to . The score for a pair is the number of members they share:

Here means "the number of elements in". If the graph is stored as a table with one row per member and one column per member, holding a 1 where two members are connected, then this count for every pair at once is just that table multiplied by itself. We'll come back to that in the next section. In the six-person graph of a later experiment, members 0 and 3 share two friends, so their score is 2.

Version 1: count the friends two people share
CONNECTIONS who is linked to whom PAIR UP every two friends of one member COUNT shared friends per pair KEEP THE TOP highest counts for each member Built in a batch job, then read as a lookup when Kavya opens the tab. Cost grows with the square of every member's connection count, and a recruiter with 4,000 connections counts as much as a close friend. Kavya has 12 connections on day three, so there is little graph to count over.
Follow the boxes left to right. Each one is cheap to describe, and the amber lines under them are the two things that break first: the pairing step explodes, and every shared friend is treated alike.

This design has a long history behind it. In a podcast interview recorded for Software Engineering Daily and transcribed in 2019, a LinkedIn engineer recalled that when PYMK was first introduced, the index was built with a process called triangle closing running on an Oracle database. A run took about a day at first. As the feature drove growth, the same job took up to a week, and the results were going stale. In 2008 LinkedIn set up its first Hadoop cluster, a group of machines that runs large batch jobs in parallel, for exactly this job, and the engineer says that moved the run to a couple of hours, and that adding machines brought it lower. So the first version worked, and it also shows us the first pressure: the cost of the counting.

It breaks in three ways, and each one points to a section. First comes the counting itself. To count shared friends we have to look at every pair of friends of every member, and a member with 4,000 connections is in 8 million such pairs all by herself. Second, every shared friend counts the same, so Kavya sharing a recruiter with a stranger looks as strong as sharing a close colleague with Rohan. Third, Kavya has twelve connections. A count of shared friends needs friends, and on her third day she has hardly any. We take these in order, and the third one stays with us until section 06.

Candidate sourcePlusMinus
Most connected membersTrivial, never emptyThe same list for everyone, and it feeds the already popular
Same company or schoolWorks with almost no graph, which suits a new memberLarge employers produce thousands of candidates, most of them strangers
Friends of friends (triangle closing)Strong signal, easy to explain, and the first one LinkedIn usedCost grows with the square of connection counts; useless without connections
Learned embeddingsCan reach beyond two steps and use profile dataNeeds training, a vector index and fresh embeddings

LinkedIn kept all of the last three. Raghavan's 2018 QCon talk lists "friends of friends" as the core candidate source with personalised PageRank as an extension, and the 2024 LiGNN paper describes adding embedding-based retrieval on top, so the sources have been pooled over time and haven't been replaced one by another.

03Triangle closing at a billion members

The first thing to fix is the counting. Written naively, the job is a program with three nested loops: for each member, for each pair of that member's friends, record the pair. Every recorded pair gets one more shared friend. In a large batch system, the recorded pairs become records that are shuffled across machines so that all the records for the same pair meet in one place and can be added up. Total records are the sum, over every member, of the number of pairs of that member's friends.

Here runs over every member and is how many connections has. Each member is the shared friend for every pair among their own connections, so they contribute that many records. Each contribution grows with the square of , which is what makes the sum so sensitive to the largest members. Our experiment below builds a million members with a heavy-tailed connection count and measures how the records divide up. (The distribution is an illustrative shape. LinkedIn hasn't published its real one.)

Try it Where do the friend-of-friend pairs come from?
import numpy as np
rng = np.random.default_rng(7)
n = 1_000_000
# heavy-tailed connection counts (an illustrative shape, not LinkedIn's)
d = np.minimum(150 * (1 - rng.random(n)) ** -0.45, 30_000).astype(int)
pairs = d * (d - 1) // 2        # friend pairs each member sits between
top = np.argsort(-pairs)[: n // 1000]          # busiest 0.1% of members
print(f"members {n:,}, mean connections {d.mean():.0f}")
print(f"candidate pairs, all members: {pairs.sum():,}")
print(f"  share from the top 0.1%: {pairs[top].sum() / pairs.sum():.0%}")
small = d <= 2_000
print(f"  members above 2,000 connections: {(~small).sum():,}")
print(f"  pairs left if they are skipped: "
      f"{pairs[small].sum() / pairs.sum():.0%}")

# the same count as a matrix product, on a six-person graph
A = np.zeros((6, 6), int)
for u, v in [(0,1),(0,2),(1,2),(1,3),(2,3),(3,4),(4,5)]:
    A[u, v] = A[v, u] = 1
C = A @ A
print("common friends of 0 and 3:", C[0, 3], " of 1 and 4:", C[1, 4])
A million members average 272 connections, and the pairing step would produce 81,019,846,142 records. Its busiest 0.1% of members, a thousand people, account for 32% of them. Members above 2,000 connections number 3,064, which is 0.3% of the total, and skipping them would remove 40% of the records, leaving 60%. On the six-person graph, the matrix product gives 2 shared friends for members 0 and 3 and 1 for members 1 and 4.

Read the numbers from the top. A mean of 272 connections says nothing about the work: a job sized for the average member would be too small by a large factor, because a thousand members produce a third of the records. A design that skips the 3,064 largest members would remove 40% of the records, which sounds attractive until you remember that those members are real friends of real people, and a recruiter's contacts include genuine colleagues. Last, the same count appears a different way. Multiplying the six-person connection table by itself gives 2 shared friends for members 0 and 3, the same answer as counting by hand.

That skew is why the batch job was the hard part of PYMK for years. LinkedIn's 2018 QCon slides show a plain version of the scoring step as two joins in a database sense: first attach each member's features to a pair, then attach the other member's, with a "wide middle" in between where the pair table is enormous. Under the heading "Need Smart Joins" the slides give two before-and-after numbers. Scoring moved from a plain join to a two-dimensional hash join and went from 6 hours to 10 seconds. Triangle closing moved to a matrix multiplication and went from 3 to 4 hours to 10 minutes. Both figures come from the slides, and the engineering blog post they cite for the details is titled "Managing Exploding Big Data".

Of the two views, the matrix one rewards a closer look. Write the connections as a square table , one row and one column per member, with if and are connected and 0 if not. Multiply the table by itself and look at one cell:

The sum adds a 1 for every that is connected to both and , so it counts the shared friends. One matrix product gives the score of every pair. Because almost all of the table is zeros, it's stored as a list of nonzero entries, and the product is computed in blocks. Cut the member list into, say, a thousand groups, so the table becomes a thousand-by-thousand grid of blocks, and give each machine one pair of blocks to multiply. Every machine then reads only the slices of the graph it needs, instead of every machine reading all of it. That's the general idea behind the two-dimensional partitioning in the slides, though LinkedIn hasn't published the exact blocking scheme.

Blocks also give us places to cut cost. Hubs make up most of the records, and they carry the least information, which we'll see in the next section. A design could skip them, cap the number of friends considered per member, or sample from them. Which of these LinkedIn applies isn't in the slides, so we'll treat them as options a design has. A system that finishes in minutes over this graph probably does something to tame the hubs, but that's an inference.

How to count shared friendsPlusMinus
Loops over friend pairs, shuffled and summedEasy to write on any batch systemRecords grow with the sum of squared degrees; a few hubs dominate
Blocked sparse matrix productEach machine reads a slice; 3 to 4 hours down to 10 minutes in LinkedIn's slidesNeeds a partitioning scheme; the whole pass still runs as a batch
Skip or sample the largest membersRemoves most of the recordsThrows away real links, and the hubs include real friends
Update incrementally when an edge appearsFresh within seconds, no full passNeeds the graph in memory and an update stream; see section 08

LinkedIn's sources describe the second, and the 2018 talk adds the fourth for freshness, which section 08 describes. Counting pairs by multiplying a table by itself shows up in plenty of other places. Counting how many documents two words share, how many users two products share, and how many paths of length two exist in a network are all the same product, and recommendation systems that count co-occurrence, like the co-visitation graph in chapter 41, are using it.

Why only two steps out? Why not friends of friends of friends?

Because the number of candidates grows by a factor of a few hundred with each step, and the evidence weakens. In the Facebook study of Backstrom and Leskovec (WSDM 2011), the authors restricted candidates mainly to nodes two steps from the source, because most new links in an online social network close a triangle, and because it keeps each candidate set small. They also dropped candidates with fewer than four mutual friends, which they say cost practically no accuracy. LinkedIn's own pipeline is described as friends of friends too, and the longer reach comes later, from random walks and embeddings.

04Not every shared friend is equal

With the counting made cheaper, we can return to the second break. Look at Kavya's twelve connections. Meghana has twelve connections of her own, and so does Dev, her former teammate. Anita, a recruiter who contacted Kavya last year, has four thousand. Rohan is connected to both Meghana and Dev. A stranger called Sam is connected to Anita. Counting shared friends gives Rohan 2 and Sam 1, which already ranks them the right way round, but it overstates the case for Sam. A recruiter with four thousand connections has connected with people from every industry in the city, and the chance that two of them know each other, because they're both on her list, is small.

Two shared friends are not worth the same
Kavya 12 friends Meghana degree 12 Dev degree 20 Anita recruiter, 4,000 Rohan Sam 1 / ln 12 = 0.40 1 / ln 20 = 0.33 1 / ln 4000 = 0.12 common friends 2 Adamic-Adar 0.74 common friends 1 Adamic-Adar 0.12 Kavya's connections on the left, two people she might know on the right.
Rohan and Sam are both two steps from Kavya. Rohan reaches her through two people with small circles, Sam through one recruiter who is connected to thousands, so the Adamic-Adar score gives Rohan about six times Sam's evidence.

A classic fix comes from a 2003 paper by Lada Adamic and Eytan Adar, which measured how similar two people are from what their web pages share. It weights each shared item by how rare it is, and applied to friends it weights each shared friend by how exclusive that friend is. Call the score Adamic-Adar:

The sum runs over the same shared friends as before, but each one contributes instead of 1, where is that friend's number of connections. A friend with 12 connections contributes 1/ln 12, about 0.40. A friend with 20 contributes about 0.33. A recruiter with 4,000 contributes 1/ln 4000, about 0.12. So Rohan scores 0.40 + 0.33 = 0.74 and Sam scores 0.12, a gap of about six to one where the raw count gave two to one. A logarithm keeps the discount gentle: doubling someone's connections lowers their weight by a small amount, and only members in the thousands are discounted hard.

There are other ways to normalise. Dividing the shared count by the geometric mean of the two members' connection counts gives the cosine form . LinkedIn's LiGNN paper uses exactly this quantity as the edge weight in its people-recommendation graph: the weight between two members is their number of common connections divided by the square root of the product of their connection counts. In that paper the weight decides how likely a neighbour is to be sampled, which is a different job from scoring a pair, and we meet it in section 06.

Why does a shared recruiter tell us so little?

Because a connection is evidence about the relationship between two people only when it is rare. If Anita is connected to 4,000 people, then "connected to Anita" describes a large and mixed group, so two people drawn from it share almost nothing else. If Meghana is connected to 12 people, the group is small and probably real: a team, a class, a family. Information is about how much a fact narrows down the possibilities, and a hub narrows them very little. That is also why the cost problem and the quality problem in this chapter have the same source, the hubs. They produce most of the pairs and say the least about them.

4.1 From one score to a model

A single number built from the graph can't use what members have written about themselves, and it can't be tuned to what led to connections. LinkedIn moved to a trained model early on. Its PYMK team page frames relevance as a binary classification problem, predicting whether two people know each other or not. According to the page, the model is a logistic regression combining hundreds of features, trained on billions of samples with LinkedIn's open-sourced large-scale machine learning library. Raghavan's 2018 slides sort the inputs into two groups. Node features describe one member: skill, school, company, and later P(invite) and P(accept given invite). Edge features describe a pair: common connections, same school, same company.

Two of the features have published papers behind them. An organisational overlap model, from a WWW 2013 paper the team page cites, accounts for when two people joined and left an organisation, how large it is and how social it is. Its own example is that a long shared tenure at a small organisation implies a stronger tie than a few months together at a large one. And impression discounting, from a KDD 2014 paper, handles the fact that a person who has been shown a suggestion several times and ignored it is unlikely to act on it later, so repeated unactioned results are ranked lower.

Scoring approachPlusMinus
Common friendsOne matrix product; easy to explainHubs inflate it; blind to profile data
Adamic-AdarSame cost, with hubs discountedStill graph-only; one fixed formula
Logistic regression over many features (LinkedIn)Combines graph and profile signals; weights learned from outcomesPair features must be built for every candidate; linear in its inputs
Deeper models and embeddingsCapture interactions between features and reach past two stepsCostlier to train and serve; harder to explain

LinkedIn's team page describes the logistic model, and its QCon slides from 2018 still list the same node and edge features, so the choice held for years. When deeper models arrived for ranking isn't dated on the page, and the ranker is probably deeper today than the 2018 slides suggest. What it does show, in 2024, is a graph neural network feeding embeddings into the retrieval stage, which section 06 covers. Weighting a shared connection by how exclusive it is shows up wherever co-occurrence is counted: in text, a word that appears in every document carries no weight (the idea behind TF-IDF, chapter 16), and in recommendations, a product everyone buys says little about taste.

05Walking the graph: personalised PageRank

Both scores so far look at paths of length two. Imagine a woman called Tara who sits on Rohan's team, which is full of people connected to Dev and Meghana, and whom Kavya has never met. Kavya, Dev, one of Dev's teammates, Tara: that is three steps, so Tara shares no friend with Kavya and neither score sees her. Yet a person standing in the middle of Kavya's colleagues is a likelier acquaintance than a stranger who happens to share a recruiter. To catch these cases we need a score that follows paths of any length and counts the ones that stay within Kavya's own circle.

A random walk is the standard tool. Put a token on Kavya. At each step, with probability (say 0.15) the token jumps back to Kavya, and otherwise it moves to a random neighbour of whichever member it's on, chosen in proportion to how strong the connection is. After a very long walk, count the share of time the token spent at each member. Members the token visits often are close to Kavya in a way that counts every route, short or long, and favours routes that circle back through tight groups. Those shares are the personalised PageRank of the graph from Kavya's point of view. In symbols, let be the table of step probabilities, with the chance of stepping from to , and a vector with a 1 at the start member and 0 elsewhere. Those visiting shares satisfy

The left form says the token is at with probability because it just restarted, and otherwise is wherever one step from the previous distribution leads. Unrolling the equation gives the right-hand form, which shows what it means: is the distribution after exactly steps, and each step count gets weight , so short paths count most and long ones less, but none is ignored. With the weight halves roughly every four steps. In practice the shares are computed by repeating the update until it settles, which takes a few dozen passes over the edges.

LinkedIn's 2018 talk lists "personalised PageRank" as the extension to friends of friends in candidate generation. Lars Backstrom, then at Facebook, and Jure Leskovec used the same idea in their 2011 paper and added a learning step. Their supervised random walk doesn't treat all edges as equal. Each edge has a feature vector , for example how old the friendship is or how often the two people communicate, and the walk's step weight is a learned function of it, . We train the weights so that, for a source member , the walk visits the people did befriend next, the set , more than the people didn't, the set :

Term by term: keeps the weights small, sets how much the ranking errors matter next to that, and is how much more the walk likes a non-friend than a future friend . Here is a smooth step that is near 0 when friends are ranked above non-friends and near 1 when the order is wrong, with width . So the loss counts, softly, how many wrong pairs there are. It's the same idea as the area under the ROC curve, turned into something a gradient can follow. Squared and Huber losses were tested as well, and the authors used this one, a logistic form of the Wilcoxon-Mann-Whitney statistic, after the others performed close to plain PageRank.

Read the results with their size in mind. On a Facebook graph of Iceland from November 2009, with 174,000 people and about 29 million edges, the authors predicted friendships formed over the next ten weeks. Their supervised walk reached an AUC of 0.828, against 0.817 for plain random walk with restart and 0.816 for Adamic-Adar. (AUC is the chance that a random future friend outranks a random non-friend, so 0.5 is a coin flip.) Its precision at 20, the number of true friends among the top 20 suggestions, was 7.57 against 6.80 and 7.35. They report an 11% relative gain in precision at 20 over the plain walk, and say the differences against a logistic regression on the same features were within the variance. Cost matters too. One edge type, with 8 weights, took about 96 minutes to train on that graph, and six edge types, with 48 weights, took about 13 hours. By node count that graph is several thousand times smaller than the one LiGNN describes.

Now we can compare the three scores on a world where we know the truth. Our next experiment builds 2,000 members in ten communities, adds ten recruiters who connect to 5% of everyone regardless of community, hides 15% of the real friendships, and asks how well each score ranks the hidden friendships among the candidate pairs, those sharing at least one friend in what's left. AUC is the chance that a random hidden friendship outranks a random non-friendship.

Try it Common friends, Adamic-Adar and personalised PageRank on a graph with recruiters
import numpy as np
rng = np.random.default_rng(3)
n, K, H = 2000, 10, 10
grp = rng.integers(0, K, n)                  # community: industry, school
same = grp[:, None] == grp[None, :]
P = np.where(same, 0.06, 0.003)              # friends cluster by group
A = np.triu(rng.random((n, n)) < P, 1)
A[:H, :] |= rng.random((H, n)) < 0.05        # H recruiters link to anyone
A = np.triu(A, 1)
A = (A | A.T).astype(float)
iu = np.array(np.triu_indices(n, 1)).T
edges = iu[A[iu[:, 0], iu[:, 1]] > 0]
edges = edges[edges[:, 0] >= H]              # predict only member pairs
test = edges[rng.random(len(edges)) < 0.15]  # hide 15% of friendships
A[test[:, 0], test[:, 1]] = A[test[:, 1], test[:, 0]] = 0
deg = A.sum(1)
CN = A @ A                                    # common friends
AA = (A / np.log(np.maximum(deg, 2))) @ A     # Adamic-Adar weights
alpha = 0.15                                  # restart probability
Q = A / deg.clip(1)[:, None]                  # one random-walk step
PPR = alpha * np.linalg.inv(np.eye(n) - (1 - alpha) * Q)
PPR = PPR + PPR.T                             # walk from either end
cand = (CN > 0) & (A == 0) & np.triu(np.ones((n, n), bool), 1)
cand[:H, :] = False
y = np.zeros((n, n), bool)
y[test[:, 0], test[:, 1]] = True
yc = y[cand]
print(f"members {n} (first {H} are recruiters), hidden {len(test)}")
print(f"candidate pairs {cand.sum():,}; hidden friendships among them "
      f"{yc.sum()}")
print(f"mean degree: recruiters {deg[:H].mean():.0f}, "
      f"others {deg[H:].mean():.0f}")

def auc(s):
    r = s[cand].argsort().argsort() + 1.0
    pos, neg = yc.sum(), (~yc).sum()
    return (r[yc].sum() - pos * (pos + 1) / 2) / (pos * neg)

for name, s in [("common friends", CN), ("Adamic-Adar", AA),
                ("personalised PageRank", PPR)]:
    print(f"{name:22} AUC {auc(s):.3f}")
With ten recruiters among 2,000 members there are 238,586 candidate pairs, and 839 of the 2,600 hidden friendships are among them. A recruiter has 118 connections on average and an ordinary member 15. Ranked by common friends, the hidden friendships score an AUC of 0.543, barely better than chance. Adamic-Adar reaches 0.622 and personalised PageRank reaches 0.735.

Common friends is close to a coin flip, because the recruiters create far more candidate pairs than the communities do, and every such pair has the recruiter as its one shared friend. Adamic-Adar discounts that friend and recovers part of the signal. Personalised PageRank does best, since walks that start at a member and stay inside her community collect visits from members several steps away, and those are the members whose friendships were hidden. Gap sizes belong to this toy. On the real Facebook graph in the 2011 paper the three methods were much closer, 0.816 for Adamic-Adar, 0.817 for the plain walk and 0.828 for the supervised walk, so the ordering is the thing to carry away and the margins are not.

Beyond two stepsPlusMinus
Personalised PageRank, fixed edge weightsCounts routes of every length; no trainingNeeds a sparse solver per source member
Supervised random walk (2011)Learns which edge types matter; best AUC in its paperHours of training on a 29-million-edge graph; gains small on Facebook
Learned embeddings (LiGNN, 2024)Fixed-size vectors; search by similarity; use profile dataNeeds a training pipeline and a vector index; see the next section

Facebook chose to restrict candidates to two hops and train the walk on them, and LinkedIn's slides list personalised PageRank as a candidate-generation extension. When LinkedIn moved to graph neural networks it kept PageRank, but changed its job: LiGNN uses it to choose which neighbours each member's embedding is built from, which is where we go next. A full walk per member over a graph this size is probably too costly, which fits the paper's choice of a fast two-hop approximation. Random walks with restart also rank web pages for a particular reader, and the same equation works on any graph where closeness to one starting point matters.

06Learning a vector for every member

Walks fix the reach problem and leave two others standing. A walk needs a pass over the graph for each member it starts from, and it sees profiles only through edges. Kavya's profile says that she works in payments, lives in Bengaluru, studied at a particular college and joined a particular company on Monday. Twelve edges can't carry all of that, and a random walk doesn't read it. What we want is a compact summary of each member, built once, that mixes who they're connected to with what they've written, so that two members who would plausibly know each other end up with similar summaries. Then finding candidates for Kavya becomes finding the members whose summaries are closest to hers.

That summary is a vector of a few hundred numbers called an embedding, and a graph neural network (chapter 18) is a way to compute it. Fedor Borisyuk and colleagues at LinkedIn describe the framework they built for this in the LiGNN paper (KDD 2024). For people recommendation it integrates the embeddings into the retrieval stage, as a source of candidates. Its encoder follows the GraphSAGE design. To compute a member's embedding, the network looks at a sample of that member's neighbours, combines their vectors, mixes the result with the member's own, and repeats for a second layer so that friends of friends contribute too. For layer :

Here is the member's input features (the profile), is the sampled set of neighbours, glues two vectors end to end, is a learned matrix, is a nonlinearity, and combines the neighbours' vectors, by averaging or with attention weights, which the paper says it uses. After two layers, is the member's embedding. Sampling is the part that connects to the earlier sections. A member with 4,000 neighbours can't feed all of them in for every training step, so we draw a few dozen, and which few dozen matters. LiGNN compares ways to draw them for people recommendation. Against a baseline of weighted two-hop sampling, personalised PageRank sampling improved validation AUC by 2.1% for the two-hop version and 2.3% for a multi-hop version computed with a forward-push approximation, and the authors say the PageRank family beats weighted sampling by at least 2%. They chose the two-hop version for production because it captures about 90% of the gain and samples three times faster. Weights in the baseline come from the edge-weight formula of section 04, the shared connections divided by the square root of the product of the two members' connection counts.

A graph neural network for people recommendation
GRAPH + PROFILES connections, skills, schools, companies SAMPLE neighbours by 2-hop personalised PageRank AGGREGATE two GraphSAGE-style layers: mean / attention EMBEDDING z one vector per member, computed offline RETRIEVAL + RANKING nearest neighbours of z(Kavya) and z as a feature in the ranker TRAINING: link prediction pair (u, v) that connected = positive; other members in the batch = negatives; loss on the score of z_u and z_v LiGNN reports this for a graph of up to a billion members and billions of connection edges. The sampling step is where 2-hop PPR beat weighted sampling by at least 2% validation AUC. Which loss and features PYMK uses in production is not stated in the paper. Read the top row left to right, then the bottom row: the same embeddings serve training and search.
The top row turns one member's neighbourhood into a vector, and the bottom row shows how the vector is trained and then used, as a retrieval source and as a feature for ranking.

Link prediction is the task the network trains on. Take a pair of members who did become connected as a positive example, take other members as negatives, and train so that the positives score higher. LiGNN lists the decoder choices for turning two embeddings into a score: a small neural network over the pair, the cosine similarity of the two vectors, or a dot product with the other pairs in the same training batch serving as negatives. For people recommendation it states the task, and it doesn't say which decoder or loss is used. Generic shapes are standard, so we can write them out. With a score from a dot product or cosine of and , a binary cross-entropy loss on a labelled pair, and a softmax loss over a batch of pairs, are

In the first, is 1 for a real connection and 0 for a sampled non-connection, and turns the score into a probability. In the second, every other member in the batch acts as a negative for , and the loss falls as the true partner's score rises above theirs. That batch form is cheap, because the embeddings are already computed, and it has the same catch as chapter 41's two-tower model. Members who connect often appear in more batches, so they appear as negatives more often, and the model learns to push down exactly the people who are popular. Chapter 41 shows a correction, subtracting the log of each item's sampling frequency from its score. LinkedIn's paper doesn't say whether its people-recommendation loss applies one, and a correction would probably help there as it did at YouTube.

Reported results are modest in size and specific. For people recommendation, the paper's Table 7 has embeddings from the network feeding an embedding-based retrieval model. Offline, recall rose 29.6%. In the online experiment, new member connections rose 2.4%, sessions 0.2% and weekly active users 0.1%. Its abstract gives the last two as the lift LiGNN delivered for people recommendation. At LinkedIn's scale a tenth of a percent in weekly users is a large absolute number, and the paper is plain that it's small in relative terms. A 2.4% rise in connections is the number closest to what PYMK is for.

6.1 The new-member problem

Kavya's graph has twelve edges, so the neighbourhood the network samples from is thin and her embedding probably leans almost entirely on her profile. LiGNN has a technique aimed at this. It calls it graph densification: when a member with few outgoing edges looks similar to a member with many, add an artificial edge between them, so the sparse member's embedding can borrow from a richer neighbourhood. In the paper, low-degree means below the 30th percentile of out-degree and high-degree means above the 90th, each low-degree node is linked to about 50 similar nodes found by an approximate nearest-neighbour index, and similarity comes from language-model embeddings of profiles. It reports a 0.5% validation AUC gain for its Follow Feed model and 0.28% for ads. It describes the method for those uses, and doesn't report it for people recommendation, so whether PYMK applies it to new members is unpublished. It's a design that fits Kavya's case, though, because it gives a three-day-old account a neighbourhood from its profile alone.

Candidate modelPlusMinus
Friends of friends onlyStrong, cheap, explainableTwo steps; needs connections; ignores profiles
Personalised PageRankAny number of steps, no trainingOne solve per member; profiles enter only through weights
GNN embeddings plus nearest-neighbour searchProfiles and graph together; one vector per member; reaches new members through attributesTraining and index infrastructure; freshness of embeddings becomes a concern

LinkedIn pooled all three. Raghavan's 2018 talk lists friends of friends and PageRank, and the 2024 paper adds embedding-based retrieval fed by the network and keeps PageRank inside the sampler. Which of the sources contributes how many of the final candidates is unpublished. Learning vectors from a graph and a profile together is also how product recommenders on purchase graphs and fraud detectors on payment graphs work, and the encoder differs little between them.

Why compute the embeddings ahead of time instead of when Kavya opens the tab?

Because running a two-layer network over a sampled neighbourhood for every request would add work to the moment she's waiting, and because the answer barely changes between two page loads. LiGNN says it produced embeddings for 500 million members and added them as features for downstream models. A vector for each member sits in a store and the retrieval model looks it up. Staleness is the cost, since a member who just connected to ten people has an old embedding until the next refresh, and section 08 shows how LinkedIn handles freshness for the graph itself.

07Ranking for two people at once

Between triangle closing, walks and embeddings, we now have a pool of candidates for Kavya. How many there are per member isn't published. We still have to put them in order, and that means deciding what the order is for. An obvious target is whether Kavya taps Connect, which is the question every click-through model answers. It's easy to log and plentiful. It's also the target that went wrong at LinkedIn, and it shows up in Raghavan's 2018 slides as the "before" in a before-and-after: PYMK invitations sent, replaced as the headline metric by PYMK invitations sent and accepted, with the same swap proposed on the receiving side, invitations received and accepted.

An invitation is half of a connection, and that drives the switch. Kavya taps Connect on Rohan, and nothing happens to the graph until Rohan sees the request and says yes. If we rank only on what Kavya will do, we'll favour profiles that look appealing to a stranger, and many of those requests will go unanswered. Showing Rohan to Kavya is worth the chance that both steps happen. Write for the chance Kavya sends and for the chance Rohan accepts, given that she did:

That's the product rule for two events in sequence. That second probability is conditional because Rohan can only accept an invitation that was sent. Raghavan's 2018 slides name P(connect) as the model's score, and list P(invite) and P(accept given invite) among its member-level features. Whether production splits the score into two separately trained models is unpublished, and separate models would probably be easier to calibrate and debug. We write the factors out because they make the structure plain: a candidate who is certain to accept and has zero chance of being invited has value zero, and so does one who is certain to be invited and never accepts. Adding the two probabilities would let a strong one cover for a missing other. Multiplying them doesn't.

Ranking for both sides of an invitation
CANDIDATES triangle closing, PPR, embeddings P(send) will Kavya tap Connect? P(accept | send) will the other person say yes? SCORE P(send) x P(accept) = expected new connection RE-RANK discount recipients who already got too many invitations; include newer members RECIPIENT INBOX (last week, illustrative) Anita, a recruiter: 40 invitations -> multiply by 0.2 Rohan, a new colleague: 2 invitations -> multiply by 1 Ranking on P(send) alone pushes eye-catching profiles up and fills their inboxes. The 2021 post describes a decay factor between 0 and 1 from a piecewise linear function of invitations received. Read across the top for the score, then down for the correction applied after it.
A connection exists only if one person sends and the other accepts, so the score multiplies the two probabilities and a re-ranker then protects the recipients who are already overloaded.

Our second factor depends on something the first doesn't: the state of the person receiving the invitation. In 2021 LinkedIn's Growth Data Science team published a post on equity in PYMK that describes what happens when it ignores that. Some highly visible members, such as influencers, senior executives and recruiters at large companies, receive very large numbers of invitations. Their feeds and notifications fill up with loosely relevant people, and they may miss the ones that matter. According to the post, this showed up in usage data and in direct feedback. A ranker trained on invitations learns that these members are attractive, which is true, and recommends them to everyone, which makes their inboxes worse and lowers the chance that any given request is answered. As the first factor gets more accurate, the problem gets worse.

Predict before you read on

In a toy world, eye-catching profiles are more likely to be invited, and anyone whose inbox holds more than a few invitations answers a smaller share of them. We rank each sender's candidates three ways and count what the system gets: (1) by P(send) alone, (2) by P(send) × P(accept), (3) the same with a discount for recipients who already received many invitations last week. Which gives the most accepted connections, and which sends the most invitations?

  1. Ranking by P(send) gives the most of both
  2. The product sends fewer invitations but gets more accepted, and the discount sends fewer still but gets more accepted again
  3. All three give about the same number of accepted connections
Show the answer

B. More invitations are not more connections. In the experiment below, the product sends about 6% fewer invitations and gets about 60% more accepted, and the discount sends about 28% fewer again and gets about 64% more than that. It also shows the problem with the product alone: the busiest inbox is still over two thousand invitations.

Our code makes the assumption explicit: a recipient's chance of accepting falls once they hold more invitations than they can read, and members differ in how eye-catching they are. Numbers belong to the toy; look at the shape of the result.

Try it Rank on P(send), on the product, and on the product with an inbox discount
import numpy as np
rng = np.random.default_rng(5)
N, M, SHOW, CAP = 20_000, 60, 5, 8   # members, candidates, slots, inbox
vis = rng.pareto(1.5, N) + 1         # how eye-catching a profile is
fit = rng.random((N, M))             # how well sender and candidate fit
cand = rng.integers(0, N, (N, M))    # candidate lists per sender
cand = np.where(rng.random((N, M)) < 0.3,
                rng.choice(N, (N, M), p=vis / vis.sum()), cand)
sig = lambda x: 1 / (1 + np.exp(-x))
p_send = sig(-4 + 3 * fit + 1.2 * np.log(vis[cand]))    # taps Connect
p_acc = sig(-1.5 + 4 * fit)                  # accepts, if inbox is empty
rows = np.arange(N)[:, None]

def run(score):
    pick = np.argsort(-score, 1)[:, :SHOW]
    j, ps, pa = cand[rows, pick], p_send[rows, pick], p_acc[rows, pick]
    sent = rng.random(ps.shape) < ps
    inbox = np.bincount(j[sent], minlength=N)    # invites received
    pa = pa * np.minimum(1.0, CAP / np.maximum(inbox[j], 1))  # overload
    acc = sent & (rng.random(ps.shape) < pa)
    return sent.sum(), acc.sum(), (inbox > 30).sum(), inbox.max(), inbox

def decay(inbox):    # piecewise linear: 1 up to 10 invites, 0.2 at 50+
    return np.clip(1 - 0.8 * (inbox - 10) / 40, 0.2, 1.0)

prod = p_send * p_acc
last_week = run(prod)[4]
variants = [("P(send)", p_send), ("P(send) x P(accept)", prod),
            ("... x load discount", prod * decay(last_week)[cand])]
print(f"{'rank by':22}{'sent':>8}{'accepted':>10}{'>30 invites':>13}")
for name, s in variants:
    a, b, c, d, _ = run(s)
    print(f"{name:22}{a:8,}{b:10,}{c:13,}   busiest inbox {d}")
Ranking by P(send) alone produces the most invitations, 85,024, and the fewest accepted, 12,522. Ranking by the product sends 79,966 and gets 20,282 accepted. With the inbox discount the system sends 57,441 invitations and gets 33,224 accepted, and the busiest inbox holds 40 invitations against 3,463 before. Members holding more than 30 invitations fall from 461 to 24, although with the product alone they rise to 533.

Counting invitations would rank the first row best, and counting accepted connections ranks it worst. Row two shows why the decay is needed: it finds more connections, but it learns that the same few members are the most likely to accept and send, so their inboxes grow, and the toy's overload rule punishes that. Discounting spreads the invitations over many more recipients, so each one is answered more often. Our toy builds in the assumption that an overloaded recipient answers less, so these numbers show the mechanism and are not a forecast for LinkedIn, where the 2021 post reports the real effects.

LinkedIn's 2021 post describes the same remedy for real. A re-ranker sits on top of the P(connect) score and multiplies it by a decay factor, so that newScore equals score times a number between 0 and 1. That factor comes from a piecewise linear function of how many invitations the recipient has received. As the post gives the example, recipients with more than ten invitations in the past week get lower priority, and the more they have received, the higher a candidate's original score has to be to appear. Our toy decay does the same, with the shape taken from that description. Its results: the number of overloaded recipients fell 50%, connection requests sent fell 1%, recipient-side sessions rose 1% and sender-side sessions were neutral, an overall session gain of 1%. Survey responses on sending and receiving requests also improved. Its authors explain the gain by saying members who receive fewer invitations get more value from each.

That post addresses a second effect that comes from the training data. Members who use LinkedIn often are overrepresented in PYMK's training data, so the model recommends them to others more, which gives them more connections and more data, a loop we look at in section 09. Their answer was a fairness re-ranking built on the LinkedIn Fairness Toolkit's equality of opportunity and equalised odds, so that qualified infrequent members and frequent ones get equal representation. It reports invitations sent to infrequent members up 5.44% and connections they made up 4.8%, with metrics for frequent members unchanged. It notes that neutral results for the frequent group alongside gains for the infrequent group are unusual, since shifting invitations towards one group would normally cost the other.

What the ranker optimisesPlusMinus
P(send): will she tap Connect?Plenty of labels, immediateFavours eye-catching profiles; many unanswered requests
P(accept): will they say yes?Close to a real relationshipIgnores whether the sender would ever act
Product: P(send) x P(accept | send)Counts only connections that complete; the metric of the 2018 talkBlind to recipient overload; reinforces popular members
Product, then a re-ranker for load and equityProtects recipients; spreads exposure; 2021 results aboveFewer invitations sent; needs the invitation counts live

LinkedIn's 2018 slides show the headline metric moving to sent-and-accepted, and its 2021 post publishes the two re-rankers. Pairing a sender's interest with a receiver's willingness shows up wherever a service connects two parties: ride matching, hiring marketplaces, and dating apps all rank on the chance that both sides agree.

Why not just rank by the chance that the recipient accepts?

Because a person who would certainly accept might never be invited. Rohan accepts nearly anything from a colleague, and if Kavya wouldn't have sent him a request, showing him to her produces nothing. Equally, a candidate Kavya loves but who ignores every stranger produces nothing. Success needs both, so the score has to carry both.

08Serving: one visit to My Network

We now have candidates and a ranker, and one more constraint decides how they run: Kavya won't wait for a billion-member graph to be walked. Everything expensive has to happen before she asks. LinkedIn's 2018 QCon talk describes the PYMK architecture "circa 2015" in three pieces. Offline, a batch job generates candidates and scores them with the P(connect) model, and the results go into a key-value store, which the slides name Venice. Online, a request fetches the stored list and rescores it with real-time signals. Alongside both, tracking events flow back for A/B testing and for model training, which the slides label Photon ML. One slide on scale makes a point that explains much of what comes later: the data processed grows linearly, while the number of records scored grows super-linearly with member growth.

A daily batch has a weakness for Kavya in particular. She joined on Wednesday, so a list built overnight on Tuesday has nothing for her, and once she's connected to Rohan the best next suggestions are on his team, which the stored list doesn't know. Raghavan's slides address this under the heading "Observation: freshness matters!" with a short argument. Network building is contextual, it often involves exploring a cohort of people who share something, and people build networks in a few long sessions and not in a daily habit. A new job, like Kavya's, is probably one of those moments. A list that lags by a day probably misses the session. Gaia, on the slides, is the near-real-time platform that was the remedy. Its input is any kind of graph, kept as a snapshot on Hadoop's file system, plus a stream of updates arriving through Kafka, a log that systems read in order, and a data-change tool, with graph algorithms written as Java code against a compute interface. One slide describes the result as one of the biggest site-wide improvements in connections, and lists more members reaching 30 connections and higher-quality sign-ups among the gains. No figures accompany it.

Offline, nearline and online paths to the list
OFFLINE (a batch job, around 2015) GRAPH SNAPSHOT connections + profiles CANDIDATES triangle closing SCORE P(connect) features per pair STORE a list per member NEARLINE (described in 2018) EVENT STREAM new connections, edits GRAPH UPDATE incremental, in memory RECOMPUTE only affected members STORE fresh lists ONLINE (Kavya opens My Network) REQUEST member id, context FETCH LIST from the store RESCORE with real-time signals SHOW a page of people Stages and names follow LinkedIn's 2018 QCon talk; latencies and list sizes are unpublished. Freshness was the reason for the middle row: people build networks in a few long sessions.
Read each row left to right: a list per member is built once a day, updated as the graph changes, and turned into the page Kavya sees.

Here is Kavya's evening against that picture, with a flag wherever the numbers aren't published. LinkedIn hasn't published latency for any stage of PYMK, and the only timings in its sources are the durations of batch jobs.

  1. Sign-upKavya creates her account, adds her employer and school, and agrees to upload her phone contacts. LinkedIn's help page says the upload is one-time, that imported contacts are used only to improve PYMK, and that contacts import data isn't used for generalised AI model training.
  2. EventsThe new account, the profile fields and the first connections arrive on an event stream. Near-line, the graph picks them up, and the affected members, Kavya and the people she's connected to, are queued for fresh candidates. How long that takes is unpublished.
  3. RequestShe opens My Network. Her request carries her member ID and context, and the service fetches her stored list: candidates from friends of friends, walks and embedding search, already scored.
  4. RescoreReal-time signals adjust the scores, for example profiles she has just viewed or members she has just connected with. Slides name the stage, not the signals.
  5. Re-rankThe load discount lowers candidates whose inboxes are full, like Anita, and the fairness re-ranking makes sure newer and less active members are represented. A handful of people make the page.
  6. ActShe taps Connect on Rohan and Meghana and closes Anita. All three are logged with what was on screen. Rohan accepts ten minutes later, the edge arrives on the stream, and her next refresh probably draws on his team, depending on how fast the near-line path runs.
When to compute the listPlusMinus
On every requestAlways freshGraph work while the member waits; far beyond any request budget
Daily batchEfficient; the whole graph in one passStale for new members and for members mid-session
Batch plus near-line updates (described in 2018)Fresh where it matters; batch remains the bulkTwo pipelines to keep consistent; a graph in memory

LinkedIn started with batch index builds, moved them to Hadoop in 2008, still ran a daily batch as the base in the 2015 architecture, and described the near-line layer in 2018, driven by the freshness argument above. Splitting work between a heavy offline pass and a light online one is how most large recommenders run, and chapter 41's funnel at YouTube sizes its stages the same way.

Slides also describe data growing under the batch jobs. They show that records scored grow faster than membership, and the slide titled "Scalability of Batch Offline" gives the shape of the pipeline: a wide middle where the pair table lives. That's the same blow-up as section 03, now seen from the scoring side.

09Training data, labels and the feedback loop

Each model so far learns from logs, and those logs record what the previous version of PYMK chose to show. Kavya's tap on Rohan is a positive example. Anita, whom she closed, is a negative, or something close to one. A candidate who was never shown to anyone has no label at all, because nobody could act on them. That last group probably contains the members the system would most like to learn about, and the logs say nothing of them.

Labels also carry the two-sidedness of section 07. An invitation sent is a different outcome from an invitation accepted, and a member who never opened the app contributes no information about whether they would have said yes. Impression discounting, from the team page's KDD 2014 reference, is the first fix: a suggestion shown repeatedly and never acted on is evidence, and it lowers the rank of that suggestion for that person. No formula is given, though the penalty probably grows with the number of times a suggestion was shown.

At the structural level, the loop is the one the 2021 post names. Frequent members are more engaged, so they appear more in the training data. So the model learns to recommend them more. They gain connections, and they appear more still. LinkedIn's fix was the fairness re-ranking of section 07, which changes what's shown, and it left the data collection alone. There's a mechanism built into triangle closing too, and we can reason about it from section 02. A member with more connections is a shared friend in more pairs and is suggested through more routes, so a score built from common friends rewards members who already have many. Normalising by the square root of the degrees, as the edge weights in LiGNN do, removes part of that advantage, and Adamic-Adar removes some of it for shared friends. Neither removes the advantage of being well connected. That argument is ours, not a measurement published by LinkedIn.

Handling the loopPlusMinus
Train on the logs as they areSimple; matches what was shownThe model learns the old system's choices and favours active members
Impression discountingStops repeated unwanted suggestions; published in 2014Treats ignoring as dislike, and a person may just be busy
Re-rank for load and for equality of opportunity (2021)Measured gains for infrequent members; no loss for frequent onesTreats the symptom after the model has scored; exposure data is still biased
Random exploration of unshown candidatesGives unshown members a labelShows some members someone they won't want; not described for PYMK

LinkedIn's published responses are the second and third rows. Exploration is a standard remedy that chapter 41 describes for YouTube, and LinkedIn's sources don't describe it for PYMK. Training on logged choices and correcting afterwards is the same compromise that ad systems and search engines make.

9.1 What the system may use

PYMK's inputs are about people who haven't been asked. Kavya uploaded her address book, which contains the phone numbers and emails of people who never agreed to anything. LinkedIn's help page on importing contacts says the upload is a one-time upload of names and email addresses, that imported contacts are used only to improve People You May Know, and that the company doesn't use contacts import data for generalised AI model training. Adam Nash, a LinkedIn employee writing on his own blog in 2008, answered readers' worries about an early version with: "We don't search your hard drive, outlook, or other files." Both statements are constraints on the data the design may use and on the models it may train, and they are why the contact import enters section 08's step list as something with a stated purpose.

Another constraint follows from the shape of the problem and from reasoning, not from anything LinkedIn has written. A suggestion carries information. If Kavya is shown Rohan because both know Meghana, Kavya learns, a little, who Meghana knows. A design has to decide how much of one member's graph may drive what another member sees, and what happens when a member has restricted who sees their connections. LinkedIn hasn't published how PYMK handles that, and we don't claim a rule for it.

10How LinkedIn knows a change helped

There are two layers, as in any recommender: offline numbers computed on logged data, and online experiments. Offline, the sources show several. For the graph network, validation AUC compares sampling strategies, and for retrieval, recall. A standard offline test for link prediction hides a share of existing connections and checks how well the model ranks them, which is what the experiment of section 05 does. These numbers are cheap, and they're also biased in the way section 09 describes. They come from logs of what an older system showed.

Online, the metrics are the ones the sources name. Raghavan's 2018 headline is invitations sent and accepted. LiGNN reports sessions, weekly active users and new member connections for the GNN. LinkedIn's 2021 post measures the number of overloaded recipients, invitations sent, connections made by infrequent members, and recipient and sender sessions. Recipients show a measurement problem, which the post explains. Sender-side impact is read directly from invitations sent, but a recipient may receive invitations from several senders. So the team built an attribution framework that credits a recipient's session to the sender whose invitation the recipient acted on.

That leads to the deeper problem. Take the experiment that tests a new ranker on half the members. Kavya is in the treatment group, and the new ranker sends Rohan a request. Rohan is in the control group. His inbox, his notifications and his decision all changed because of Kavya's treatment. An ordinary A/B test assumes each member's outcome depends only on their own assignment, which is known as the stable unit treatment value assumption, or SUTVA. In a network it fails, and the failure doesn't average out. Guillaume Saint-Jacques, Maneesh Varshney, Jeremy Simpson and Ya Xu state the consequence in their 2019 ego-cluster paper: a typical experimentation platform, with random assignment per member and a two-sample t-test, can fail to account for the network effect and give highly biased results. Their example is a feature that makes treated members share more. Control members then see more interesting content and become more engaged too, so the measured difference between the two groups understates the true effect.

A standard remedy is to randomise whole groups of connected members together, but the paper explains why that fails on a graph like LinkedIn's. Partitioning it into 10,000 balanced clusters gives only about 20% isolation, so a member has on average 80% of their connections outside their own cluster, and the number of clusters is too small for a powerful test. Its alternative is the ego cluster. Choose a focal member, the ego, and her connections, the alters. Give the ego and all her alters the same assignment, then measure only the ego. Different egos get different assignments by a coin flip, so each ego experiences a world where all her peers got variant A or all got variant B. Two quantities matter in the paper:

where is ego 's outcome when she has treatment and her peers have . If all egos are put in treatment and only the alters vary, the difference isolates the network effect. If each ego shares her alters' assignment, it gives the total effect. Analysis is the plain two-sample t-test between egos, which keeps it compatible with the existing platform.

Why a plain A/B test breaks on a network, and the ego-cluster fix
Member-level A/B test Ego-cluster test Each person is flipped alone, so most of her friends are in the other group. ego ego An ego and her alters share one assignment; only egos are measured.
On the left, the colour is each member's own assignment and most edges join different colours, so treated members affect control members. On the right, a whole circle gets one colour, and the effect is read on the ego in the middle.

Here's the difficulty: every member can sit in only one cluster, so clusters take each other's alters, and some of an ego's friends end up in another group. Its name for the share of an ego's alters lost this way is the loss rate, written . Here is what that does to the measurement.

Predict before you read on

Half the traffic outside the clusters is treated, so the lost alters of any ego are treated half the time. Suppose each ego loses 20% of her alters (). In the "all peers treated" arm, what share of an ego's peers is treated, and in the "no peers treated" arm? If a member's response grows in proportion to the share of peers treated, what fraction of the true network effect does the test measure?

Show the answer

In the treated arm, 80% of alters are treated by design and half of the lost 20% are treated by chance, so 90% are treated. In the control arm, none of the 80% are treated and half the lost 20% are, so 10% are treated. So the test compares 90% with 10%, an 80-point gap in place of 100. In general with a global treatment share , the arms see and , and with the gap is . A linear response then gives 80% of the true effect. That test is biased towards zero and not away from it, which the paper calls conservative, and for a launch decision that is probably the safer error.

That's why the paper accepts a small loss rate. Its design principles are to keep the loss rate low and equal across egos, to keep the egos representative of the member base, and to avoid modelling assumptions. In its algorithm, egos are drawn in turn from bins of connection count, from the lowest bin up, taking just enough alters to hit a target loss rate, until the highest-degree bin runs out. That typically yields 150,000 to 200,000 egos with a degree distribution that matches LinkedIn's. A map-reduce step then attaches the leftover members to the egos they are most strongly connected to, subject to equalising loss rates. They also compare it with a naive sequential approach, which sees loss rates climb to 30% after 100,000 egos, so late egos have a much higher loss.

Traffic and statistical power are the price. Getting about 200,000 egos, the paper reports, takes treating about 10 million members, and since only egos are measured, the effective sample is small. Its guidance is that p-values under 0.1 count as significant or borderline, and that users should look at the sign and size of the difference. An extension with a variance-reducing nearest-neighbour assignment brings the minimum detectable effect, at 80% power, from 1.5% to 1% on sessions. Clusters go stale, so the paper advises never using a selection older than a month and rerunning the clustering for every experiment. It also warns that the definition of an edge matters. For feed experiments the team used past feed impressions in place of connections, because connections gave very large clusters and a subset of them were ever seen.

Its examples are about the feed and not PYMK. In one, a feed ranking traded some direct engagement for more sharing. With every ego in control, egos whose alters received the ranking showed engagement up 3.1% (p = 0.03) and scrolling up 2.9% (p = 0.02), a network effect by construction. LinkedIn's sources don't say which PYMK experiments run this way. They do show that PYMK's two-sidedness is exactly the case where one member's treatment changes another's experience, so PYMK is probably among the places the method is used.

Experiment designPlusMinus
Member-level A/B testStandard platform; huge samplesTreated members change control members' outcomes; biased
Graph-cluster randomisationWhole communities share an assignmentAt LinkedIn, 10,000 clusters isolate about 20%; low power
Ego clusters (2019)No product-specific design; runs on the existing platform; dozens a yearAbout 10 million treated for 200,000 egos; conservative bias; short-lived clusters
Attribution of receiver sessions to senders (2021)Measures the receiving side of an invitation inside a normal testCredits one sender when several invited; a modelling choice

LinkedIn's 2021 post describes members randomly assigned to different models, and its 2019 paper describes ego clusters for the cases where network effects are the question, run, the authors say, dozens of times a year. Marketplaces, ride-hailing and ad auctions have the same interference, where a treated buyer changes the price a control buyer sees, and they use switchback and cluster designs for it.

Why can't we just compare treated and control members and adjust afterwards?

Because the damage is done at the assignment stage. If Kavya's treatment changes Rohan's behaviour, then the control group is no longer a picture of a world without the feature, and no adjustment recovers a counterfactual that was never observed. Ego clusters change who gets which assignment, so that each ego's neighbourhood is, as nearly as possible, in a single state.

11What went wrong, and what it cost

LinkedIn's sources describe several rounds of fixing a system that had learned to chase the wrong thing or hit a wall. We list them as the sources present them.

First came freshness through cost. According to the Software Engineering Daily interview, the index took a day to build on Oracle, and as the feature drove growth it took up to a week, with results growing stale. Moving to Hadoop cut it to a couple of hours. Success carries the second cost: the 2018 slides show that records scored grow faster than membership, and the team page says second-degree data grows faster than the site, so every few years the same job needed a new trick. Smart joins in 2018 are one of those tricks, and the figures from them, 6 hours to 10 seconds and 3 to 4 hours to 10 minutes, are what a missed scaling step costs.

Third came the metric. Counting invitations sent rewarded a model for getting people to tap, whatever followed. Raghavan's 2018 talk replaced it with sent and accepted, on both the sending and receiving side, and what that changed in the ranking is the content of section 07.

Fourth, in 2021, came overloaded recipients and frequent-member bias. That post is direct about both: visible members' inboxes filled with loosely relevant requests, and the model favoured members who were already active because they filled the training data. Fixes cost a little of what the team had been measuring, about 1% fewer connection requests sent, in return for 50% fewer overloaded recipients and 1% more sessions, and for 5.44% more invitations sent to infrequent members. It says the team expected key engagement metrics such as invitations sent to fall, and saw net engagement gains instead.

Fifth comes a limit, not an incident. LiGNN's gains from graph neural networks for people recommendation are 0.2% in sessions and 0.1% in weekly active users, with a 2.4% rise in new member connections. They are honest, small, and they come from a system that was already tuned for years. In the Facebook study of 2011 the supervised walk's precision at 20 was within the variance of a plain logistic regression. Neither result says the methods are weak. Both say that on a mature product each new idea buys little, and the measurement has to be good enough to see it. Ego clusters carry a minimum detectable effect, the paper reports, of 1.5% on sessions, falling to 1% with an extension, so a 0.1% or 0.2% effect is far below what a test of that size could detect.

Mistakes in this list share a structure. Each had a stand-in for the real goal, a build time, an invitation count, a click, and the system optimised the stand-in until it stopped tracking the goal. Fixes were rarely a better model. They were a better target, or a correction applied after the score.

12The whole system

We can now draw the full design. On the left is the online path, Kavya's visit. On the right, the offline and near-line path keeps the lists and models current: events and invitations are logged, candidates are generated from the graph by three routes, models are trained and scored, and a change reaches members only after an experiment that is built to survive network effects.

The whole design, online and offline
ONLINE: Kavya opens My Network OFFLINE + NEARLINE: how lists and models stay current APP My Network tab FETCH + RESCORE stored list, real-time signals TWO-SIDED SCORE P(send) x P(accept | send) RE-RANK inbox load discount, newer members PAGE OF PEOPLE Connect / Ignore INVITATION AND REPLY Kavya sends; Rohan accepts or ignores; both are logged with what was shown GRAPH + EVENTS connections, profiles, contact imports (only for PYMK), invitations CANDIDATES triangle closing, PPR walks, GNN embedding retrieval TRAIN + SCORE P(send), P(accept), embeddings; scored in batch and near-line A/B TEST member-level, plus ego-cluster tests for network effects promote what was shown and what happened Kavya's click and Rohan's reply become the next model's labels, so the system learns from a graph that its earlier suggestions helped to build. That is the feedback loop. Sizes, latencies and refresh schedules in this picture are unpublished.
Start at the app on the left and follow the request down to the page. Then follow the log across to the right, through training, scoring and the experiment, and back to the ranker.

Kavya's request fetches a list that was prepared earlier and rescores it with live signals. A two-sided score ranks it, the re-ranker protects overloaded members and spreads exposure, and she sees a page of people. What she does, and what Rohan does in reply, is logged with what was on screen and flows back into the graph and the training data. A new ranker, a new sampling strategy or a new decay factor goes to an experiment, usually a member-level test and, where a feature's effect travels along connections, an ego-cluster test. Several parts of this picture are unpublished: how many candidates each source contributes, the sizes of the lists, the refresh schedule for embeddings, and every online latency. Sources describe the system as of 2008, 2015, 2018, 2021 and 2024, and the current system has probably moved on since.

ComponentWhat it doesAdded because
Triangle closing as a matrix productCounts shared connections for every pairFriends of friends is the strongest cheap signal (§02), and loops over pairs explode (§03)
Exclusivity-weighted scoresDiscount shared friends who know everyoneHubs produce most pairs and carry the least evidence (§04)
Personalised PageRankReaches past two steps; samples neighboursA candidate three steps away inside Kavya's circle has no shared friend (§05)
GNN embeddingsOne vector per member, searched by similarityProfiles and graph together; a way into sparse neighbourhoods (§06)
Two-sided scoreP(send) x P(accept | send)An invitation is half a connection (§07)
Load discount and fairness re-rankProtects recipients; spreads exposureVisible members drowned; frequent members over-represented (§07, §09)
Offline + near-line servingStored lists, updated as the graph changesA day-old list misses a new member's session (§08)
Ego-cluster experimentsMeasure effects that travel along edgesPlain A/B tests are biased on a network (§10)

13Summary

  1. PYMK is link prediction on a graph of over a billion members. LinkedIn's about page lists 1.3 billion members and over 18,000 connections a minute, and the system says it built more than half of the professional graph.
  2. Version 1 counts shared friends. Triangle closing is a matrix product, and at first it took a day on Oracle, then up to a week, then a couple of hours on Hadoop.
  3. Counting is dominated by hubs. Records grow with the sum of squared connection counts, so a tiny share of members produces a third of the work in our illustration, and smart joins cut LinkedIn's runs from hours to minutes.
  4. Shared friends differ in value. Adamic-Adar weights each by one over the log of their connections, so a recruiter with 4,000 contacts counts for about a third of a colleague with 12.
  5. Random walks reach further. Personalised PageRank counts routes of every length with decaying weight, and the supervised version learns edge strengths, at a cost of hours on a graph of 29 million edges.
  6. GNN embeddings combine graph and profile. LiGNN samples neighbours by two-hop personalised PageRank, which beat weighted sampling by about 2%, and its embeddings raised offline recall 29.6% and new connections 2.4%.
  7. An invitation is half a connection. The score is P(send) times P(accept given send), and in 2018 LinkedIn changed its headline metric from invitations sent to invitations sent and accepted.
  8. Protect the recipients. A decay on invitations received cut overloaded recipients by 50% and lifted sessions 1%, and a fairness re-ranking raised connections made by infrequent members 4.8%.
  9. Freshness needs a near-line path. A daily batch misses the session of a new member, so LinkedIn added a graph updated from an event stream.
  10. The logs are a feedback loop. Frequent members fill the training data and get recommended more, and the fixes are re-ranking and discounting, with exploration left unpublished for PYMK.
  11. Network effects break ordinary A/B tests. Ego clusters give each ego a neighbourhood in one state, at the price of about 10 million treated members for 200,000 egos and a conservative bias.

14Build this

The ideas in this chapter are easy to agree with and easy to get wrong in code. You can rebuild the heart of PYMK on a laptop with synthetic data, and watch each fix change what gets recommended.

Project A small PYMK with hubs, two-sided ranking and an ego-cluster test ~5 hours · numpy only

Build a world where you know the truth: 3,000 members in 12 communities, a handful of recruiters who connect to everyone, and a hidden 15% of the real friendships to predict.

  1. Generate the graph and hide the test friendships. Rank candidate pairs three ways, by common friends, by Adamic-Adar and by personalised PageRank, and report AUC and precision at 10 for each. Vary the number of recruiters from 0 to 30 and plot how each score degrades.
  2. Count the records the pairing step would produce, the sum of d(d-1)/2, and compare with the number of nonzero entries in the product of the adjacency matrix with itself. Cap the number of friends per member at 200 and measure the quality you lose.
  3. Give each member a sociability and a response rule: a probability of sending that grows with the candidate's visibility, and an acceptance probability that falls once their inbox exceeds a limit. Rank by P(send), by the product, and by the product with a decay on last week's invitation counts. Report invitations sent, accepted and the largest inbox.
  4. Simulate a feature whose effect spreads along edges: a treated member increases the response of each of their friends by a fixed amount. Run an ordinary member-level A/B test and measure the estimated effect. Then build ego clusters with a loss rate near 20% and compare the estimate with the true total effect.
  5. Close the loop. Retrain your ranker for 10 rounds on the connections the previous round produced, and track the share of members who ever get recommended. Repeat with a fairness re-rank that reserves a fixed share of slots for the least-connected quarter of members.
You'll know it worked when common friends degrades fastest as recruiters are added and Adamic-Adar and the walk degrade more slowly, the product ranking sends fewer invitations than P(send) but gets more accepted, the member-level test reports a fraction of the true spread effect while the ego-cluster estimate lands within a few percent of it, and the re-rank keeps a larger share of members visible after ten rounds.
A harder variant. Add profile attributes and train a small two-layer neighbourhood-averaging network as in section 06. Compare retrieval recall against the walk for members who have fewer than five connections.

15Interview questions

BeginnerWhat is triangle closing and why is it the first signal for People You May Know?

If A knows B and B knows C, then A and C may know each other, and the more friends they share, the likelier it is. In a graph stored as an adjacency table, multiplying the table by itself gives the number of shared friends for every pair at once. LinkedIn's team page names it as the first signal, and early on the job of building the index ran for a day on Oracle before it moved to Hadoop in 2008. It's strong because most new links in an online social network close a triangle, which Backstrom and Leskovec use to restrict candidates to two steps.

BeginnerWhy does PYMK optimise for invitations accepted and not invitations sent?

A connection forms only when the other person accepts. A ranker trained on sends favours eye-catching profiles and produces many unanswered requests. Raghavan's 2018 QCon talk proposed counting PYMK invitations sent and accepted, and received and accepted, as the metric, in service of "engaged members with high quality connections". So the score becomes P(send) times P(accept given send), so both steps must be likely.

IntermediateWhy does Adamic-Adar beat a plain count of common friends?

It weights each shared friend by 1 over the log of their connection count. A friend with 12 connections contributes about 0.40 and one with 4,000 about 0.12. A shared hub says little because it is connected to a large, mixed group, and hubs also account for most of the candidate pairs. In a toy graph with ten recruiters connected to 5% of everyone, common friends ranked hidden friendships at an AUC of 0.54, Adamic-Adar at 0.62 and personalised PageRank at 0.74. On the real Facebook graph in the 2011 supervised-walk paper, the differences between these methods were far smaller, about 0.001 in AUC between Adamic-Adar and a plain walk.

IntermediateExplain personalised PageRank and how it differs from friends of friends.

Start a walker at the member. At each step, with probability alpha it returns to the start, otherwise it moves to a neighbour in proportion to edge weight. Long-run share of time at each node is the score. Unrolled, it is a weighted sum over walks of every length, with weight alpha(1-alpha)^k for length k, so it counts routes beyond two steps and favours those that circle back through tight groups. A candidate three steps away, with no shared friend, can still rank high. LiGNN also uses personalised PageRank to choose which neighbours feed each member's embedding.

IntermediateHow would you handle a recruiter who is recommended to everyone?

Their inbox fills, they answer less, and the first-stage model, which has learned they are attractive, keeps promoting them. LinkedIn's 2021 post adds a re-ranker that multiplies the score by a decay factor between 0 and 1, from a piecewise linear function of the invitations received that week. In the post, overloaded recipients fell 50%, connection requests sent fell 1% and recipient sessions rose 1%. An earlier stage uses the same idea, impression discounting, which lowers suggestions a member keeps ignoring.

IntermediateWhy embed members with a GNN when you already have friends of friends?

Friends of friends needs connections and sees only two steps. A GNN builds a vector from a member's profile and a sampled neighbourhood, so a member with few connections still gets a useful vector, and retrieval becomes nearest-neighbour search. LiGNN reports a 29.6% offline recall gain and a 2.4% rise in new member connections for people recommendation. Its sampling uses two-hop personalised PageRank, chosen over weighted sampling because it gave about 2% more validation AUC.

DeepWhy can't you A/B test a new PYMK ranker by assigning members at random?

Behind the test sits an assumption, that one member's outcome depends only on their own assignment, and it fails. A treated sender's invitations change a control recipient's inbox, and treatment on one side of an edge affects the other. Control is then not a world without the feature, and the estimate is biased, often towards zero. Ego-cluster randomisation gives an ego and all her alters one assignment and measures the ego. With a loss rate alpha and half the outside traffic treated, the two arms see shares 1-alpha/2 and alpha/2 of peers treated, so with a linear response you see a fraction 1-alpha of the true effect. Cost: about 10 million treated members for 200,000 egos.

DeepHow would you keep results fresh for a member who joined an hour ago?

A daily batch has nothing for them. LinkedIn's 2018 talk describes a near-real-time platform: a graph kept as a snapshot plus a stream of updates from Kafka, with algorithms run on affected members when edges change. People build networks in a few long sessions, so a delay of hours misses the session. For the profile-only start, a design can use attribute-based candidates and embeddings, and LiGNN's densification links sparse members to similar well-connected ones, though the paper describes it for other products and not for PYMK.

DeepDescribe the feedback loop in PYMK and how you would test whether you've broken it.

Active members fill the training data, so the model recommends them more, they gain connections, and they appear more in later data. Triangle closing adds its own pull, since well-connected members sit in more candidate pairs. LinkedIn's 2021 fix re-ranks for equal representation of qualified infrequent and frequent members, with gains of 5.44% in invitations sent to infrequent members and 4.8% in their connections, neutral for frequent members. To test it, track the share of members who are ever recommended, the concentration of invitations received, and connections for the least-connected quartile across successive retrains, and run longer tests, since the effect builds over months.

16Go deeper

📄
Paper
LiGNN: Graph Neural Networks at LinkedIn
Borisyuk et al., KDD 2024. PageRank sampling, densification and the people-recommendation results of section 06. arXiv:2402.11139
📄
Paper
Using Ego-Clusters to Measure Network Effects at LinkedIn
Saint-Jacques, Varshney, Simpson and Xu, 2019. Why member-level A/B tests are biased on a network and how ego clusters fix it. arXiv:1903.08755
📄
Paper
Supervised Random Walks: Predicting and Recommending Links in Social Networks
Backstrom and Leskovec, WSDM 2011. Learned edge strengths in personalised PageRank, tested on Facebook. arXiv:1011.4071
🎤
Talk
Building Near Realtime Contextual Recommendations for Active Communities on LinkedIn
Hema Raghavan, QCon San Francisco 2018. Covers the sent-and-accepted metric, the 2015 architecture, smart joins and near-real-time updates.
📝
Company blog
Optimizing People You May Know (PYMK) for Equity in Network Creation
LinkedIn Engineering, August 5, 2021. Overloaded recipients, frequent-member bias and the re-rankers of section 07.
📝
Company page
People You May Know
LinkedIn Engineering team page, undated. Triangle closing, the logistic model, organisational overlap and impression discounting.
🎙️
Interview
Software Engineering Daily, episode 3: LinkedIn and Hadoop
A LinkedIn engineer on the first Hadoop use case: the PYMK index that took a day, then a week, on Oracle. Transcript, 2019.
📘
Official docs
Import your Gmail contacts to LinkedIn
LinkedIn Help. What imported contacts are used for and what they are not used for.