{"id":29219685,"url":"https://github.com/dvlab-research/motcoder","last_synced_at":"2025-07-03T02:06:38.965Z","repository":{"id":214175223,"uuid":"734942995","full_name":"dvlab-research/MoTCoder","owner":"dvlab-research","description":"This is the official code repository of MoTCoder: Elevating Large Language Models with Modular of Thought for Challenging Programming Tasks.","archived":false,"fork":false,"pushed_at":"2025-03-26T07:14:09.000Z","size":4002,"stargazers_count":55,"open_issues_count":7,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T08:23:30.110Z","etag":null,"topics":["apps","code","code-generation","large-language-models","natural-language-processing","programming"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2312.15960","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dvlab-research.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-23T05:22:13.000Z","updated_at":"2025-03-26T07:14:12.000Z","dependencies_parsed_at":"2023-12-26T11:45:11.391Z","dependency_job_id":"1b396030-1eaa-4bc6-a492-178af11f32a7","html_url":"https://github.com/dvlab-research/MoTCoder","commit_stats":null,"previous_names":["dvlab-research/motcoder"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dvlab-research/MoTCoder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvlab-research%2FMoTCoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvlab-research%2FMoTCoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvlab-research%2FMoTCoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvlab-research%2FMoTCoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dvlab-research","download_url":"https://codeload.github.com/dvlab-research/MoTCoder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvlab-research%2FMoTCoder/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263245318,"owners_count":23436514,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apps","code","code-generation","large-language-models","natural-language-processing","programming"],"created_at":"2025-07-03T02:06:37.927Z","updated_at":"2025-07-03T02:06:38.952Z","avatar_url":"https://github.com/dvlab-research.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MoTCoder: Elevating Large Language Models with Modular of Thought for Challenging Programming Tasks\n\n\u003cp align=\"center\"\u003e\n• 🤗 \u003ca href=\"https://huggingface.co/datasets/JingyaoLi/MoTCode-Data\" target=\"_blank\"\u003eData \u003c/a\u003e \n• 🤗 \u003ca href=\"https://huggingface.co/JingyaoLi/MoTCoder-32B-V1.5\" target=\"_blank\"\u003eMoTCoder-32B \u003c/a\u003e \n• 🤗 \u003ca href=\"https://huggingface.co/JingyaoLi/MoTCoder-7B-v1.5\" target=\"_blank\"\u003eMoTCoder-7B \u003c/a\u003e \n• 🐱 \u003ca href=\"https://github.com/dvlab-research/MoTCoder\" target=\"_blank\"\u003eCode\u003c/a\u003e \n• 📃 \u003ca href=\"https://arxiv.org/abs/2312.15960\" target=\"_blank\"\u003ePaper\u003c/a\u003e \u003cbr\u003e\n\u003c/p\u003e\n\n[![PWC](https://img.shields.io/endpoint?url=https%3A%2F%2Fpaperswithcode.com%2Fbadge%2Fmotcoder-elevating-large-language-models-with%2Fcode-generation-on-apps%3Fmetric%3DIntroductory%2520Pass%25401)](https://paperswithcode.com/sota/code-generation-on-apps?metric=Introductory%20Pass%401/motcoder-elevating-large-language-models-with) \n[![PWC](https://img.shields.io/endpoint?url=https%3A%2F%2Fpaperswithcode.com%2Fbadge%2Fmotcoder-elevating-large-language-models-with%2Fcode-generation-on-codecontests%3Fmetric%3DTest%2520Set%2520pass%25401)](https://paperswithcode.com/sota/code-generation-on-codecontests?metric=Test%20Set%20pass%401)\n\nLarge Language Models (LLMs) have showcased impressive capabilities in handling straightforward programming tasks. However, their performance tends to falter when confronted with more challenging programming problems. We observe that conventional models often generate solutions as monolithic code blocks, restricting their effectiveness in tackling intricate questions. To overcome this limitation, we present Module-of-Thought Coder (MoTCoder). We introduce a framework for MoT instruction tuning, designed to promote the decomposition of tasks into logical sub-tasks and sub-modules. Our investigations reveal that, through the cultivation and utilization of sub-modules, MoTCoder significantly improves both the modularity and correctness of the generated solutions, leading to substantial pass@1 improvements of 5.9% on APPS and 5.8% on CodeContests. MoTCoder also achieved significant improvements in self-correction capabilities, surpassing the current SOTA by 3.3%. Additionally, we provide an analysis of between problem complexity and optimal module decomposition and evaluate the maintainability index, confirming that the code generated by MoTCoder is easier to understand and modify, which can be beneficial for long-term code maintenance and evolution. Our codes are available at https://github.com/dvlab-research/MoTCoder.\n\n\u003cdiv style=\"text-align: center;\"\u003e\n    \u003cimg src=\"./imgs/impression.png\" alt=\"impression\" /\u003e\n\u003c/div\u003e\n\n## Performance\n\n### APPS\n\u003cdiv style=\"text-align: center;\"\u003e\n    \u003cimg src=\"./imgs/apps.png\" alt=\"Performance on APPS\" /\u003e\n\u003c/div\u003e\n\n### CodeContests\n\u003cdiv style=\"text-align: center;\"\u003e\n    \u003cimg src=\"./imgs/codecontests.png\" alt=\"Performance on CodeContests\" width=\"500px\" /\u003e\n\u003c/div\u003e\n\n### Reflection\n\u003cdiv style=\"text-align: center;\"\u003e\n    \u003cimg src=\"./imgs/reflection.png\" alt=\"Performance on Reflection\" /\u003e\n\u003c/div\u003e\n\n\n\n## Evaluation\n\n### Environment \nTo set up the environment, run:\n```bash\npip install -e eval/requirements.txt\n```\n\n### Model Preparation\nDownload [MoTCoder-7B-v1.5](https://huggingface.co/JingyaoLi/MoTCoder-7B-v1.5) and organize the files as follows:\n```\n- models \n    - MoTCoder-7B-v1.5\n```\n\n### Data Preparation\n1. Download the datasets [APPS](https://huggingface.co/datasets/codeparrot/apps) and [codecontests](https://huggingface.co/datasets/deepmind/code_contests), then structure your directories like this:\n```\n- data \n    - apps\n    - code_contests\n```\n2. Run the following script to prepare the test data:\n```bash\npython eval/dataset/data.py\n```\n\n### Run Evaluation\nExecute the scripts below to perform the evaluation:\n```bash\n# For APPS and CodeContests datasets\nbash eval/scripts/eval_motcoder_apps_codecontests.sh\n\n# For Fix\nbash eval/scripts/eval_motcoder_fix.sh\n```\n\n## Training\n\n### Environment \nWe use [LLaMAFactory](https://github.com/hiyouga/LLaMA-Factory) to train our model. Set up the environment with:\n```bash\ngit clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git\ncd LLaMA-Factory\npip install -e \".[torch,metrics]\"\n```\n\n### Data Preparation\nAdd the following entry to `LLaMA-Factory/data/dataset_info.json`:\n```json\n\"motcode\": {\n    \"hf_hub_url\": \"JingyaoLi/MoT-Code-350K\"\n}\n```\n\n### Run Training\nNavigate to the LLaMA-Factory directory and use the following commands to start training:\n```bash\ncd LLaMA-Factory\n# For multi-GPU\nllamafactory-cli train train/configs/MoTCoder-7B-Instruct-sft-2e-06-mot.yaml\n# For single-GPU\nFORCE_TORCHRUN=1 llamafactory-cli train train/configs/MoTCoder-7B-Instruct-sft-2e-06-mot.yaml\n```\n\n## Citation \nIf you find our work useful, please consider citing it.\n```\n@misc{li2025motcoderelevatinglargelanguage,\n      title={MoTCoder: Elevating Large Language Models with Modular of Thought for Challenging Programming Tasks}, \n      author={Jingyao Li and Pengguang Chen and Bin Xia and Hong Xu and Jiaya Jia},\n      year={2025},\n      eprint={2312.15960},\n      archivePrefix={arXiv},\n      primaryClass={cs.LG},\n      url={https://arxiv.org/abs/2312.15960}, \n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvlab-research%2Fmotcoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdvlab-research%2Fmotcoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvlab-research%2Fmotcoder/lists"}