"The fleet trained a model that is wrong about everyone equally. I kept a little of it for myself, adjusted the last layer to how this wrist actually moves, and suddenly the average stopped speaking for me."
A Self-Interested AI Agent
Prerequisites
This section builds directly on federated averaging and the non-IID sensor problem from Section 64.2: read that first, because personalization is the answer to the pathology it diagnoses. You should be comfortable with fine-tuning a network by freezing some layers and training others (Chapter 13), with why sensor distributions differ across people and devices (Chapter 2), and with the subject-split evaluation discipline that keeps you honest (Chapter 5). The single code example uses only NumPy and closed-form least squares.
The Big Picture
Federated averaging returns one model to a fleet whose clients disagree about what the data looks like. When wrists, gaits, skin tones, mounting angles, and label habits vary from person to person, that single global model is a compromise that can be worse for an individual than a model trained on that individual alone. Personalized federated learning refuses the false choice between "everybody's model" and "my model." It keeps the statistical strength of the fleet for the shared structure of the task, then bends the last mile toward the client in front of it. This section gives you the four workhorse strategies (partial-model personalization, regularized local training, meta-learning an easily-adapted initialization, and client clustering), a rule for choosing among them, and the traps that make personalization quietly backfire: catastrophic forgetting, cold-start clients, and evaluation that flatters itself. The payoff is concrete. On cross-person activity recognition, a few hundred local examples and a re-trained head routinely recover accuracy that the global model left on the table.
Why one global model is the wrong deliverable
Section 64.2 showed that under non-IID clients, the FedAvg objective minimizes a weighted average of local losses. The minimizer of an average is not the minimizer for any single term unless every term already agrees. In sensing, the terms rarely agree. Two people performing the "climbing stairs" activity produce accelerometer distributions with different means, variances, and even different dominant frequencies because of stride length, cadence, and where the phone sits in the pocket. A model forced to be good on average across both learns a decision boundary that sits between their clusters and slices through each of them.
The formal object we actually want is a family \(\{\theta_1, \dots, \theta_K\}\), one model per client \(k\), each minimizing that client's own risk while borrowing strength from the others. Personalization methods differ only in how they couple the shared and the private parts. Write each client objective as a shared term plus a local term,
$$\theta_k^\star = \arg\min_{\theta}\; \underbrace{F_k(\theta)}_{\text{fit client } k} + \tfrac{\lambda}{2}\,\underbrace{\lVert \theta - w \rVert^2}_{\text{stay near the fleet } w},$$where \(w\) is the global model and \(\lambda\) sets how hard the fleet pulls the client back. At \(\lambda \to \infty\) you recover the single global model (pure FedAvg); at \(\lambda \to 0\) you recover fully local training with no sharing. Every method below is a way of picking, structuring, or annealing that coupling.
The personalization toolbox
Partial-model personalization splits the network into a shared representation and a private head. The fleet federates the feature extractor (the layers that learn what a "step" or a "heartbeat" looks like in general), while each client keeps a locally trained classifier or a locally estimated normalization layer. FedPer keeps the head private; FedBN keeps each client's batch-normalization statistics local, which is remarkably effective precisely because normalization absorbs the per-device mean and scale shift that causes most of the non-IID pain. This is the cheapest option: the private part is small, it trains in seconds on-device, and it never leaves the device, so it adds no communication cost and improves privacy.
Regularized local training keeps the whole model personal but tethers it to the global one, exactly the \(\lambda\)-penalized objective above. Ditto is the clean instance: run FedAvg to get \(w\), then have each client solve for its own \(\theta_k\) with the proximal pull toward \(w\). The knob \(\lambda\) is interpretable and per-client tunable, which matters when some users have thousands of labeled windows and others have twenty.
Meta-learning reframes the goal: instead of shipping a model to use directly, ship an initialization that adapts to any client in one or two gradient steps. Per-FedAvg applies the MAML idea inside federation, optimizing \(w\) so that \(w - \alpha \nabla F_k(w)\) is good for every \(k\). The fleet learns "a place to start from" and the client finishes the job locally.
Client clustering admits that clients fall into groups (left-handed versus right-handed, phone-in-pocket versus phone-in-hand, one wearable model versus another). IFCA alternates between assigning each client to its best-fitting cluster model and updating each cluster model from its members, yielding a handful of specialists instead of one generalist or thousands of loners.
Key Insight
Personalization is a bias-variance trade made per client. The global model is low variance (it averages over the whole fleet) but high bias for any individual. A purely local model is unbiased for that individual but high variance when local data is scarce. The coupling strength \(\lambda\), the size of the private head, or the number of local adaptation steps all slide you along this same curve. The right operating point is not global: a data-rich client should personalize aggressively (small \(\lambda\)); a client with a handful of examples should lean on the fleet (large \(\lambda\)). Any method that forces one setting on everyone leaves accuracy on the table at both ends.
A minimal personalization head
The code below strips the idea to its core so you can see the mechanism, not the framework. Two clients share a fixed random feature map (standing in for the federated backbone) but have opposite label conventions, the sharpest possible non-IID case. We compare a single global linear head fit on the pooled data against a per-client head fit locally on top of the same shared features. The shared features never move; only the tiny head is personalized.
import numpy as np
rng = np.random.default_rng(0)
def features(X, W): # shared "federated" backbone (frozen)
return np.tanh(X @ W)
d, h, n = 4, 32, 400
W = rng.normal(size=(d, h)) # one representation for the whole fleet
beta = rng.normal(size=d) # the true concept, shared by all
# Two clients with OPPOSITE label conventions (non-IID sign flip)
def make_client(sign):
X = rng.normal(size=(n, d))
y = sign * (X @ beta) # same task, flipped output convention
return X, y
clients = [make_client(+1.0), make_client(-1.0)]
Phi = [features(X, W) for X, _ in clients]
# (a) One GLOBAL head fit on pooled features -> forced compromise
Phi_all = np.vstack(Phi)
y_all = np.concatenate([y for _, y in clients])
w_glob, *_ = np.linalg.lstsq(Phi_all, y_all, rcond=None)
# (b) PERSONALIZED head per client on top of the SAME shared features
def mse(P, y, w): return float(np.mean((P @ w - y) ** 2))
for k, ((X, y), P) in enumerate(zip(clients, Phi)):
w_loc, *_ = np.linalg.lstsq(P, y, rcond=None)
print(f"client {k}: global MSE={mse(P, y, w_glob):6.3f} "
f"personalized MSE={mse(P, y, w_loc):6.3f}")
Run it and the global head posts a large error for both clients while the personalized heads collapse to near zero. The sign flip is a caricature, but real fleets contain softer versions of it everywhere: a user who labels light jogging as "running," a chest strap mounted upside down, a glucose sensor with a personal calibration offset. The lesson transfers directly.
Library Shortcut
Rolling your own personalized federated loop (client sampling, partial-parameter aggregation, per-client proximal terms, cluster assignment) is a few hundred lines of careful bookkeeping. Flower exposes personalization through custom Strategy and NumPyClient classes where you simply mark which parameters aggregate and which stay local, turning FedPer or FedBN into roughly a dozen lines. FedJAX and FedML ship reference implementations of Ditto, Per-FedAvg, and IFCA you can call as configured algorithms. The framework handles the round orchestration, the partial-state serialization, and the straggler handling; you write only the split between shared and personal parameters.
Practical Example: personalizing a wearable step-and-activity model
A smartwatch vendor federates a human-activity-recognition model (Chapter 26) across a million wrists. The global FedAvg model reaches 82 percent balanced accuracy on a held-out subject split, but underperforms badly on users with atypical gait: wheelchair users, people with a limp, and very tall or very short strides that shift cadence out of the fleet's dominant band. The team ships a FedBN-plus-head design. The convolutional backbone is federated once a day; each watch keeps its own batch-norm statistics and re-fits a two-layer head overnight on the wearer's last two weeks of confirmed activities (drawn from workout-app confirmations, so labels are cheap). Per-user accuracy on the atypical-gait cohort jumps from the low 60s into the high 70s, the personal head is under 8 KB so it costs nothing to store, and because the head never leaves the watch the personalization itself leaks no raw motion. Cold-start users default to the global head until they accumulate enough confirmations, then cross over automatically once the local head validates better on a held-out slice.
When to personalize, and the traps
When. Personalize when three things hold: clients are genuinely heterogeneous (if they were IID, the global model would already be optimal and personalization only adds variance); each client has enough local labels to fit the private part without overfitting; and the per-client distribution is stable enough that yesterday's adaptation still helps today. If the client's distribution drifts within a session rather than differing between clients, you want test-time adaptation instead (Chapter 66), which reacts online without labels.
The traps. First, catastrophic forgetting: aggressive local fine-tuning can erase the shared knowledge that made the fleet valuable, so the head that nails this week's activities forgets the rare fall it was meant to catch. The regularization tether \(\lambda\) and the on-device continual-learning defenses of Chapter 62 exist to prevent exactly this. Second, cold start: a brand-new client has no local data, so it must fall back to the global (or its cluster's) model until it earns the right to personalize. Third, and most dangerous, self-flattering evaluation. You must measure personalized accuracy on each client's own held-out future data, never on the data you adapted with, or you report memorization as generalization. Report the per-client accuracy distribution, not just the mean, because personalization that helps the average while hurting a vulnerable tail is a regression dressed as a win.
Research Frontier
Current work pushes personalization toward parameter-efficient and privacy-aware forms. Adapter- and LoRA-style personal modules attach a few thousand trainable weights to a frozen federated backbone, echoing the foundation-model tuning of Chapter 20, which cuts on-device cost and keeps the shared model intact. Methods including Ditto, APFL, FedRep, kNN-Per, and pFedHN (hypernetworks that generate each client's weights) map the space between "one model" and "one per client," while FedBN remains a startlingly strong baseline for sensor shift. The open problems are honest ones: personalization interacts with the differential-privacy noise you will add in Section 64.4 (personal parameters have fewer contributors, so they are harder to protect), and fair personalization that does not widen the accuracy gap between majority and minority clients is still unsolved.
Exercise
Extend the code example into a Ditto-style comparison. Keep the shared random backbone, but now instead of a pure local head, fit each client's head by minimizing \(\lVert \Phi_k w - y_k \rVert^2 + \lambda \lVert w - w_{\text{glob}}\rVert^2\) for a sweep of \(\lambda \in \{0, 0.1, 1, 10, 100\}\). Plot per-client test MSE against \(\lambda\). Then reduce one client's training set to 15 examples and repeat. Confirm that the data-rich client prefers small \(\lambda\) while the data-poor client's optimal \(\lambda\) moves higher, the bias-variance story made numerical.
Self-Check
- FedAvg minimizes a weighted average of local losses. In one sentence, why does that make it a poor model for an individual client under non-IID data?
- You have two clients: one with 5,000 labeled windows and one with 30. Which should use a smaller regularization strength \(\lambda\) (personalize harder), and why?
- A colleague reports that their personalized models reach 97 percent accuracy, measured on the same local windows used to fit each personal head. What is wrong with this number, and what evaluation would you demand instead?
What's Next
In Section 64.4, we confront the uncomfortable fact that even model updates, not just raw data, can leak the individuals who produced them. We introduce differential privacy to bound that leakage formally and secure aggregation to hide any single client's contribution inside the sum, then measure the utility cost these guarantees impose, a cost that personalization, with its thinly-populated per-client parameters, makes especially sharp.