{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/heterogeneous-swarms-jointly-optimizing-model","title":"Heterogeneous Swarms: Jointly Optimizing Model Roles and Weights for Multi-LLM Systems","arxiv_id":"2502.04510","date":"2025-02-06","proceeding":null,"authors":["Shangbin Feng","Zifeng Wang","Palash Goyal","Yike Wang","Weijia Shi","Huang Xia","Hamid Palangi","Luke Zettlemoyer","Yulia Tsvetkov","Chen-Yu Lee","Tomas Pfister"],"abstract":"We propose Heterogeneous Swarms, an algorithm to design multi-LLM systems by jointly optimizing model roles and weights. We represent multi-LLM systems as directed acyclic graphs (DAGs) of LLMs with topological message passing for collaborative generation. Given a pool of LLM experts and a utility function, Heterogeneous Swarms employs two iterative steps: role-step and weight-step. For role-step, we interpret model roles as learning a DAG that specifies the flow of inputs and outputs between LLMs. Starting from a swarm of random continuous adjacency matrices, we decode them into discrete DAGs, call the LLMs in topological order, evaluate on the utility function (e.g. accuracy on a task), and optimize the adjacency matrices with particle swarm optimization based on the utility score. For weight-step, we assess the contribution of individual LLMs in the multi-LLM systems and optimize model weights with swarm intelligence. We propose JFK-score to quantify the individual contribution of each LLM in the best-found DAG of the role-step, then optimize model weights with particle swarm optimization based on the JFK-score. Experiments demonstrate that Heterogeneous Swarms outperforms 15 role- and/or weight-based baselines by 18.5% on average across 12 tasks. Further analysis reveals that Heterogeneous Swarms discovers multi-LLM systems with heterogeneous model roles and substantial collaborative gains, and benefits from the diversity of language models.","url_abs":"https://arxiv.org/abs/2502.04510v1","url_pdf":"https://arxiv.org/pdf/2502.04510v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2502.04510","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2502.04510"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/BunsenFeng/heterogeneous_swarm","reach":null}],"summary":{"ran_honours":1,"ran_fixture":6,"ran_draft_wrong":2,"unverified":4},"by_repo_kind":{"found_in_text":{"samples":13,"ran":9,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":13,"samples":[{"code_sha256_prefix":"4efc4f340a8c12ee","entry":"assign_gpu","repo":"BunsenFeng/heterogeneous_swarm","repo_kind":"found_in_text","path":"search.py","file_url":"https://github.com/BunsenFeng/heterogeneous_swarm/blob/HEAD/search.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4efc4f340a8c12ee"}},{"code_sha256_prefix":"2a9ac558452970b5","entry":"batch_generate","repo":"BunsenFeng/heterogeneous_swarm","repo_kind":"found_in_text","path":"search.py","file_url":"https://github.com/BunsenFeng/heterogeneous_swarm/blob/HEAD/search.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"2a9ac558452970b5"}},{"code_sha256_prefix":"e39027f28fba78ae","entry":"batch_generate_chat_template","repo":"BunsenFeng/heterogeneous_swarm","repo_kind":"found_in_text","path":"search.py","file_url":"https://github.com/BunsenFeng/heterogeneous_swarm/blob/HEAD/search.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e39027f28fba78ae"}},{"code_sha256_prefix":"c2840c3ed37c731c","entry":"graph_decode","repo":"BunsenFeng/heterogeneous_swarm","repo_kind":"found_in_text","path":"search.py","file_url":"https://github.com/BunsenFeng/heterogeneous_swarm/blob/HEAD/search.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c2840c3ed37c731c"}},{"code_sha256_prefix":"babad0e4877852b6","entry":"multiple_choice_answer_parsing","repo":"BunsenFeng/heterogeneous_swarm","repo_kind":"found_in_text","path":"search.py","file_url":"https://github.com/BunsenFeng/heterogeneous_swarm/blob/HEAD/search.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"babad0e4877852b6"}},{"code_sha256_prefix":"4ffba672bf62f870","entry":"multiple_choice_prompt","repo":"BunsenFeng/heterogeneous_swarm","repo_kind":"found_in_text","path":"search.py","file_url":"https://github.com/BunsenFeng/heterogeneous_swarm/blob/HEAD/search.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4ffba672bf62f870"}},{"code_sha256_prefix":"380f691b7059126a","entry":"softmax","repo":"BunsenFeng/heterogeneous_swarm","repo_kind":"found_in_text","path":"search.py","file_url":"https://github.com/BunsenFeng/heterogeneous_swarm/blob/HEAD/search.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"380f691b7059126a"}},{"code_sha256_prefix":"56b551b6ea8c8892","entry":"top_p_sampling_selection","repo":"BunsenFeng/heterogeneous_swarm","repo_kind":"found_in_text","path":"search.py","file_url":"https://github.com/BunsenFeng/heterogeneous_swarm/blob/HEAD/search.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"56b551b6ea8c8892"}},{"code_sha256_prefix":"9e81861a2b61b612","entry":"topological_sort","repo":"BunsenFeng/heterogeneous_swarm","repo_kind":"found_in_text","path":"search.py","file_url":"https://github.com/BunsenFeng/heterogeneous_swarm/blob/HEAD/search.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"TIMEOUT","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9e81861a2b61b612"}},{"code_sha256_prefix":"c3251894d6a5c6ec","entry":"evaluate","repo":"BunsenFeng/heterogeneous_swarm","repo_kind":"found_in_text","path":"search.py","file_url":"https://github.com/BunsenFeng/heterogeneous_swarm/blob/HEAD/search.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c3251894d6a5c6ec"}},{"code_sha256_prefix":"393290bc3ad879ee","entry":"get_gpu_memory_in_gb","repo":"BunsenFeng/heterogeneous_swarm","repo_kind":"found_in_text","path":"search.py","file_url":"https://github.com/BunsenFeng/heterogeneous_swarm/blob/HEAD/search.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"393290bc3ad879ee"}},{"code_sha256_prefix":"fe99d09909adebc7","entry":"graph_generate","repo":"BunsenFeng/heterogeneous_swarm","repo_kind":"found_in_text","path":"search.py","file_url":"https://github.com/BunsenFeng/heterogeneous_swarm/blob/HEAD/search.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"fe99d09909adebc7"}},{"code_sha256_prefix":"37e76befc6431d2f","entry":"node_evaluate","repo":"BunsenFeng/heterogeneous_swarm","repo_kind":"found_in_text","path":"search.py","file_url":"https://github.com/BunsenFeng/heterogeneous_swarm/blob/HEAD/search.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"37e76befc6431d2f"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}