[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KKDRAHJHZ2B9ZPQCYPCXM6":3,"skill-same:01M6KKDRAHJHZ2B9ZPQCYPCXM6":47},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":6,"repositoryNo":11,"starsCount":12,"licenseSpdxId":13,"licenseFileUrl":6,"sourceHtmlUrl":14,"categories":15,"keywords":16,"publishedAt":21,"linkOnly":22,"markdownContent":23,"markdownBody":23,"frontMatter":24,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M6KKDRAHJHZ2B9ZPQCYPCXM6","simpo-loss-implementation",null,"cxcscmu\u002FSkillLearnBench","cxcscmu","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142838272?v=4","01M6KCQDFQWPDSN0MKZY96MSQP","01M6KCQDM7G70TKJ28NTSQC0RZ",92,"MIT","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fb4-skill-creator-gemini-3-flash-preview\u002Fnlp-paper-reproduction\u002Fsimpo-loss-implementation\u002FSKILL.md",[],[17,18,19,20],"implementation","simpo","simpo loss","simpo loss implementation","2026-11-10 10:12:30",false,"name: simpo-loss-implementation\ndescription: Guidance on implementing the SimPO (Simple Preference Optimization) loss function in a trainer class. Use this skill when you need to implement or debug the SimPO loss, ensuring correct use of beta, gamma_beta_ratio, and average log probabilities.\n\n# SimPO Loss Implementation Guide\n\nSimPO is a reference-free preference optimization algorithm. The key design is using the average log probability of a sequence as the implicit reward and introducing a target reward margin.\n\n## Reward Formulation\nThe implicit reward for a response $y$ given prompt $x$ is:\n$$r(x, y) = \\frac{\\beta}{|y|} \\log \\pi_\\theta(y | x)$$\nwhere $|y|$ is the number of tokens in the response.\n\n## SimPO Loss Formula\nThe SimPO loss for a pair of winning ($y_w$) and losing ($y_l$) responses is:\n$$L_{SimPO} = -\\log \\sigma \\left( \\frac{\\beta}{|y_w|} \\log \\pi_\\theta(y_w | x) - \\frac{\\beta}{|y_l|} \\log \\pi_\\theta(y_l | x) - \\gamma \\right)$$\nIn implementation, we often use `gamma = gamma_beta_ratio * beta`.\n\n## Implementation Details\nWhen implementing `simpo_loss` in a `SimPOTrainer` class:\n\n1. **Input Probabilities**: Ensure `policy_chosen_logps` and `policy_rejected_logps` are the average log probabilities (log-likelihood normalized by length).\n2. **Margin Calculation**: Calculate `gamma` as `self.gamma_beta_ratio * self.beta`.\n3. **Logits**: Compute the logits as:\n   `logits = self.beta * policy_chosen_logps - self.beta * policy_rejected_logps - gamma`\n4. **Loss Types**:\n   - **Sigmoid**: `losses = -F.logsigmoid(logits)`\n   - **Hinge**: `losses = torch.relu(1 - logits)`\n5. **Rewards**: Return the rewards for logging:\n   - `chosen_rewards = self.beta * policy_chosen_logps`\n   - `rejected_rewards = self.beta * policy_rejected_logps`\n\n## Example Snippet\n```python\ndef simpo_loss(self, policy_chosen_logps, policy_rejected_logps):\n    gamma = self.gamma_beta_ratio * self.beta\n    logits = self.beta * policy_chosen_logps - self.beta * policy_rejected_logps - gamma\n\n    if self.loss_type == \"sigmoid\":\n        losses = -F.logsigmoid(logits)\n    elif self.loss_type == \"hinge\":\n        losses = torch.relu(1 - logits)\n    else:\n        raise ValueError(f\"Unknown loss type: {self.loss_type}\")\n\n    chosen_rewards = self.beta * policy_chosen_logps\n    rejected_rewards = self.beta * policy_rejected_logps\n\n    return losses, chosen_rewards, rejected_rewards\n```\n",{},"main","726e1f79b96b0cb3d729d0e55a1c847e0b5353ae","skills\u002Fb4-skill-creator-gemini-3-flash-preview\u002Fnlp-paper-reproduction\u002Fsimpo-loss-implementation",7,"https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench","https:\u002F\u002Fcxcscmu.github.io\u002FSkillLearnBench","https:\u002F\u002Fgithub.com\u002Fcxcscmu","2026-10-02 22:55:36",{"source":7,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add cxcscmu\u002FSkillLearnBench --skill simpo-loss-implementation",{"tool":39,"command":40},"bunx","bunx skills add cxcscmu\u002FSkillLearnBench --skill simpo-loss-implementation",{"tool":42,"command":43},"pnpm","pnpm dlx skills add cxcscmu\u002FSkillLearnBench --skill simpo-loss-implementation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fb4-skill-creator-gemini-3-flash-preview\u002Fnlp-paper-reproduction\u002Fsimpo-loss-implementation\u002FSKILL.md",true,[],[48,66,91,109,129,141],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":6,"repositoryNo":11,"starsCount":12,"licenseSpdxId":13,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":59,"publishedAt":21},"01M6KM5KH175P5ABP5JMX2SBDQ","object_counter","Count occurrences of an object in the image using computer vision algorithm.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Fvideo-object-counting\u002Fobject_counter\u002FSKILL.md",[54],{"categoryNo":55,"categoryName":56,"taxonomyType":57,"taxonomyTypeDesc":58},"01JBSEEDCAT000000000000016","图像与多媒体","SCENARIO","使用场景",[60,61,62,63,64,65],"object counter","object","vision","computer","Computer Vision","image",{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":6,"repositoryNo":11,"starsCount":12,"licenseSpdxId":13,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":75,"publishedAt":21},"01M6KM51TMVXG79MMPCS6Y8G86","travel-planning-workflow","Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftravel-planning\u002Ftravel-planning-workflow\u002FSKILL.md",[72],{"categoryNo":73,"categoryName":74,"taxonomyType":57,"taxonomyTypeDesc":58},"01JBSEEDCAT000000000000023","Skill与智能体开发",[76,77,78,79,80,81,82,83,84,85,86,87,88,89,90],"workflow","planning","planning workflow","travel","travel planning","travel planning workflow","structured","performing","plan","for","user","it","requirements","essential","itineraries",{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":6,"repositoryNo":11,"starsCount":12,"licenseSpdxId":13,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":21},"01M6KM4DY820XHS9YTSK5QP5HD","bundled-dataset-search-tool","invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftravel-planning\u002Fbundled-dataset-search-tool\u002FSKILL.md",[],[98,99,100,101,102,103,104,79,105,106,80,107,85,108,77],"search","tool","dataset","bundled dataset search tool","restaurants","Tools","up","look","flights","you","database",{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":6,"repositoryNo":11,"starsCount":12,"licenseSpdxId":13,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":21},"01M6KM465BB9PQ0B548HQSVAWZ","glm-output","Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final \u002Froot\u002Fmetrics.json.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftemperature-simulation\u002Fglm-output\u002FSKILL.md",[],[116,117,118,85,119,120,121,122,123,124,125,126,107,127,128],"glm output","output","glm","tasks","metrics","json","basics","guidance","matching","verifier","processing","root","calibration",{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":6,"repositoryNo":11,"starsCount":12,"licenseSpdxId":13,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":136,"publishedAt":21},"01M6KM40KY3QWDW5W97S39R2BC","glm-calibration","Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftemperature-simulation\u002Fglm-calibration\u002FSKILL.md",[135],{"categoryNo":73,"categoryName":74,"taxonomyType":57,"taxonomyTypeDesc":58},[137,128,118,117,123,122,119,138,139,85,140],"glm calibration","setup","companion","metric",{"skillNo":142,"name":143,"nameZh":6,"description":144,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":6,"repositoryNo":11,"starsCount":12,"licenseSpdxId":13,"licenseFileUrl":6,"sourceHtmlUrl":145,"categories":146,"keywords":147,"publishedAt":21},"01M6KM3VHHVSGMGHJQB3PPT6YG","glm-basics","A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftemperature-simulation\u002Fglm-basics\u002FSKILL.md",[],[148,118,122,149,137,128,85,117,150,151,152,153,154,155,119],"glm basics","inspect","relevant","files","good","use","how","Evaluation"]