How do four small agents learn to think together? Hugging Face's guide to multi-agent training

Hugging Face's guide teaches four copies of one small model to cooperate through reinforcement learning: the setup, the reward design and how to run it yourself.

Paylaş
How do four small agents learn to think together? Hugging Face's guide to multi-agent training

Whisper a number to each of four people. Nobody knows anyone else's number, and the job is to say all four in sorted order. No one can do it alone; they have to talk. A guide published on 26 November by Hugging Face's Ben Burtenshaw and Kashif Rasul has AI agents play exactly this game and shows step by step how to teach cooperation with reinforcement learning. Four copies of the same small model go from solving the task 6.6% of the time to 82.3% after 75 updates, while spending fewer tokens.

The question: does talking actually help?

Many teams now split problems across several agents. The guide asks whether communication really helps or just burns more compute. It notes that in Anthropic's vulnerability-finding experiment, coordinated agents found more bugs but used more tokens, so results per million tokens were about the same. A fair test compares equal budgets: four agents with a quarter of the tokens each against one agent with all of them.

Three difficulties

A single agent learns in a loop of observing, acting and getting rewarded. A team has a shared reward and each agent sees only part of the world, which brings three problems. Teammates keep changing while you learn. Credit is hard to assign: when the team succeeds, whose message helped? And messages change what others observe. Two common answers exist: a hierarchy where a lead hands out work and often only the lead is trained, or a distributed team of peers without a lead. The experiment uses the second.

How the experiment is set up

The task comes from the information-aggregation problem in the s3 paper. Each of four agents holds a private integer from 1 to 99 and knows its teammates' names. The team succeeds if at least one agent submits the full sorted list, duplicates kept, such as [5, 5, 26, 78]. Agents have three tools: message(to, text) for direct or broadcast messages, read_messages() and check_notifications(). There are not four models: a single Qwen3-0.6B policy acts as four agents with separate contexts, so it learns both sides of the conversation.

How it is trained: reward and team advantage

The team gets a budget of 4 × (8,192 work + 1,024 answer tokens) = 36,864. The reward is success × (1 − 0.25 × min(1, tokens used / 36,864)), so a correct team using half its budget earns 0.875 and a failed team earns 0. Messaging earns nothing on its own; agents learn to talk only when it helps, and length is gently penalised.

Training runs in Hugging Face's TRL in GRPO style. Each problem gets eight team attempts, with rewards normalised within the group. Credit assignment is handled simply: every agent on a team, including those with wrong answers, receives the team's advantage. Each agent's tokens form one training row, and the loss is averaged within teams and then across teams. The original run used 32 problems per update, 8 attempts each, a learning rate of 5e-7, a pool of 1,024 generated problems, one trainer GPU and seven vLLM rollout GPUs.

What they learned

Over 75 updates, training success rose from 6.6% to 82.3%, with 81.25% on 32 held-out problems. Tokens per team fell from about 12,800 to 8,000 (37.4% fewer) while messages per team rose from 3.48 to 6.28: the agents learned to talk more, but more briefly. Broadcasts rose from 2.38 to 5.73, and teams where every agent sent exactly one broadcast went from 4% to 18.2%. An untrained team taking the best of eight attempts reaches 37.5% at about 103,000 tokens per problem; the trained team reaches 82.3% in one attempt at about 8,000. The paper reports 93.2% after 200 updates and over 25 times more coordination problems solved than the strongest baseline when teams are twice the training size.

The authors list the limits. The task cannot be solved by one agent, so it does not yet measure communication against an equal-budget single agent; the next post in the series will. Teams drifted toward broadcasts rather than direct messages, message counts are not text volume, and the eight-attempt comparison is an estimate.

Try it yourself

The guide suggests about five hours on 2 H200s with Hugging Face Jobs, roughly $50 of compute; TRL's own run took 4.8 hours on 2 H100s and reached 60.9% held-out success at update 50. The code is in TRL's examples folder. Log in with hf auth login, create a results bucket with hf buckets create, then launch the guide's train-swarm.sh with hf jobs run --flavor h200x2. The script serves Qwen3-0.6B with vLLM on one GPU, evaluates the base model on 192 problems, trains 50 updates with async_grpo_s3_aggregation.py on the other and evaluates again. Watch team/success, team/messages and team/tokens in trackio. With the right reward, agents learn when and how much to talk, and a small model plus a few GPU hours is enough to see it.

Sources: Hugging Face: Swarms, Flocks, Gangs (Part 1), s3 paper, TRL example code