Skip to main content
Back

MAC Beats Top Prompt Optimizers by 50% Writing Its Own AI Rules

A four-agent system learns natural-language rulebooks that steer LLMs on PII tagging and reasoning tasks, beating GEPA and MIPRO by over 50%.

Pro

  • MAC learns Constitutional AI rulebooks automatically via a 4-agent propose-edit-validate loop, published on arXiv.
  • Beats GEPA and MIPRO on 8 of 9 PII tagging configurations, with gains up to +174% at 3B scale.
  • Matches supervised fine-tuning and GRPO performance without touching model weights or requiring gradient updates.
  • Generalizes to HoVer fact verification (+63%), HotpotQA (+14%), and pushes GSM8K to 100% accuracy.
  • Rulebooks are plain-English, auditable, and transferable across models without retraining pipelines.
  • Installable via pip install mac-prompt, dual-licensed with free non-commercial use.

Constitutional AI works by giving a model a set of natural-language rules to follow. The catch is that those rules are almost always hand-written by experts, which does not scale to every new task or domain. A new method called Multi-Agent Constitution Learning (MAC) tries to fix that by treating the ruleset itself as something you can train, using a network of specialized LLM agents instead of gradient descent.

The headline claim is strong: MAC optimizes over structured prompts represented as sets of rules using a network of agents with specialized tasks to accept, edit, or reject rule updates, and it beats recent prompt optimizers by over 50% while producing rulebooks a human can read and audit.

Where existing prompt optimizers hit a wall

Tools like GEPA and MIPROv2 already automate prompt writing, but the authors argue they break down on constitution-style tasks for two reasons. They need a lot of labeled examples, and they treat the prompt as one flat blob of text. As that blob grows, edits start canceling each other out and improvements plateau.

The problem shows up clearly in domains like PII tagging for legal, financial, or medical documents, where you may only have a few dozen labeled examples and every decision needs to be justifiable to a compliance officer. A model needs rules like "mark a date as private when it references a birth or death, but not when it appears in generic narrative text" and it needs someone to be able to read that rule back.

Four agents, one rulebook

MAC replaces the monolithic prompt with a structured list of rules that four agents cooperate to grow. Instead of editing a flat prompt string, MAC optimizes over a structured set of rules -- a constitution -- using a network of four specialized agents.

MAC+ architecture showing student and teacher model agents in a collaborative learning loop

Each training epoch runs a closed loop:

  1. Annotator applies the current constitution to a training batch and scores every example.
  2. Decision Agent looks at the errors and decides whether to add a new rule or edit an existing one.
  3. Rule Proposer drafts a candidate rule targeting the observed error pattern.
  4. Rule Editor refines existing rules to remove contradictions or sharpen specificity.

Every proposed change is tested on a held-out validation batch before being merged. If the score goes up, the rule stays. If not, it is discarded, so the constitution never regresses. A fifth meta-model runs once before training to rewrite the four agent prompts so they speak the vocabulary of your specific task, output schema, and evaluation criteria.

The paper also introduces MAC+, which trains the agents on their own successful trajectories to reinforce the kinds of edits that historically raise the reward. This is a form of self-improvement over the rule-writing policy itself, not the underlying worker model.

Results that hold up against fine-tuning

The evaluation centers on tagging Personally Identifiable Information across Legal, Finance, and Healthcare documents using Qwen2.5-Instruct at 3B, 7B, and 14B scales, with GPT-4o driving the MAC agents. MAC wins 8 of 9 configurations against GEPA and MIPRO.

DatasetMethod3B7B14B
LegalGEPA12.752.150.1
LegalMIPRO13.238.644.3
LegalMAC36.055.167.3
FinanceMAC30.137.545.5
HealthcareMAC9.720.126.7

The largest single gain is Legal at 3B, where MAC scores 36.0 F1 against 13.2 for the next best method. At 14B, a general-purpose Qwen2.5 with a learned constitution also beats purpose-built PII taggers: it outperforms Microsoft's Presidio on legal documents by 17 F1 points and beats the fine-tuned GLiNER extractor on healthcare data by 123%. The paper's own summary is that MAC achieves performance comparable to supervised fine-tuning and GRPO without requiring parameter updates.

MAC also generalizes beyond classification. On HoVer fact verification, a gpt-4o-mini worker jumps from 25% to 88% accuracy after learning a constitution. On HotpotQA multi-hop reasoning, gains reach +14%. On GSM8K math, a Qwen3-8B worker climbs from 94% zero-shot to 100%.

Where the approach struggles

The absolute F1 scores on PII tagging remain modest in some domains. Healthcare tops out at 26.7 F1 even at 14B scale, and at 3B the healthcare setup is the one configuration where GEPA actually beats MAC. The method is also heavier at training time than a single prompt rewrite, since every candidate rule triggers another validation pass with multiple agent calls. The recommended setup is a tiered configuration where a cheap local model does the annotation and a stronger cloud model runs the MAC agents.

Availability and how to run it

MAC ships as an installable Python package. The mac-prompt package on PyPI and the source repository both expose a single compiler object you configure with a worker model, an agent model, and a task description:

compiler = MAC(
    model="Qwen/Qwen3-8B",
    base_url="http://localhost:8000/v1",
    mac_model="gpt-4o",
    task_description="Solve AIME competition math problems.",
    rule_type="math reasoning rules",
)

The project is released under a dual license, with non-commercial use free and commercial use requiring a separate license. Full training dynamics, ablations, and the reMAC retrieval variant are documented on the project site.

For anyone building agents in regulated domains where every decision needs a paper trail, a learned rulebook that a lawyer or clinician can read line by line is a very different artifact from a fine-tuned checkpoint. That is the practical wedge MAC is trying to open.