Skip to main content

LLM collaboration

Project description

MoCo Logo

MoCo: A One-Stop Shop for Model Collaboration Research

MoCo is a toolkit for Model Collaboration research, where multiple language models collaborate and complement each other for compositional AI systems.

Quick Start

conda env create -f environment.yml
pip install modelco
conda activate model_collaboration

Run your first model collaboration experiment (if you don't have 3 GPUs, go to model_collaboration/test_config.json and set "gpu_ids": [0], [0,1], or whatever you have; if your GPU is nice, increase batch_size):

python -m model_collaboration.main -c model_collaboration/test_config.json

You will see the outputs and evaluation results in the model_collaboration/logs/ folder.

Supported Methods

MoCo currently supports the following model collaboration algorithms, across API-level, text-level, logit-level, and weight-level collaboration. We provide a sample config for each method in examples/ and please check out docs/user_readme.md for more details about writing configs and the different collaboration methods implemented.

Method Core Idea Code Sample Config Doc
API: Nudging one model guides the decoding of another link link link
API: Prompt Routing prompt an LM to decide which model to use based on model descriptions link link link
API: Switch Generation multiple LMs take turns to generate parts of the response link link link
API: Trained Router train an LM to route based on the dev set link link link
API: Graph Routing train a graph neural network for routing link link link
API: Cascade use multiple models in a cascade to improve efficiency link link link
API: Mentor Collab a mentor model guides a smaller student model for generation link link link
API: Co-LLM train LMs to defer to another model when uncertain link link link
Text: Multiagent Refine multiple LMs refine each other's answers iteratively link link link
Text: Multiagent Feedback multiple LMs provide feedback to each other's answers link link link
Text: Knowledge Card models generate knowledge paragraphs to assist each other link link link
Text: LLM Blender use ranker and fuser LMs to combine multiple answers link link link
Text: Heterogeneous Swarms optimize a graph of multiple LLMs for collaboration link link link
Text: Majority Vote majority vote link link link
Text: Structured Interaction execute a structured interaction protocol among LLMs link link link
Text: Multiagent Finetuning multiple LLMs critique, debate, and refine via finetuning link link link
Text: BBMAS blackboard-based collaboration among LLMs link link link
Text: Sparta Alignment models compete and combat for collective alignment link link link
Text: AggLM RL to train a solution aggregation model link link link
Logit: Logit Fusion merge the next-token logits from multiple models link link link
Logit: Logit Contrastive contrast the logits from best/worst models link link link
Weight: Greedy Soup iteratively consider adding each model's weights from best to worst link link link
Weight: Dare Ties the dare-ties model merging algorithm link link link
Weight: Model Swarms particle swarm optimization for models to search in the weight space link link link
Weight: LoraHub gradient-free optimization of lora combinations link link link
Weight: ExPO model weight extrapolation link link link

Please note that MoCo does not aim to be a reproducibility study: we adapt the core ideas behind related papers and employ what works flexibly.

Supported Data

MoCo comes with a lot of evaluation datasets built-in, and you are free to bring your own datasets, or even just generate responses only and take evaluation elsewhere. Essentially, change the task and task_type in the config to use diverse datasets. Check out link for more details.

Contributing to MoCo

We welcome contributions to MoCo!

If you are interested in contributing new model collaboration methods, check out link.

If you are interested in contributing new datasets, check out link.

If you have any suggestions, please open an issue.

Citation

If MoCo is helpful for you, please consider citing:

@article{feng2025one,
  title={When one llm drools, multi-llm collaboration rules},
  author={Feng, Shangbin and Ding, Wenxuan and Liu, Alisa and Wang, Zifeng and Shi, Weijia and Wang, Yike and Shen, Zejiang and Han, Xiaochuang and Lang, Hunter and Lee, Chen-Yu and others},
  journal={arXiv preprint arXiv:2502.04506},
  year={2025}
}

// MoCo reference pending

Also, please cite the related papers for the methods you employed, as listed in docs/user_readme.md.

Have a nice day.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modelco-0.0.1.6.tar.gz (9.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modelco-0.0.1.6-py3-none-any.whl (9.2 MB view details)

Uploaded Python 3

File details

Details for the file modelco-0.0.1.6.tar.gz.

File metadata

  • Download URL: modelco-0.0.1.6.tar.gz
  • Upload date:
  • Size: 9.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for modelco-0.0.1.6.tar.gz
Algorithm Hash digest
SHA256 ae92824da806dbfba6cb1a97c7dea1fc36f4945bc6b2f49fc2b7a851c84faccb
MD5 9d4c3d3a1bba22e276b8dce8b833ac86
BLAKE2b-256 5cac97b59f59555ee2c074e0a0a013cbb85ddd3a6af5e2da405c0b5306636782

See more details on using hashes here.

File details

Details for the file modelco-0.0.1.6-py3-none-any.whl.

File metadata

  • Download URL: modelco-0.0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 9.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for modelco-0.0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d652f46572e6b24915325a06eeb0bab717aed991e3faed3e0c52d4d0c5a9beea
MD5 3b72681b63fe901b543dedf843515b1d
BLAKE2b-256 1efb3d9358b04522a140aadf6a3ee1a87ddc342cd1eed4053d1ad44ed6fbb79d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page