{"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/adamoe-token-adaptive-routing-with-null","title":"AdaMoE: Token-Adaptive Routing with Null Experts for Mixture-of-Experts Language Models","arxiv_id":"2406.13233","date":"2024-06-19","proceeding":null,"authors":["Zihao Zeng","Yibo Miao","Hongcheng Gao","Hao Zhang","Zhijie Deng"],"abstract":"Mixture of experts (MoE) has become the standard for constructing production-level large language models (LLMs) due to its promise to boost model capacity without causing significant overheads. Nevertheless, existing MoE methods usually enforce a constant top-k routing for all tokens, which is arguably restrictive because various tokens (e.g., \"<EOS>\" vs. \"apple\") may require various numbers of experts for feature abstraction. Lifting such a constraint can help make the most of limited resources and unleash the potential of the model for downstream tasks. In this sense, we introduce AdaMoE to realize token-adaptive routing for MoE, where different tokens are permitted to select a various number of experts. AdaMoE makes minimal modifications to the vanilla MoE with top-k routing -- it simply introduces a fixed number of null experts, which do not consume any FLOPs, to the expert set and increases the value of k. AdaMoE does not force each token to occupy a fixed number of null experts but ensures the average usage of the null experts with a load-balancing loss, leading to an adaptive number of null/true experts used by each token. AdaMoE exhibits a strong resemblance to MoEs with expert choice routing while allowing for trivial auto-regressive modeling. AdaMoE is easy to implement and can be effectively applied to pre-trained (MoE-)LLMs. Extensive studies show that AdaMoE can reduce average expert load (FLOPs) while achieving superior performance. For example, on the ARC-C dataset, applying our method to fine-tuning Mixtral-8x7B can reduce FLOPs by 14.5% while increasing accuracy by 1.69%.","url_abs":"https://arxiv.org/abs/2406.13233v2","url_pdf":"https://arxiv.org/pdf/2406.13233v2.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":[{"paper_slug":"adamoe-token-adaptive-routing-with-null","repo_url":"https://github.com/cengzihao/adamoe","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"arc","task_name":"ARC"},{"task_slug":"mixture-of-experts","task_name":"Mixture-of-Experts"}],"methods":[{"method_slug":"moe","method_name":"MoE"},{"method_slug":"set","method_name":"SET"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2406.13233","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2406.13233"}},"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":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/cengzihao/adamoe","reach":{"status":"ok"}}],"summary":{"ran":2,"ran_draft_wrong":1,"unverified":2},"by_repo_kind":{"official":{"samples":5,"ran":3,"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":5,"samples":[{"code_sha256_prefix":"7b4d35d5ca974ddd","entry":"detect_nan_inf","repo":"cengzihao/adamoe","repo_kind":"official","path":"exp_1/src/mola_modeling_llama_hacked.py","file_url":"https://github.com/cengzihao/adamoe/blob/HEAD/exp_1/src/mola_modeling_llama_hacked.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7b4d35d5ca974ddd"}},{"code_sha256_prefix":"e9ff56fcac52d4ac","entry":"load_balancing_loss_func","repo":"cengzihao/adamoe","repo_kind":"official","path":"exp_1/src/mola_modeling_llama_hacked.py","file_url":"https://github.com/cengzihao/adamoe/blob/HEAD/exp_1/src/mola_modeling_llama_hacked.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e9ff56fcac52d4ac"}},{"code_sha256_prefix":"b99eea6376d1e212","entry":"rotate_half","repo":"cengzihao/adamoe","repo_kind":"official","path":"exp_1/src/mola_modeling_llama_hacked.py","file_url":"https://github.com/cengzihao/adamoe/blob/HEAD/exp_1/src/mola_modeling_llama_hacked.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b99eea6376d1e212"}},{"code_sha256_prefix":"f11dbd11fe06507b","entry":"load_balancing_loss_func_with_null_experts","repo":"cengzihao/adamoe","repo_kind":"official","path":"exp_2/LLaMA_Factory/src/llamafactory/model/adaptive_moe_utils.py","file_url":"https://github.com/cengzihao/adamoe/blob/HEAD/exp_2/LLaMA_Factory/src/llamafactory/model/adaptive_moe_utils.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":"f11dbd11fe06507b"}},{"code_sha256_prefix":"67a726db0e25cb25","entry":"load_config","repo":"cengzihao/adamoe","repo_kind":"official","path":"exp_2/LLaMA_Factory/src/llamafactory/model/loader.py","file_url":"https://github.com/cengzihao/adamoe/blob/HEAD/exp_2/LLaMA_Factory/src/llamafactory/model/loader.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":"67a726db0e25cb25"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}