Imagine three hospitals that each want a better model for reading chest X-rays. Together they have far more scans than any one of them alone, and a model trained on all of them would be better for every patient. But patient records cannot leave the building.
Federated learning is a way to train one shared model on all of that data without ever collecting it in one place. This post explains how it works in plain language, with just one short formula.
Why not just pool the data?
Machine learning models get better with more examples. The obvious move is to copy everyone’s data to one server and train there. Often that is not allowed, or not wise.
Medical records are protected by law. Banks cannot share customer transactions with each other. Your phone has years of your typing, photos and voice, and you would rather it stayed on your phone. Even when sharing is legal, moving terabytes of data around is slow and expensive, and every extra copy is one more thing that can leak.
So the data is stuck where it is. Federated learning asks: if the data cannot come to the model, can the model go to the data?
Send the model, not the data
In federated learning, a central server holds one shared model but never sees any raw data. Instead, it sends a copy of the model to each participant, called a client. A client might be a hospital, a bank, or a single phone.
Each client improves its copy using only its own data, then sends back just the changes it made. The server combines those changes into a better shared model. The data never moves; only what the model learned from it does.
One round, step by step
Training happens in rounds. Every round has the same four steps:
- The server sends out the current model. Every participating hospital receives an identical copy.
- Each hospital trains it locally. It runs ordinary training on its own patients for a short while, so its copy gets a little better at its own cases.
- Each hospital sends back only its update. That is the difference between the model it received and the model it ended up with: a list of numbers, not patient records.
- The server averages the updates. The result becomes the new shared model, and the next round begins.
After tens or hundreds of rounds, the shared model has learned from every hospital’s patients without any of them ever leaving the building.
How the averaging works
The standard recipe is called Federated Averaging, or FedAvg. It is a weighted average: a hospital that trained on more patients gets a bigger say than one that trained on fewer.
Written as a formula, if client has examples out of in total, and returns model weights , the new shared model is
That is the whole trick. In the example above, for Hospital A, for B and for C.
Where it is used
One of the best-known deployments is Google’s Gboard keyboard, which used federated learning to improve next-word suggestions from what people type on their phones, without uploading the text itself.
Other common settings follow the same pattern: hospitals building diagnostic models together, banks spotting fraud patterns across institutions, and cars or cameras learning from what they see on the road. Anywhere data is valuable but cannot be pooled, federated learning is a candidate.
What makes it hard
Every client’s data looks different. In a normal training set the examples are shuffled together. Here they are not. A children’s hospital sees mostly children; a heart clinic sees mostly older patients. Researchers call this non-IID data (not independent and identically distributed).
When clients see such different data, their updates can pull the shared model in opposite directions, and averaging them can produce a model that is worse for everyone. A lot of federated learning research is about handling exactly this.
Communication is the bottleneck. Models can have millions of numbers, and sending them back and forth every round over a phone connection is slow. That is why each client trains for a while locally before reporting back, instead of after every single example.
Clients come and go. Phones go offline, run low on battery or are simply busy. Each round usually uses whichever clients happen to be available, so the system has to cope with partial participation.
Is it automatically private?
No. Keeping data on the device is a big step, but the updates themselves can leak information. Researchers have shown that, in some settings, an attacker who sees an individual update can reconstruct training examples, such as images, from it.
Two protections are commonly layered on top:
Differential privacy adds carefully measured random noise to each update, so that no single person’s data can noticeably change what is sent. Secure aggregation uses cryptography so the server can compute the sum of all updates without being able to see any individual one.
There is also the opposite problem: a client can be dishonest and send poisoned updates that quietly damage the shared model. Detecting such clients, and removing the influence they already had, is an active research area, called federated unlearning.
The mental model
- Move the model, not the data. Raw data stays with whoever owns it.
- Learn in rounds. Send the model out, train locally, send updates back, average.
- Bigger datasets get a bigger say in the average.
- Different data is the main difficulty. Clients rarely see the same kinds of examples.
- Private by design, not by default. Updates can still leak, so add noise and secure aggregation when it matters.