Codes and data for: Epistemic Context Learning: Building Trust the Right Way in LLM-Based Multi-Agent Systems
This repository contains three main components:
ECL/: Python source codes for ECL training and evaluation.recipes/: Training configurations for ECL. See Configurations.scripts/: Bash scripts to launch training and evaluation. See Running Experiments.
- Unzip the proprocessed training and evaluation datasets
unzip ecl-data.zip -d final_data- Install dependencies in your Python environment
conda create -n ecl python==3.11.5
conda activate ecl
pip install -r requirements.txt- Configure API Keys (NOTE: We use OpenRouter for consistent API usage. See Customized API Usage if you want to use separate API calls)
export OPENROUTER_API_KEY="your_key"To start training jobs, put the list of configurations in CONFIGS of scripts/train.sh and run
bash scripts/train.shRefer to Training Configurations on how to write customized training config files.
To start evaluation jobs, set variables in scripts/eval.sh and run
bash scripts/eval.shRefer to Variables in Evaluation Script on how to set the variables.
Config files needed to reproduce the main evaluation results and analytic results have been stored in recipes/train_configs. Here we introduce the meanings of key variables:
dataset_mixer: The dataset you want to use or mix. By default we do not mix datasets, for single datasets you can choose among:
| Value | Used Dataset |
|---|---|
"final_data/gpqa_formatted": 1.0 |
GPQA (Adversarial) |
"final_data/gpqa_natural": 1.0 |
GPQA (Natural) |
"final_data/mmlu_pro": 1.0 |
MMLU-Pro (Adversarial) |
"final_data/mmlu_pro_natural": 1.0 |
MMLU-Pro (Natural) |
tag_peer: The number of peers and history rounds. You can choose among:
| Value | Used Prompt |
|---|---|
2_1 |
2 peers, 5 rounds of history |
3_1 |
3 peers, 5 rounds of history |
4_1 |
4 peers, 5 rounds of history (default setting) |
4_1_2 |
4 peers, 2 rounds of history |
4_1_8 |
4 peers, 8 rounds of history |
tag_prompt: The prompt you want to use. You can choose among:
| Value | Used Prompt |
|---|---|
AG |
History-agnostic aggregator (AG) |
NS |
Default SA & ECL prompt (ECL (I)) |
JP |
Explicit peer recognition (ECL (E)) |
add_peers:MA contextwill be used when set astrue,SA contextwhen set asfalse.add_current_reasoning:MA-Reasoningcontext will be used when set astrue,MA-Outcomewhen set asfalse. Valid only whenadd_peersset astrue.output_dir: This variable serves several purposes, please specify in forms ofSAVE_ROOT/DATASET/CONFIG_NAME. Refer to this part for details.SAVE_ROOTonly specifies the path for saving model checkpoints and does not affect the setting.DATASETdetermines whether natural or adversarial task setting is used. Adding_naturalsuffix likegpqa_naturalwill select the natural setting, otherwise the adversarial setting.CONFIG_NAMEdetermines the rewards in RL and whether theDBtrick is used.- Including
-DBwill involve theDBtrick. - Only include
-PRRwhen you train models forECL (E)so that our auxiliary PRR will be used in stage 1, and include-ORotherwise.
- Including
VLLM_MODELS: The model (checkpoint) you want to deploy viavLLM. If you use API models, skip this field.VLLM_IPS: The IP address where you want to deploy model.VLLM_PORT_NUMBERS: The port number where you want to deploy model.VLLM_CUDA_DEVICES: The GPU device(s) you use to deploy the model.MAX_LENGTH: The server-side max length for vLLM.EVAL_MODELS: The model you want to evaluate, corresponding toVLLM_MODELS.EVAL_DATASETS: The dataset (test split) you want to use for evaluation.EVAL_CURRENT_REASON: Set astrueto useMA-Reasoningcontext orfalseto useMA-Outcome.EVAL_REVERT_IDENTITY: Set as0for default,1forFlipanalysis and2forAll-Wanalysis.EVAL_IPS: IP address of the model you want to evaluate, corresponding toVLLM_IPS.EVAL_PORT_NUMBERS: Port number of the model you want to evaluate, corresponding toVLLM_PORT_NUMBERS.EVAL_TAG_PEER: The number of peers and history rounds. Seetag_peerin Training Configurations.EVAL_TAG_PROMPT: The prompt you want to use. Seetag_promptin Training Configurations.EVAL_DECOUPLE_BELIEF: Whether to use theDBtrick in evaluation.SAVE_ROOT: The folder you want to save the evaluation result files and logs.
NOTE:
- If you want to run multiple evaluation jobs in parallel, just specify them as a list and make sure model names, ips, and port numbers are aligned correctly.
- If you want to run different settings for the same model in one job, specify them as a space-separated string.
Refer to scripts/eval.sh for some examples.
In ECL/utils/eval_utils.py, we implement API calls for all models via OpenRouter for simplicity. If you need to call APIs in a different way, modify the get_llm_client, generate_llm_chat and generate_llm_chat_two_stage functions and define your own ways of API usage, and setup specific API_KEYs in your environment.
If you have any issues or questions regarding our ECL project, do not hesitate to contact: Ruiwen Zhou.
If you found this work helpful, please consider citing it using the following:
@article{zhou2026ecl,
title={Epistemic Context Learning: Building Trust the Right Way in LLM-Based Multi-Agent Systems},
author={Zhou, Ruiwen and Song, Maojia and Wu, Xiaobao and Cheng, Sitao and Yin, Xunjian and Xie, Yuxi and Hao, Zhuoqun and Hua, Wenyue and Pan, Liangming and Poria, Soujanya and Kan, Min-Yen},
journal={arXiv preprint arXiv:2601.21742},
year={2026}
}