Book Deep Read · ML System Design Interview · Chapter 11

People You May Know: the hard part isn't guessing right, it's cutting a billion down to ten thousand

Machine Learning System Design Interview · Ch 11 · Ali Aminian & Alex Xu · 2023

中文 →

What is this chapter about?

You sign up for a social app and fill in nothing but your name. Three days later it hands you a list of "people you may know" — and your college roommate and two former coworkers are actually on it. This chapter is about how it pulls that off.

A strange thing first

You'd assume it matches your profile against everyone else's: same school, same employer, same city. Those help, but none of them is the engine.

The real engine is one single clue: how many friends the two of you have in common. That one signal alone surfaces most of the right people. It doesn't even need to know who you are or what you do.

Why the old world found this hard

The difficulty isn't the guessing. It's how many guesses you'd have to make.

A platform has a billion people. Taken literally, deciding "who might you know" means pairing every person with every other person — an astronomical number that all the machines on earth couldn't finish. So the first job isn't building a clever model. It's figuring out how to know that almost everybody isn't worth looking at, without looking at them.

The core idea, in plain terms

Step one: only look at friends of your friends. Almost everyone you meet, you meet through someone you already know. Restricting candidates to friends-of-friends shrinks the pool from a billion to tens of thousands — a hundred-thousand-fold cut.

Step two: discount mutual friends. The naive move is to count them and rank by the count. That has a trap: if the person in the middle is a super-connector with five thousand friends, they are "mutual" with everyone, which tells you nothing. Flip it around — someone with only thirty friends who knows both of you is strong evidence you two really move in the same circle. So: the more friends the middleman has, the less their vote is worth.

Step three: give everyone a position on a social map. Let each person look around at who surrounds them, then at who surrounds those people, and derive a coordinate from that. Two people whose coordinates sit close together should be recommended to each other — this catches the subtler signal of "you two share no friends at all, but your circles look remarkably alike."

How to think about it

What makes this powerful is that it reconstructs real-world social circles from nothing but "who is connected to whom."

And that is exactly the cost: it knows the two of you are connected, but not why you'd rather this person couldn't find you — so it will happily surface an ex-colleague, an ex-partner, or someone from a context you never wanted linked to your name.

One sentence to remember

Friend recommendation is won or lost before the model: use friends-of-friends to cut a billion candidates down to ten thousand, then count mutual friends and discount each one by how many friends the middleman has — a super-connector's vote is worth far less than that of someone from a small, tight circle.

Want the mechanisms, notation and diagrams? → Switch to the deep read