[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-InternLM--InternLM-Math":3,"tool-InternLM--InternLM-Math":64},[4,17,27,35,48,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",145895,2,"2026-04-08T11:32:59",[13,14,15],"开发框架","Agent","语言模型","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,3,"2026-04-06T11:19:32",[15,26,14,13],"图像",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":10,"last_commit_at":33,"category_tags":34,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":10,"last_commit_at":41,"category_tags":42,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",85052,"2026-04-08T11:03:08",[26,43,44,45,14,46,15,13,47],"数据工具","视频","插件","其他","音频",{"id":49,"name":50,"github_repo":51,"description_zh":52,"stars":53,"difficulty_score":23,"last_commit_at":54,"category_tags":55,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[14,26,13,15,46],{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":23,"last_commit_at":62,"category_tags":63,"status":16},519,"PaddleOCR","PaddlePaddle\u002FPaddleOCR","PaddleOCR 是一款基于百度飞桨框架开发的高性能开源光学字符识别工具包。它的核心能力是将图片、PDF 等文档中的文字提取出来，转换成计算机可读取的结构化数据，让机器真正“看懂”图文内容。\n\n面对海量纸质或电子文档，PaddleOCR 解决了人工录入效率低、数字化成本高的问题。尤其在人工智能领域，它扮演着连接图像与大型语言模型（LLM）的桥梁角色，能将视觉信息直接转化为文本输入，助力智能问答、文档分析等应用场景落地。\n\nPaddleOCR 适合开发者、算法研究人员以及有文档自动化需求的普通用户。其技术优势十分明显：不仅支持全球 100 多种语言的识别，还能在 Windows、Linux、macOS 等多个系统上运行，并灵活适配 CPU、GPU、NPU 等各类硬件。作为一个轻量级且社区活跃的开源项目，PaddleOCR 既能满足快速集成的需求，也能支撑前沿的视觉语言研究，是处理文字识别任务的理想选择。",75149,"2026-04-08T11:09:19",[15,26,13,46],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":79,"owner_email":80,"owner_twitter":81,"owner_website":82,"owner_url":83,"languages":84,"stars":96,"forks":97,"last_commit_at":98,"license":99,"difficulty_score":23,"env_os":78,"env_gpu":100,"env_ram":100,"env_deps":101,"category_tags":104,"github_topics":79,"view_count":10,"oss_zip_url":79,"oss_zip_packed_at":79,"status":16,"created_at":105,"updated_at":106,"faqs":107,"releases":136},5590,"InternLM\u002FInternLM-Math","InternLM-Math","State-of-the-art bilingual open-sourced Math reasoning LLMs.","InternLM-Math 是一款由上海人工智能实验室推出的开源双语数学推理大语言模型，旨在成为解决复杂数学问题的全能助手。它不仅能像“解题者”一样逐步推导答案，还能作为“证明器”处理形式化数学证明，并具备“验证器”和“数据增强”能力，实现了从非自然语言推理到 Lean 4 形式化证明的全流程覆盖。\n\n该工具主要解决了传统 AI 在处理高难度数学题时逻辑链条断裂、无法进行严谨形式化证明以及中英文数学语境理解不均的痛点。通过引入思维链（Chain-of-Thought）和代码解释器技术，InternLM-Math 在 MiniF2F、ProofNet 等国际权威数学评测基准上取得了领先的性能表现，显著提升了推理的准确性和可靠性。\n\nInternLM-Math 特别适合 AI 研究人员、教育科技开发者以及需要高精度数学辅助的专业人士使用。研究人员可利用其开放的策略模型与批评模型探索自动定理证明的前沿；开发者可基于其多尺寸版本（从 1.8B 到 8x22B）构建智能辅导系统或科研辅助工具。其独特的亮点在于构建了大规模的 Lean-Workbook 和 Lean-Github 数据集，并发布了","InternLM-Math 是一款由上海人工智能实验室推出的开源双语数学推理大语言模型，旨在成为解决复杂数学问题的全能助手。它不仅能像“解题者”一样逐步推导答案，还能作为“证明器”处理形式化数学证明，并具备“验证器”和“数据增强”能力，实现了从非自然语言推理到 Lean 4 形式化证明的全流程覆盖。\n\n该工具主要解决了传统 AI 在处理高难度数学题时逻辑链条断裂、无法进行严谨形式化证明以及中英文数学语境理解不均的痛点。通过引入思维链（Chain-of-Thought）和代码解释器技术，InternLM-Math 在 MiniF2F、ProofNet 等国际权威数学评测基准上取得了领先的性能表现，显著提升了推理的准确性和可靠性。\n\nInternLM-Math 特别适合 AI 研究人员、教育科技开发者以及需要高精度数学辅助的专业人士使用。研究人员可利用其开放的策略模型与批评模型探索自动定理证明的前沿；开发者可基于其多尺寸版本（从 1.8B 到 8x22B）构建智能辅导系统或科研辅助工具。其独特的亮点在于构建了大规模的 Lean-Workbook 和 Lean-Github 数据集，并发布了专门的 Step-Prover 模型，让机器不仅能“算出”结果，更能像数学家一样“证明”结论，为数学 AI 领域树立了新的标杆。","# InternLM-Math\n\n\u003Cdiv align=\"center\">\n\n\u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002FInternLM\u002FInternLM\u002Fmain\u002Fassets\u002Flogo.svg\" width=\"200\"\u002F>\n  \u003Cdiv> \u003C\u002Fdiv>\n  \u003Cdiv align=\"center\">\n    \u003Cb>\u003Cfont size=\"5\">InternLM-Math\u003C\u002Ffont>\u003C\u002Fb>\n    \u003Csup>\n      \u003Ca href=\"https:\u002F\u002Finternlm.intern-ai.org.cn\u002F\">\n        \u003Ci>\u003Cfont size=\"4\">HOT\u003C\u002Ffont>\u003C\u002Fi>\n      \u003C\u002Fa>\n    \u003C\u002Fsup>\n    \u003Cdiv> \u003C\u002Fdiv>\n  \u003C\u002Fdiv>\n\n[![license](https:\u002F\u002Fraw.githubusercontent.com\u002FInternLM\u002FInternLM\u002Fmain\u002Fassets\u002Flicense.svg)](.\u002FLICENSE)\n\nState-of-the-art bilingual open-sourced Math reasoning LLMs. \nA **solver**, **prover**, **verifier**, **augmentor**.\n\n\n\n[📑 Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2402.06332) [💻 Github](https:\u002F\u002Fgithub.com\u002FInternLM\u002FInternLM-Math) [🤗 Demo](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Finternlm\u002Finternlm2-math-7b) [🤗 Checkpoints](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002Finternlm\u002Finternlm2-math-65b0ce88bf7d3327d0a5ad9f) [![OpenXLab](https:\u002F\u002Fcdn-static.openxlab.org.cn\u002Fheader\u002Fopenxlab_models.svg)](https:\u002F\u002Fopenxlab.org.cn\u002Fmodels\u002Fdetail\u002FOpenLMLab\u002FInternLM2-Math-7B) [\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_375e99f5914e.png\" width=\"20px\" \u002F> ModelScope](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-7b\u002Fsummary)\n\u003C\u002Fdiv>\n\n# News\n- [2024.10.22] We release **InternLM2.5-Step-Prover** policy and critic models with 14k proves found in Lean-Workbook. [🤗Dataset](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Finternlm\u002FLean-Workbook) [🤗Policy-model](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2_5-step-prover) [🤗Critic-model](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2_5-step-prover-critic) [📑 Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.15700)\n- [2024.07.25] We release **Lean-Github** and **InternLM2-Step-Prover** with 29K theorems compiled from 100+ Lean 4 repos and a 7B models fine-tuned on Lean-Github and Lean-Workbook with SOTA performance on MiniF2F-test (54.5%), ProofNet (18.1%), and Putnam (5 problems). [🤗Dataset](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Finternlm\u002FLean-Github) [🤗Model](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-step-prover) [📑 Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2407.17227) [📖 README](https:\u002F\u002Fgithub.com\u002FInternLM\u002FInternLM-Math\u002Fblob\u002Fmain\u002Flean-github\u002FREADME.md)\n- [2024.06.06] We release **Lean-Workbook** with 57K math problems formalized in Lean 4 with 5K searched proof for autoformalization and auto theorem proving. [🤗Dataset](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Finternlm\u002FLean-Workbook) [📑 Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2406.03847)\n- [2024.05.24] We release updated version **InternLM2-Math-Plus** with 4 sizes and state-of-the-art performances including 1.8B, 7B, 20B, and 8x22B. We improve informal math reasoning performance (chain-of-thought and code-interpreter) and formal math reasoning performance (LEAN 4 translation and LEAN 4 theorem proving) significantly.\n- [2024.02.10] We add tech reports and citation references.\n- [2024.01.31] We add MiniF2F results with evaluation codes!\n- [2024.01.29] We add checkpoints from ModelScope. Update results about majority voting and Code Interpreter. Tech report is on the way!\n- [2024.01.26] We add checkpoints from OpenXLab, which ease Chinese users to download!\n\n# InternLM2-Math-Plus\n\n## Checkpoints\n\n| Model                                | Model Type | Transformers(HF)                                                                                                | ModelScope                                                                                                                                              | Release Date |\n| ------------------------------------ | ---------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |\n| **InternLM2-Math-Plus-1.8B**         | Chat       | 🤗[internlm\u002Finternlm2-math-plus-1_8b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-plus-1_8b\u002F)                 | [Shanghai_AI_Laboratory\u002Finternlm2-math-plus-1_8b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-plus-1_8b\u002Fsummary)                 | 2024-05-27   |\n| **InternLM2-Math-Plus-7B**           | Chat       | 🤗[internlm\u002Finternlm2-math-plus-7b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-plus-7b\u002F)                     | [Shanghai_AI_Laboratory\u002Finternlm2-math-plus-7b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-plus-7b\u002Fsummary)                     | 2024-05-27   |\n| **InternLM2-Math-Plus-20B**          | Chat       | 🤗[internlm\u002Finternlm2-math-plus-20b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-plus-20b\u002F)                   | [Shanghai_AI_Laboratory\u002Finternlm2-math-plus-20b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-plus-20b\u002Fsummary)                   | 2024-05-27   |\n| **InternLM2-Math-Plus-Mixtral8x22B** | Chat       | 🤗[internlm\u002Finternlm2-math-plus-mixtral8x22b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-plus-mixtral8x22b\u002F) | [Shanghai_AI_Laboratory\u002Finternlm2-math-plus-mixtral8x22b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-plus-mixtral8x22b\u002Fsummary) | 2024-05-27   |\n\n## Formal Math Reasoning\nWe evaluate the performance of InternLM2-Math-Plus on formal math reasoning benchmark MiniF2F-test. The evaluation setting is same as Llemma with LEAN 4. \n\n> This is how to reproduce our performance on [MiniF2F](minif2f\u002FREADME.md).\n\n| Models                           | MiniF2F-test |\n| -------------------------------- | ------------ |\n| ReProver                         | 26.5         |\n| LLMStep                          | 27.9         |\n| GPT-F                            | 36.6         |\n| HTPS                             | 41.0         |\n| Llemma-7B                        | 26.2         |\n| Llemma-34B                       | 25.8         |\n| InternLM2-Math-7B-Base           | 30.3         |\n| InternLM2-Math-20B-Base          | 29.5         |\n| InternLM2-Math-Plus-1.8B         | 38.9         |\n| InternLM2-Math-Plus-7B           | **43.4**     |\n| InternLM2-Math-Plus-20B          | 42.6         |\n| InternLM2-Math-Plus-Mixtral8x22B | 37.3         |\n\n## Informal Math Reasoning\nWe evaluate the performance of InternLM2-Math-Plus on informal math reasoning benchmark MATH and GSM8K. InternLM2-Math-Plus-1.8B outperforms MiniCPM-2B in the smallest size setting. InternLM2-Math-Plus-7B outperforms Deepseek-Math-7B-RL which is the state-of-the-art math reasoning open source model. InternLM2-Math-Plus-Mixtral8x22B achieves 68.5 on MATH (with Python) and 91.8 on GSM8K.\n\n> For tool-calling inference and evaluation, please see the [agent section](agent\u002F).\n\n| Model                            | MATH     | MATH-Python | GSM8K    |\n| -------------------------------- | -------- | ----------- | -------- |\n| MiniCPM-2B                       | 10.2     | -           | 53.8     |\n| InternLM2-Math-Plus-1.8B         | **37.0** | **41.5**    | **58.8** |\n| InternLM2-Math-7B                | 34.6     | 50.9        | 78.1     |\n| Deepseek-Math-7B-RL              | 51.7     | 58.8        | **88.2** |\n| InternLM2-Math-Plus-7B           | **53.0** | **59.7**    | 85.8     |\n| InternLM2-Math-20B               | 37.7     | 54.3        | 82.6     |\n| InternLM2-Math-Plus-20B          | **53.8** | **61.8**    | **87.7** |\n| Mixtral8x22B-Instruct-v0.1       | 41.8     | -           | 78.6     |\n| Eurux-8x22B-NCA                  | 49.0     | -           | -        |\n| InternLM2-Math-Plus-Mixtral8x22B | **58.1** | **68.5**    | **91.8** |\n\nWe also evaluate models on [MathBench-A](https:\u002F\u002Fgithub.com\u002Fopen-compass\u002FMathBench). InternLM2-Math-Plus-Mixtral8x22B has comparable performance compared to Claude 3 Opus.\n| Model                            | Arithmetic | Primary | Middle | High | College | Average |\n| -------------------------------- | ---------- | ------- | ------ | ---- | ------- | ------- |\n| GPT-4o-0513                      | 77.7       | 87.7    | 76.3   | 59.0 | 54.0    | 70.9    |\n| Claude 3 Opus                    | 85.7       | 85.0    | 58.0   | 42.7 | 43.7    | 63.0    |\n| Qwen-Max-0428                    | 72.3       | 86.3    | 65.0   | 45.0 | 27.3    | 59.2    |\n| Qwen-1.5-110B                    | 70.3       | 82.3    | 64.0   | 47.3 | 28.0    | 58.4    |\n| Deepseek-V2                      | 82.7       | 89.3    | 59.0   | 39.3 | 29.3    | 59.9    |\n| Llama-3-70B-Instruct             | 70.3       | 86.0    | 53.0   | 38.7 | 34.7    | 56.5    |\n| InternLM2-Math-Plus-Mixtral8x22B | 77.5       | 82.0    | 63.6   | 50.3 | 36.8    | 62.0    |\n| InternLM2-Math-20B               | 58.7       | 70.0    | 43.7   | 24.7 | 12.7    | 42.0    |\n| InternLM2-Math-Plus-20B          | 65.8       | 79.7    | 59.5   | 47.6 | 24.8    | 55.5    |\n| Llama3-8B-Instruct               | 54.7       | 71.0    | 25.0   | 19.0 | 14.0    | 36.7    |\n| InternLM2-Math-7B                | 53.7       | 67.0    | 41.3   | 18.3 | 8.0     | 37.7    |\n| Deepseek-Math-7B-RL              | 68.0       | 83.3    | 44.3   | 33.0 | 23.0    | 50.3    |\n| InternLM2-Math-Plus-7B           | 61.4       | 78.3    | 52.5   | 40.5 | 21.7    | 50.9    |\n| MiniCPM-2B                       | 49.3       | 51.7    | 18.0   | 8.7  | 3.7     | 26.3    |\n| InternLM2-Math-Plus-1.8B         | 43.0       | 43.3    | 25.4   | 18.9 | 4.7     | 27.1    |\n\n\n# Introduction (For InternLM2-Math)\n- **7B and 20B Chinese and English Math LMs with better than ChatGPT performances.** InternLM2-Math are continued pretrained from InternLM2-Base with ~100B high quality math-related tokens and SFT with ~2M bilingual math supervised data. We apply minhash and exact number match to decontaminate possible test set leakage. \n- **Add Lean as a support language for math problem solving and math theorem proving.** We are exploring combining Lean 3 with InternLM-Math for verifiable math reasoning. InternLM-Math can generate Lean codes for simple math reasoning tasks like GSM8K or provide possible proof tactics based on Lean states.\n- **Also can be viewed as a reward model, which supports the Outcome\u002FProcess\u002FLean Reward Model.** We supervise InternLM2-Math with various types of reward modeling data, to make InternLM2-Math can also verify chain-of-thought processes. We also add the ability to convert a chain-of-thought process into Lean 3 code.\n- **A Math LM Augment Helper** and **Code Interpreter**. InternLM2-Math can help augment math reasoning problems and solve them using the code interpreter which makes you generate synthesis data quicker!\n\n![math256](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_69badfe3ace2.jpeg)\n![hungarian](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_8cb111727cd0.jpeg)\n\n# Models\n**InternLM2-Math-Base-7B** and **InternLM2-Math-Base-20B** are pretrained checkpoints. **InternLM2-Math-7B** and **InternLM2-Math-20B** are SFT checkpoints.\n| Model                       | Model Type | Transformers(HF)                                                                             | OpenXLab                                                                                                                                                      | ModelScope                                                                                                                                                             | Release Date |\n| --------------------------- | ---------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |\n| **InternLM2-Math-Base-7B**  | Base       | [🤗internlm\u002Finternlm2-math-base-7b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-base-7b)   | [![Open in OpenXLab](https:\u002F\u002Fcdn-static.openxlab.org.cn\u002Fheader\u002Fopenxlab_models.svg)](https:\u002F\u002Fopenxlab.org.cn\u002Fmodels\u002Fdetail\u002FOpenLMLab\u002FInternLM2-Math-Base-7B)  | [\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_375e99f5914e.png\" width=\"20px\" \u002F> internlm2-math-base-7b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-base-7b\u002Fsummary)   | 2024-01-23   |\n| **InternLM2-Math-Base-20B** | Base       | [🤗internlm\u002Finternlm2-math-base-20b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-base-20b) | [![Open in OpenXLab](https:\u002F\u002Fcdn-static.openxlab.org.cn\u002Fheader\u002Fopenxlab_models.svg)](https:\u002F\u002Fopenxlab.org.cn\u002Fmodels\u002Fdetail\u002FOpenLMLab\u002FInternLM2-Math-Base-20B) | [\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_375e99f5914e.png\" width=\"20px\" \u002F> internlm2-math-base-20b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-base-20b\u002Fsummary) | 2024-01-23   |\n| **InternLM2-Math-7B**       | Chat       | [🤗internlm\u002Finternlm2-math-7b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-7b)             | [![Open in OpenXLab](https:\u002F\u002Fcdn-static.openxlab.org.cn\u002Fheader\u002Fopenxlab_models.svg)](https:\u002F\u002Fopenxlab.org.cn\u002Fmodels\u002Fdetail\u002FOpenLMLab\u002FInternLM2-Math-7B)       | [\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_375e99f5914e.png\" width=\"20px\" \u002F> internlm2-math-7b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-7b\u002Fsummary)             | 2024-01-23   |\n| **InternLM2-Math-20B**      | Chat       | [🤗internlm\u002Finternlm2-math-20b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-20b)           | [![Open in OpenXLab](https:\u002F\u002Fcdn-static.openxlab.org.cn\u002Fheader\u002Fopenxlab_models.svg)](https:\u002F\u002Fopenxlab.org.cn\u002Fmodels\u002Fdetail\u002FOpenLMLab\u002FInternLM2-Math-20B)      | [\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_375e99f5914e.png\" width=\"20px\" \u002F> internlm2-math-20b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-20b\u002Fsummary)           | 2024-01-23   |\n\n\n# Performance\n\n## Pretrain Performance\nWe evaluate pretrain checkpoints based on greedy decoding with few-shot COT. Details of pretraining will be introduced in the tech report.\n| Benchmark                   | GSM8K MAJ@1 | GSM8K MAJ@100 | MATH MAJ@1 | MATH MAJ@256 |\n| --------------------------- | ----------- | ------------- | ---------- | ------------ |\n| Llama2-7B                   | 14.6        | -             | 2.5        | -            |\n| Llemma-7B                   | 36.4        | 54.0          | 18.0       | 33.5         |\n| InternLM2-Base-7B           | 36.5        | -             | 8.6        | -            |\n| **InternLM2-Math-Base-7B**  | **49.2**    | **75.7**      | **21.5**   | **35.6**     |\n| Minerva-8B                  | 16.2        | 28.4          | 14.1       | 25.4         |\n| InternLM2-Base-20B          | 54.6        | -             | 13.7       | -            |\n| **InternLM2-Math-Base-20B** | **63.7**    | **84.8**      | **27.3**   | **46.2**     |\n| Llemma-34B                  | 51.5        | 69.3          | 25.0       | 43.1         |\n| Minerva-62B                 | 52.4        | 68.5          | 27.6       | 43.4         |\n| Minerva-540B                | 58.8        | 78.5          | 33.6       | 50.3         |\n\nWe evaluate pretrain checkpoints using few-shot on MiniF2F. Please see **eval\u002Fpretrain\u002Fminif2f** for evaluation.\n| Benchmark                   | MiniF2F-test |\n| --------------------------- | ------------ |\n| ReProver                    | 26.5         |\n| LLMStep                     | 27.9         |\n| Code-Llama-7B               | 26.2         |\n| Code-Llama-34B              | 25.8         |\n| Llemma-7B                   | 26.2         |\n| Llemma-34B                  | 25.8         |\n| **InternLM2-Math-7B-Base**  | 30.3         |\n| **InternLM2-Math-20B-Base** | 29.5         |\n\n\n## SFT Peformance\nAll performance is based on greedy decoding with COT. We notice that the performance of Hungary has a big variance between our different checkpoints, while other performance is very stable. This may be due to the problem amount about Hungary. \n| Model                  | Model Type  | GSM8K    | MATH     | Hungary |\n| ---------------------- | ----------- | -------- | -------- | ------- |\n| Qwen-7B-Chat           | Genearl     | 51.7     | 11.6     | -       |\n| DeepSeek-7B-Chat       | General     | 63.0     | 15.8     | 28.5    |\n| InternLM2-Chat-7B      | General     | 70.7     | 23.0     | -       |\n| ChatGLM3-6B            | General     | 53.8     | 20.4     | 32      |\n| MetaMath-Mistral-7B    | Mathematics | 77.7     | 28.2     | 29      |\n| MetaMath-Llemma-7B     | Mathematics | 69.2     | 30.0     | -       |\n| **InternLM2-Math-7B**  | Mathematics | **78.1** | **34.6** | **55**  |\n| InternLM2-Chat-20B     | General     | 79.6     | 31.9     | -       |\n| MetaMath-Llemma-34B    | Mathematics | 75.8     | 34.8     | -       |\n| **InternLM2-Math-20B** | Mathematics | **82.6** | **37.7** | **66**  |\n| Qwen-72B               | General     | 78.9     | 35.2     | 52      |\n| DeepSeek-67B           | General     | 84.1     | 32.6     | 58      |\n| ChatGPT (GPT-3.5)      | General     | 80.8     | 34.1     | 41      |\n| GPT4 (First version)   | General     | 92.0     | 42.5     | 68      |\n\n## Code Intepreter Performance\nAll performance is based on interacting with Python.\n| Model                          | GSM8K    | MATH     |\n| ------------------------------ | -------- | -------- |\n| DeepSeek-Coder-Instruct-7B     | 62.8     | 28.6     |\n| DeepSeek-Coder-Instruct-1.5-7B | 72.6     | 34.1     |\n| ToRA-7B                        | 72.6     | 44.6     |\n| MathCODER-CL-7B                | 67.8     | 30.2     |\n| InternLM2-Chat-7B              | 77.9     | 45.1     |\n| **InternLM2-Math-7B**          | **79.4** | **50.9** |\n| ToRA-13B                       | 75.8     | 48.1     |\n| MathCODER-CL-13B               | 74.1     | 35.9     |\n| InternLM2-Chat-20B             | **84.5** | 51.2     |\n| **InternLM2-Math-20B**         | 80.7     | **54.3** |\n| MathCODER-CL-34B               | 81.7     | 45.2     |\n| ToRA-70B                       | 84.3     | 49.7     |\n| GPT-4 Code Interpreter *       | **97.0** | **69.7** |\n\n# Eval\nYou can effortlessly evaluate InternLM2-Math across a diverse array of mathematical datasets, such as Math and GSM8K, using [OpenCompass](https:\u002F\u002Fgithub.com\u002Fopen-compass\u002Fopencompass) with a single command. To get started, simply execute the following in your terminal after installing OpenCompass:\n\n```bash\npython run.py --models hf_internlm2_chat_math_7b --datasets gsm8k_gen math_gen_736506\n```\n\nAlternatively, for a streamlined experience, you can utilize a predefined configuration file. To do this, run the command below, making sure to adjust the arguments according to your requirements:\n\n```bash\npython run.py config\u002Feval_internlm_math_chat.py\n```\n\n# Inference\n\n## LMDeploy\nWe suggest using [LMDeploy](https:\u002F\u002Fgithub.com\u002FInternLM\u002FLMDeploy)(>=0.2.1) for inference.\n```python\nfrom lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig\n\nbackend_config = TurbomindEngineConfig(model_name='internlm2-chat-7b', tp=1, cache_max_entry_count=0.3)\nchat_template = ChatTemplateConfig(model_name='internlm2-chat-7b', system='', eosys='', meta_instruction='')\npipe = pipeline(model_path='internlm\u002Finternlm2-math-7b', chat_template_config=chat_template, backend_config=backend_config)\n\nproblem = '1+1='\nresult = pipe([problem], request_output_len=1024, top_k=1)\n```\n\n## Huggingface\n```python\nimport torch\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\ntokenizer = AutoTokenizer.from_pretrained(\"internlm\u002Finternlm2-math-7b\", trust_remote_code=True)\n# Set `torch_dtype=torch.float16` to load model in float16, otherwise it will be loaded as float32 and might cause OOM Error.\nmodel = AutoModelForCausalLM.from_pretrained(\"internlm\u002Finternlm2-math-7b\", trust_remote_code=True, torch_dtype=torch.float16).cuda()\nmodel = model.eval()\nresponse, history = model.chat(tokenizer, \"1+1=\", history=[], meta_instruction=\"\")\nprint(response)\n```\n\n# Special usages\nWe list some instructions used in our SFT. You can use them to help you. You can use the other ways to prompt the model, but the following are recommended. InternLM2-Math may combine the following abilities but it is not guaranteed.\n\nTranslate proof problem to Lean:\n![nl2lean3](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_7d1ca4c61cbc.jpeg)\n\nUsing Lean 3 to solve GSM8K problem:\n![gsm8k_lean](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_6d3f15d829f0.jpeg)\n\nGenerate problem based on Lean 3 code:\n![lean_problem](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_c77a95a8bb41.jpeg)\n\nPlay 24 point game:\n![24](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_2e1f27be90c0.jpeg)\n\nAugment a harder math problem:\n![augment_hard](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_5cec54fd319d.jpeg)\n\n| Description                                                         | Query                                                                                                        |\n| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |\n| Solving question via chain-of-thought                               | {Question}                                                                                                   |\n| Solving question via Lean 3                                         | {Question}\\nSolve this via Lean 3                                                                            |\n| Outcome reward model                                                | Given a question and an answer, check is it correct?\\nQuestion:{Question}\\nAnswer:{COT}                      |\n| Process reward model                                                | Given a question and an answer, check correctness of each step.\\nQuestion:{Question}\\nAnswer:{COT}           |\n| Reward model                                                        | Given a question and two answers, which one is better? \\nQuestion:{Question}\\nAnswer 1:{COT}\\nAnswer 2:{COT} |\n| Convert chain-of-thought to Lean 3                                  | Convert this answer into Lean3. Question:{Question}\\nAnswer:{COT}                                            |\n| Convert Lean 3 to chain-of-thought                                  | Convert this lean 3 code into a natural language problem with answers:\\n{LEAN Code}                          |\n| Translate question and chain-of-thought answer to a proof statement | Convert this question and answer into a proof format.\\nQuestion:{Question}\\nAnswer:{COT}                     |\n| Translate proof problem to Lean 3                                   | Convert this natural langauge statement into a Lean 3 theorem statement:{Theorem}                            |\n| Translate Lean 3 to proof problem                                   | Convert this Lean 3 theorem statement into natural language:{STATEMENT}                                      |\n| Suggest a tactic based on Lean state                                | Given the Lean 3 tactic state, suggest a next tactic:\\n{LEAN State}                                          |\n| Rephrase Problem                                                    | Describe this problem in another way. {Question}                                                             |\n| Augment Problem                                                     | Please augment a new problem based on: {Question}                                                            |\n| Augment a harder Problem                                            | Increase the complexity of the problem: {Question}                                                           |\n| Change specific numbers                                             | Change specific numbers: {Question}                                                                          |\n| Introduce fractions or percentages                                  | Introduce fractions or percentages: {Question}                                                               |\n| Code Interpreter                                                    | [lagent](https:\u002F\u002Fgithub.com\u002FInternLM\u002FInternLM\u002Fblob\u002Fmain\u002Fagent\u002Flagent.md)                                     |\n| In-context Learning                                                 | Question:{Question}\\nAnswer:{COT}\\n...Question:{Question}\\nAnswer:{COT}                                      |\n\n# Fine-tune and others\nPlease refer to [InternLM](https:\u002F\u002Fgithub.com\u002FInternLM\u002FInternLM\u002Ftree\u002Fmain).\n\n# Known issues\nOur model is still under development and will be upgraded. There are some possible issues of InternLM-Math. If you find performances of some abilities are not great, welcome to open an issue.\n- Jump the calculating step.\n- Perform badly at Chinese fill-in-the-bank problems and English choice problems due to SFT data composition.\n- Tend to generate Code Interpreter when facing Chinese problems due to SFT data composition.\n- The reward model mode can be better leveraged with assigned token probabilities.\n- Code switch due to SFT data composition.\n- Some abilities of Lean can only be adapted to GSM8K-like problems (e.g. Convert chain-of-thought to Lean 3), and performance related to Lean is not guaranteed.\n\n# Citation and Tech Report\n```\n@misc{ying2024internlmmath,\n      title={InternLM-Math: Open Math Large Language Models Toward Verifiable Reasoning}, \n      author={Huaiyuan Ying and Shuo Zhang and Linyang Li and Zhejian Zhou and Yunfan Shao and Zhaoye Fei and Yichuan Ma and Jiawei Hong and Kuikun Liu and Ziyi Wang and Yudong Wang and Zijian Wu and Shuaibin Li and Fengzhe Zhou and Hongwei Liu and Songyang Zhang and Wenwei Zhang and Hang Yan and Xipeng Qiu and Jiayu Wang and Kai Chen and Dahua Lin},\n      year={2024},\n      eprint={2402.06332},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n@misc{ying2024lean,\n      title={Lean Workbook: A large-scale Lean problem set formalized from natural language math problems}, \n      author={Huaiyuan Ying and Zijian Wu and Yihan Geng and Jiayu Wang and Dahua Lin and Kai Chen},\n      year={2024},\n      eprint={2406.03847},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n@misc{wu2024leangithubcompilinggithublean,\n      title={LEAN-GitHub: Compiling GitHub LEAN repositories for a versatile LEAN prover}, \n      author={Zijian Wu and Jiayu Wang and Dahua Lin and Kai Chen},\n      year={2024},\n      eprint={2407.17227},\n      archivePrefix={arXiv},\n      primaryClass={cs.AI},\n      url={https:\u002F\u002Farxiv.org\u002Fabs\u002F2407.17227}, \n}\n@misc{wu2024internlm25stepproveradvancingautomatedtheorem,\n      title={InternLM2.5-StepProver: Advancing Automated Theorem Proving via Expert Iteration on Large-Scale LEAN Problems}, \n      author={Zijian Wu and Suozhi Huang and Zhejian Zhou and Huaiyuan Ying and Jiayu Wang and Dahua Lin and Kai Chen},\n      year={2024},\n      eprint={2410.15700},\n      archivePrefix={arXiv},\n      primaryClass={cs.AI},\n      url={https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.15700}, \n}\n```\n","# InternLM-Math\n\n\u003Cdiv align=\"center\">\n\n\u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002FInternLM\u002FInternLM\u002Fmain\u002Fassets\u002Flogo.svg\" width=\"200\"\u002F>\n  \u003Cdiv> \u003C\u002Fdiv>\n  \u003Cdiv align=\"center\">\n    \u003Cb>\u003Cfont size=\"5\">InternLM-Math\u003C\u002Ffont>\u003C\u002Fb>\n    \u003Csup>\n      \u003Ca href=\"https:\u002F\u002Finternlm.intern-ai.org.cn\u002F\">\n        \u003Ci>\u003Cfont size=\"4\">HOT\u003C\u002Ffont>\u003C\u002Fi>\n      \u003C\u002Fa>\n    \u003C\u002Fsup>\n    \u003Cdiv> \u003C\u002Fdiv>\n  \u003C\u002Fdiv>\n\n[![license](https:\u002F\u002Fraw.githubusercontent.com\u002FInternLM\u002FInternLM\u002Fmain\u002Fassets\u002Flicense.svg)](.\u002FLICENSE)\n\n最先进的双语开源数学推理大模型。既是**求解器**，也是**证明者**、**验证者**和**增强器**。\n\n\n\n[📑 论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2402.06332) [💻 Github](https:\u002F\u002Fgithub.com\u002FInternLM\u002FInternLM-Math) [🤗 演示](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Finternlm\u002Finternlm2-math-7b) [🤗 检查点](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002Finternlm\u002Finternlm2-math-65b0ce88bf7d3327d0a5ad9f) [![OpenXLab](https:\u002F\u002Fcdn-static.openxlab.org.cn\u002Fheader\u002Fopenxlab_models.svg)](https:\u002F\u002Fopenxlab.org.cn\u002Fmodels\u002Fdetail\u002FOpenLMLab\u002FInternLM2-Math-7B) [\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_375e99f5914e.png\" width=\"20px\" \u002F> ModelScope](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-7b\u002Fsummary)\n\u003C\u002Fdiv>\n\n# 新闻\n- [2024.10.22] 我们发布了具有1.4万条Lean-Workbook中发现的证明的**InternLM2.5-Step-Prover**策略模型和批评家模型。[🤗数据集](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Finternlm\u002FLean-Workbook) [🤗策略模型](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2_5-step-prover) [🤗批评家模型](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2_5-step-prover-critic) [📑 论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.15700)\n- [2024.07.25] 我们发布了包含从100多个Lean 4仓库中整理出的2.9万条定理的**Lean-Github**以及在Lean-Github和Lean-Workbook上微调的7B模型——**InternLM2-Step-Prover**，其在MiniF2F测试（54.5%）、ProofNet（18.1%）和普特南竞赛（5道题）上的表现均达到当前最佳水平。[🤗数据集](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Finternlm\u002FLean-Github) [🤗模型](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-step-prover) [📑 论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2407.17227) [📖 README](https:\u002F\u002Fgithub.com\u002FInternLM\u002FInternLM-Math\u002Fblob\u002Fmain\u002Flean-github\u002FREADME.md)\n- [2024.06.06] 我们发布了包含5.7万道用Lean 4形式化处理的数学问题的**Lean-Workbook**，其中5千道已搜索到证明，可用于自动形式化和自动定理证明。[🤗数据集](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Finternlm\u002FLean-Workbook) [📑 论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2406.03847)\n- [2024.05.24] 我们发布了更新版本的**InternLM2-Math-Plus**，提供四种规模，性能均处于行业领先水平，包括1.8B、7B、20B以及8×22B版本。我们在非形式化数学推理（思维链和代码解释器）和形式化数学推理（LEAN 4翻译与LEAN 4定理证明）方面均有显著提升。\n- [2024.02.10] 我们新增了技术报告和引用参考文献。\n- [2024.01.31] 我们增加了MiniF2F测试结果及评估代码！\n- [2024.01.29] 我们添加了来自ModelScope的检查点，并更新了多数投票和代码解释器的相关结果。技术报告正在撰写中！\n- [2024.01.26] 我们增加了来自OpenXLab的检查点，方便中国用户下载！\n\n# InternLM2-Math-Plus\n\n## 检查点\n\n| 模型                                | 模型类型 | Hugging Face Transformers                                                                                                | ModelScope                                                                                                                                              | 发布日期 |\n| ------------------------------------ | ---------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |\n| **InternLM2-Math-Plus-1.8B**         | 对话       | 🤗[internlm\u002Finternlm2-math-plus-1_8b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-plus-1_8b\u002F)                 | [Shanghai_AI_Laboratory\u002Finternlm2-math-plus-1_8b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-plus-1_8b\u002Fsummary)                 | 2024-05-27   |\n| **InternLM2-Math-Plus-7B**           | 对话       | 🤗[internlm\u002Finternlm2-math-plus-7b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-plus-7b\u002F)                     | [Shanghai_AI_Laboratory\u002Finternlm2-math-plus-7b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-plus-7b\u002Fsummary)                     | 2024-05-27   |\n| **InternLM2-Math-Plus-20B**          | 对话       | 🤗[internlm\u002Finternlm2-math-plus-20b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-plus-20b\u002F)                   | [Shanghai_AI_Laboratory\u002Finternlm2-math-plus-20b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-plus-20b\u002Fsummary)                   | 2024-05-27   |\n| **InternLM2-Math-Plus-Mixtral8x22B** | 对话       | 🤗[internlm\u002Finternlm2-math-plus-mixtral8x22b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-plus-mixtral8x22b\u002F) | [Shanghai_AI_Laboratory\u002Finternlm2-math-plus-mixtral8x22b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-plus-mixtral8x22b\u002Fsummary) | 2024-05-27   |\n\n## 形式化数学推理\n我们对InternLM2-Math-Plus在形式化数学推理基准MiniF2F-test上的表现进行了评估。评估设置与Llemma相同，使用LEAN 4。\n\n> 这是我们在[MiniF2F](minif2f\u002FREADME.md)上复现我们性能的方法。\n\n| 模型                           | MiniF2F-test |\n| -------------------------------- | ------------ |\n| ReProver                         | 26.5         |\n| LLMStep                          | 27.9         |\n| GPT-F                            | 36.6         |\n| HTPS                             | 41.0         |\n| Llemma-7B                        | 26.2         |\n| Llemma-34B                       | 25.8         |\n| InternLM2-Math-7B-Base           | 30.3         |\n| InternLM2-Math-20B-Base          | 29.5         |\n| InternLM2-Math-Plus-1.8B         | 38.9         |\n| InternLM2-Math-Plus-7B           | **43.4**     |\n| InternLM2-Math-Plus-20B          | 42.6         |\n| InternLM2-Math-Plus-Mixtral8x22B | 37.3         |\n\n## 非正式数学推理\n我们在非正式数学推理基准 MATH 和 GSM8K 上评估了 InternLM2-Math-Plus 的性能。在最小尺寸设置下，InternLM2-Math-Plus-1.8B 的表现优于 MiniCPM-2B。InternLM2-Math-Plus-7B 的表现则超过了当前最先进的开源数学推理模型 Deepseek-Math-7B-RL。InternLM2-Math-Plus-Mixtral8x22B 在 MATH（使用 Python）上取得了 68.5 分，在 GSM8K 上取得了 91.8 分。\n\n> 关于工具调用推理和评估，请参阅[代理部分](agent\u002F)。\n\n| 模型                            | MATH     | MATH-Python | GSM8K    |\n| -------------------------------- | -------- | ----------- | -------- |\n| MiniCPM-2B                       | 10.2     | -           | 53.8     |\n| InternLM2-Math-Plus-1.8B         | **37.0** | **41.5**    | **58.8** |\n| InternLM2-Math-7B                | 34.6     | 50.9        | 78.1     |\n| Deepseek-Math-7B-RL              | 51.7     | 58.8        | **88.2** |\n| InternLM2-Math-Plus-7B           | **53.0** | **59.7**    | 85.8     |\n| InternLM2-Math-20B               | 37.7     | 54.3        | 82.6     |\n| InternLM2-Math-Plus-20B          | **53.8** | **61.8**    | **87.7** |\n| Mixtral8x22B-Instruct-v0.1       | 41.8     | -           | 78.6     |\n| Eurux-8x22B-NCA                  | 49.0     | -           | -        |\n| InternLM2-Math-Plus-Mixtral8x22B | **58.1** | **68.5**    | **91.8** |\n\n我们还在 [MathBench-A](https:\u002F\u002Fgithub.com\u002Fopen-compass\u002FMathBench) 上对模型进行了评估。InternLM2-Math-Plus-Mixtral8x22B 的表现与 Claude 3 Opus 相当。\n| 模型                            | 算术 | 小学 | 初中 | 高中 | 大学 | 平均 |\n| -------------------------------- | ---------- | ------- | ------ | ---- | ------- | ------- |\n| GPT-4o-0513                      | 77.7       | 87.7    | 76.3   | 59.0 | 54.0    | 70.9    |\n| Claude 3 Opus                    | 85.7       | 85.0    | 58.0   | 42.7 | 43.7    | 63.0    |\n| Qwen-Max-0428                    | 72.3       | 86.3    | 65.0   | 45.0 | 27.3    | 59.2    |\n| Qwen-1.5-110B                    | 70.3       | 82.3    | 64.0   | 47.3 | 28.0    | 58.4    |\n| Deepseek-V2                      | 82.7       | 89.3    | 59.0   | 39.3 | 29.3    | 59.9    |\n| Llama-3-70B-Instruct             | 70.3       | 86.0    | 53.0   | 38.7 | 34.7    | 56.5    |\n| InternLM2-Math-Plus-Mixtral8x22B | 77.5       | 82.0    | 63.6   | 50.3 | 36.8    | 62.0    |\n| InternLM2-Math-20B               | 58.7       | 70.0    | 43.7   | 24.7 | 12.7    | 42.0    |\n| InternLM2-Math-Plus-20B          | 65.8       | 79.7    | 59.5   | 47.6 | 24.8    | 55.5    |\n| Llama3-8B-Instruct               | 54.7       | 71.0    | 25.0   | 19.0 | 14.0    | 36.7    |\n| InternLM2-Math-7B                | 53.7       | 67.0    | 41.3   | 18.3 | 8.0     | 37.7    |\n| Deepseek-Math-7B-RL              | 68.0       | 83.3    | 44.3   | 33.0 | 23.0    | 50.3    |\n| InternLM2-Math-Plus-7B           | 61.4       | 78.3    | 52.5   | 40.5 | 21.7    | 50.9    |\n| MiniCPM-2B                       | 49.3       | 51.7    | 18.0   | 8.7  | 3.7     | 26.3    |\n| InternLM2-Math-Plus-1.8B         | 43.0       | 43.3    | 25.4   | 18.9 | 4.7     | 27.1    |\n\n\n# 简介（针对 InternLM2-Math）\n- **7B 和 20B 中英双语数学语言模型，性能超越 ChatGPT。** InternLM2-Math 是在 InternLM2-Base 的基础上继续预训练得到的，使用了约 1000 亿高质量的数学相关 token，并结合约 200 万条双语数学监督数据进行 SFT 训练。我们采用了 minhash 和精确数字匹配方法来消除可能的测试集泄露问题。\n- **新增 Lean 作为数学问题求解和数学定理证明的支持语言。** 我们正在探索将 Lean 3 与 InternLM-Math 结合，以实现可验证的数学推理。InternLM-Math 可以为简单的数学推理任务（如 GSM8K）生成 Lean 代码，或根据 Lean 状态提供可能的证明策略。\n- **也可被视为一种奖励模型，支持结果\u002F过程\u002FLean 奖励模型。** 我们使用多种类型的奖励建模数据对 InternLM2-Math 进行监督训练，使其能够验证思维链过程。此外，我们还增加了将思维链过程转换为 Lean 3 代码的功能。\n- **数学推理增强助手** 和 **代码解释器**。InternLM2-Math 可以帮助增强数学推理问题，并通过代码解释器解决问题，从而更快地生成合成数据！\n\n![math256](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_69badfe3ace2.jpeg)\n![hungarian](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_8cb111727cd0.jpeg)\n\n# 模型\n**InternLM2-Math-Base-7B** 和 **InternLM2-Math-Base-20B** 是预训练检查点。**InternLM2-Math-7B** 和 **InternLM2-Math-20B** 是 SFT 检查点。\n| 模型                       | 模型类型 | Transformers(HF)                                                                             | OpenXLab                                                                                                                                                      | ModelScope                                                                                                                                                             | 发布日期 |\n| --------------------------- | ---------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |\n| **InternLM2-Math-Base-7B**  | 基础       | [🤗internlm\u002Finternlm2-math-base-7b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-base-7b)   | [![在 OpenXLab 中打开](https:\u002F\u002Fcdn-static.openxlab.org.cn\u002Fheader\u002Fopenxlab_models.svg)](https:\u002F\u002Fopenxlab.org.cn\u002Fmodels\u002Fdetail\u002FOpenLMLab\u002FInternLM2-Math-Base-7B)  | [\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_375e99f5914e.png\" width=\"20px\" \u002F> internlm2-math-base-7b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-base-7b\u002Fsummary)   | 2024-01-23   |\n| **InternLM2-Math-Base-20B** | 基础       | [🤗internlm\u002Finternlm2-math-base-20b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-base-20b) | [![在 OpenXLab 中打开](https:\u002F\u002Fcdn-static.openxlab.org.cn\u002Fheader\u002Fopenxlab_models.svg)](https:\u002F\u002Fopenxlab.org.cn\u002Fmodels\u002Fdetail\u002FOpenLMLab\u002FInternLM2-Math-Base-20B) | [\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_375e99f5914e.png\" width=\"20px\" \u002F> internlm2-math-base-20b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-base-20b\u002Fsummary) | 2024-01-23   |\n| **InternLM2-Math-7B**       | 对话       | [🤗internlm\u002Finternlm2-math-7b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-7b)             | [![在 OpenXLab 中打开](https:\u002F\u002Fcdn-static.openxlab.org.cn\u002Fheader\u002Fopenxlab_models.svg)](https:\u002F\u002Fopenxlab.org.cn\u002Fmodels\u002Fdetail\u002FOpenLMLab\u002FInternLM2-Math-7B)       | [\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_375e99f5914e.png\" width=\"20px\" \u002F> internlm2-math-7b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-7b\u002Fsummary)             | 2024-01-23   |\n| **InternLM2-Math-20B**      | 对话       | [🤗internlm\u002Finternlm2-math-20b](https:\u002F\u002Fhuggingface.co\u002Finternlm\u002Finternlm2-math-20b)           | [![在 OpenXLab 中打开](https:\u002F\u002Fcdn-static.openxlab.org.cn\u002Fheader\u002Fopenxlab_models.svg)](https:\u002F\u002Fopenxlab.org.cn\u002Fmodels\u002Fdetail\u002FOpenLMLab\u002FInternLM2-Math-20B)      | [\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_375e99f5914e.png\" width=\"20px\" \u002F> internlm2-math-20b](https:\u002F\u002Fmodelscope.cn\u002Fmodels\u002FShanghai_AI_Laboratory\u002Finternlm2-math-20b\u002Fsummary)           | 2024-01-23   |\n\n\n# 性能\n\n## 预训练性能\n我们基于贪婪解码和少样本 COT 评估预训练检查点。预训练的详细信息将在技术报告中介绍。\n| 基准                   | GSM8K MAJ@1 | GSM8K MAJ@100 | MATH MAJ@1 | MATH MAJ@256 |\n| --------------------------- | ----------- | ------------- | ---------- | ------------ |\n| Llama2-7B                   | 14.6        | -             | 2.5        | -            |\n| Llemma-7B                   | 36.4        | 54.0          | 18.0       | 33.5         |\n| InternLM2-Base-7B           | 36.5        | -             | 8.6        | -            |\n| **InternLM2-Math-Base-7B**  | **49.2**    | **75.7**      | **21.5**   | **35.6**     |\n| Minerva-8B                  | 16.2        | 28.4          | 14.1       | 25.4         |\n| InternLM2-Base-20B          | 54.6        | -             | 13.7       | -            |\n| **InternLM2-Math-Base-20B** | **63.7**    | **84.8**      | **27.3**   | **46.2**     |\n| Llemma-34B                  | 51.5        | 69.3          | 25.0       | 43.1         |\n| Minerva-62B                 | 52.4        | 68.5          | 27.6       | 43.4         |\n| Minerva-540B                | 58.8        | 78.5          | 33.6       | 50.3         |\n\n我们使用 MiniF2F 上的少样本评估预训练检查点。请参阅 **eval\u002Fpretrain\u002Fminif2f** 进行评估。\n| 基准                   | MiniF2F-test |\n| --------------------------- | ------------ |\n| ReProver                    | 26.5         |\n| LLMStep                     | 27.9         |\n| Code-Llama-7B               | 26.2         |\n| Code-Llama-34B              | 25.8         |\n| Llemma-7B                   | 26.2         |\n| Llemma-34B                  | 25.8         |\n| **InternLM2-Math-7B-Base**  | 30.3         |\n| **InternLM2-Math-20B-Base** | 29.5         |\n\n\n## SFT 性能\n所有性能均基于带有 COT 的贪婪解码。我们注意到，匈牙利任务的表现在我们的不同检查点之间存在较大差异，而其他任务的表现则非常稳定。这可能是由于匈牙利任务的数量问题所致。\n| 模型                  | 模型类型  | GSM8K    | MATH     | 匈牙利 |\n| ---------------------- | ----------- | -------- | -------- | ------- |\n| Qwen-7B-Chat           | 通用      | 51.7     | 11.6     | -       |\n| DeepSeek-7B-Chat       | 通用      | 63.0     | 15.8     | 28.5    |\n| InternLM2-Chat-7B      | 通用      | 70.7     | 23.0     | -       |\n| ChatGLM3-6B            | 通用      | 53.8     | 20.4     | 32      |\n| MetaMath-Mistral-7B    | 数学      | 77.7     | 28.2     | 29      |\n| MetaMath-Llemma-7B     | 数学      | 69.2     | 30.0     | -       |\n| **InternLM2-Math-7B**  | 数学      | **78.1** | **34.6** | **55**  |\n| InternLM2-Chat-20B     | 通用      | 79.6     | 31.9     | -       |\n| MetaMath-Llemma-34B    | 数学      | 75.8     | 34.8     | -       |\n| **InternLM2-Math-20B** | 数学      | **82.6** | **37.7** | **66**  |\n| Qwen-72B               | 通用      | 78.9     | 35.2     | 52      |\n| DeepSeek-67B           | 通用      | 84.1     | 32.6     | 58      |\n| ChatGPT (GPT-3.5)      | 通用      | 80.8     | 34.1     | 41      |\n| GPT4（第一版）         | 通用      | 92.0     | 42.5     | 68      |\n\n## 代码解释器性能\n所有性能均基于与 Python 的交互测试。\n| 模型                          | GSM8K    | MATH     |\n| ------------------------------ | -------- | -------- |\n| DeepSeek-Coder-Instruct-7B     | 62.8     | 28.6     |\n| DeepSeek-Coder-Instruct-1.5-7B | 72.6     | 34.1     |\n| ToRA-7B                        | 72.6     | 44.6     |\n| MathCODER-CL-7B                | 67.8     | 30.2     |\n| InternLM2-Chat-7B              | 77.9     | 45.1     |\n| **InternLM2-Math-7B**          | **79.4** | **50.9** |\n| ToRA-13B                       | 75.8     | 48.1     |\n| MathCODER-CL-13B               | 74.1     | 35.9     |\n| InternLM2-Chat-20B             | **84.5** | 51.2     |\n| **InternLM2-Math-20B**         | 80.7     | **54.3** |\n| MathCODER-CL-34B               | 81.7     | 45.2     |\n| ToRA-70B                       | 84.3     | 49.7     |\n| GPT-4 Code Interpreter *       | **97.0** | **69.7** |\n\n# 评估\n您可以使用 [OpenCompass](https:\u002F\u002Fgithub.com\u002Fopen-compass\u002Fopencompass)，只需一条命令，即可轻松评估 InternLM2-Math 在多种数学数据集上的表现，例如 Math 和 GSM8K。开始之前，请先安装 OpenCompass，然后在终端中执行以下命令：\n\n```bash\npython run.py --models hf_internlm2_chat_math_7b --datasets gsm8k_gen math_gen_736506\n```\n\n或者，为了更便捷的操作，您也可以使用预定义的配置文件。为此，请运行下面的命令，并根据您的需求调整参数：\n\n```bash\npython run.py config\u002Feval_internlm_math_chat.py\n```\n\n# 推理\n\n## LMDeploy\n我们建议使用 [LMDeploy](https:\u002F\u002Fgithub.com\u002FInternLM\u002FLMDeploy)(>=0.2.1) 进行推理。\n```python\nfrom lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig\n\nbackend_config = TurbomindEngineConfig(model_name='internlm2-chat-7b', tp=1, cache_max_entry_count=0.3)\nchat_template = ChatTemplateConfig(model_name='internlm2-chat-7b', system='', eosys='', meta_instruction='')\npipe = pipeline(model_path='internlm\u002Finternlm2-math-7b', chat_template_config=chat_template, backend_config=backend_config)\n\nproblem = '1+1='\nresult = pipe([problem], request_output_len=1024, top_k=1)\n```\n\n## Huggingface\n```python\nimport torch\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\ntokenizer = AutoTokenizer.from_pretrained(\"internlm\u002Finternlm2-math-7b\", trust_remote_code=True)\n# 设置 `torch_dtype=torch.float16` 可以以 float16 格式加载模型，否则会以 float32 加载，可能导致 OOM 错误。\nmodel = AutoModelForCausalLM.from_pretrained(\"internlm\u002Finternlm2-math-7b\", trust_remote_code=True，torch_dtype=torch.float16).cuda()\nmodel = model.eval()\nresponse, history = model.chat(tokenizer，\"1+1=\"，history=[], meta_instruction=\"\")\nprint(response)\n```\n\n# 特殊用法\n我们列出了一些在我们的 SFT 训练中使用的指令，你可以参考这些来帮助你。当然，你也可以使用其他方式来引导模型，但以下方法是推荐的。InternLM2-Math 可能会结合以下能力，但并不保证一定能实现。\n\n将证明问题翻译成 Lean：\n![nl2lean3](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_7d1ca4c61cbc.jpeg)\n\n使用 Lean 3 解决 GSM8K 问题：\n![gsm8k_lean](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_6d3f15d829f0.jpeg)\n\n根据 Lean 3 代码生成题目：\n![lean_problem](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_c77a95a8bb41.jpeg)\n\n玩 24 点游戏：\n![24](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_2e1f27be90c0.jpeg)\n\n增强一道更难的数学题：\n![augment_hard](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_readme_5cec54fd319d.jpeg)\n\n| 描述                                                         | 查询                                                                                                        |\n| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |\n| 通过思维链解题                               | {问题}                                                                                                   |\n| 通过 Lean 3 解题                                         | {问题}\\n请用 Lean 3 来解决                                                                                 |\n| 结果奖励模型                                                | 给定一道题目和一个答案，判断其是否正确？\\n题目：{问题}\\n答案：{COT}                      |\n| 过程奖励模型                                                | 给定一道题目和一个答案，检查每一步的正确性。\\n题目：{问题}\\n答案：{COT}           |\n| 奖励模型                                                        | 给定一道题目和两个答案，哪个更好？ \\n题目：{问题}\\n答案 1：{COT}\\n答案 2：{COT} |\n| 将思维链转换为 Lean 3                                  | 请将这个答案转换成 Lean3 格式。 题目：{问题}\\n答案：{COT}                                            |\n| 将 Lean 3 转换为思维链                                  | 请将这段 Lean 3 代码转换成一道带有答案的自然语言题目：\\n{LEAN 代码}                          |\n| 将题目和思维链答案翻译成证明语句                       | 请将这道题目和答案转换成证明格式。\\n题目：{问题}\\n答案：{COT}                     |\n| 将证明问题翻译成 Lean 3                                   | 请将这段自然语言表述转换成 Lean 3 定理形式：{定理}                            |\n| 将 Lean 3 翻译成证明问题                                   | 请将这段 Lean 3 定理表述转换成自然语言：{陈述}                                      |\n| 根据 Lean 状态建议策略                                    | 给定 Lean 3 的策略状态，请建议下一步的策略：\\n{LEAN 状态}                                          |\n| 重新表述题目                                                    | 请用另一种方式描述这道题目。 {问题}                                                             |\n| 增强题目                                                     | 请基于：{问题} 增加一道新题                                                                   |\n| 增加难度                                                     | 提高题目的复杂度：{问题}                                                                           |\n| 更改特定数字                                             | 更改特定数字：{问题}                                                                          |\n| 引入分数或百分比                                  | 引入分数或百分比：{问题}                                                               |\n| 代码解释器                                                    | [lagent](https:\u002F\u002Fgithub.com\u002FInternLM\u002FInternLM\u002Fblob\u002Fmain\u002Fagent\u002Flagent.md)                                     |\n| 上下文学习                                                 | 题目：{问题}\\n答案：{COT}\\n...题目：{问题}\\n答案：{COT}                                      |\n\n# 微调及其他\n请参考 [InternLM](https:\u002F\u002Fgithub.com\u002FInternLM\u002FInternLM\u002Ftree\u002Fmain)。\n\n# 已知问题\n我们的模型仍在开发中，并将持续升级。InternLM-Math 目前仍存在一些潜在问题。如果你发现某些能力的表现不够理想，欢迎提交问题。\n- 跳过计算步骤。\n- 由于 SFT 数据构成的原因，在中文填空题和英文选择题上表现不佳。\n- 由于 SFT 数据构成的原因，面对中文问题时倾向于生成代码解释器。\n- 奖励模型模式可以通过分配更合适的 token 概率来进一步优化。\n- 由于 SFT 数据构成的原因，可能出现语言切换现象。\n- Lean 的部分能力仅适用于类似 GSM8K 的问题（例如将思维链转换为 Lean 3），且与 Lean 相关的表现并不保证。\n\n# 引用与技术报告\n```\n@misc{ying2024internlmmath,\n      title={InternLM-Math: 开放数学大语言模型迈向可验证推理}, \n      author={Ying Huaiyuan, Zhang Shuo, Li Linyang, Zhou Zhejian, Shao Yunfan, Fei Zhaoye, Ma Yichuan, Hong Jiawei, Liu Kuikun, Wang Ziyi, Wang Yudong, Wu Zijian, Li Shuaibin, Zhou Fengzhe, Liu Hongwei, Zhang Songyang, Zhang Wenwei, Yan Hang, Qiu Xipeng, Wang Jiayu, Chen Kai, Lin Dahua},\n      year={2024},\n      eprint={2402.06332},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n@misc{ying2024lean,\n      title={Lean 练习册：大规模从自然语言数学问题形式化而来的 Lean 题库}, \n      author={Ying Huaiyuan, Wu Zijian, Geng Yihan, Wang Jiayu, Lin Dahua, Chen Kai},\n      year={2024},\n      eprint={2406.03847},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n@misc{wu2024leangithubcompilinggithublean,\n      title={LEAN-GitHub：编译 GitHub 上的 LEAN 仓库以构建多功能 LEAN 定理证明器}, \n      author={Wu Zijian, Wang Jiayu, Lin Dahua, Chen Kai},\n      year={2024},\n      eprint={2407.17227},\n      archivePrefix={arXiv},\n      primaryClass={cs.AI},\n      url={https:\u002F\u002Farxiv.org\u002Fabs\u002F2407.17227}, \n}\n@misc{wu2024internlm25stepproveradvancingautomatedtheorem,\n      title={InternLM2.5-StepProver：通过大规模 LEAN 问题上的专家迭代推进自动定理证明}, \n      author={Wu Zijian, Huang Suozhi, Zhou Zhejian, Ying Huaiyuan, Wang Jiayu, Lin Dahua, Chen Kai},\n      year={2024},\n      eprint={2410.15700},\n      archivePrefix={arXiv},\n      primaryClass={cs.AI},\n      url={https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.15700}, \n}\n```","# InternLM-Math 快速上手指南\n\nInternLM-Math 是上海人工智能实验室推出的开源双语数学推理大语言模型系列。它兼具**求解器**、**证明器**、**验证器**和**数据增强器**的功能，支持非形式化数学推理（如 GSM8K、MATH）和形式化数学推理（基于 Lean 4）。本指南将帮助您快速部署并使用 InternLM2-Math-Plus 系列模型。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**: Linux (推荐 Ubuntu 20.04+) 或 macOS。\n*   **Python**: 3.8 或更高版本。\n*   **GPU**: 推荐使用 NVIDIA GPU。\n    *   `InternLM2-Math-Plus-1.8B`: 显存需求约 4GB+。\n    *   `InternLM2-Math-Plus-7B`: 显存需求约 16GB+ (FP16)。\n    *   更大参数模型（20B, 8x22B）需要多卡或高显存环境，建议使用量化推理。\n*   **前置依赖**:\n    *   `torch` (建议 2.0+)\n    *   `transformers` (建议 4.35+)\n    *   `accelerate`\n    *   `sentencepiece`\n\n## 安装步骤\n\n推荐使用 Python 虚拟环境进行安装。\n\n1.  **创建并激活虚拟环境**：\n    ```bash\n    python -m venv internlm-math-env\n    source internlm-math-env\u002Fbin\u002Factivate  # Windows 用户使用: internlm-math-env\\Scripts\\activate\n    ```\n\n2.  **安装核心依赖**：\n    为了加速下载，国内用户建议使用镜像源。\n    ```bash\n    pip install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118\n    pip install transformers accelerate sentencepiece -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n    ```\n\n3.  **安装 InternLM 专用库（可选但推荐）**：\n    如果需要完整功能（如特定的 Tokenizer 处理），可安装官方库：\n    ```bash\n    pip install git+https:\u002F\u002Fgithub.com\u002FInternLM\u002FInternLM.git -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n    ```\n\n## 基本使用\n\n以下示例展示如何使用 `transformers` 加载 **InternLM2-Math-Plus-7B** 模型进行简单的数学问题推理。\n\n### 1. 模型下载（国内加速）\n\n国内开发者推荐使用 **ModelScope (魔搭)** 或 **OpenXLab** 下载模型，速度更快。\n\n**方式 A：使用 ModelScope 下载**\n```bash\npip install modelscope -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n在 Python 代码中直接加载（自动缓存到本地）：\n```python\nfrom modelscope import snapshot_download\nmodel_dir = snapshot_download('Shanghai_AI_Laboratory\u002Finternlm2-math-plus-7b')\n```\n\n**方式 B：使用 Hugging Face (需网络条件)**\n```python\nfrom huggingface_hub import snapshot_download\nmodel_dir = snapshot_download('internlm\u002Finternlm2-math-plus-7b')\n```\n\n### 2. 推理代码示例\n\n创建一个名为 `infer.py` 的文件，填入以下代码。该示例展示了如何加载模型并进行对话式数学推理。\n\n```python\nimport torch\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\n\n# 配置模型路径 (如果使用 ModelScope 下载，填写本地路径; 否则填写 HF repo ID)\n# 例如: model_path = \".\u002FShanghai_AI_Laboratory\u002Finternlm2-math-plus-7b\"\nmodel_path = \"internlm\u002Finternlm2-math-plus-7b\" \n\n# 加载分词器和模型\n# trust_remote_code=True 是加载 InternLM 系列模型的必要参数\ntokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)\nmodel = AutoModelForCausalLM.from_pretrained(\n    model_path, \n    torch_dtype=torch.float16, \n    device_map=\"auto\", \n    trust_remote_code=True\n)\nmodel.eval()\n\n# 构建输入提示 (Prompt)\n# InternLM2-Math 通常遵循标准的对话格式\nquery = \"Alice has 5 apples and Bob gives her 3 more. How many apples does Alice have now?\"\nhistory = [] # 历史对话列表，多轮对话时保留\n\n# 生成回答\nresponse, history = model.chat(tokenizer, query, history=history)\n\nprint(f\"问题: {query}\")\nprint(f\"回答: {response}\")\n```\n\n### 3. 运行测试\n\n在终端执行脚本：\n```bash\npython infer.py\n```\n\n**预期输出示例：**\n```text\n问题: Alice has 5 apples and Bob gives her 3 more. How many apples does Alice have now?\n回答: Alice originally has 5 apples. Bob gives her 3 more apples. So, the total number of apples Alice has now is 5 + 3 = 8.\n```\n\n### 进阶提示：代码解释器模式\nInternLM2-Math-Plus 支持调用 Python 代码解决复杂数学问题。在构造 Prompt 时，模型会自动识别是否需要生成代码块。若需强制开启代码解释器功能，请确保在推理参数中允许模型生成 `\u003C|action_start|>\u003C|interpreter|>` 等特殊标记（具体取决于使用的推理框架版本，上述 `model.chat` 接口已内置基础支持）。","某高校数学建模团队正致力于将复杂的竞赛题目转化为形式化证明，以验证解题逻辑的严密性并构建自动解题系统。\n\n### 没有 InternLM-Math 时\n- **自然语言转形式化困难**：队员需手动将中文或英文的题目描述逐句翻译为 Lean 4 代码，耗时极长且极易出现符号定义错误。\n- **证明搜索效率低下**：面对复杂定理，传统求解器往往无法找到证明路径，导致大量题目卡在“已知条件”到“结论”的最后一步。\n- **验证反馈滞后**：错误的证明尝试需要人工反复检查逻辑漏洞，缺乏实时的自动化批判与修正建议，迭代周期以天计算。\n- **多语言能力受限**：现有的开源模型大多仅支持英文推理，处理中文奥数题或教材内容时需先经过低质量的机器翻译，丢失关键语义。\n\n### 使用 InternLM-Math 后\n- **精准自动形式化**：利用 InternLM-Math 的双语能力，直接输入中文题目即可生成高质量的 Lean 4 形式化陈述，准确率大幅提升，初始化时间从小时级缩短至分钟级。\n- **智能分步证明**：借助其 Step-Prover 策略模型，系统能自动拆解证明步骤，在 MiniF2F 等基准测试中展现出 SOTA 级别的推理能力，成功攻克以往无法自动证明的难题。\n- **实时自我修正**：Critic 模型充当“虚拟审稿人”，实时评估每一步推导的合理性并提供修正建议，实现了从“试错”到“自优化”的闭环。\n- **原生双语推理**：无需翻译预处理，InternLM-Math 直接在中文语境下进行思维链（Chain-of-Thought）推理和代码解释器调用，完美保留题目中的文化背景与特殊表述。\n\nInternLM-Math 通过打通自然语言理解与形式化证明的壁垒，将数学研究从繁琐的手工编码中解放出来，让科研人员能专注于更高阶的逻辑创新。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FInternLM_InternLM-Math_69badfe3.jpg","InternLM","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FInternLM_bc4eb14c.png","",null,"internlm@pjlab.org.cn","intern_lm","https:\u002F\u002Fchat.intern-ai.org.cn\u002F","https:\u002F\u002Fgithub.com\u002FInternLM",[85,89,93],{"name":86,"color":87,"percentage":88},"Python","#3572A5",92.9,{"name":90,"color":91,"percentage":92},"Shell","#89e051",3.7,{"name":94,"color":79,"percentage":95},"Lean",3.4,543,37,"2026-04-07T21:25:39","Apache-2.0","未说明",{"notes":102,"python":100,"dependencies":103},"README 主要介绍了模型的性能指标、数据集、检查点下载链接（HuggingFace, ModelScope, OpenXLab）以及数学推理能力。文中未明确列出具体的运行环境需求（如操作系统、GPU 型号、显存大小、Python 版本或依赖库列表）。用户需参考提供的 HuggingFace Spaces 演示或相关论文以获取具体的部署配置建议。",[],[15,46],"2026-03-27T02:49:30.150509","2026-04-09T01:04:52.166928",[108,113,118,123,127,131],{"id":109,"question_zh":110,"answer_zh":111,"source_url":112},25359,"使用 OpenCompass 评估 InternLM2-Math-Plus-7B 时准确率极低（如 5.06%）怎么办？","这通常是因为模型文件损坏或配置不匹配导致的。解决方案如下：\n1. 重新从 HuggingFace 下载 InternLM2-Math-Plus-7B 模型。\n2. 评估时设置 batch-size=1。\n3. 确保使用正确的 Prompt 模板。官方 MATH 数据集的 ChatML 格式 Prompt 为：\n\u003C|im_start|>user\\nProblem:\\n{问题内容}\\nLet's think step by step\\nSolution:\\n\u003C|im_end|>\\n\u003C|im_start|>assistant\\n\n如果不使用 ChatML 模板，格式为：\nProblem:\\n{问题内容}\\nLet's think step by step\\nSolution:","https:\u002F\u002Fgithub.com\u002FInternLM\u002FInternLM-Math\u002Fissues\u002F24",{"id":114,"question_zh":115,"answer_zh":116,"source_url":117},25360,"Lean-Workbook 中的定理证明是使用什么模型生成的？相关代码是否开源？","Lean-Workbook 中的完整证明搜索使用的是经过微调的 InternLM-Math-Plus-20B 模型。目前完整的证明搜索代码尚未公开，因为团队仍在改进整体证明能力。暂时的替代方案是使用提供的 Lean-Workbook 数据来训练您自己的完整证明搜索模型。此外，用于数据提取和自然语言推理（NLI）的翻译模型也是基于 InternLM-Math-Plus-20B 微调而成的。","https:\u002F\u002Fgithub.com\u002FInternLM\u002FInternLM-Math\u002Fissues\u002F30",{"id":119,"question_zh":120,"answer_zh":121,"source_url":122},25361,"InternLM2.5-StepProver 中 Critic-Guide 搜索与 BFS 搜索在 Lean 交互次数和时间成本上有何区别？","两者在 Lean 交互方式上没有区别。对于 Best-First (BF) 和 Critic-Guide (CG)，采样数（例如 32）代表生成的策略候选数量。每个候选都会传递给 Lean REPL 以获取下一个 Lean 状态。\n- BF 通过平均对数概率分数对这些状态进行排名。\n- CG 将这些 Lean 状态传递给批判模型（Critic Model）进行评分。\n因此，两者每一步都需要与 Lean 编译器交互相同的次数，时间成本主要取决于生成候选和 Lean 执行的时间，而非排序或评分机制本身。","https:\u002F\u002Fgithub.com\u002FInternLM\u002FInternLM-Math\u002Fissues\u002F42",{"id":124,"question_zh":125,"answer_zh":126,"source_url":122},25362,"在 Critic-Guide 搜索中，如果策略导致编译错误会被直接丢弃吗？这对公平性有影响吗？","是的，导致错误的策略会被丢弃，但这在 BF 和 CG 中是一致的，因此是公平的。\n1. 如果 Lean 的 C++ 内核抛出异常，无论使用 CG 还是 BF，Lean 进程都会立即终止。\n2. 如果是由 Lean 本身抛出的异常（表示某些策略候选不可行），这些候选自然会被丢弃。\n获取 Critic 模型评分的前提确实是编译成功并获得状态信息，无法编译的策略无法进入评分阶段，这与 BF 中无法获得有效状态从而无法计算概率分数的逻辑是等效的。",{"id":128,"question_zh":129,"answer_zh":130,"source_url":122},25363,"Critic 模型使用的 Prompt 模板是什么样的？","Critic 模型的 Prompt 模板旨在让模型判断哪个状态更接近“无目标”（no goals，即证明完成）。一个有效的实现示例如下：\n\nprompt = \"Which state is closer to 'no goals'?\"\nanswer1 = \"no goals\"\nchat = [\n    {\"role\": \"user\", \"content\": prompt},\n    {\"role\": \"assistant\", \"content\": answer1}\n]\nscore = critic_model.get_score(tokenizer, chat)\n\n这种简单的指令跟随格式已被验证是有效的。",{"id":132,"question_zh":133,"answer_zh":134,"source_url":135},25364,"运行 Lean 4 REPL 时遇到导入错误或无法编译的问题如何解决？","这通常是 Lean 4 版本不匹配导致的。该项目的环境是基于 Lean v4.7.0 及其对应的 mathlib 版本构建的。\n在新版本的 Lean 中，一些导入路径发生了变化（例如 `Mathlib.Algebra.BigOperators.Basic` 在新版中被移除或移动），导致代码无法编译。\n**解决方案**：请将您的 Lean 环境版本切换为 **v4.7.0**，并确保使用与该版本兼容的 mathlib，这样即可正常运行 REPL 和相关代码。","https:\u002F\u002Fgithub.com\u002FInternLM\u002FInternLM-Math\u002Fissues\u002F31",[]]