{"id":25286250,"url":"https://github.com/ahxt/mini-r1-zero","last_synced_at":"2025-10-27T20:32:24.102Z","repository":{"id":275383928,"uuid":"925891693","full_name":"ahxt/mini-r1-zero","owner":"ahxt","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-02T05:01:55.000Z","size":1442,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T06:17:53.804Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ahxt.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":"2025-02-02T01:45:34.000Z","updated_at":"2025-02-02T05:38:44.000Z","dependencies_parsed_at":"2025-02-02T06:27:57.460Z","dependency_job_id":null,"html_url":"https://github.com/ahxt/mini-r1-zero","commit_stats":null,"previous_names":["ahxt/mini-r1-zero"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahxt%2Fmini-r1-zero","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahxt%2Fmini-r1-zero/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahxt%2Fmini-r1-zero/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahxt%2Fmini-r1-zero/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahxt","download_url":"https://codeload.github.com/ahxt/mini-r1-zero/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238554925,"owners_count":19491707,"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":[],"created_at":"2025-02-12T21:33:59.686Z","updated_at":"2025-10-27T20:32:18.635Z","avatar_url":"https://github.com/ahxt.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mini-r1-zero\n\nThis repo aims to reproduce the reasoning phenomenon \"Aha Moment\" of Deepseek-R1-Zero on the GSM8K dataset. I designed multiple rewards to guide the model's reasoning process.\n\n\n\n## Results\n\n### Case Study\n*Example of model reasoning process and output format*\n![Case Study](./img/case.png)\n\n### Reward Curve\n![Reward Curve During Training](./img/reward.png)\n*Reward Curve During Training*\n\n\n\n\n### Reward Functions\n\nI am using the following reward functions:\n\n\n1. **Accuracy Reward**\n\n    use exact match to judge the accuracy of the model's final answer for gsm8k dataset.\n\n\n2. **Format Reward**\n\n    use the same format as the Deepseek-R1-Zero's output format and judge the format of the model's output.\n    ```\n    \u003cthink\u003e\n    [reasoning process]\n    \u003c/think\u003e\n    \u003canswer\u003e\n    [final answer]\n    \u003c/answer\u003e\n    ```\n\n3. **Reflection Reward**\n\n    I plot the distribution of the words of Deepseek-R1-Zero's reasoning path and use the special words to judge the reflection of the model.\n\n    ![Word Distribution](./img/word_distribution.png)\n\n    based on the distribution, I use the following words to judge the reflection of the model and give a score to each word.\n    ```python\n    reflection_words = {\n        \"wait\": 0.1,\n        \"possible\": 0.1,\n        \"perhaps\": 0.1,\n        \"check\": 0.1,\n        \"perhaps\": 0.1,\n        \"maybe\": 0.1,\n        \"let me\": 0.1,\n        \"would be\": 0.1,\n        \"but the\": 0.1,\n        \"wait but\": 0.1,\n        \"check if\": 0.1,\n        \"but how\": 0.1,\n        \"but the\": 0.1,\n        \"wait no\": 0.1,\n        \"but wait\": 0.1,\n        \"let me check\": 0.1,\n        \"let me think\": 0.1,\n        \"but let me\": 0.1,\n    }\n    ```\n\n   \n4. **Length Reward**\n\n    I normalize the length of the model's output by 5000 and give a score to each length.\n\n    ```python\n    length_rewards = [len(content)/5000.0 for content in completion_contents]\n    ```\n\n\n\n\n\n## Quick Start\n\n### Run on SLURM cluster\n```bash\n# Run on SLURM cluster\nsbatch run_rl_grpo.cardinal.slurm\n\n# Or run directly\nbash rl_grpo.sh\n```\n\n### Base Configuration\n- Model: Qwen2.5-1.5B\n- Learning Rate: 3e-6\n- Batch Size: 32\n- Mixed Precision: bf16\n- Number of Generations per Sample: 18\n\n\n\nThe code mainly refer to the [trl](https://github.com/huggingface/trl/blob/main/trl/trainer/grpo_trainer.py) and [open r1](https://github.com/huggingface/open-r1/blob/main/src/open_r1/grpo.py).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahxt%2Fmini-r1-zero","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahxt%2Fmini-r1-zero","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahxt%2Fmini-r1-zero/lists"}