SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2603.11992 · 2026

Few-for-Many Personalized Federated Learning

Xi Lin, Qingfu Zhang, Xiang Li, Ping Guo, Tiantian Zhang, Zhi-Ri Tang

arXiv · PDF · Open in the Atlas

Code that ran

4 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 3 failures of our instrument; 4 no recorded run), measured 2026-11-22; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2603.11992.json · badge: /api/ran/2603.11992.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
pgg3/FedFew community
Papers with Code archive
4 ran · 4 no recorded run
FunctionStatusWhere it lives
_get_dataset_root Ran
ran on a synthesized input
pgg3/FedFew/PFLlib/system/flcore/servers/serverfedfews.py
code served (permissive licence) · get_code("f16cc0fcf384ba3b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
import shutil

# Create a temporary directory structure to simulate the dataset environment
temp_base = tempfile.mkdtemp()
temp_system_dir = os.path.join(temp_base, 'system')
os.makedirs(temp_system_dir, exist_ok=True)

# Create dataset directories at various expected locations
dataset_dir_v1 = os.path.join(temp_base, 'dataset')
os.makedirs(dataset_dir_v1, exist_ok=True)

# Since the function takes no parameters, ARGS should be an empty dict
ARGS = {}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
process_image Ran
ran; our contract draft was wrong, not the code
pgg3/FedFew/PFLlib/system/flcore/servers/serverfedfews.py
code served (permissive licence) · get_code("c7e7971b001d0d94")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# The function expects a dict with keys 'x' and 'y'
# 'x' can be either a list of numpy arrays or a numpy array/tensor
# 'y' should be array-like that can be converted to a tensor

# Create sample data with distinct dimensions for clarity
# Using shape (2, 4) for batch of 2 samples with 4 features
x_list = [np.random.randn(4).astype(np.float32) for _ in range(2)]
y_data = np.array([0, 1], dtype=np.int64)

data = {
    'x': x_list,
    'y': y_data
}

ARGS = {
    'data': data
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
read_client_data Ran
ran; our contract draft was wrong, not the code
pgg3/FedFew/PFLlib/system/flcore/servers/serverfedfews.py
code served (permissive licence) · get_code("30123ffcd4022409")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from collections import defaultdict
import os
import tempfile
import pickle

torch.manual_seed(0)

# Create a temporary directory structure to mock the dataset
temp_dir = tempfile.mkdtemp()
dataset_name = "MNIST"
train_dir = os.path.join(temp_dir, dataset_name, "train")
test_dir = os.path.join(temp_dir, dataset_name, "test")
os.makedirs(train_dir, exist_ok=True)
os.makedirs(test_dir, exist_ok=True)

# Set environment variable to point to our temp dataset directory
os.environ['PFLLIB_DATA_DIR'] = temp_dir

# Create mock data files for image dataset (MNIST style)
mock_train_data = {
    'x': [np.random.rand(28, 28).astype(np.float32) for _ in range(2)],
    'y': [0, 1]
}

mock_test_data = {
    'x': [np.random.rand(28, 28).astype(np.float32) for _ in range(2)],
    'y': [0, 1]
}

# Save mock data as pickle files
with open(os.path.join(train_dir, '0.pkl'), 'wb') as f:
    pickle.dump(mock_train_data, f)

with open(os.path.join(test_dir, '0.pkl'), 'wb') as f:
    pickle.dump(mock_test_data, f)

# Also create a Shakespeare dataset variant
shakespeare_dir = os.path.join(temp_dir, "Shakespeare")
shakespeare_train_dir = os.path.join(shakespeare_dir, "train")
os.makedirs(shakespeare_train_dir, exist_ok=True)

mock_shakespeare_data = {
    'x': [1, 2, 3, 4],
    'y': [0, 1, 0, 1]
}

with open(os.path.join(shakespeare_train_dir, '0.pkl'), 'wb') as f:
    pickle.dump(mock_shakespeare_data, f)

ARGS = {
    'dataset': 'MNIST',
    'idx': 0,
    'is_train': True,
    'few_shot': 0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
read_data Ran
ran; our contract draft was wrong, not the code
pgg3/FedFew/PFLlib/system/flcore/servers/serverfedfews.py
code served (permissive licence) · get_code("d13245af66b72045")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
import pickle
import numpy as np

# Create a temporary directory structure to simulate dataset
temp_dir = tempfile.mkdtemp()
dataset_name = "test_dataset"
dataset_path = os.path.join(temp_dir, dataset_name)
train_dir = os.path.join(dataset_path, "train")
test_dir = os.path.join(dataset_path, "test")

os.makedirs(train_dir, exist_ok=True)
os.makedirs(test_dir, exist_ok=True)

# Create sample data files
sample_data = {
    'x': np.array([[1, 2, 3], [4, 5, 6]]),
    'y': np.array([0, 1])
}

# Write a pickle file for train data
with open(os.path.join(train_dir, "0.pkl"), 'wb') as f:
    pickle.dump(sample_data, f)

# Write a pickle file for test data
with open(os.path.join(test_dir, "0.pkl"), 'wb') as f:
    pickle.dump(sample_data, f)

# Set environment variable to point to the temp dataset root
os.environ['PFLLIB_DATA_DIR'] = temp_dir

ARGS = {
    'dataset': dataset_name,
    'idx': 0,
    'is_train': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
Client Not yet run
unverified (harvested, no recorded run)
pgg3/FedFew/PFLlib/system/flcore/servers/serverfedfews.py
code served (permissive licence) · get_code("26ccd2730c4ba2c8")
How it ran

no invocation recorded.

FedFewS Not yet run
unverified (harvested, no recorded run)
pgg3/FedFew/PFLlib/system/flcore/servers/serverfedfews.py
code served (permissive licence) · get_code("987451b5ad544d35")
How it ran

no invocation recorded.

Server Not yet run
unverified (harvested, no recorded run)
pgg3/FedFew/PFLlib/system/flcore/servers/serverfedfews.py
code served (permissive licence) · get_code("892305b1fbfbb8cb")
How it ran

no invocation recorded.

clientFedFewS Not yet run
unverified (harvested, no recorded run)
pgg3/FedFew/PFLlib/system/flcore/servers/serverfedfews.py
code served (permissive licence) · get_code("d8cd91ba76b905db")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 8 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Personalized Federated Learning (PFL) aims to train customized models for clients with highly heterogeneous data distributions while preserving data privacy. Existing approaches often rely on heuristics like clustering or model interpolation, which lack principled mechanisms for balancing heterogeneous client objectives. Serving M clients with distinct data distributions is inherently a multiobjective optimization problem, where achieving optimal personalization ideally requires M distinct models on the Pareto front. However, maintaining M separate models poses significant scalability challenges in federated settings with hundreds or thousands of clients. To address this challenge, we reformulate PFL as a few-for-many optimization problem that maintains only K shared server models (K ≪ M ) to collectively serve all M clients. We prove that this framework achieves near-optimal personalization: the approximation error diminishes as K increases and each client's model converges to each client's optimum as data grows. Building on this reformulation, we propose FedFew, a practical algorithm that jointly optimizes the K server models through efficient gradient-based updates. Unlike clustering-based approaches that require manual client partitioning or interpolation-based methods that demand careful hyperparameter tuning, FedFew automatically discovers the optimal model diversity through its optimization process. Experiments across vision, NLP, and real-world medical imaging datasets demonstrate that FedFew, with just 3 models, consistently outperforms other state-of-the-art approaches. Code is available at https: //github.com/pgg3/FedFew.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2603.11992")
get_code_for_paper("2603.11992")
have("2603.11992")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2603.11992.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2603.11992.svg)](https://syntology.ai/paper/2603.11992)

Connect an agent — have() is free.