Official implementation of PRISM: PRIvileged Sibling-guided Multi-Agent Topology Design.
Privileged-teacher, on-policy self-distillation (OPSD) for multi-agent topology design, built on ARG-Designer. A teacher that sees the query and its gold rationale gives dense per-step supervision to a query-only student. The supervision is applied to pseudo-graphs that the student samples itself.
Stage 0 cold start on D_exp LLM calls: the only LLM cost
Stage 1 privileged teacher finetune no LLM
Stage 2 OPSD: rollout -> teacher KL no LLM (replaces D_pruned)
Stage 3 evaluation LLM calls; the teacher is discarded
The LLM runs on a local vLLM server, and .env points the pipeline at it.
PRISM/
├── experiment/
│ ├── model.py # ARG-Designer autoregressive graph generator
│ ├── paths.py # all data/output paths (overridable via env vars)
│ ├── evaluate_math.py # cross-benchmark evaluator (gsm8k, aqua, multiarith, svamp)
│ ├── opsd/ # PRISM / OPSD: teacher, rollouts, KL losses, SFT baseline
│ │ ├── run_opsd.py # entry point: Stage 1 + Stage 2
│ │ └── run_sft.py # matched supervised-finetuning baseline
│ ├── gsm8k/ aqua/ mmlu/ humaneval/ mixchain/
│ │ # per-dataset cold_start_*, finetune_*, evaluate_*
│ └── ...
├── mas_framework/ # agents, graph execution, LLM client, tools
├── requirements.txt
└── template.env
datasets/ holds the dataset loaders (datasets/*_dataset.py) and the
benchmark files, at the paths set in experiment/paths.py. These files are
already included:
| dataset | file |
|---|---|
| GSM8K | datasets/gsm8k/gsm8k.jsonl |
| AQuA | datasets/AQuA/AQuA.jsonl |
| HumanEval | datasets/humaneval/humaneval-py.jsonl (evaluation only) |
| MMLU | datasets/MMLU/data/: dev for training, test for evaluation (re-download with python datasets/MMLU/download.py) |
| MultiArith, SVAMP | datasets/MultiArith/, datasets/SVAMP/ (evaluation only) |
| MBPP | datasets/MBPP/mbpp.jsonl (training only) |
MixChain-Z-PRM12K, a math corpus used only for training, is not included. Fetch
it with python datasets/MixChain/download.py, run from the repo root.
Do not
pip install datasets(HuggingFace) into this environment. The localdatasets/folder is a namespace package, and the HF library would shadow it. This is also whysentence-transformersis pinned to2.7.0.
conda create -n prism python=3.10 -y
conda activate prism
pip install -r requirements.txtcp template.env .env BASE_URL = "http://localhost:8000/v1"
API_KEY = "EMPTY"
LLM_MAX_CONCURRENCY = 32
LLM_TIMEOUT = 180
LLM_MAX_RETRIES = 5Optional path overrides (the defaults are <repo>/data and <repo>/output):
ARG_DATA_ROOT = ""
ARG_OUTPUT_ROOT = ""Start the server:
CUDA_VISIBLE_DEVICES=0 vllm serve Qwen/Qwen2.5-7B-Instruct --port 8000This serves the model at http://localhost:8000/v1, which matches BASE_URL
in .env. The model id is also the name you pass as --llm_name.
Qwen2.5-7B in bf16 needs about 16 GB of VRAM. On a smaller card, serve
Qwen/Qwen2.5-7B-Instruct-AWQ instead. To check the pipeline cheaply, serve
Qwen/Qwen2.5-1.5B-Instruct; accuracy from that model is not comparable. In
either case, pass the same model id as --llm_name.
MODEL=Qwen/Qwen2.5-7B-Instruct is used below. Substitute your own model id.
cd experiment/gsm8k
python cold_start_gsm8k.py --llm_name Qwen/Qwen2.5-7B-Instruct \
--batch_size 4 --num_iterations 10This writes data/ColdStartData_gsm8k/ and data/task_split_gsm8k.json.
python finetune_gsm8k.py --pretrain --llm_name Qwen/Qwen2.5-7B-Instruct --batch_size 4This writes output/gsm8k_<timestamp>/best_model.pth, the cold-start checkpoint
that PRISM starts from. The finetuned baseline is saved as
ef_best_model.pth in the same directory.
Run from the repo root:
cd ../..
python -m experiment.opsd.run_opsd \
--dataset gsm8k \
--student_dir output/gsm8k_<timestamp> \
--teacher_epochs 40 --opsd_epochs 30 \
--rollouts_per_query 4 --kl_direction reverse --anchor_weight 0.3Add --dry_run first. It loads the graphs, privileged table and rollout pool,
prints them and stops. Data-plumbing errors show up in seconds this way.
If the gain is close to zero, the teacher is not using the privileged information. Stop there, because distillation cannot help.
Stage 2 reports teacher/student agreement (agree). It also reports the mean
size of the pseudo-graphs (|V|, |E|). If PRISM does the job of D_pruned,
these sizes should fall while accuracy holds.
This arm uses the same checkpoint, data, split and epoch budget. It adds no teacher and no KL:
python -m experiment.opsd.run_sft --dataset gsm8k \
--student_dir output/gsm8k_<timestamp> --sft_epochs 30cd experiment/gsm8k
# PRISM / OPSD student (and SFT arm): they save best_model.pth -> --ef 0
python evaluate_gsm8k.py --model_path ../../output/gsm8k_opsd_seed42_<timestamp> \
--ef 0 --llm_name Qwen/Qwen2.5-7B-Instruct --eval_batch_size 32
# ARG-Designer baseline (Stage-2 finetuned, ef_best_model.pth) -> --ef 1 (default)
python evaluate_gsm8k.py --model_path ../../output/gsm8k_<timestamp> \
--ef 1 --llm_name Qwen/Qwen2.5-7B-Instruct --eval_batch_size 32To evaluate across benchmarks (the designer can come from any math corpus), run from the repo root:
python experiment/evaluate_math.py --model_path output/<run_dir> \
--target svamp --llm_name Qwen/Qwen2.5-7B-Instruct
# --target: gsm8k | aqua | multiarith | svampThe pattern is the same for each dataset: cold_start_<ds>.py, then
finetune_<ds>.py --pretrain, then run_opsd --dataset <ds>, then evaluate.
| dataset | directory | OPSD --dataset |
|---|---|---|
| AQuA | experiment/aqua/ |
aqua |
| MMLU | experiment/mmlu/ |
mmlu |
| MBPP (train-only code corpus) | experiment/humaneval/ (pointed at MBPP, see below) |
not supported yet |
| MixChain (train-only math corpus) | experiment/mixchain/ |
mixchain |
MMLU trains on the dev split (cold start, finetune, OPSD). evaluate_mmlu.py
scores on the test split.
MBPP is the training corpus for the code designer, and HumanEval is used only
for evaluation. MBPP has no scripts of its own, so it runs through the HumanEval
scripts. Point them at mbpp.jsonl, and give MBPP its own output paths:
cd experiment/humaneval
python cold_start_humaneval.py --llm_name Qwen/Qwen2.5-7B-Instruct \
--dataset_json ../../datasets/MBPP/mbpp.jsonl \
--output_dir ../../data/ColdStartData_mbpp \
--task_split_file ../../data/task_split_mbpp.json
python finetune_humaneval.py --pretrain --llm_name Qwen/Qwen2.5-7B-Instruct \
--dataset_json ../../datasets/MBPP/mbpp.jsonl \
--cold_start_dir ../../data/ColdStartData_mbpp \
--task_split_file ../../data/task_split_mbpp.json
# HumanEval never took part in training, so score every problem with --full_test
python evaluate_humaneval.py --model_path <run_dir> --full_test \
--llm_name Qwen/Qwen2.5-7B-InstructTo fit one teacher on several corpora, pass
--teacher_dataset gsm8k aqua --extra_data_dir data/ColdStartData_aqua.
If you use PRISM, please cite:
@article{dat2026prism,
title={PRISM: PRIvileged Sibling-guided Multi-Agent Topology Design},
author={Dat, Phuong Tuan and Li, Qi and Wang, Xinchao},
journal={preprint},
year={2026}
}Built on ARG-Designer (Li et al., AAAI 2026), which in turn builds on GPTSwarm and GDesigner.