{"kind":"task","effective_mode":"full","benchmark":{"kind":"benchmark","effective_mode":"full","slug":"longbench-v2","formal_name":"LongBench v2","introduction":"長い資料の深い理解と推論を、多肢選択問題で評価するベンチマークです。公式紹介では503問を収録し、単一・複数文書の質問応答やコードリポジトリ理解などを扱います。\n\nLongBench v2 evaluates deep understanding and reasoning over long contexts through multiple-choice questions. Its official description lists 503 questions spanning tasks such as single-document and multi-document QA and code-repository understanding.","introduction_ja":"","introduction_en":"","category":"Category not supplied","task_count":null,"acquisition_status":"Acquisition status not supplied","official_url":"https://huggingface.co/datasets/zai-org/LongBench-v2","indexing_mode":"noindex"},"task_id":"08fb2b8b-55ba-53b1-8622-b4483efe9fff","task_key":"train--66fab090bb02136c067c74e7","task_revision_id":"1","upstream_id":"66fab090bb02136c067c74e7","short_description":"Regarding the comparison of the methods for improving math ability in these two…","config":"","split":"train","body":"{\"choice_A\":\"The methods of both articles include extracting math-related web pages from Common Crawl and processing them for pre-training.\",\"choice_B\":\"Both articles use 7B as one of the training model sizes. Mammoth2 experiments on more models of different sizes, while the DeepSeekMath article does not train models of other sizes.\",\"choice_C\":\"DeepSeekMath improves the PPO algorithm and uses the current round of training data to estimate the advantage instead of using the value model that needs to be updated.\",\"choice_D\":\"The GSM8k and MATH scores of MAmmoTH2-Plus are lower than those of Deepseek-Math-RL.\",\"context\":\"Abstract\\nMathematical reasoning poses a significant challenge for language models due to its complex\\nand structured nature. In this paper, we introduce DeepSeekMath 7B, which continues pre-\\ntraining DeepSeek-Coder-Base-v1.5 7B with 120B math-related tokens sourced from Common\\nCrawl, together with natural language and code data. DeepSeekMath 7B has achieved an\\nimpressive score of 51.7% on the competition-level MATH benchmark without relying on\\nexternal toolkits and voting techniques, approaching the performance level of Gemini-Ultra\\nand GPT-4. Self-consistency over 64 samples from DeepSeekMath 7B achieves 60.9% on MATH.\\nThe mathematical reasoning capability of DeepSeekMath is attributed to two key factors: First,\\nwe harness the significant potential of publicly available web data through a meticulously\\nengineered data selection pipeline. Second, we introduce Group Relative Policy Optimization\\n(GRPO), a variant of Proximal Policy Optimization (PPO), that enhances mathematical reasoning\\nabilities while concurrently optimizing the memory usage of PPO.\\nFigure 1 | Top1 accuracy of open-source models on the competition-level MATH benchmark\\n(Hendrycks et al., 2021) without the use of external toolkits and voting techniques.\\n∗Core contributors.\\n† Work done during internship at DeepSeek-AI.\\narXiv:2402.03300v3  [cs.CL]  27 Apr 2024\\n\\n\\n1. Introduction\\nLarge language models (LLM) have revolutionized the approach to mathematical reasoning\\nin artificial intelligence, spurring significant advancements in both the quantitative reasoning\\nbenchmark (Hendrycks et al., 2021) and the geometry reasoning benchmark (Trinh et al., 2024).\\nMoreover, these models have proven instrumental in assisting humans in solving complex\\nmathematical problems (Tao, 2023). However, cutting-edge models such as GPT-4 (OpenAI,\\n2023) and Gemini-Ultra (Anil et al., 2023) are not publicly available, and the currently accessible\\nopen-source models considerably trail behind in performance.\\nIn this study, we introduce DeepSeekMath, a domain-specific language model that signifi-\\ncantly outperforms the mathematical capabilities of open-source models and approaches the\\nperformance level of GPT-4 on academic benchmarks. To achieve this, we create the DeepSeek-\\nMath Corpus, a large-scale high-quality pre-training corpus comprising 120B math tokens. This\\ndataset is extracted from the Common Crawl (CC) using a fastText-based classifier (Joulin et al.,\\n2016). In the initial iteration, the classifier is trained using instances from OpenWebMath (Paster\\net al., 2023) as positive examples, while incorporating a diverse selection of other web pages to\\nserve as negative examples. Subsequently, we employ the classifier to mine additional positive\\ninstances from the CC, which are further refined through human annotation. The classifier is\\nthen updated with this enhanced dataset to improve its performance. The evaluation results\\nindicate that the large-scale corpus is of high quality, as our base model DeepSeekMath-Base\\n7B achieves 64.2% on GSM8K (Cobbe et al., 2021) and 36.2% on the competition-level MATH\\ndataset (Hendrycks et al., 2021), outperforming Minerva 540B (Lewkowycz et al., 2022a). In\\naddition, the DeepSeekMath Corpus is multilingual, so we notice an improvement in Chinese\\nmathematical benchmarks (Wei et al., 2023; Zhong et al., 2023). We believe that our experience\\nin mathematical data processing is a starting point for the research community, and there is\\nsignificant room for improvement in the future.\\nDeepSeekMath-Base is initialized with DeepSeek-Coder-Base-v1.5 7B (Guo et al., 2024), as\\nwe notice that starting from a code training model is a better choice compared to a general\\nLLM. Furthermore, we observe the math training also improves model capability on MMLU\\n(Hendrycks et al., 2020) and BBH benchmarks (Suzgun et al., 2022), indicating it does not only\\nenhance the model’s mathematical abilities but also amplifies general reasoning capabilities.\\nAfter pre-training, we apply mathematical instruction tuning to DeepSeekMath-Base with\\nchain-of-thought (Wei et al., 2022), program-of-thought (Chen et al., 2022; Gao et al., 2023), and\\ntool-integrated reasoning (Gou et al., 2023) data. The resulting model DeepSeekMath-Instruct\\n7B beats all 7B counterparts and is comparable with 70B open-source instruction-tuned models.\\nFurthermore, we introduce the Group Relative Policy Optimization (GRPO), a variant rein-\\nforcement learning (RL) algorithm of Proximal Policy Optimization (PPO) (Schulman et al., 2017).\\nGRPO foregoes the critic model, instead estimating the baseline from group scores, significantly\\nreducing training resources. By solely using a subset of English instruction tuning data, GRPO\\nobtains a substantial improvement over the strong DeepSeekMath-Instruct, including both\\nin-domain (GSM8K: 82.9% →88.2%, MATH: 46.8% →51.7%) and out-of-domain mathematical\\ntasks (e.g., CMATH: 84.6% →88.8%) during the reinforcement learning phase. We also provide\\na unified paradigm to understand different methods, such as Rejection Sampling Fine-Tuning\\n(RFT) (Yuan et al., 2023a), Direct Preference Optimization (DPO) (Rafailov et al., 2023), PPO and\\nGRPO. Based on such a unified paradigm, we find that all these methods are conceptualized as\\neither direct or simplified RL techniques. We also conduct extensive experiments, e.g., online\\nv.s. offline training, outcome v.s. process supervision, single-turn v.s. iterative RL and so on,\\n2\\n\\n\\nto deeply investigate the essential elements of this paradigm. At last, we explain why our RL\\nboosts the performance of instruction-tuned models, and further summarize potential directions\\nto achieve more effective RL based on this unified paradigm.\\n1.1. Contributions\\nOur contribution includes scalable math pre-training, along with the exploration and analysis of\\nreinforcement learning.\\nMath Pre-Training at Scale\\n• Our research provides compelling evidence that the publicly accessible Common Crawl\\ndata contains valuable information for mathematical purposes. By implementing a metic-\\nulously designed data selection pipeline, we successfully construct the DeepSeekMath\\nCorpus, a high-quality dataset of 120B tokens from web pages filtered for mathemati-\\ncal content, which is almost 7 times the size of the math web pages used by Minerva\\n(Lewkowycz et al., 2022a) and 9 times the size of the recently released OpenWebMath\\n(Paster et al., 2023).\\n• Our pre-trained base model DeepSeekMath-Base 7B achieves comparable performance\\nwith Minerva 540B (Lewkowycz et al., 2022a), indicating the number of parameters is not\\nthe only key factor in mathematical reasoning capability. A smaller model pre-trained on\\nhigh-quality data could achieve strong performance as well.\\n• We share our findings from math training experiments. Code training prior to math\\ntraining improves models’ ability to solve mathematical problems both with and without\\ntool use. This offers a partial answer to the long-standing question: does code training\\nimprove reasoning abilities? We believe it does, at least for mathematical reasoning.\\n• Although training on arXiv papers is common, especially in many math-related papers, it\\nbrings no notable improvements on all mathematical benchmarks adopted in this paper.\\nExploration and Analysis of Reinforcement Learning\\n• We introduce Group Relative Policy Optimization (GRPO), an efficient and effective\\nreinforcement learning algorithm. GRPO foregoes the critic model, instead estimating\\nthe baseline from group scores, significantly reducing training resources compared to\\nProximal Policy Optimization (PPO).\\n• We demonstrate that GRPO significantly enhances the performance of our instruction-\\ntuned model DeepSeekMath-Instruct, by solely using the instruction-tuning data. Further-\\nmore, we observe enhancements in the out-of-domain performance during the reinforce-\\nment learning process.\\n• We provide a unified paradigm to understand different methods, such as RFT, DPO,\\nPPO, and GRPO. We also conduct extensive experiments, e.g., online v.s. offline training,\\noutcome v.s. process supervision, single-turn v.s. iterative reinforcement learning, and so\\non to deeply investigate the essential elements of this paradigm.\\n• Based on our unified paradigm, we explore the reasons behind the effectiveness of rein-\\nforcement learning, and summarize several potential directions to achieve more effective\\nreinforcement learning of LLMs.\\n1.2. Summary of Evaluations and Metrics\\n• English and Chinese Mathematical Reasoning: We conduct comprehensive assessments\\nof our models on English and Chinese benchmarks, covering mathematical problems\\n3\\n\\n\\nfrom grade-school level to college level. English benchmarks include GSM8K (Cobbe\\net al., 2021), MATH (Hendrycks et al., 2021), SAT (Azerbayev et al., 2023), OCW Courses\\n(Lewkowycz et al., 2022a), MMLU-STEM (Hendrycks et al., 2020). Chinese benchmarks\\ninclude MGSM-zh (Shi et al., 2023), CMATH (Wei et al., 2023), Gaokao-MathCloze (Zhong\\net al., 2023), and Gaokao-MathQA (Zhong et al., 2023). We evaluate models’ ability\\nto generate self-contained text solutions without tool use, and also the ability to solve\\nproblems using Python.\\nOn English benchmarks, DeepSeekMath-Base is competitive with the closed-source Min-\\nerva 540B (Lewkowycz et al., 2022a), and surpasses all open-source base models (e.g., Mis-\\ntral 7B (Jiang et al., 2023) and Llemma-34B (Azerbayev et al., 2023)), regardless of whether\\nthey’ve undergone math pre-training or not, often by a significant margin. Notably,\\nDeepSeekMath-Base is superior on Chinese benchmarks, likely because we don’t follow\\nprevious works (Azerbayev et al., 2023; Lewkowycz et al., 2022a) to collect English-only\\nmath pre-training data, and also include high-quality non-English ones. With mathemati-\\ncal instruction tuning and reinforcement learning, the resulting DeepSeekMath-Instruct\\nand DeepSeekMath-RL demonstrate strong performance, obtaining an accuracy of over\\n50% on the competition-level MATH dataset for the first time within the open-source\\ncommunity.\\n• Formal Mathematics: We evaluate DeepSeekMath-Base using the informal-to-formal\\ntheorem proving task from (Jiang et al., 2022) on miniF2F (Zheng et al., 2021) with Isabelle\\n(Wenzel et al., 2008) chosen to be the proof assistant. DeepSeekMath-Base demonstrates\\nstrong few-shot autoformalization performance.\\n• Natural Language Understanding, Reasoning, and Code: To build a comprehensive\\nprofile of models’ general understanding, reasoning, and coding capabilities, we eval-\\nuate DeepSeekMath-Base on the Massive Multitask Language Understanding (MMLU)\\nbenchmark (Hendrycks et al., 2020) which encompasses 57 multiple-choice tasks covering\\ndiverse subjects, BIG-Bench Hard (BBH) (Suzgun et al., 2022) which consists of 23 chal-\\nlenging tasks that mostly require multi-step reasoning to solve, as well as HumanEval\\n(Chen et al., 2021) and MBPP (Austin et al., 2021) which are widely used to evaluate code\\nlanguage models. Math pre-training benefits both language understanding and reasoning\\nperformance.\\n2. Math Pre-Training\\n2.1. Data Collection and Decontamination\\nIn this section, we will outline the process of constructing the DeepSeekMath Corpus from\\nCommon Crawl. As depicted in Figure 2, we present an iterative pipeline that demonstrates\\nhow to systematically gather a large-scale mathematical corpus from Common Crawl, starting\\nwith a seed corpus (e.g., a small but high-quality collection of math-related dataset). It’s worth\\nnoting that this approach is also applicable to other domains, such as coding.\\nFirst, we choose OpenWebMath (Paster et al., 2023), a collection of high-quality mathematical\\nweb texts, as our initial seed corpus. Using this corpus, we train a fastText model (Joulin et al.,\\n2016) to recall more OpenWebMath-like mathematical web pages. Specifically, we randomly\\nselect 500,000 data points from the seed corpus as positive training examples and another\\n500,000 web pages from Common Crawl as negative ones. We employ an open-source library1\\nfor training, configuring the vector dimension to 256, learning rate to 0.1, the maximum length\\n1https://fasttext.cc\\n4\\n\\n\\nMath Seed\\nMath Corpus\\n1. Train a FastText Model\\n2. Recall Math-Related Webpages \\nFrom Common Crawl\\n3. Discover Math-Related Domains\\n4. Annotate Math-Related \\nURL Path From Labelers\\nDeduplicated Common Crawl\\n40B HTML pages\\nFigure 2 | An iterative pipeline that collects mathematical web pages from Common Crawl.\\nof word n-gram to 3, the minimum number of word occurrences to 3, and the number of\\ntraining epochs to 3. To reduce the size of the original Common Crawl, we employ URL-based\\ndeduplication and near-deduplication techniques, resulting in 40B HTML web pages. We then\\nrecall mathematical web pages from deduplicated Common Crawl with the fastText model.\\nTo filter out low-quality mathematical content, we rank the collected pages according to their\\nscores predicted by the fastText model, and only preserve the top-ranking ones. The volume\\nof data preserved is assessed through pre-training experiments on the top 40B, 80B, 120B, and\\n160B tokens. In the first iteration, we choose to keep the top 40B tokens.\\nAfter the first iteration of data collection, numerous mathematical web pages remain un-\\ncollected, mainly because the fastText model is trained on a set of positive examples that lacks\\nsufficient diversity. We therefore identify additional mathematical web sources to enrich the seed\\ncorpus, so that we can optimize the fastText model. Specifically, we first organize the entire Com-\\nmon Crawl into disjoint domains; a domain is defined as web pages sharing the same base URL.\\nFor each domain, we calculate the percentage of web pages that are collected in the first iteration.\\nDomains where over 10% of the web pages have been collected are classified as math-related\\n(e.g., mathoverflow.net). Subsequently, we manually annotate the URLs associated with\\nmathematical content within these identified domains (e.g., mathoverflow.net/questions).\\nWeb pages linked to these URLs, yet uncollected, will be added to the seed corpus. This ap-\\nproach enables us to gather more positive examples, thereby training an improved fastText\\nmodel capable of recalling more mathematical data in the subsequent iteration. After four\\niterations of data collection, we end up with 35.5M mathematical web pages, totaling 120B\\ntokens. In the fourth iteration, we notice that nearly 98% of the data has already been collected\\nin the third iteration, so we decide to cease data collection.\\nTo avoid benchmark contamination, we follow Guo et al. (2024) to filter out web pages\\ncontaining questions or answers from English mathematical benchmarks such as GSM8K (Cobbe\\net al., 2021) and MATH (Hendrycks et al., 2021) and Chinese benchmarks such as CMATH\\n(Wei et al., 2023) and AGIEval (Zhong et al., 2023). The filtering criteria are as follows: any\\ntext segment containing a 10-gram string that matches exactly with any sub-string from the\\nevaluation benchmarks is removed from our math training corpus. For benchmark texts that\\nare shorter than 10 grams but have at least 3 grams, we employ exact matching to filter out\\ncontaminated web pages.\\n5\\n\\n\\n2.2. Validating the Quality of the DeepSeekMath Corpus\\nWe run pre-training experiments to investigate how the DeepSeekMath Corpus is compared\\nwith the recently released math-training corpora:\\n• MathPile (Wang et al., 2023c): a multi-source corpus (8.9B tokens) aggregated from\\ntextbooks, Wikipedia, ProofWiki, CommonCrawl, StackExchange, and arXiv, with the\\nmajority (over 85%) sourced from arXiv;\\n• OpenWebMath (Paster et al., 2023): CommonCrawl data filtered for mathematical content,\\ntotaling 13.6B tokens;\\n• Proof-Pile-2 (Azerbayev et al., 2023): a mathematical corpus consisting of OpenWeb-\\nMath, AlgebraicStack (10.3B tokens of mathematical code), and arXiv papers (28.0B to-\\nkens). When experimenting on Proof-Pile-2, we follow Azerbayev et al. (2023) to use an\\narXiv:Web:Code ratio of 2:4:1.\\n2.2.1. Training Setting\\nWe apply math training to a general pre-trained language model with 1.3B parameters, which\\nshares the same framework as the DeepSeek LLMs (DeepSeek-AI, 2024), denoted as DeepSeek-\\nLLM 1.3B. We separately train a model on each mathematical corpus for 150B tokens. All\\nexperiments are conducted using the efficient and light-weight HAI-LLM (High-flyer, 2023)\\ntraining framework. Following the training practice of DeepSeek LLMs, we use the AdamW\\noptimizer (Loshchilov and Hutter, 2017) with 𝛽1 = 0.9, 𝛽2 = 0.95, and weight_decay = 0.1, along\\nwith a multi-step learning rate schedule where the learning rate reaches the peak after 2,000\\nwarmup steps, decreases to its 31.6% after 80% of the training process, and further decreases to\\n10.0% of the peak after 90% of the training process. We set the maximum value of learning rate\\nto 5.3e-4, and use a batch size of 4M tokens with a 4K context length.\\nMath Corpus\\nSize\\nEnglish Benchmarks\\nChinese Benchmarks\\nGSM8K MATH OCW\\nSAT\\nMMLU\\nSTEM\\nCMATH\\nGaokao\\nMathCloze\\nGaokao\\nMathQA\\nNo Math Training\\nN/A\\n2.9%\\n3.0%\\n2.9% 15.6%\\n19.5%\\n12.3%\\n0.8%\\n17.9%\\nMathPile\\n8.9B\\n2.7%\\n3.3%\\n2.2% 12.5%\\n15.7%\\n1.2%\\n0.0%\\n2.8%\\nOpenWebMath\\n13.6B\\n11.5%\\n8.9%\\n3.7% 31.3%\\n29.6%\\n16.8%\\n0.0%\\n14.2%\\nProof-Pile-2\\n51.9B\\n14.3%\\n11.2%\\n3.7% 43.8%\\n29.2%\\n19.9%\\n5.1%\\n11.7%\\nDeepSeekMath Corpus 120.2B\\n23.8%\\n13.6%\\n4.8% 56.3%\\n33.1%\\n41.5%\\n5.9%\\n23.6%\\nTable 1 | Performance of DeepSeek-LLM 1.3B trained on different mathematical corpora, evalu-\\nated using few-shot chain-of-thought prompting. Corpus sizes are calculated using our tokenizer\\nwith a vocabulary size of 100K.\\n2.2.2. Evaluation Results\\nThe DeepSeekMath Corpus is of high quality, covers multilingual mathematical content, and\\nis the largest in size.\\n• High-quality: We evaluate downstream performance on 8 mathematical benchmarks using\\nfew-shot chain-of-thought prompting Wei et al. (2022). As shown in Table 1, there is a clear\\nperformance lead of the model trained on the DeepSeekMath Corpus. Figure 3 shows that\\nthe model trained on the DeepSeekMath Corpus demonstrates better performance than\\n6\\n\\n\\nFigure 3 | Benchmark curves of DeepSeek-LLM 1.3B trained on different mathematical corpora.\\nProof-Pile-2 at 50B tokens (1 full epoch of Proof-Pile-2), indicating the average quality of\\nDeepSeekMath Corpus is higher.\\n• Multilingual: The DeepSeekMath Corpus encompasses data in multiple languages, pre-\\ndominantly featuring English and Chinese as the two most represented languages. As\\nshown in Table 1, training on the DeepSeekMath Corpus enhances mathematical reasoning\\nperformance in both English and Chinese. In contrast, existing mathematical corpora,\\nwhich are primarily English-centric, show limited improvement and may even hinder\\nperformance in Chinese mathematical reasoning.\\n• Large-scale: The DeepSeekMath Corpus is several times larger than existing mathematical\\ncorpora. As depicted in Figure 3, DeepSeek-LLM 1.3B, when trained on the DeepSeek-\\nMath Corpus, shows a steeper learning curve along with more lasting improvements. In\\ncontrast, the baseline corpora are much smaller, and have already been repeated multiple\\nrounds during training, with the resulting model performance quickly reaching a plateau.\\n2.3. Training and Evaluating DeepSeekMath-Base 7B\\nIn this section, we introduce DeepSeekMath-Base 7B, a base model with strong reasoning\\nabilities, especially in mathematics. Our model is initialized with DeepSeek-Coder-Base-v1.5 7B\\n7\\n\\n\\n(Guo et al., 2024) and trained for 500B tokens. The distribution of the data is as follows: 56%\\nis from the DeepSeekMath Corpus, 4% from AlgebraicStack, 10% from arXiv, 20% is Github\\ncode, and the remaining 10% is natural language data from Common Crawl in both English and\\nChinese. We mainly adopt the training setting specified in Section 2.2.1, except that we set the\\nmaximum value of the learning rate to 4.2e-4 and use a batch size of 10M tokens.\\nWe conduct a comprehensive assessment of the mathematical capabilities of DeepSeekMath-\\nBase 7B, focusing on its ability to produce self-contained mathematical solutions without relying\\non external tools, solve mathematical problems using tools, and conduct formal theorem proving.\\nBeyond mathematics, we also provide a more general profile of the base model, including its\\nperformance of natural language understanding, reasoning, and programming skills.\\nMathematical Problem Solving with Step-by-Step Reasoning\\nWe evaluate DeepSeekMath-\\nBase’s performance of solving mathematical problems using few-shot chain-of-thought prompt-\\ning (Wei et al., 2022), across eight benchmarks in English and Chinese. These benchmarks encom-\\npass quantitative reasoning (e.g., GSM8K (Cobbe et al., 2021), MATH (Hendrycks et al., 2021),\\nand CMATH (Wei et al., 2023)) and multiple-choice problems (e.g., MMLU-STEM (Hendrycks\\net al., 2020) and Gaokao-MathQA (Zhong et al., 2023)), covering diverse fields of mathematics\\nfrom elementary to college-level complexity.\\nAs shown in Table 2, DeepSeekMath-Base 7B leads in performance across all eight bench-\\nmarks among the open-source base models (including the widely-used general model Mistral\\n7B (Jiang et al., 2023) and the recently released Llemma 34B (Azerbayev et al., 2023) which\\nunderwent math training on Proof-Pile-2 (Azerbayev et al., 2023)). Notably, on the competition-\\nlevel MATH dataset, DeepSeekMath-Base surpasses existing open-source base models by over\\n10% absolute, and outperforms Minerva 540B (Lewkowycz et al., 2022a), a closed-source base\\nmodel 77 times larger which builds on PaLM (Lewkowycz et al., 2022b) and is further trained\\non mathematical texts.\\nModel\\nSize\\nEnglish Benchmarks\\nChinese Benchmarks\\nGSM8K MATH OCW\\nSAT\\nMMLU\\nSTEM\\nCMATH\\nGaokao\\nMathCloze\\nGaokao\\nMathQA\\nClosed-Source Base Model\\nMinerva\\n7B\\n16.2%\\n14.1%\\n7.7%\\n-\\n35.6%\\n-\\n-\\n-\\nMinerva\\n62B\\n52.4%\\n27.6%\\n12.0%\\n-\\n53.9%\\n-\\n-\\n-\\nMinerva\\n540B\\n58.8%\\n33.6%\\n17.6%\\n-\\n63.9%\\n-\\n-\\n-\\nOpen-Source Base Model\\nMistral\\n7B\\n40.3%\\n14.3%\\n9.2%\\n71.9%\\n51.1%\\n44.9%\\n5.1%\\n23.4%\\nLlemma\\n7B\\n37.4%\\n18.1%\\n6.3%\\n59.4% 43.1%\\n43.4%\\n11.9%\\n23.6%\\nLlemma\\n34B\\n54.0%\\n25.3%\\n10.3% 71.9%\\n52.9%\\n56.1%\\n11.9%\\n26.2%\\nDeepSeekMath-Base 7B\\n64.2%\\n36.2% 15.4% 84.4%\\n56.5%\\n71.7%\\n20.3%\\n35.3%\\nTable 2 | Comparisons between DeepSeekMath-Base 7B and strong base models on English and\\nChinese mathematical benchmarks. Models are evaluated with chain-of-thought prompting.\\nMinerva results are quoted from Lewkowycz et al. (2022a).\\n8\\n\\n\\nMathematical Problem Solving with Tool Use\\nWe evaluate program-aided mathematical\\nreasoning on GSM8K and MATH using few-shot program-of-thought prompting (Chen et al.,\\n2022; Gao et al., 2023). Models are prompted to solve each problem by writing a Python program\\nwhere libraries such as math and sympy can be utilized for intricate computations. The execution\\nresult of the program is evaluated as the answer. As shown in Table 3, DeepSeekMath-Base 7B\\noutperforms the prior state-of-the-art Llemma 34B.\\nModel\\nSize\\nProblem Solving w/ Tools\\nInformal-to-Formal Proving\\nGSM8K+Python MATH+Python miniF2F-valid miniF2F-test\\nMistral\\n7B\\n48.5%\\n18.2%\\n18.9%\\n18.0%\\nCodeLlama\\n7B\\n27.1%\\n17.2%\\n16.3%\\n17.6%\\nCodeLlama\\n34B\\n52.7%\\n23.5%\\n18.5%\\n18.0%\\nLlemma\\n7B\\n41.0%\\n18.6%\\n20.6%\\n22.1%\\nLlemma\\n34B\\n64.6%\\n26.3%\\n21.0%\\n21.3%\\nDeepSeekMath-Base 7B\\n66.9%\\n31.4%\\n25.8%\\n24.6%\\nTable 3 | Few-shot evaluation of base models’ ability to solve mathematical problems using tools\\nand the ability to conduct informal-to-formal theorem proving in Isabelle.\\nFormal Mathematics\\nFormal proof automation is beneficial to ensure the accuracy and relia-\\nbility of mathematical proofs and enhance efficiency, with increasing attention in recent years.\\nWe evaluate DeepSeekMath-Base 7B on the task of informal-to-formal proving from (Jiang et al.,\\n2022) which is to generate a formal proof based on an informal statement, a formal counterpart\\nof the statement, and an informal proof. We evaluate on miniF2F (Zheng et al., 2021), a bench-\\nmark for formal Olympiad-level mathematics, and generate a formal proof in Isabelle for each\\nproblem with few-shot prompting. Following Jiang et al. (2022), we leverage models to generate\\nproof sketches, and execute the off-the-shelf automated prover Sledgehammer (Paulson, 2010)\\nto fill in the missing details. As shown in Table 3, DeepSeekMath-Base 7B demonstrates strong\\nperformance in proof autoformalization.\\nModel\\nSize MMLU\\nBBH\\nHumanEval (Pass@1) MBPP (Pass@1)\\nMistral\\n7B\\n62.4%\\n55.7%\\n28.0%\\n41.4%\\nDeepSeek-Coder-Base-v1.5† 7B\\n42.9%\\n42.9%\\n40.2%\\n52.6%\\nDeepSeek-Coder-Base-v1.5\\n7B\\n49.1%\\n55.2%\\n43.2%\\n60.4%\\nDeepSeekMath-Base\\n7B\\n54.9%\\n59.5%\\n40.9%\\n52.6%\\nTable 4 | Evaluation on natural language understanding, reasoning, and code benchmarks.\\nDeepSeek-Coder-Base-v1.5† is the checkpoint right before learning rate decay, which is used to\\ntrain DeepSeekMath-Base. On MMLU and BBH, we use few-shot chain-of-thought prompting.\\nOn HumanEval and MBPP, we evaluate model performance under the zero-shot setting and a\\nfew-shot setting, respectively.\\nNatural Language Understanding, Reasoning, and Code\\nWe evaluate model performance of\\nnatural language understanding on MMLU (Hendrycks et al., 2020), reasoning on BBH (Suzgun\\net al., 2022), and coding capabilities on HumanEval (Chen et al., 2021) and MBPP (Austin et al.,\\n9\\n\\n\\n2021). As shown in Table 4, DeepSeekMath-Base 7B exhibits significant enhancements in per-\\nformance on MMLU and BBH over its precursor, DeepSeek-Coder-Base-v1.5 (Guo et al., 2024),\\nillustrating the positive impact of math training on language understanding and reasoning.\\nAdditionally, by including code tokens for continual training, DeepSeekMath-Base 7B effectively\\nmaintains the performance of DeepSeek-Coder-Base-v1.5 on the two coding benchmarks. Over-\\nall, DeepSeekMath-Base 7B significantly outperforms the general model Mistral 7B (Jiang et al.,\\n2023) on the three reasoning and coding benchmarks.\\n3. Supervised Fine-Tuning\\n3.1. SFT Data Curation\\nWe construct a mathematical instruction-tuning dataset covering English and Chinese problems\\nfrom different mathematical fields and of varying complexity levels: problems are paired with\\nsolutions in chain-of-thought (CoT) (Wei et al., 2022), program-of-thought (PoT) (Chen et al.,\\n2022; Gao et al., 2023), and tool-integrated reasoning format (Gou et al., 2023). The total number\\nof training examples is 776K.\\n• English mathematical datasets: We annotate GSM8K and MATH problems with tool-\\nintegrated solutions, and adopt a subset of MathInstruct (Yue et al., 2023) along with the\\ntraining set of Lila-OOD (Mishra et al., 2022) where problems are solved with CoT or\\nPoT. Our English collection covers diverse fields of mathematics, e.g., algebra, probability,\\nnumber theory, calculus, and geometry.\\n• Chinese mathematical datasets: We collect Chinese K-12 mathematical problems spanning\\n76 sub-topics such as linear equations, with solutions annotated in both CoT and tool-\\nintegrated reasoning format.\\n3.2. Training and Evaluating DeepSeekMath-Instruct 7B\\nIn this section, we introduce DeepSeekMath-Instruct 7B which undergoes mathematical instruc-\\ntion tuning based on DeepSeekMath-Base. Training examples are randomly concatenated until\\nreaching a maximum context length of 4K tokens. We train the model for 500 steps with a batch\\nsize of 256 and a constant learning rate of 5e-5.\\nWe evaluate models’ mathematical performance both without and with tool use, on 4\\nquantitative reasoning benchmarks in English and Chinese. We benchmark our model against\\nthe leading models of the time:\\n• Closed-source models include: (1) the GPT family among which GPT-4 (OpenAI, 2023)\\nand GPT-4 Code Interpreter 2 are the most capable ones, (2) Gemini Ultra and Pro (Anil\\net al., 2023), (3) Inflection-2 (Inflection AI, 2023), (4) Grok-1 3, as well as models recently\\nreleased by Chinese companies including (5) Baichuan-3 4, (6) the latest GLM-4 5 from the\\nGLM family (Du et al., 2022). These models are for general purposes, most of which have\\nundergone a series of alignment procedures.\\n• Open-source models include: general models like (1) DeepSeek-LLM-Chat 67B (DeepSeek-\\nAI, 2024), (2) Qwen 72B (Bai et al., 2023), (3) SeaLLM-v2 7B (Nguyen et al., 2023), and (4)\\n2https://openai.com/blog/chatgpt-plugins#code-interpreter\\n3https://x.ai/model-card\\n4https://www.baichuan-ai.com\\n5https://open.bigmodel.cn/dev/api#glm-4\\n10\\n\\n\\nChatGLM3 6B (ChatGLM3 Team, 2023), as well as models with enhancements in mathemat-\\nics including (5) InternLM2-Math 20B 6 which builds on InternLM2 and underwent math\\ntraining followed by instruction tuning, (6) Math-Shepherd-Mistral 7B which applys PPO\\ntraining (Schulman et al., 2017) to Mistral 7B (Jiang et al., 2023) with a process-supervised\\nreward model, (7) the WizardMath series (Luo et al., 2023) which improves mathematical\\nreasoning in Mistral 7B and Llama-2 70B (Touvron et al., 2023) using evolve-instruct (i.e.,\\na version of instruction tuning that uses AI-evolved instructions) and PPO training with\\ntraining problems primarily sourced from GSM8K and MATH, (8) MetaMath 70B (Yu et al.,\\n2023) which is Llama-2 70B fine-tuned on an augmented version of GSM8K and MATH,\\n(9) ToRA 34B Gou et al. (2023) which is CodeLlama 34B fine-tuned to do tool-integrated\\nmathematical reasoning, (10) MAmmoTH 70B (Yue et al., 2023) which is Llama-2 70B\\ninstruction-tuned on MathInstruct.\\nAs shown in Table 5, under the evaluation setting where tool use is disallowed, DeepSeekMath-\\nInstruct 7B demonstrates strong performance of step-by-step reasoning.\\nNotably, on the\\ncompetition-level MATH dataset, our model surpasses all open-source models and the ma-\\njority of proprietary models (e.g., Inflection-2 and Gemini Pro) by at least 9% absolute. This\\nis true even for models that are substantially larger (e.g., Qwen 72B) or have been specifi-\\ncally enhanced through math-focused reinforcement learning (e.g., WizardMath-v1.1 7B). While\\nDeepSeekMath-Instruct rivals the Chinese proprietary models GLM-4 and Baichuan-3 on MATH,\\nit still underperforms GPT-4 and Gemini Ultra.\\nUnder the evaluation setting where models are allowed to integrate natural language rea-\\nsoning and program-based tool use for problem solving, DeepSeekMath-Instruct 7B approaches\\nan accuracy of 60% on MATH, surpassing all existing open-source models. On the other bench-\\nmarks, our model is competitive with DeepSeek-LLM-Chat 67B, the prior state-of-the-art that is\\n10 times larger.\\n4. Reinforcement Learning\\n4.1. Group Relative Policy Optimization\\nReinforcement learning (RL) has been proven to be effective in further improving the mathe-\\nmatical reasoning ability of LLMs after the Supervised Fine-Tuning (SFT) stage (Luo et al., 2023;\\nWang et al., 2023b). In this section, we introduce our efficient and effective RL algorithm, Group\\nRelative Policy Optimization (GRPO).\\n4.1.1. From PPO to GRPO\\nProximal Policy Optimization (PPO) (Schulman et al., 2017) is an actor-critic RL algorithm that is\\nwidely used in the RL fine-tuning stage of LLMs (Ouyang et al., 2022). In particular, it optimizes\\nLLMs by maximizing the following surrogate objective:\\nJ\\n𝑃𝑃𝑂(𝜃) = E[𝑞∼𝑃(𝑄), 𝑜∼𝜋𝜃𝑜𝑙𝑑(𝑂|𝑞)] 1\\n|𝑜|\\n|𝑜|\\n∑︁\\n𝑡=1\\nmin\\n\\u0014 𝜋𝜃(𝑜𝑡|𝑞, 𝑜<𝑡)\\n𝜋𝜃𝑜𝑙𝑑(𝑜𝑡|𝑞, 𝑜<𝑡) 𝐴𝑡, clip\\n\\u0012 𝜋𝜃(𝑜𝑡|𝑞, 𝑜<𝑡)\\n𝜋𝜃𝑜𝑙𝑑(𝑜𝑡|𝑞, 𝑜<𝑡) , 1 −𝜀, 1 + 𝜀\\n\\u0013\\n𝐴𝑡\\n\\u0015\\n,\\n(1)\\nwhere 𝜋𝜃and 𝜋𝜃𝑜𝑙𝑑are the current and old policy models, and 𝑞, 𝑜are questions and outputs\\nsampled from the question dataset and the old policy 𝜋𝜃𝑜𝑙𝑑, respectively. 𝜀is a clipping-related\\nhyper-parameter introduced in PPO for stabilizing training. 𝐴𝑡is the advantage, which is\\ncomputed by applying Generalized Advantage Estimation (GAE) (Schulman et al., 2015), based\\n6https://github.com/InternLM/InternLM-Math\\n11\\n\\n\\nModel\\nSize English Benchmarks Chinese Benchmarks\\nGSM8K\\nMATH\\nMGSM-zh CMATH\\nChain-of-Thought Reasoning\\nClosed-Source Model\\nGemini Ultra\\n-\\n94.4%\\n53.2%\\n-\\n-\\nGPT-4\\n-\\n92.0%\\n52.9%\\n-\\n86.0%\\nInflection-2\\n-\\n81.4%\\n34.8%\\n-\\n-\\nGPT-3.5\\n-\\n80.8%\\n34.1%\\n-\\n73.8%\\nGemini Pro\\n-\\n86.5%\\n32.6%\\n-\\n-\\nGrok-1\\n-\\n62.9%\\n23.9%\\n-\\n-\\nBaichuan-3\\n-\\n88.2%\\n49.2%\\n-\\n-\\nGLM-4\\n-\\n87.6%\\n47.9%\\n-\\n-\\nOpen-Source Model\\nInternLM2-Math\\n20B\\n82.6%\\n37.7%\\n-\\n-\\nQwen\\n72B\\n78.9%\\n35.2%\\n-\\n-\\nMath-Shepherd-Mistral\\n7B\\n84.1%\\n33.0%\\n-\\n-\\nWizardMath-v1.1\\n7B\\n83.2%\\n33.0%\\n-\\n-\\nDeepSeek-LLM-Chat\\n67B\\n84.1%\\n32.6%\\n74.0%\\n80.3%\\nMetaMath\\n70B\\n82.3%\\n26.6%\\n66.4%\\n70.9%\\nSeaLLM-v2\\n7B\\n78.2%\\n27.5%\\n64.8%\\n-\\nChatGLM3\\n6B\\n72.3%\\n25.7%\\n-\\n-\\nWizardMath-v1.0\\n70B\\n81.6%\\n22.7%\\n64.8%\\n65.4%\\nDeepSeekMath-Instruct 7B\\n82.9%\\n46.8%\\n73.2%\\n84.6%\\nDeepSeekMath-RL\\n7B\\n88.2%\\n51.7%\\n79.6%\\n88.8%\\nTool-Integrated Reasoning\\nClosed-Source Model\\nGPT-4 Code Interpreter\\n-\\n97.0%\\n69.7%\\n-\\n-\\nOpen-Source Model\\nInternLM2-Math\\n20B\\n80.7%\\n54.3%\\n-\\n-\\nDeepSeek-LLM-Chat\\n67B\\n86.7%\\n51.1%\\n76.4%\\n85.4%\\nToRA\\n34B\\n80.7%\\n50.8%\\n41.2%\\n53.4%\\nMAmmoTH\\n70B\\n76.9%\\n41.8%\\n-\\n-\\nDeepSeekMath-Instruct 7B\\n83.7%\\n57.4%\\n72.0%\\n84.3%\\nDeepSeekMath-RL\\n7B\\n86.7%\\n58.8%\\n78.4%\\n87.6%\\nTable 5 | Performance of Open- and Closed-Source models with both Chain-of-Thought and\\nTool-Integrated Reasoning on English and Chinese Benchmarks. Scores in gray denote majority\\nvotes with 32 candidates; The others are Top1 scores. DeepSeekMath-RL 7B beats all open-\\nsource models from 7B to 70B, as well as the majority of closed-source models. Although\\nDeepSeekMath-RL 7B is only further trained on chain-of-thought-format instruction tuning data\\nof GSM8K and MATH, it improves over DeepSeekMath-Instruct 7B on all benchmarks.\\n12\\n\\n\\n𝑞𝑞\\n𝑜𝑜!\\n𝑜𝑜\\\"\\n𝑜𝑜#\\n𝑟𝑟\\n!\\n𝑟𝑟\\\"\\n𝑟𝑟#\\n𝐴𝐴!\\n𝐴𝐴\\\"\\n𝐴𝐴#\\n𝑞𝑞\\n𝑜𝑜\\nGAE\\n𝐴𝐴\\n𝑟𝑟\\n𝑣𝑣\\nReward \\nModel\\nPolicy \\nModel\\nValue \\nModel\\n…\\n…\\n…\\nPolicy \\nModel\\nReference \\nModel\\nReward \\nModel\\nPPO\\nGRPO\\nTrained\\nModels\\nFrozen\\nModels\\nReference \\nModel\\n⊕\\n𝐾𝐾𝐾𝐾\\n𝐾𝐾𝐾𝐾\\nGroup \\nComputation\\nFigure 4 | Demonstration of PPO and our GRPO. GRPO foregoes the value model, instead\\nestimating the baseline from group scores, significantly reducing training resources.\\non the rewards {𝑟≥𝑡} and a learned value function 𝑉𝜓. Thus, in PPO, a value function needs to\\nbe trained alongside the policy model and to mitigate over-optimization of the reward model,\\nthe standard approach is to add a per-token KL penalty from a reference model in the reward at\\neach token (Ouyang et al., 2022), i.e.,\\n𝑟𝑡= 𝑟𝜑(𝑞, 𝑜≤𝑡) −𝛽log 𝜋𝜃(𝑜𝑡|𝑞, 𝑜<𝑡)\\n𝜋𝑟𝑒𝑓(𝑜𝑡|𝑞, 𝑜<𝑡) ,\\n(2)\\nwhere 𝑟𝜑is the reward model, 𝜋𝑟𝑒𝑓is the reference model, which is usually the initial SFT model,\\nand 𝛽is the coefficient of the KL penalty.\\nAs the value function employed in PPO is typically another model of comparable size as\\nthe policy model, it brings a substantial memory and computational burden. Additionally,\\nduring RL training, the value function is treated as a baseline in the calculation of the advantage\\nfor variance reduction. While in the LLM context, usually only the last token is assigned a\\nreward score by the reward model, which may complicate the training of a value function that is\\naccurate at each token. To address this, as shown in Figure 4, we propose Group Relative Policy\\nOptimization (GRPO), which obviates the need for additional value function approximation as\\nin PPO, and instead uses the average reward of multiple sampled outputs, produced in response\\nto the same question, as the baseline. More specifically, for each question 𝑞, GRPO samples a\\ngroup of outputs {𝑜1, 𝑜2, · · · , 𝑜𝐺} from the old policy 𝜋𝜃𝑜𝑙𝑑and then optimizes the policy model\\nby maximizing the following objective:\\nJ\\n𝐺𝑅𝑃𝑂(𝜃) = E[𝑞∼𝑃(𝑄), {𝑜𝑖}𝐺\\n𝑖=1 ∼𝜋𝜃𝑜𝑙𝑑(𝑂|𝑞)]\\n1\\n𝐺\\n𝐺\\n∑︁\\n𝑖=1\\n1\\n|𝑜𝑖|\\n|𝑜𝑖|\\n∑︁\\n𝑡=1\\n\\u001a\\nmin\\n\\u0014 𝜋𝜃(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡)\\n𝜋𝜃𝑜𝑙𝑑(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡)\\nˆ\\n𝐴𝑖,𝑡, clip\\n\\u0012 𝜋𝜃(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡)\\n𝜋𝜃𝑜𝑙𝑑(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡) , 1 −𝜀, 1 + 𝜀\\n\\u0013\\nˆ\\n𝐴𝑖,𝑡\\n\\u0015\\n−𝛽D𝐾𝐿\\n\\u0002\\n𝜋𝜃||𝜋𝑟𝑒𝑓\\n\\u0003\\u001b\\n,\\n(3)\\nwhere 𝜀and 𝛽are hyper-parameters, and ˆ\\n𝐴𝑖,𝑡is the advantage calculated based on relative\\nrewards of the outputs inside each group only, which will be detailed in the following subsec-\\ntions. The group relative way that GRPO leverages to calculate the advantages, aligns well with\\nthe comparative nature of rewards models, as reward models are typically trained on datasets\\nof comparisons between outputs on the same question. Also note that, instead of adding KL\\npenalty in the reward, GRPO regularizes by directly adding the KL divergence between the\\ntrained policy and the reference policy to the loss, avoiding complicating the calculation of ˆ\\n𝐴𝑖,𝑡.\\n13\\n\\n\\nAlgorithm 1 Iterative Group Relative Policy Optimization\\nInput initial policy model 𝜋𝜃init; reward models 𝑟𝜑; task prompts D; hyperparameters 𝜀, 𝛽, 𝜇\\n1: policy model 𝜋𝜃←𝜋𝜃init\\n2: for iteration = 1, ..., I do\\n3:\\nreference model 𝜋𝑟𝑒𝑓←𝜋𝜃\\n4:\\nfor step = 1, ..., M do\\n5:\\nSample a batch D𝑏from D\\n6:\\nUpdate the old policy model 𝜋𝜃𝑜𝑙𝑑←𝜋𝜃\\n7:\\nSample 𝐺outputs {𝑜𝑖}𝐺\\n𝑖=1 ∼𝜋𝜃𝑜𝑙𝑑(· | 𝑞) for each question 𝑞∈D𝑏\\n8:\\nCompute rewards {𝑟𝑖}𝐺\\n𝑖=1 for each sampled output 𝑜𝑖by running 𝑟𝜑\\n9:\\nCompute ˆ\\n𝐴𝑖,𝑡for the 𝑡-th token of 𝑜𝑖through group relative advantage estimation.\\n10:\\nfor GRPO iteration = 1, ..., 𝜇do\\n11:\\nUpdate the policy model 𝜋𝜃by maximizing the GRPO objective (Equation 21)\\n12:\\nUpdate 𝑟𝜑through continuous training using a replay mechanism.\\nOutput 𝜋𝜃\\nAnd different from the KL penalty term used in (2), we estimate the KL divergence with the\\nfollowing unbiased estimator (Schulman, 2020):\\nD𝐾𝐿\\n\\u0002\\n𝜋𝜃||𝜋𝑟𝑒𝑓\\n\\u0003\\n=\\n𝜋𝑟𝑒𝑓(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡)\\n𝜋𝜃(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡) −log\\n𝜋𝑟𝑒𝑓(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡)\\n𝜋𝜃(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡) −1,\\n(4)\\nwhich is guaranteed to be positive.\\n4.1.2. Outcome Supervision RL with GRPO\\nFormally, for each question 𝑞, a group of outputs {𝑜1, 𝑜2, · · · , 𝑜𝐺} are sampled from the old\\npolicy model 𝜋𝜃𝑜𝑙𝑑. A reward model is then used to score the outputs, yielding 𝐺rewards\\nr = {𝑟1, 𝑟2, · · · , 𝑟𝐺} correspondingly. Subsequently, these rewards are normalized by subtracting\\nthe group average and dividing by the group standard deviation. Outcome supervision provides\\nthe normalized reward at the end of each output 𝑜𝑖and sets the advantages ˆ\\n𝐴𝑖,𝑡of all tokens in\\nthe output as the normalized reward, i.e., ˆ\\n𝐴𝑖,𝑡= e\\n𝑟𝑖= 𝑟𝑖−mean(r)\\nstd(r)\\n, and then optimizes the policy by\\nmaximizing the objective defined in equation (3).\\n4.1.3. Process Supervision RL with GRPO\\nOutcome supervision only provides a reward at the end of each output, which may not be\\nsufficient and efficient to supervise the policy in complex mathematical tasks. Following Wang\\net al. (2023b), we also explore process supervision, which provides a reward at the end of\\neach reasoning step. Formally, given the question 𝑞and 𝐺sampled outputs {𝑜1, 𝑜2, · · · , 𝑜𝐺}, a\\nprocess reward model is used to score each step of the outputs, yielding corresponding rewards:\\nR = {{𝑟𝑖𝑛𝑑𝑒𝑥(1)\\n1\\n, · · · , 𝑟𝑖𝑛𝑑𝑒𝑥(𝐾1)\\n1\\n}, · · · , {𝑟𝑖𝑛𝑑𝑒𝑥(1)\\n𝐺\\n, · · · , 𝑟𝑖𝑛𝑑𝑒𝑥(𝐾𝐺)\\n𝐺\\n}}, where 𝑖𝑛𝑑𝑒𝑥( 𝑗) is the end token index\\nof the 𝑗-th step, and 𝐾𝑖is the total number of steps in the 𝑖-th output. We also normalize these\\nrewards with the average and the standard deviation, i.e.,e\\n𝑟𝑖𝑛𝑑𝑒𝑥( 𝑗)\\n𝑖\\n=\\n𝑟𝑖𝑛𝑑𝑒𝑥( 𝑗)\\n𝑖\\n−mean(R)\\nstd(R)\\n. Subsequently,\\nthe process supervision calculates the advantage of each token as the sum of the normalized\\nrewards from the following steps, i.e., ˆ\\n𝐴𝑖,𝑡= Í\\n𝑖𝑛𝑑𝑒𝑥( 𝑗)≥𝑡e\\n𝑟𝑖𝑛𝑑𝑒𝑥( 𝑗)\\n𝑖\\n, and then optimizes the policy by\\nmaximizing the objective defined in equation (3).\\n14\\n\\n\\n4.1.4. Iterative RL with GRPO\\nAs the reinforcement learning training process progresses, the old reward model may not be\\nsufficient to supervise the current policy model. Therefore, we also explore the iterative RL\\nwith GRPO. As shown in Algorithm 1, in iterative GRPO, we generate new training sets for the\\nreward model based on the sampling results from the policy model and continually train the\\nold reward model using a replay mechanism that incorporates 10% of historical data. Then, we\\nset the reference model as the policy model, and continually train the policy model with the\\nnew reward model.\\n4.2. Training and Evaluating DeepSeekMath-RL\\nWe conduct RL based on DeepSeekMath-Instruct 7B. The training data of RL are chain-of-\\nthought-format questions related to GSM8K and MATH from the SFT data, which consists\\nof around 144K questions. We exclude other SFT questions to investigate the impact of RL\\non benchmarks that lack data throughout the RL phase. We construct the training set of\\nreward models following (Wang et al., 2023b). We train our initial reward model based on the\\nDeepSeekMath-Base 7B with a learning rate of 2e-5. For GRPO, we set the learning rate of the\\npolicy model as 1e-6. The KL coefficient is 0.04. For each question, we sample 64 outputs. The\\nmax length is set to 1024, and the training batch size is 1024. The policy model only has a single\\nupdate following each exploration stage. We evaluate DeepSeekMath-RL 7B on benchmarks\\nfollowing DeepSeekMath-Instruct 7B. For DeepSeekMath-RL 7B, GSM8K and MATH with\\nchain-of-thought reasoning can be regarded as in-domain tasks and all the other benchmarks\\ncan be regarded as out-of-domain tasks.\\nTable 5 demonstrates the performance of open- and closed-source models with both chain-\\nof-thought and tool-integrated reasoning on English and Chinese benchmarks. We find that:\\n1) DeepSeekMath-RL 7B attains accuracies of 88.2% and 51.7% on GSM8K and MATH, respec-\\ntively, utilizing chain-of-thought reasoning. This performance surpasses that of all open-source\\nmodels in the 7B to 70B range, as well as the majority of closed-source models. 2) Crucially,\\nDeepSeekMath-RL 7B is only trained on chain-of-thought-format instruction tuning data of\\nGSM8K and MATH, starting from DeepSeekMath-Instruct 7B. Despite the constrained scope\\nof its training data, it outperforms DeepSeekMath-Instruct 7B across all evaluation metrics,\\nshowcasing the effectiveness of reinforcement learning.\\n5. Discussion\\nIn this section, we will share our findings in pre-training and RL experiments.\\n5.1. Lessons Learnt in Pre-Training\\nWe first share our experience in pre-training. Unless otherwise specified, we will adhere to\\nthe training settings outlined in Section 2.2.1. It is worth noting that, when referring to the\\nDeepSeekMath Corpus in this section, we use an 89B-token dataset from the second iteration of\\nthe data collection process.\\n5.1.1. Code Training Benefits Mathematical Reasoning\\nA popular yet unverified hypothesis suggests that code training improves reasoning. We attempt\\nto offer a partial response to this, particularly within the mathematical domain: code training\\n15\\n\\n\\nTraining Setting\\nTraining Tokens\\nw/o Tool Use\\nw/ Tool Use\\nGeneral Code Math GSM8K MATH CMATH GSM8K+Python MATH+Python\\nNo Continual Training\\n–\\n–\\n–\\n2.9%\\n3.0%\\n12.3%\\n2.7%\\n2.3%\\nTwo-Stage Training\\nStage 1: General Training\\n400B\\n–\\n–\\n2.9%\\n3.2%\\n14.8%\\n3.3%\\n2.3%\\nStage 2: Math Training\\n–\\n–\\n150B\\n19.1%\\n14.4%\\n37.2%\\n14.3%\\n6.7%\\nStage 1: Code Training\\n–\\n400B –\\n5.9%\\n3.6%\\n19.9%\\n12.4%\\n10.0%\\nStage 2: Math Training\\n–\\n–\\n150B\\n21.9%\\n15.3%\\n39.7%\\n17.4%\\n9.4%\\nOne-Stage Training\\nMath Training\\n–\\n–\\n150B\\n20.5%\\n13.1%\\n37.6%\\n11.4%\\n6.5%\\nCode & Math Mixed Training –\\n400B 150B\\n17.6%\\n12.1%\\n36.3%\\n19.7%\\n13.5%\\nTable 6 | Investigation of how code affects mathematical reasoning under different training\\nsettings. We experiment with DeepSeek-LLM 1.3B, and evaluate its mathematical reasoning\\nperformance without and with tool use via few-shot chain-of-thought prompting and few-shot\\nprogram-of-thought prompting, respectively.\\nimproves models’ ability to do mathematical reasoning both with and without tool use.\\nTo study how code training affects mathematical reasoning, we experimented with the\\nfollowing two-stage training and one-stage training settings:\\nTwo-Stage Training\\n• Code Training for 400B Tokens →Math Training for 150B Tokens: We train DeepSeek-\\nLLM 1.3B for 400B code tokens followed by 150B math tokens;\\n• General Training for 400B Tokens →Math Training for 150B Tokens: As a control\\nexperiment, we also experiment with general tokens (sampled from a large-scale general\\ncorpus created by DeepSeek-AI) instead of code tokens in the first stage of training, in an\\nattempt to investigate the advantages of code tokens over general tokens in improving\\nmathematical reasoning.\\nOne-Stage Training\\n• Math Training for 150B Tokens: We train DeepSeek-LLM 1.3B for 150B math tokens;\\n• Training on a mixture of 400B Code Tokens and 150B Math Tokens: Math training fol-\\nlowing code training degrades coding performance. We investigate whether code tokens,\\nwhen mixed with math tokens for one-stage training, would still improve mathematical\\nreasoning and also alleviate the problem of catastrophic forgetting.\\nResults\\nTable 6 and Table 7 demonstrate the downstream performance under different training\\nsettings.\\nCode training benefits program-aided mathematical reasoning, both under the two-stage\\ntraining and one-stage training settings. As shown in Table 6, under the two-stage training\\nsetting, code training alone already significantly enhances the ability to solve GSM8K and\\nMATH problems using Python. Math training in the second stage yields further improvements.\\nInterestingly, under the one-stage training setting, mixing code tokens and math tokens effec-\\ntively mitigates the issue of catastrophic forgetting that arises from two-stage training, and also\\nsynergizes coding (Table 7) and program-aided mathematical reasoning (Table 6).\\n16\\n\\n\\nTraining Setting\\nTraining Tokens\\nMMLU\\nBBH\\nHumanEval (Pass@1) MBPP (Pass@1)\\nGeneral Code Math\\nNo Continual Training\\n–\\n–\\n–\\n24.5%\\n28.1%\\n12.2%\\n13.0%\\nTwo-Stage Training\\nStage 1: General Training\\n400B\\n–\\n–\\n25.9%\\n27.7%\\n15.2%\\n13.6%\\nStage 2: Math Training\\n–\\n–\\n150B\\n33.1%\\n32.7%\\n12.8%\\n13.2%\\nStage 1: Code Training\\n–\\n400B –\\n25.0%\\n31.5%\\n25.0%\\n40.0%\\nStage 2: Math Training\\n–\\n–\\n150B\\n36.2%\\n35.3%\\n12.2%\\n17.0%\\nOne-Stage Training\\nMath Training\\n–\\n–\\n150B\\n32.3%\\n32.5%\\n11.6%\\n13.2%\\nCode & Math Mixed Training –\\n400B 150B\\n33.5%\\n35.6%\\n29.3%\\n39.4%\\nTable 7 | Investigation of how different settings of code and math training affect model perfor-\\nmance of language understanding, reasoning, and coding. We experiment with DeepSeek-LLM\\n1.3B. We evaluate the models on MMLU and BBH using few-shot chain-of-thought prompting.\\nOn HumanEval and MBPP, we conduct zero-shot and few-shot evaluations, respectively.\\nModel\\nSize ArXiv Corpus\\nEnglish Benchmarks\\nChinese Benchmarks\\nGSM8K MATH OCW\\nSAT\\nMMLU\\nSTEM\\nCMATH\\nGaokao\\nMathCloze\\nGaokao\\nMathQA\\nDeepSeek-LLM\\n1.3B\\nNo Math Training\\n2.9%\\n3.0%\\n2.9% 15.6%\\n19.5%\\n12.3%\\n0.8%\\n17.9%\\nMathPile\\n2.7%\\n3.3%\\n2.2% 12.5%\\n15.7%\\n1.2%\\n0.0%\\n2.8%\\nArXiv-RedPajama\\n3.3%\\n3.4%\\n4.0%\\n9.4%\\n9.0%\\n7.4%\\n0.8%\\n2.3%\\nDeepSeek-Coder-Base-v1.5 7B\\nNo Math Training\\n29.0%\\n12.5%\\n6.6% 40.6%\\n38.1%\\n45.9%\\n5.9%\\n21.1%\\nMathPile\\n23.6%\\n11.5%\\n7.0% 46.9%\\n35.8%\\n37.9%\\n4.2%\\n25.6%\\nArXiv-RedPajama\\n28.1%\\n11.1%\\n7.7% 50.0%\\n35.2%\\n42.6%\\n7.6%\\n24.8%\\nTable 8 | Effect of math training on different arXiv datasets. Model performance is evaluated\\nwith few-shot chain-of-thought prompting.\\nArXiv Corpus\\nminiF2F-valid miniF2F-test\\nNo Math Training\\n20.1%\\n21.7%\\nMathPile\\n16.8%\\n16.4%\\nArXiv-RedPajama\\n14.8%\\n11.9%\\nTable 9 | Effect of math training on different arXiv corpora, the base model being DeepSeek-\\nCoder-Base-v1.5 7B. We evaluate informal-to-formal proving in Isabelle.\\nCode training also improves mathematical reasoning without tool use. Under the two-stage\\ntraining setting, the initial stage of code training already results in moderate enhancements.\\nIt also boosts the efficiency of the subsequent math training, eventually leading to the best\\nperformance. However, combining code tokens and math tokens for one-stage training com-\\npromises mathematical reasoning without tool use. One conjecture is that DeepSeek-LLM 1.3B,\\ndue to its limited scale, lacks the capacity to fully assimilate both code and mathematical data\\nsimultaneously.\\n5.1.2. ArXiv Papers Seem Ineffective in Improving Mathematical Reasoning\\nArXiv papers are commonly included as a component of math pre-training data (Azerbayev\\net al., 2023; Lewkowycz et al., 2022a; Polu and Sutskever, 2020; Wang et al., 2023c). However,\\n17\\n\\n\\ndetailed analysis regarding their impact on mathematical reasoning has not been extensively\\nconducted. Perhaps counter-intuitively, according to our experiments, arXiv papers seem\\nineffective in improving mathematical reasoning. We experiment with models of different sizes,\\nincluding DeepSeek-LLM 1.3B and DeepSeek-Coder-Base-v1.5 7B (Guo et al., 2024), using arXiv\\ncorpora that underwent varied processing pipelines:\\n• MathPile (Wang et al., 2023c): an 8.9B-token corpus developed with cleaning and filtering\\nheuristic rules, over 85% of which are scientific arXiv papers;\\n• ArXiv-RedPajama (Computer, 2023): the entirety of arXiv LaTeX files with preambles,\\ncomments, macros, and bibliographies removed, totaling 28.0B tokens.\\nIn our experiments, we separately train DeepSeek-LLM 1.3B for 150B tokens and DeepSeek-\\nCoder-Base-v1.5 7B for 40B tokens on each arXiv corpus. It seems that arXiv papers are ineffective\\nin improving mathematical reasoning. When trained on a arXiv-only corpus, both models dis-\\nplay no notable improvements or even deterioration across various mathematical benchmarks of\\ndifferent complexities employed in this study. These benchmarks include quantitative reasoning\\ndatasets like GSM8K and MATH (Table 8), multiple-choice challenges like MMLU-STEM (Table\\n8), and formal mathematics like miniF2F (Table 9).\\nHowever, this conclusion has its limitations and should be taken with a grain of salt. We\\nhave not yet studied:\\n• The impact of arXiv tokens on specific math-related tasks not included in this research,\\nsuch as informalization of theorems which is to convert formal statements or proofs to\\ntheir informal versions;\\n• The effect of arXiv tokens when combined with other types of data;\\n• Whether the benefits of arXiv papers would manifest themselves at a larger model scale.\\nThus, further exploration is required, which we leave for future studies.\\n5.2. Insights of Reinforcement Learning\\n5.2.1. Towards to a Unified Paradigm\\nIn this section, we provide a unified paradigm to analyze different training methods, such as\\nSFT, RFT, DPO, PPO, GRPO, and further conduct experiments to explore the factors of the\\nunified paradigm. Generally, the gradient with respect to the parameter 𝜃of a training method\\ncan be written as:\\n∇𝜃JA(𝜃) = E[(𝑞, 𝑜) ∼D\\n|       {z       }\\n𝐷𝑎𝑡𝑎𝑆𝑜𝑢𝑟𝑐𝑒\\n]\\n©\\n­\\n­\\n­\\n«\\n1\\n|𝑜|\\n|𝑜|\\n∑︁\\n𝑡=1\\n𝐺𝐶A(𝑞, 𝑜, 𝑡, 𝜋𝑟𝑓)\\n|               {z               }\\n𝐺𝑟𝑎𝑑𝑖𝑒𝑛𝑡𝐶𝑜𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡\\n∇𝜃log 𝜋𝜃(𝑜𝑡|𝑞, 𝑜<𝑡)\\nª\\n®\\n®\\n®\\n¬\\n.\\n(5)\\nThere exist three key components: 1) Data Source D, which determines the training data; 2)\\nReward Function 𝜋𝑟𝑓, which is the source of the training reward signal; 3) Algorithm A: which\\nprocesses the training data and the reward signal to the gradient coefficient 𝐺𝐶that determines\\nthe magnitude of the penalty or reinforcement for the data. We analyze several representative\\nmethods based on such a unified paradigm:\\n• Supervised Fine-tuning (SFT): SFT fine-tunes pretrained model on human selected SFT\\ndata.\\n18\\n\\n\\nMethods\\nData Source\\nReward Function\\nGradient Coefficient\\nSFT\\n𝑞, 𝑜∼𝑃𝑠𝑓𝑡(𝑄, 𝑂)\\n-\\n1\\nRFT\\n𝑞∼𝑃𝑠𝑓𝑡(𝑄), 𝑜∼𝜋𝑠𝑓𝑡(𝑂|𝑞)\\nRule\\nEquation 10\\nDPO\\n𝑞∼𝑃𝑠𝑓𝑡(𝑄), 𝑜+, 𝑜−∼𝜋𝑠𝑓𝑡(𝑂|𝑞)\\nRule\\nEquation 14\\nOnline RFT\\n𝑞∼𝑃𝑠𝑓𝑡(𝑄), 𝑜∼𝜋𝜃(𝑂|𝑞)\\nRule\\nEquation 10\\nPPO\\n𝑞∼𝑃𝑠𝑓𝑡(𝑄), 𝑜∼𝜋𝜃(𝑂|𝑞)\\nModel\\nEquation 18\\nGRPO\\n𝑞∼𝑃𝑠𝑓𝑡(𝑄), {𝑜𝑖}𝐺\\n𝑖=1 ∼𝜋𝜃(𝑂|𝑞)\\nModel\\nEquation 21\\nTable 10 | The data source and gradient coefficient of different methods. 𝑃𝑠𝑓𝑡denotes the data\\ndistribution of supervised fine-tuning datasets. 𝜋𝜃𝑠𝑓𝑡and 𝜋𝜃denote the supervised fine-tuned\\nmodel and the real-time policy model during the online training process, respectively.\\n0\\n2000\\n4000\\n6000\\n8000\\nSteps\\n56\\n58\\n60\\n62\\n64\\n66\\nAcc (%)\\nGSM8K\\n0\\n2000\\n4000\\n6000\\n8000\\nSteps\\n27\\n28\\n29\\n30\\nAcc (%)\\nMATH\\nRFT\\nOnline RFT\\nGRPO+OS\\nGRPO+PS\\nFigure 5 | Performance of the DeepSeekMath-Instruct 1.3B model, which was further trained\\nusing various methods, on two benchmarks.\\n• Rejection Sampling Fine-tuning (RFT): RFT further fine-tunes the SFT model on the\\nfiltered outputs sampled from the SFT model based on SFT questions. RFT filters the\\noutputs based on the correctness of their answers.\\n• Direct Preference Optimization (DPO): DPO further refines the SFT model by fine-tuning\\nit on augmented outputs sampled from the SFT model, using pair-wise DPO loss.\\n• Online Rejection Sampling Fine-tuning (Online RFT): Different from RFT, Online RFT\\ninitiates the policy model using the SFT model and refines it by fine-tuning with the\\naugmented outputs sampled from the real-time policy model.\\n• PPO/GRPO: PPO/GRPO initializes the policy model using the SFT model and reinforces\\nit with the outputs sampled from the real-time policy model.\\nWe summarize the components of these methods in Table 10. Please refer to Appendix A.1 for a\\nmore detailed derivation process.\\nObservation about Data Source\\nWe divide the data source into two categories, online sam-\\npling, and offline sampling. Online sampling denotes that the training data is from the explo-\\nration results of the real-time training policy model, while offline sampling denotes that the\\n19\\n\\n\\n0\\n1300\\n2300\\n3300\\n4300\\n5300\\nSteps\\n83\\n84\\n85\\n86\\n87\\n88\\n89\\nAcc (%)\\nGSM8K\\n0\\n1300\\n2300\\n3300\\n4300\\n5300\\nSteps\\n47\\n48\\n49\\n50\\n51\\n52\\nAcc (%)\\nMATH\\nIteration-0\\nIteration-1\\nIteration-2\\nFigure 6 | Performance of iterative reinforcement learning with DeepSeekMath-Instruct 7B on\\ntwo benchmarks.\\ntraining data is from the sampling results of the initial SFT model. RFT and DPO follow the\\noffline style, while Online RFT and GRPO follow the online style.\\nAs shown in Figure 5, we find that the Online RFT significantly outperforms RFT on two\\nbenchmarks. Specifically, Online RFT is comparable to RFT in the early stage of training but\\ngains an absolute advantage in the later stage, demonstrating the superiority of online training.\\nThis is intuitive, as in the initial stage, the actor and the SFT model exhibit close resemblance,\\nwith the sampled data revealing only minor differences. In the later stage, however, the data\\nsampled from the actor will exhibit more significant differences, and real-time data sampling\\nwill offer greater advantages.\\nObservation about Gradient Coefficient\\nThe algorithm processes the reward signal to the\\ngradient coefficient to update the model parameter. We divide the reward function as ‘Rule’\\nand ‘Model’ in our experiments. Rule refers to judging the quality of a response based on\\nthe correctness of the answer, and Model denotes that we train a reward model to score each\\nresponse. The training data of the reward model is based on the rule judgment. Equations 10\\nand 21 highlight a key difference between GRPO and Online RFT: GRPO uniquely adjusts its\\ngradient coefficient based on the reward value provided by the reward model. This allows for\\ndifferential reinforcement and penalization of responses according to their varying magnitudes.\\nIn contrast, Online RFT lacks this feature; it does not penalize incorrect responses and uniformly\\nreinforces all responses with correct answers at the same level of intensity.\\nAs demonstrated in Figure 5, GRPO surpasses online RFT, thereby highlighting the efficiency\\nof altering positive and negative gradient coefficients. In addition, GRPO+PS shows superior\\nperformance compared to GRPO+OS, indicating the benefits of using fine-grained, step-aware\\ngradient coefficients. Furthermore, we explore the iterative RL, in our experiments, we conduct\\ntwo rounds of iteration. As shown in Figure 6, we notice that the iterative RL significantly\\nimproves the performance, especially at the first iteration.\\n20\\n\\n\\n1\\n4\\n8\\n16\\n32\\n64\\nK: The number of candidates\\n82\\n84\\n86\\n88\\n90\\n92\\n94\\n96\\n98\\nAcc (%)\\nGSM8K\\n1\\n4\\n8\\n16\\n32\\n64\\nK: The number of candidates\\n45\\n50\\n55\\n60\\n65\\n70\\n75\\n80\\n85\\nAcc (%)\\nMATH\\nMaj@K-Instruct\\nMaj@K-RL\\nPass@K-Instruct\\nPass@K-RL\\nFigure 7 | The Maj@K and Pass@K of SFT and RL DeepSeekMath 7B on GSM8K and MATH\\n(temperature 0.7). It was noted that RL enhances Maj@K but not Pass@K.\\n5.2.2. Why RL Works?\\nIn this paper, we conduct reinforcement learning based on a subset of instruction tuning\\ndata, and it achieves significant performance enhancement upon the instruction tuning model.\\nTo further explain why reinforcement learning works. We evaluate the Pass@K and Maj@K\\naccuracy of the Instruct and RL models on two benchmarks. As shown in Figure 7, RL enhances\\nMaj@K’s performance but not Pass@K. These findings indicate that RL enhances the model’s\\noverall performance by rendering the output distribution more robust, in other words, it seems\\nthat the improvement is attributed to boosting the correct response from TopK rather than\\nthe enhancement of fundamental capabilities. Similarly, (Wang et al., 2023a) identified a\\nmisalignment problem in reasoning tasks within the SFT model, showing that the reasoning\\nperformance of SFT models can be improved through a series of preference alignment strategies\\n(Song et al., 2023; Wang et al., 2023a; Yuan et al., 2023b).\\n5.2.3. How to Achieve More Effective RL?\\nWe demonstrate RL works pretty well in mathematical reasoning tasks. We also provide a unified\\nparadigm to understand different representative training methods. Within this paradigm, all\\nmethods are conceptualized as either direct or simplified RL techniques. As summarized in\\nEquation 5, there exist three key components: Data Source, Algorithm, and Reward Function.\\nWe provide some potential future directions about the three components.\\nData Source\\nData source is the raw material of all training methods. In the context of RL, we\\nspecifically refer to the data source as the unlabeled questions with the outputs sampled from\\nthe policy model. In this paper, we only use the questions from the instruction tuning stage and\\na naive nucleus sampling to sample outputs. We think this is a potential reason that our RL\\npipeline only improves the Maj@K performance. In the future, we will explore our RL pipeline\\non out-of-distribution question prompts, in conjunction with advanced sampling (decoding)\\nstrategies, like those based on tree-search methods (Yao et al., 2023). Also, the efficient inference\\ntechniques (Kwon et al., 2023; Leviathan et al., 2023; Xia et al., 2023, 2024), which determines\\n21\\n\\n\\nthe exploration efficiency of policy models, also play an exceedingly important role.\\nAlgorithms\\nAlgorithms process the data and reward signal to the gradient coefficient to update\\nthe model parameter. Based on Equation 5, to some extent, all methods now fully TRUST the\\nsignal of the reward function to increase or decrease the conditional probability of a certain\\ntoken. However, it is impossible to ensure the reward signal is always reliable, especially in\\nextremely complex tasks. For example, even the PRM800K datasets (Lightman et al., 2023),\\nwhich have been carefully annotated by well-trained annotators, still contain approximately 20%\\nof incorrectly annotations7. To this end, we will explore the reinforcement learning algorithm\\nthat is robust against noisy reward signals. We believe such WEAK-TO-STRONG (Burns et al.,\\n2023) alignment methods will bring a fundamental change to the learning algorithms.\\nReward Function\\nReward function is the source of the training signal. In RL, the reward\\nfunction is usually the neural reward model. We think there exist three important directions for\\nreward models: 1) How to enhance the generalization ability of the reward model. The reward\\nmodel must be effectively generalized to handle out-of-distribution questions and advanced\\ndecoding outputs; otherwise, reinforcement learning may merely stabilize the distribution of\\nLLMs rather than improve their fundamental capabilities; 2) How to reflect the uncertainty\\nof reward model. The uncertainty could potentially act as a linking bridge between the weak\\nreward model and the weak-to-strong learning algorithms; 3) How to efficiently build high-\\nquality process reward models that can provide fine-grained training signals for the reasoning\\nprocess (Lightman et al., 2023; Wang et al., 2023b).\\n6. Conclusion, Limitation, and Future Work\\nWe present DeepSeekMath, which outperforms all open-source models on the competition-\\nlevel MATH benchmark and approaches the performance of closed models. DeepSeekMath is\\ninitialized with DeepSeek-Coder-v1.5 7B and undergoes continual training for 500B tokens, with\\na significant component of the training data being 120B math tokens sourced from Common\\nCrawl. Our extensive ablation study shows web pages offer significant potential for high-quality\\nmathematical data, while arXiv may not as beneficial as we expected. We introduce Group\\nRelative Policy Optimization (GRPO), a variant of Proximal Policy Optimization (PPO), which\\ncan notably improve mathematical reasoning capabilities with less memory consumption. The\\nexperiment results show that GRPO is effective even if DeepSeekMath-Instruct 7B has reached\\na high score on benchmarks. We also provide a unified paradigm to understand a series of\\nmethods and summarize several potential directions for more effective reinforcement learning.\\nAlthough DeepSeekMath achieves impressive scores on quantitative reasoning benchmarks,\\nits capability on geometry and theorem-proof are relatively weaker than closed models. For\\ninstance, in our dry run, the model cannot handle problems related to triangles and ellipses,\\nwhich may indicate data selection bias in pre-training and fine-tuning. In addition, restricted\\nby the model scale, DeepSeekMath is worse than GPT-4 on few-shot capability. GPT-4 could\\nimprove its performance with few-shot inputs, while DeepSeekMath shows similar performance\\nin zero-shot and few-shot evaluation. In the future, we will further improve our engineered\\ndata selection pipeline to construct more high-quality pre-trained corpus. In addition, we will\\nexplore the potential directions (Section 5.2.3) for more effective reinforcement learning of LLMs.\\n7https://github.com/openai/prm800k/issues/12#issuecomment-1728491852\\n22\\n\\n\\nReferences\\nR. Anil, S. Borgeaud, Y. Wu, J. Alayrac, J. Yu, R. Soricut, J. Schalkwyk, A. M. Dai, A. Hauth,\\nK. Millican, D. Silver, S. Petrov, M. Johnson, I. Antonoglou, J. Schrittwieser, A. Glaese, J. Chen,\\nE. Pitler, T. P. Lillicrap, A. Lazaridou, O. Firat, J. Molloy, M. Isard, P. R. Barham, T. Hennigan,\\nB. Lee, F. Viola, M. Reynolds, Y. Xu, R. Doherty, E. Collins, C. Meyer, E. Rutherford, E. Moreira,\\nK. Ayoub, M. Goel, G. Tucker, E. Piqueras, M. Krikun, I. Barr, N. Savinov, I. Danihelka,\\nB. Roelofs, A. White, A. Andreassen, T. von Glehn, L. Yagati, M. Kazemi, L. Gonzalez,\\nM. Khalman, J. Sygnowski, and et al. Gemini: A family of highly capable multimodal\\nmodels. CoRR, abs/2312.11805, 2023. doi: 10.48550/ARXIV.2312.11805. URL https:\\n//doi.org/10.48550/arXiv.2312.11805.\\nJ. Austin, A. Odena, M. Nye, M. Bosma, H. Michalewski, D. Dohan, E. Jiang, C. Cai, M. Terry,\\nQ. Le, et al. Program synthesis with large language models. arXiv preprint arXiv:2108.07732,\\n2021.\\nZ. Azerbayev, H. Schoelkopf, K. Paster, M. D. Santos, S. McAleer, A. Q. Jiang, J. Deng, S. Bider-\\nman, and S. Welleck. Llemma: An open language model for mathematics. arXiv preprint\\narXiv:2310.10631, 2023.\\nJ. Bai, S. Bai, Y. Chu, Z. Cui, K. Dang, X. Deng, Y. Fan, W. Ge, Y. Han, F. Huang, et al. Qwen\\ntechnical report. arXiv preprint arXiv:2309.16609, 2023.\\nC. Burns, P. Izmailov, J. H. Kirchner, B. Baker, L. Gao, L. Aschenbrenner, Y. Chen, A. Ecoffet,\\nM. Joglekar, J. Leike, et al. Weak-to-strong generalization: Eliciting strong capabilities with\\nweak supervision. arXiv preprint arXiv:2312.09390, 2023.\\nChatGLM3 Team. Chatglm3 series: Open bilingual chat llms, 2023. URL https://github.c\\nom/THUDM/ChatGLM3.\\nM. Chen, J. Tworek, H. Jun, Q. Yuan, H. P. de Oliveira Pinto, J. Kaplan, H. Edwards, Y. Burda,\\nN. Joseph, G. Brockman, A. Ray, R. Puri, G. Krueger, M. Petrov, H. Khlaaf, G. Sastry, P. Mishkin,\\nB. Chan, S. Gray, N. Ryder, M. Pavlov, A. Power, L. Kaiser, M. Bavarian, C. Winter, P. Tillet,\\nF. P. Such, D. Cummings, M. Plappert, F. Chantzis, E. Barnes, A. Herbert-Voss, W. H. Guss,\\nA. Nichol, A. Paino, N. Tezak, J. Tang, I. Babuschkin, S. Balaji, S. Jain, W. Saunders, C. Hesse,\\nA. N. Carr, J. Leike, J. Achiam, V. Misra, E. Morikawa, A. Radford, M. Knight, M. Brundage,\\nM. Murati, K. Mayer, P. Welinder, B. McGrew, D. Amodei, S. McCandlish, I. Sutskever, and\\nW. Zaremba. Evaluating large language models trained on code. CoRR, abs/2107.03374, 2021.\\nURL https://arxiv.org/abs/2107.03374.\\nW. Chen, X. Ma, X. Wang, and W. W. Cohen. Program of thoughts prompting: Disentangling\\ncomputation from reasoning for numerical reasoning tasks. CoRR, abs/2211.12588, 2022. doi:\\n10.48550/ARXIV.2211.12588. URL https://doi.org/10.48550/arXiv.2211.12588.\\nK. Cobbe, V. Kosaraju, M. Bavarian, M. Chen, H. Jun, L. Kaiser, M. Plappert, J. Tworek,\\nJ. Hilton, R. Nakano, et al. Training verifiers to solve math word problems. arXiv preprint\\narXiv:2110.14168, 2021.\\nT. Computer. Redpajama: an open dataset for training large language models, Oct. 2023. URL\\nhttps://github.com/togethercomputer/RedPajama-Data.\\nDeepSeek-AI. Deepseek LLM: scaling open-source language models with longtermism. CoRR,\\nabs/2401.02954, 2024. doi: 10.48550/ARXIV.2401.02954. URL https://doi.org/10.485\\n50/arXiv.2401.02954.\\n23\\n\\n\\nZ. Du, Y. Qian, X. Liu, M. Ding, J. Qiu, Z. Yang, and J. Tang. Glm: General language model\\npretraining with autoregressive blank infilling. In Proceedings of the 60th Annual Meeting\\nof the Association for Computational Linguistics (Volume 1: Long Papers), pages 320–335,\\n2022.\\nL. Gao, A. Madaan, S. Zhou, U. Alon, P. Liu, Y. Yang, J. Callan, and G. Neubig. PAL: program-\\naided language models. In A. Krause, E. Brunskill, K. Cho, B. Engelhardt, S. Sabato, and\\nJ. Scarlett, editors, International Conference on Machine Learning, ICML 2023, 23-29 July\\n2023, Honolulu, Hawaii, USA, volume 202 of Proceedings of Machine Learning Research,\\npages 10764–10799. PMLR, 2023. URL https://proceedings.mlr.press/v202/gao23f.\\nhtml.\\nZ. Gou, Z. Shao, Y. Gong, Y. Shen, Y. Yang, M. Huang, N. Duan, and W. Chen. Tora: A tool-\\nintegrated reasoning agent for mathematical problem solving. CoRR, abs/2309.17452, 2023.\\ndoi: 10.48550/ARXIV.2309.17452. URL https://doi.org/10.48550/arXiv.2309.1745\\n2.\\nD. Guo, Q. Zhu, D. Yang, Z. Xie, K. Dong, W. Zhang, G. Chen, X. Bi, Y. Wu, Y. K. Li, F. Luo,\\nY. Xiong, and W. Liang. Deepseek-coder: When the large language model meets programming\\n– the rise of code intelligence, 2024.\\nD. Hendrycks, C. Burns, S. Basart, A. Zou, M. Mazeika, D. Song, and J. Steinhardt. Measuring\\nmassive multitask language understanding. arXiv preprint arXiv:2009.03300, 2020.\\nD. Hendrycks, C. Burns, S. Kadavath, A. Arora, S. Basart, E. Tang, D. Song, and J. Steinhardt. Mea-\\nsuring mathematical problem solving with the math dataset. arXiv preprint arXiv:2103.03874,\\n2021.\\nHigh-flyer. Hai-llm: 高效且轻量的大模型训练工具, 2023. URL https://www.high-flyer.c\\nn/en/blog/hai-llm.\\nInflection AI. Inflection-2, 2023. URL https://inflection.ai/inflection-2.\\nA. Q. Jiang, S. Welleck, J. P. Zhou, W. Li, J. Liu, M. Jamnik, T. Lacroix, Y. Wu, and G. Lample. Draft,\\nsketch, and prove: Guiding formal theorem provers with informal proofs. arXiv preprint\\narXiv:2210.12283, 2022.\\nA. Q. Jiang, A. Sablayrolles, A. Mensch, C. Bamford, D. S. Chaplot, D. d. l. Casas, F. Bressand,\\nG. Lengyel, G. Lample, L. Saulnier, et al. Mistral 7b. arXiv preprint arXiv:2310.06825, 2023.\\nA. Joulin, E. Grave, P. Bojanowski, M. Douze, H. Jégou, and T. Mikolov. Fasttext. zip: Compress-\\ning text classification models. arXiv preprint arXiv:1612.03651, 2016.\\nW. Kwon, Z. Li, S. Zhuang, Y. Sheng, L. Zheng, C. H. Yu, J. E. Gonzalez, H. Zhang, and I. Stoica.\\nEfficient memory management for large language model serving with pagedattention. In\\nProceedings of the ACM SIGOPS 29th Symposium on Operating Systems Principles, 2023.\\nY. Leviathan, M. Kalman, and Y. Matias. Fast inference from transformers via speculative\\ndecoding. In International Conference on Machine Learning, pages 19274–19286. PMLR,\\n2023.\\nA. Lewkowycz, A. Andreassen, D. Dohan, E. Dyer, H. Michalewski, V. Ramasesh, A. Slone,\\nC. Anil, I. Schlag, T. Gutman-Solo, et al. Solving quantitative reasoning problems with\\nlanguage models. Advances in Neural Information Processing Systems, 35:3843–3857, 2022a.\\n24\\n\\n\\nA. Lewkowycz, A. Andreassen, D. Dohan, E. Dyer, H. Michalewski, V. V. Ramasesh, A. Slone,\\nC. Anil, I. Schlag, T. Gutman-Solo, Y. Wu, B. Neyshabur, G. Gur-Ari, and V. Misra. Solving\\nquantitative reasoning problems with language models. In S. Koyejo, S. Mohamed, A. Agarwal,\\nD. Belgrave, K. Cho, and A. Oh, editors, Advances in Neural Information Processing Systems\\n35: Annual Conference on Neural Information Processing Systems 2022, NeurIPS 2022, New\\nOrleans, LA, USA, November 28 - December 9, 2022, 2022b. URL http://papers.nips.\\ncc/paper_files/paper/2022/hash/18abbeef8cfe9203fdf9053c9c4fe191-Abstr\\nact-Conference.html.\\nH. Lightman, V. Kosaraju, Y. Burda, H. Edwards, B. Baker, T. Lee, J. Leike, J. Schulman,\\nI. Sutskever, and K. Cobbe. Let’s verify step by step. arXiv preprint arXiv:2305.20050, 2023.\\nI. Loshchilov and F. Hutter.\\nDecoupled weight decay regularization.\\narXiv preprint\\narXiv:1711.05101, 2017.\\nH. Luo, Q. Sun, C. Xu, P. Zhao, J. Lou, C. Tao, X. Geng, Q. Lin, S. Chen, and D. Zhang.\\nWizardmath: Empowering mathematical reasoning for large language models via reinforced\\nevol-instruct. arXiv preprint arXiv:2308.09583, 2023.\\nS. Mishra, M. Finlayson, P. Lu, L. Tang, S. Welleck, C. Baral, T. Rajpurohit, O. Tafjord, A. Sab-\\nharwal, P. Clark, and A. Kalyan. LILA: A unified benchmark for mathematical reasoning.\\nIn Y. Goldberg, Z. Kozareva, and Y. Zhang, editors, Proceedings of the 2022 Conference on\\nEmpirical Methods in Natural Language Processing, EMNLP 2022, Abu Dhabi, United Arab\\nEmirates, December 7-11, 2022, pages 5807–5832. Association for Computational Linguistics,\\n2022. doi: 10.18653/V1/2022.EMNLP-MAIN.392. URL https://doi.org/10.18653/v1/\\n2022.emnlp-main.392.\\nX. Nguyen, W. Zhang, X. Li, M. M. Aljunied, Q. Tan, L. Cheng, G. Chen, Y. Deng, S. Yang,\\nC. Liu, H. Zhang, and L. Bing. Seallms - large language models for southeast asia. CoRR,\\nabs/2312.00738, 2023. doi: 10.48550/ARXIV.2312.00738. URL https://doi.org/10.485\\n50/arXiv.2312.00738.\\nOpenAI. GPT4 technical report. arXiv preprint arXiv:2303.08774, 2023.\\nL. Ouyang, J. Wu, X. Jiang, D. Almeida, C. Wainwright, P. Mishkin, C. Zhang, S. Agarwal,\\nK. Slama, A. Ray, et al. Training language models to follow instructions with human feedback.\\nAdvances in Neural Information Processing Systems, 35:27730–27744, 2022.\\nK. Paster, M. D. Santos, Z. Azerbayev, and J. Ba. Openwebmath: An open dataset of high-quality\\nmathematical web text. CoRR, abs/2310.06786, 2023. doi: 10.48550/ARXIV.2310.06786. URL\\nhttps://doi.org/10.48550/arXiv.2310.06786.\\nL. C. Paulson. Three years of experience with sledgehammer, a practical link between auto-\\nmatic and interactive theorem provers. In R. A. Schmidt, S. Schulz, and B. Konev, editors,\\nProceedings of the 2nd Workshop on Practical Aspects of Automated Reasoning, PAAR-2010,\\nEdinburgh, Scotland, UK, July 14, 2010, volume 9 of EPiC Series in Computing, pages 1–10.\\nEasyChair, 2010. doi: 10.29007/TNFD. URL https://doi.org/10.29007/tnfd.\\nS. Polu and I. Sutskever. Generative language modeling for automated theorem proving. CoRR,\\nabs/2009.03393, 2020. URL https://arxiv.org/abs/2009.03393.\\nR. Rafailov, A. Sharma, E. Mitchell, S. Ermon, C. D. Manning, and C. Finn. Direct preference\\noptimization: Your language model is secretly a reward model. 2023.\\n25\\n\\n\\nJ. Schulman. Approximating kl divergence, 2020. URL http://joschu.net/blog/kl-app\\nrox.html.\\nJ. Schulman, P. Moritz, S. Levine, M. Jordan, and P. Abbeel. High-dimensional continuous\\ncontrol using generalized advantage estimation. arXiv preprint arXiv:1506.02438, 2015.\\nJ. Schulman, F. Wolski, P. Dhariwal, A. Radford, and O. Klimov. Proximal policy optimization\\nalgorithms. arXiv preprint arXiv:1707.06347, 2017.\\nF. Shi, M. Suzgun, M. Freitag, X. Wang, S. Srivats, S. Vosoughi, H. W. Chung, Y. Tay, S. Ruder,\\nD. Zhou, D. Das, and J. Wei. Language models are multilingual chain-of-thought reasoners.\\nIn The Eleventh International Conference on Learning Representations, ICLR 2023, Kigali,\\nRwanda, May 1-5, 2023. OpenReview.net, 2023. URL https://openreview.net/pdf?id=\\nfR3wGCk-IXp.\\nF. Song, B. Yu, M. Li, H. Yu, F. Huang, Y. Li, and H. Wang. Preference ranking optimization for\\nhuman alignment. arXiv preprint arXiv:2306.17492, 2023.\\nM. Suzgun, N. Scales, N. Schärli, S. Gehrmann, Y. Tay, H. W. Chung, A. Chowdhery, Q. V. Le,\\nE. H. Chi, D. Zhou, et al. Challenging big-bench tasks and whether chain-of-thought can solve\\nthem. arXiv preprint arXiv:2210.09261, 2022.\\nT. Tao. Embracing change and resetting expectations, 2023. URL https://unlocked.micro\\nsoft.com/ai-anthology/terence-tao/.\\nH. Touvron, L. Martin, K. Stone, P. Albert, A. Almahairi, Y. Babaei, N. Bashlykov, S. Batra,\\nP. Bhargava, S. Bhosale, D. Bikel, L. Blecher, C. Canton-Ferrer, M. Chen, G. Cucurull, D. Esiobu,\\nJ. Fernandes, J. Fu, W. Fu, B. Fuller, C. Gao, V. Goswami, N. Goyal, A. Hartshorn, S. Hosseini,\\nR. Hou, H. Inan, M. Kardas, V. Kerkez, M. Khabsa, I. Kloumann, A. Korenev, P. S. Koura,\\nM. Lachaux, T. Lavril, J. Lee, D. Liskovich, Y. Lu, Y. Mao, X. Martinet, T. Mihaylov, P. Mishra,\\nI. Molybog, Y. Nie, A. Poulton, J. Reizenstein, R. Rungta, K. Saladi, A. Schelten, R. Silva, E. M.\\nSmith, R. Subramanian, X. E. Tan, B. Tang, R. Taylor, A. Williams, J. X. Kuan, P. Xu, Z. Yan,\\nI. Zarov, Y. Zhang, A. Fan, M. Kambadur, S. Narang, A. Rodriguez, R. Stojnic, S. Edunov, and\\nT. Scialom. Llama 2: Open foundation and fine-tuned chat models. CoRR, abs/2307.09288,\\n2023. doi: 10.48550/arXiv.2307.09288. URL https://doi.org/10.48550/arXiv.2307.\\n09288.\\nT. H. Trinh, Y. Wu, Q. V. Le, H. He, and T. Luong. Solving olympiad geometry without human\\ndemonstrations. Nature, 625(7995):476–482, 2024.\\nP. Wang, L. Li, L. Chen, F. Song, B. Lin, Y. Cao, T. Liu, and Z. Sui. Making large language models\\nbetter reasoners with alignment. arXiv preprint arXiv:2309.02144, 2023a.\\nP. Wang, L. Li, Z. Shao, R. Xu, D. Dai, Y. Li, D. Chen, Y. Wu, and Z. Sui. Math-shepherd: Verify\\nand reinforce llms step-by-step without human annotations. CoRR, abs/2312.08935, 2023b.\\nZ. Wang, R. Xia, and P. Liu. Generative AI for math: Part I - mathpile: A billion-token-scale\\npretraining corpus for math. CoRR, abs/2312.17120, 2023c. doi: 10.48550/ARXIV.2312.17120.\\nURL https://doi.org/10.48550/arXiv.2312.17120.\\nJ. Wei, X. Wang, D. Schuurmans, M. Bosma, B. Ichter, F. Xia, E. H. Chi, Q. V. Le, and D. Zhou.\\nChain-of-thought prompting elicits reasoning in large language models. In NeurIPS, 2022.\\nURL http://papers.nips.cc/paper_files/paper/2022/hash/9d5609613524ecf\\n4f15af0f7b31abca4-Abstract-Conference.html.\\n26\\n\\n\\nT. Wei, J. Luan, W. Liu, S. Dong, and B. Wang. Cmath: Can your language model pass chinese\\nelementary school math test?, 2023.\\nM. Wenzel, L. C. Paulson, and T. Nipkow. The isabelle framework. In O. A. Mohamed, C. A.\\nMuñoz, and S. Tahar, editors, Theorem Proving in Higher Order Logics, 21st International\\nConference, TPHOLs 2008, Montreal, Canada, August 18-21, 2008. Proceedings, volume 5170\\nof Lecture Notes in Computer Science, pages 33–38. Springer, 2008. doi: 10.1007/978-3-540-7\\n1067-7\\\\_7. URL https://doi.org/10.1007/978-3-540-71067-7_7.\\nH. Xia, T. Ge, P. Wang, S.-Q. Chen, F. Wei, and Z. Sui. Speculative decoding: Exploiting\\nspeculative execution for accelerating seq2seq generation. In H. Bouamor, J. Pino, and K. Bali,\\neditors, Findings of the Association for Computational Linguistics: EMNLP 2023, pages 3909–\\n3925, Singapore, Dec. 2023. Association for Computational Linguistics. doi: 10.18653/v1/20\\n23.findings-emnlp.257. URL https://aclanthology.org/2023.findings-emnlp.257.\\nH. Xia, Z. Yang, Q. Dong, P. Wang, Y. Li, T. Ge, T. Liu, W. Li, and Z. Sui. Unlocking efficiency\\nin large language model inference: A comprehensive survey of speculative decoding. arXiv\\npreprint arXiv:2401.07851, 2024.\\nS. Yao, D. Yu, J. Zhao, I. Shafran, T. L. Griffiths, Y. Cao, and K. Narasimhan. Tree of thoughts:\\nDeliberate problem solving with large language models. arXiv preprint arXiv:2305.10601,\\n2023.\\nL. Yu, W. Jiang, H. Shi, J. Yu, Z. Liu, Y. Zhang, J. T. Kwok, Z. Li, A. Weller, and W. Liu.\\nMetamath: Bootstrap your own mathematical questions for large language models. CoRR,\\nabs/2309.12284, 2023. doi: 10.48550/ARXIV.2309.12284. URL https://doi.org/10.485\\n50/arXiv.2309.12284.\\nZ. Yuan, H. Yuan, C. Li, G. Dong, C. Tan, and C. Zhou. Scaling relationship on learning\\nmathematical reasoning with large language models. arXiv preprint arXiv:2308.01825, 2023a.\\nZ. Yuan, H. Yuan, C. Tan, W. Wang, S. Huang, and F. Huang. Rrhf: Rank responses to align\\nlanguage models with human feedback without tears. arXiv preprint arXiv:2304.05302, 2023b.\\nX. Yue, X. Qu, G. Zhang, Y. Fu, W. Huang, H. Sun, Y. Su, and W. Chen. Mammoth: Building\\nmath generalist models through hybrid instruction tuning. CoRR, abs/2309.05653, 2023. doi:\\n10.48550/ARXIV.2309.05653. URL https://doi.org/10.48550/arXiv.2309.05653.\\nK. Zheng, J. M. Han, and S. Polu. Minif2f: a cross-system benchmark for formal olympiad-level\\nmathematics. arXiv preprint arXiv:2109.00110, 2021.\\nW. Zhong, R. Cui, Y. Guo, Y. Liang, S. Lu, Y. Wang, A. Saied, W. Chen, and N. Duan. AGIEval: A\\nhuman-centric benchmark for evaluating foundation models. CoRR, abs/2304.06364, 2023.\\ndoi: 10.48550/arXiv.2304.06364. URL https://doi.org/10.48550/arXiv.2304.06364.\\n27\\n\\n\\nA. Appendix\\nA.1. Analysis of Reinforcement Learning\\nWe provide the detailed derivation of the data source and gradient coefficient (algorithm and\\nreward function) across various methods, including SFT, RFT, Online RFT, DPO, PPO, and\\nGRPO.\\nA.1.1. Supervised Fine-tuning\\nThe objective of Supervised Fine-tuning is maximizing the following objective:\\nJ\\n𝑆𝐹𝑇(𝜃) = E[𝑞, 𝑜∼𝑃𝑠𝑓𝑡(𝑄, 𝑂)]\\n \\n1\\n|𝑜|\\n|𝑜|\\n∑︁\\n𝑡=1\\nlog 𝜋𝜃(𝑜𝑡|𝑞, 𝑜<𝑡)\\n!\\n.\\n(6)\\nThe gradient of J\\n𝑆𝐹𝑇(𝜃) is:\\n∇𝜃J\\n𝑆𝐹𝑇= E[𝑞, 𝑜∼𝑃𝑠𝑓𝑡(𝑄, 𝑂)]\\n \\n1\\n|𝑜|\\n|𝑜|\\n∑︁\\n𝑡=1\\n∇𝜃log 𝜋𝜃(𝑜𝑡|𝑞, 𝑜<𝑡)\\n!\\n.\\n(7)\\nData Source: The dataset employed for SFT. Reward Function: This can be regarded as human\\nselection. Gradient Coefficient: always set to 1.\\nA.1.2. Rejection Sampling Fine-tuning\\nRejection Sampling Fine-tuning first samples multiple outputs from the supervised fine-tuned\\nLLMs for each question, and then trains LLMs on the sampled outputs with the correct answer.\\nFormally, the objective of RFT is to maximize the following objectives:\\nJ\\n𝑅𝐹𝑇(𝜃) = E[𝑞∼𝑃𝑠𝑓𝑡(𝑄), 𝑜∼𝜋𝑠𝑓𝑡(𝑂|𝑞)]\\n \\n1\\n|𝑜|\\n|𝑜|\\n∑︁\\n𝑡=1\\nI(𝑜) log 𝜋𝜃(𝑜𝑡|𝑞, 𝑜<𝑡)\\n!\\n.\\n(8)\\nThe gradient of J\\n𝑅𝐹𝑇(𝜃) is:\\n∇𝜃J\\n𝑅𝐹𝑇(𝜃) = E[𝑞∼𝑃𝑠𝑓𝑡(𝑄), 𝑜∼𝜋𝑠𝑓𝑡(𝑂|𝑞)]\\n \\n1\\n|𝑜|\\n|𝑜|\\n∑︁\\n𝑡=1\\nI(𝑜)∇𝜃log 𝜋𝜃(𝑜𝑡|𝑞, 𝑜<𝑡)\\n!\\n.\\n(9)\\nData Source: question in SFT dataset with outputs sampled from SFT model. Reward Function:\\nRule (whether the answer is correct or not). Gradient Coefficient:\\n𝐺𝐶𝑅𝐹𝑇(𝑞, 𝑜, 𝑡) = I(𝑜) =\\n(\\n1\\nthe answer of o is correct\\n0\\nthe answer of o is incorrect\\n(10)\\nA.1.3. Online Rejection Sampling Fine-tuning\\nThe only difference between RFT and Online RFT is that the outputs of Online RFT are sampled\\nfrom the real-time policy model 𝜋𝜃, rather than from the SFT model 𝜋𝜃𝑠𝑓𝑡. Therefore, the gradient\\nof online RFT is:\\n∇𝜃J\\n𝑂𝑛𝑅𝐹𝑇(𝜃) = E[𝑞∼𝑃𝑠𝑓𝑡(𝑄), 𝑜∼𝜋𝜃(𝑂|𝑞)]\\n \\n1\\n|𝑜|\\n|𝑜|\\n∑︁\\n𝑡=1\\nI(𝑜)∇𝜃log 𝜋𝜃(𝑜𝑡|𝑞, 𝑜<𝑡)\\n!\\n.\\n(11)\\n28\\n\\n\\nA.1.4. Direct Preference Optimization (DPO)\\nThe objective of DPO is:\\nJ\\n𝐷𝑃𝑂(𝜃) = E[𝑞∼𝑃𝑠𝑓𝑡(𝑄), 𝑜+, 𝑜−∼𝜋𝑠𝑓𝑡(𝑂|𝑞)] log 𝜎©\\n­\\n«\\n𝛽1\\n|𝑜+|\\n|𝑜+|\\n∑︁\\n𝑡=1\\nlog\\n𝜋𝜃(𝑜+\\n𝑡|𝑞, 𝑜+\\n<𝑡)\\n𝜋ref(𝑜+\\n𝑡|𝑞, 𝑜+\\n<𝑡) −𝛽1\\n|𝑜−|\\n|𝑜−|\\n∑︁\\n𝑡=1\\nlog\\n𝜋𝜃(𝑜−\\n<𝑡|𝑞, 𝑜−\\n<𝑡)\\n𝜋ref(𝑜−\\n<𝑡|𝑞, 𝑜−\\n<𝑡)\\nª\\n®\\n¬\\n(12)\\nThe gradient of J\\n𝐷𝑃𝑂(𝜃) is:\\n∇𝜃J\\n𝐷𝑃𝑂(𝜃) = E[𝑞∼𝑃𝑠𝑓𝑡(𝑄), 𝑜+, 𝑜−∼𝜋𝑠𝑓𝑡(𝑂|𝑞)] ©\\n­\\n«\\n1\\n|𝑜+|\\n|𝑜+|\\n∑︁\\n𝑡=1\\n𝐺𝐶𝐷𝑃𝑂(𝑞, 𝑜, 𝑡)∇𝜃log 𝜋𝜃(𝑜+\\n𝑡|𝑞, 𝑜+\\n<𝑡)\\n−\\n1\\n|𝑜−|\\n|𝑜−|\\n∑︁\\n𝑡=1\\n𝐺𝐶𝐷𝑃𝑂(𝑞, 𝑜, 𝑡)∇𝜃log 𝜋𝜃(𝑜−\\n𝑡|𝑞, 𝑜−\\n<𝑡)ª\\n®\\n¬\\n(13)\\nData Source: question in SFT dataset with outputs sampled from SFT model. Reward Function:\\nhuman preference in the general domain (can be ‘Rule’ in mathematical tasks). Gradient\\nCoefficient:\\n𝐺𝐶𝐷𝑃𝑂(𝑞, 𝑜, 𝑡) = 𝜎\\n\\u0012\\n𝛽log\\n𝜋𝜃(𝑜−\\n𝑡|𝑞, 𝑜−\\n<𝑡)\\n𝜋ref(𝑜−\\n𝑡|𝑞, 𝑜−\\n<𝑡) −𝛽log\\n𝜋𝜃(𝑜+\\n𝑡|𝑞, 𝑜+\\n<𝑡)\\n𝜋ref(𝑜+\\n𝑡|𝑞, 𝑜+\\n<𝑡)\\n\\u0013\\n(14)\\nA.1.5. Proximal Policy Optimization (PPO)\\nThe objective of PPO is:\\nJ\\n𝑃𝑃𝑂(𝜃) = E[𝑞∼𝑃𝑠𝑓𝑡(𝑄), 𝑜∼𝜋𝜃𝑜𝑙𝑑(𝑂|𝑞)] 1\\n|𝑜|\\n|𝑜|\\n∑︁\\n𝑡=1\\nmin\\n\\u0014 𝜋𝜃(𝑜𝑡|𝑞, 𝑜<𝑡)\\n𝜋𝜃𝑜𝑙𝑑(𝑜𝑡|𝑞, 𝑜<𝑡) 𝐴𝑡, clip\\n\\u0012 𝜋𝜃(𝑜𝑡|𝑞, 𝑜<𝑡)\\n𝜋𝜃𝑜𝑙𝑑(𝑜𝑡|𝑞, 𝑜<𝑡) , 1 −𝜀, 1 + 𝜀\\n\\u0013\\n𝐴𝑡\\n\\u0015\\n.\\n(15)\\nTo simplify the analysis, it is assumed that the model only has a single update following each\\nexploration stage, thereby ensuring that 𝜋𝜃𝑜𝑙𝑑= 𝜋𝜃. In this case, we can remove the min and clip\\noperation:\\nJ\\n𝑃𝑃𝑂(𝜃) = E[𝑞∼𝑃𝑠𝑓𝑡(𝑄), 𝑜∼𝜋𝜃𝑜𝑙𝑑(𝑂|𝑞)] 1\\n|𝑜|\\n|𝑜|\\n∑︁\\n𝑡=1\\n𝜋𝜃(𝑜𝑡|𝑞, 𝑜<𝑡)\\n𝜋𝜃𝑜𝑙𝑑(𝑜𝑡|𝑞, 𝑜<𝑡) 𝐴𝑡.\\n(16)\\nThe gradient of J\\n𝑃𝑃𝑂(𝜃) is:\\n∇𝜃J\\n𝑃𝑃𝑂(𝜃) = E[𝑞∼𝑃𝑠𝑓𝑡(𝑄), 𝑜∼𝜋𝜃𝑜𝑙𝑑(𝑂|𝑞)] 1\\n|𝑜|\\n|𝑜|\\n∑︁\\n𝑡=1\\n𝐴𝑡∇𝜃log 𝜋𝜃(𝑜𝑡|𝑞, 𝑜<𝑡)\\n(17)\\nData Source: question in SFT dataset with outputs sampled from policy model. Reward Function:\\nreward model. Gradient Coefficient:\\n𝐺𝐶𝑃𝑃𝑂(𝑞, 𝑜, 𝑡, 𝜋𝜃𝑟𝑚) = 𝐴𝑡,\\n(18)\\nwhere 𝐴𝑡is the advantage, which is computed by applying Generalized Advantage Estimation\\n(GAE) (Schulman et al., 2015), based on the rewards {𝑟≥𝑡} and a learned value function 𝑉𝜓.\\nA.1.6. Group Relative Policy Optimization (GRPO)\\nThe objective of GRPO is (assume 𝜋𝜃𝑜𝑙𝑑= 𝜋𝜃for simplified analysis):\\nJ\\n𝐺𝑅𝑃𝑂(𝜃) = E[𝑞∼𝑃𝑠𝑓𝑡(𝑄), {𝑜𝑖}𝐺\\n𝑖=1 ∼𝜋𝜃𝑜𝑙𝑑(𝑂|𝑞)]\\n1\\n𝐺\\n𝐺\\n∑︁\\n𝑖=1\\n1\\n|𝑜𝑖|\\n|𝑜𝑖|\\n∑︁\\n𝑡=1\\n\\u0014 𝜋𝜃(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡)\\n𝜋𝜃𝑜𝑙𝑑(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡)\\nˆ\\n𝐴𝑖,𝑡−𝛽(\\n𝜋𝑟𝑒𝑓(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡)\\n𝜋𝜃(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡) −log\\n𝜋𝑟𝑒𝑓(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡)\\n𝜋𝜃(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡) −1)\\n\\u0015\\n.\\n(19)\\n29\\n\\n\\nThe gradient of J\\n𝐺𝑅𝑃𝑂(𝜃) is:\\n∇𝜃J\\n𝐺𝑅𝑃𝑂(𝜃) = E[𝑞∼𝑃𝑠𝑓𝑡(𝑄), {𝑜𝑖}𝐺\\n𝑖=1 ∼𝜋𝜃𝑜𝑙𝑑(𝑂|𝑞)]\\n1\\n𝐺\\n𝐺\\n∑︁\\n𝑖=1\\n1\\n|𝑜𝑖|\\n|𝑜𝑖|\\n∑︁\\n𝑡=1\\n\\u0014\\nˆ\\n𝐴𝑖,𝑡+ 𝛽\\n\\u0012 𝜋𝑟𝑒𝑓(𝑜𝑖,𝑡|𝑜𝑖,<𝑡)\\n𝜋𝜃(𝑜𝑖,𝑡|𝑜𝑖,<𝑡) −1\\n\\u0013\\u0015\\n∇𝜃log 𝜋𝜃(𝑜𝑖,𝑡|𝑞, 𝑜𝑖,<𝑡).\\n(20)\\nData Source: question in SFT dataset with outputs sampled from policy model. Reward Function:\\nreward model. Gradient Coefficient:\\n𝐺𝐶𝐺𝑅𝑃𝑂(𝑞, 𝑜, 𝑡, 𝜋𝜃𝑟𝑚) = ˆ\\n𝐴𝑖,𝑡+ 𝛽\\n\\u0012 𝜋𝑟𝑒𝑓(𝑜𝑖,𝑡|𝑜𝑖,<𝑡)\\n𝜋𝜃(𝑜𝑖,𝑡|𝑜𝑖,<𝑡) −1\\n\\u0013\\n,\\n(21)\\nwhere ˆ\\n𝐴𝑖,𝑡is computed based on the group reward scores.\\n30\\n\\n\\nMAmmoTH2: Scaling Instructions from the Web\\n♢Xiang Yue∗\\n, ♠Tuney Zheng∗\\n, ♠Ge Zhang∗\\n, ♠Wenhu Chen∗\\n♢Carnegie Mellon University, ♠University of Waterloo\\nxyue2@andrew.cmu.edu\\nwenhuchen@uwaterloo.ca\\nhttps://tiger-ai-lab.github.io/MAmmoTH2/\\nAbstract\\nInstruction tuning improves the reasoning abilities of large language models\\n(LLMs), with data quality and scalability being the crucial factors. Most instruction\\ntuning data come from human crowd-sourcing or GPT-4 distillation. We propose a\\nparadigm to efficiently harvest 10 million naturally existing instruction data from\\nthe pre-training web corpus to enhance LLM reasoning. Our approach involves\\n(1) recalling relevant documents, (2) extracting instruction-response pairs, and (3)\\nrefining the extracted pairs using open-source LLMs. Fine-tuning base LLMs on\\nthis dataset, we build MAmmoTH2 models, which significantly boost performance on\\nreasoning benchmarks. Notably, MAmmoTH2-7B’s (Mistral) performance increases\\nfrom 11% to 36.7% on MATH and from 36% to 68.4% on GSM8K without training\\non any in-domain data. Further training MAmmoTH2 on public instruction tuning\\ndatasets yields MAmmoTH2-Plus, achieving state-of-the-art performance on several\\nreasoning and chatbot benchmarks. Our work demonstrates how to harvest large-\\nscale, high-quality instruction data without costly human annotation or GPT-4\\ndistillation, providing a new paradigm for building better instruction tuning data.\\n25\\n22\\n72\\n32\\n61\\n57\\n35\\n48\\n85\\n36\\n73\\n75\\n29\\n45\\n85\\n37\\n65\\n63\\n34\\n47\\n86\\n38\\n72\\n74\\n20\\n30\\n40\\n50\\n60\\n70\\n80\\n90\\n100\\nTheoremQA\\nMATH\\nGSM8K\\nGPQA\\nMMLU-STEM\\nBBH\\nMixtral-8x7B-Instruct\\nQwen-1.5-110B\\nMAmmoTH2-7B-Plus (Ours)\\nMAmmoTH2-8x7B-Plus (Ours)\\n60\\n24\\n23\\n68.7\\n33.8\\n32.6\\n0\\n20\\n40\\n60\\n80\\nMBPP\\nAlpacaEval2 ArenaHard\\nMixtral-8x7B-Instruct\\nMAmmoTH2-8x7B-Plus (Ours)\\nReasoning Benchmarks\\nAdditional Benchmarks\\nFigure 1: Overview of MAmmoTH2-Plus results. The MAmmoTH2-8x7B-Plus variant outperforms\\nMixtral-Instruct on reasoning benchmarks, matching Qwen-1.5-110B with only 13B active parameters.\\nIt also surpasses Mixtral-Instruct by around 10 points on general code and chatbot benchmarks.\\n1\\nIntroduction\\nReasoning is a fundamental aspect of human cognition and problem-solving (Clark et al., 2018;\\nHendrycks et al., 2021a; Cobbe et al., 2021; Rein et al., 2023; Yue et al., 2023a). Proficiency in\\n∗All of the authors are core contributors to the project.\\narXiv:2405.03548v4  [cs.CL]  23 May 2024\\n\\n\\nExtract\\nWeb\\nRecall\\nWebInstruct: 10M instruction data from the web\\nDistillation from GPT-4\\nHuman annotation\\nSeed Data \\nCostly, usually small-scale\\nSynthetic\\nAnnotated\\nProne to bias & hallucinations\\nDiverse, high quality and large-scale\\nRaw Doc\\nExtracted QA\\nAnnotators\\nPrevious Methods\\nOur Method\\nRefine\\nRefined QA\\nFigure 2: Comparison between our dataset curation method and previous studies.\\nreasoning is essential for advancing scientific knowledge, developing new technologies, and making\\ninformed decisions in various contexts. Recently, large language models (LLMs) (Brown et al., 2020;\\nOuyang et al., 2022; Touvron et al., 2023a,b; Achiam et al., 2023; Team et al., 2023) have shown\\nremarkable progress in various NLP tasks. However, their ability to perform complex reasoning\\ntasks (Lin et al., 2024) in the domains of mathematics, science, and engineering is still limited.\\nRecent studies have extensively explored how to enhance base LLMs’ reasoning abilities. The two\\nmain approaches are continued training and instruction tuning. Continued training trains LLMs on\\nlarge-scale filtered documents (Lewkowycz et al., 2022; Taylor et al., 2022; Azerbayev et al., 2023;\\nShao et al., 2024; Ying et al., 2024). Instruction tuning seeks to employ supervised fine-tuning loss on,\\nusually small-scale, high-quality instruction-response pairs (Ouyang et al., 2022; Chung et al., 2024).\\nWhile human-annotated instruction datasets (Cobbe et al., 2021; Hendrycks et al., 2021b; Amini\\net al., 2019) are often limited in scale, recent studies (Yu et al., 2023; Yue et al., 2023b; Toshniwal\\net al., 2024; Li et al., 2024a; Tang et al., 2024) attempt to prompt GPT-4 with seed data to increase\\nthe scalability. However, the synthesized instruction data becomes highly biased, not diverse, and\\nprone to a high degree of hallucination.\\nTo address these limitations, we propose to discover naturally existing instruction data from the\\nweb (Figure 2). We argue that the pre-training corpus (e.g., Common Crawl) already contains a vast\\namount of high-quality instruction data for LLM reasoning. For example, the web corpus contains a\\nlarge amount of educational materials in the form of instruction-following pairs. These documents\\nrange across various domains like math, science, engineering, and humanities. Such readily available\\ninstruction data is not only diverse but also of high quality. However, such instruction data is highly\\ndispersed across the corpus, which makes it particularly challenging to discover.\\nIn this paper, we aim to mine these instruction-response pairs from the web using a three-step pipeline.\\n(1) Recall step: We create a diverse seed dataset by crawling several quiz websites. We use this\\nseed data to train a fastText model (Joulin et al., 2016) and employ it to recall documents from\\nCommon Crawl (Computer, 2023). GPT-4 is used to trim down the recalled documents by their root\\nURL. We obtain 18M documents through this step. (2) Extract step: We utilize open-source LLMs\\nlike Mixtral (Jiang et al., 2024) to extract Q-A pairs from these documents, producing roughly 5M\\ncandidate Q-A pairs. (3) Refine step: After extraction, we further employ Mixtral-8×7B (Jiang et al.,\\n2024) and Qwen-72B (Bai et al., 2023) to refine (Zheng et al., 2024b) these candidate Q-A pairs. This\\nrefinement operation aims to remove unrelated content, fix formality, and add missing explanations\\nto the candidate Q-A pairs. This refinement operation is pivotal to maintaining the quality of the\\nmined Q-A pairs. Eventually, we harvest a total of 10M instruction-response pairs through these\\nsteps. Unlike existing instruction-tuning dataset, our dataset WEBINSTRUCT is purely mined from\\nthe Web without any human crowdsourcing or GPT-4 distillation.\\nWe validate the effectiveness of WEBINSTRUCT by training MAmmoTH2 on various base models\\n(Figure 1), including Mistral-7B (Jiang et al., 2023), Llama3-8B (Meta, 2024), Mixtral-8×7B (Jiang\\net al., 2024), and Yi-34B (Young et al., 2024). MAmmoTH2 significantly outperforms the base models\\non seven held-out reasoning benchmarks: TheoremQA (Chen et al., 2023b), GSM8K (Cobbe et al.,\\n2021), MATH (Hendrycks et al., 2021b), ARC-C (Clark et al., 2018), MMLU-STEM (Hendrycks\\net al., 2021b), GPQA (Rein et al., 2023), and BBH (Suzgun et al., 2022). MAmmoTH2-7B improves\\nMistral-7B’s performance by an average of 14 absolute points, while MAmmoTH2-34B enhances Yi-\\n34B’s performance by an average of 5.8 absolute points. Notably, Mistral-7B’s MATH accuracy can\\nrise from 11.2% to 36.7% after training on WEBINSTRUCT. As our dataset contains no in-domain\\ndata from our evaluation benchmarks, this highlights the models’ strong generalization ability.\\nWe further enhance MAmmoTH2’s performance on code generation, math reasoning, and instruction-\\nfollowing tasks by tuning it on open-source instruction datasets, including OpenHermes2.5 (Teknium,\\n2\\n\\n\\n2023), Code-Feedback (Zheng et al., 2024c), and Math-plus. The resulting model, MAmmoTH2-Plus,\\nexcels on seven reasoning benchmarks and other general tasks.\\nMAmmoTH2-7B-Plus and\\nMAmmoTH2-8B-Plus achieve state-of-the-art performance on TheoremQA, ARC-C, MMLU-STEM,\\nGPQA, and BBH, and competitive results on MATH (45%) and GSM8K (85%). MAmmoTH2-Plus\\nalso performs well on general tasks, with MAmmoTH2-7B-Plus showing promising results on Hu-\\nmanEval and MBPP, and MAmmoTH2-8×7B leading the AlpacaEval 2.0 and Arena Hard leaderboards.\\nInterestingly, MAmmoTH2-8B-Plus and Llama-3-8B-Instruct, both tuned from Llama-3-base using\\ndatasets of the same size (10M), provide an apple-to-apple comparison. The only distinction is that\\nLlama-3-8B-Instruct is trained on 10M human-annotated dataset while we do not require any human\\nannotation. MAmmoTH2-8B-Plus outperforms Llama-3-Instruct by 6 points on reasoning tasks while\\nmatching its performance on general tasks, reflecting WEBINSTRUCT’s cost-effectiveness advantage.\\nMAmmoTH2-Plus consistently surpasses official instruction models like Mixtral-Instruct on chat\\nbenchmarks. These results demonstrate the effectiveness of our approach to scale up instruction data\\nfrom the web and offer a new perspective for future instruction tuning studies.\\n2\\nWEBINSTRUCT\\nIn this section, we outline the process of constructing WEBINSTRUCT. Specifically, we divide the\\ndata collection pipeline into three stages: (1) relevant document recall from the web corpus, (2) Q-A\\npair extraction from recalled document, and (3) Q-A pair refinement. The full pipeline is depicted\\nin Figure 3 and an example for extraction and refinement is provided in Figure 4.\\n2.1\\nRecall from Common Crawl\\nIn contrast to previous math-centric approaches (Paster et al., 2023; Wang et al., 2023c; Shao et al.,\\n2024), we aim for broad coverage of disciplines such as math, science, engineering, etc. Therefore,\\ncareful balancing of the seed data is necessary to ensure diversity. However, publicly available\\ntraining datasets are mostly limited to mathematics. To address this issue, we propose to crawl new\\nFast-Text\\nLLM Extraction\\nLLM Refinement\\n1\\n2\\nRecall from Web\\nQ-A Pair Extraction\\nPre-process\\nFast-Text\\nCC\\nCC\\nSeed\\nDecontaminate\\nURL Filter\\n3 Q-A Pair Refinement\\nURL Select\\nFigure 3: Step 1: Recall relevant documents from Common Crawl. Step 2: Extracting Q-A pairs.\\nStep 3: Refine with the extracted Q-A pairs.\\nTopics Science\\\\nAnatomy&Physiology\\\\nAstronomy\\\\nAstrophysics\\n\\\\nBiology\\\\nChemistry \\\\n...Socratic Meta...Featured Answers\\nHow do you simplify #((u^4v^3)/(u^2v^-1)^4)^0# and write it using only \\npositive exponents?\\nAnswer by NickTheTurtle (Apr 1, 2017)\\nExplanation:\\\\nAnything raised to the \\\\(0^{th}\\\\) power is simply 1.\\n\\\\n\\\\nRelated Questions\\\\n What is the quotient of powers property?\\n\\\\n\\\\n\\\\n\\\\n How do you simplify expressions using the quotient\\nrule?…\\\\nImpact of this question\\\\n1274 views around the world\\n#Apps\\\\niOS\\\\nAndroid\\\\nLinks\\\\n[Privacy](#)\\\\n[Terms](#)\\\\n[Help](#)\\nRaw Docs\\nQuestion: How do you simplify (𝑢! 𝑣\\\"\\n𝑢# 𝑣$% !\\n⁄\\n)& and write it using\\nonly positive exponents?\\nAnswer: Explanation: Anything to the 0𝑡ℎpower is just simply 1.\\nExtracted QA\\nQuestion:\\nHow do you simplify (𝑢! 𝑣\\\"\\n𝑢# 𝑣$% !\\n⁄\\n)&and write it using only\\npositive exponents?\\nAnswer:\\nTo simplify the expression (𝑢! 𝑣\\\"\\n𝑢# 𝑣$% !\\n⁄\\n)& and rewrite it\\nusing only positive exponents, we start by evaluating the\\nexpression from the innermost operation outward.\\nFirst, consider the exponent of zero on the entire fraction:\\nAny expression raised to the power of zero is equal to 1 (provided\\nthe base is not zero). Therefore, (𝑢! 𝑣\\\"\\n𝑢# 𝑣$% !\\n⁄\\n)& = 1\\nThis simplification makes the other calculations unnecessary\\nbecause raising any non-zero expression to the power of zero will\\nalways result in 1.\\nSo, the simplified expression is simply: 1\\nRewritten QA\\nUnformatted Text, Site Information, Ads\\nFormatted QA but lacking detailed solutions\\nFormatted QA augmented with detailed solutions\\nFigure 4: An illustrating example from WEBINSTRUCT for the extraction and refinement step.\\n3\\n\\n\\nexam problems from several educational websites. These sites contain diverse problems from various\\ndisciplines, helping to ensure diversity. We crawled 100K seed data as positive training examples\\nand randomly selected 100K negative documents from CC (Computer, 2023) to train a fastText\\nmodel (Joulin et al., 2016). The trained fastText model is used to recall relevant documents. We\\nemploy the open-source fastText library with a vector dimension of 256 to train the model for 3\\nepochs, with a learning rate of 0.1, a maximum n-gram length of 3, and a maximum number of\\nword occurrences of 3. We recalled 100B tokens using the trained fasttext model from an internal\\nCC. These raw web documents are further grouped by their domains (root URL) and only domains\\nwith more than 1000 documents are retained. We extracted roughly 600K domains from the recalled\\ndocuments. We then prompt GPT-3.5 to scan through the domains and automatically select those\\nthat might contain instruction data. Around 50K domains are further labeled as positive samples\\nby GPT-3.5. Note that all the recalled documents in the first round are not kept for further usage\\nin Q-A Pair Extraction and Refinement. Next, we sample documents from the selected domains as\\npositive examples, and documents from the non-selected domains and general Common Crawl as\\nnegative examples to re-train an improved fastText classifier. The newly trained fastText classifier\\nis used to recall documents. We recalled 40B tokens using the newly trained fastText model. We\\nprompt GPT-4 to sift through the recalled domains again, ultimately leading to 18M raw documents,\\nprimarily originating from the desired websites.\\n2.2\\nQ-A Pair Extraction\\nWe observe that a significant number of naturally existing Q-A pairs are present in the 18M documents.\\nHowever, these Q-A pairs are interspersed with a high volume of noise such as ads, markups,\\nboilerplate, etc. Our preliminary training on these raw documents only yields limited gains.\\nFirst, we carefully pre-process the HTML to pre-extract useful content from the recalled documents.\\nThis is mostly rule-based filtering to clean site information, ads, HTML boilerplate, etc. This step\\nsignificantly reduces the document length for the next stage. We then prompt Qwen-72B (Bai et al.,\\n2023) to identify the question and answer pairs from the preprocessed documents. Specifically, we\\nprovide a few in-context examples to help the model understand what to extract. We also allow the\\nmodel to return void if no natural question-answer pairs exist. In this stage, only 30% of the recalled\\ndocuments were identified as containing naturally existing Q-A pairs, resulting in roughly 5M Q-A\\npairs as our candidates for the next step. However, these candidates still contain a substantial amount\\nof unrelated content and formality issues. Besides that, a large portion of the extracted Q-A pairs also\\nlack explanations for how the answer is derived. Therefore, we propose to perform another round of\\nrefinement to increase the data quality.\\nTo avoid contamination, we follow previous work (Shao et al., 2024) and filter out web pages\\ncontaining questions or answers to all of our evaluation benchmarks. Specifically, we filter out all\\nweb pages that contain n-grams (n = 10) string matches with either the questions or answers.\\n2.3\\nQ-A Pair Refinement\\nTo further improve the extracted Q-A pair candidates, we propose refining them using LLMs. In this\\nstep, we prompt Mixtral-22B×8 (Jiang et al., 2024) and Qwen-72B (Bai et al., 2023) to reformat\\nthe extracted Q-A pairs. If the answer does not contain any explanation, these two LLMs will\\nattempt to complete the intermediate reasoning steps leading to the given answer. We adopt two\\nmodels to increase the diversity of our dataset. Eventually, we harvest 10M Q-A pairs as our final\\ninstruction-tuning dataset WEBINSTRUCT.\\n2.4\\nDataset Statistics\\nTo better distinguish our dataset from the existing ones, we include a summarization table in Table 1.\\nIt can be observed that most SFT datasets contain less than 1M samples but are of high quality.\\nXwinMath (Li et al., 2024a) is the largest dataset, scaling up to over 1M samples through GPT4\\nsynthesis, while OpenMathInstruct (Toshniwal et al., 2024) has not been generated using GPT-4 but\\ninstead uses Mixtral-8x7B Jiang et al. (2024). However, the seed data for both datasets is only based\\non GSM and MATH, leading to narrow domain coverage. In contrast, continue-training (CT) datasets\\nare normally filtered from the web with much larger size, often exceeding 10B tokens and even rising\\nto 120B tokens. However, continued pre-training on these massive datasets can be not only expensive\\n4\\n\\n\\nTable 1: The list of existing supervise-fine-tuning (SFT) and continue-training (CT) datasets. SFT\\ndatasets are primarily from academic NLP sources or synthesized by GPT-3.5/4 using seed data. CT\\ndatasets are larger but nosier. Our dataset falls between these two types.\\nDataset\\n#Pairs\\nDomain\\nFormat\\nDataset Source\\nFLAN V2 (Chung et al., 2024)\\n100K\\nGeneral\\nSFT\\nNLP data + Human CoT\\nSelf-Instruct (Wang et al., 2023b)\\n82K\\nGeneral\\nSFT\\nGenerated by GPT3\\nGPT4-Alpaca (Taori et al., 2023)\\n52K\\nGeneral\\nSFT\\nGenerated by GPT4\\nSuperNI (Wang et al., 2022)\\n96K\\nGeneral\\nSFT\\nNLP Datasets\\nTora (Gou et al., 2023)\\n16K\\nMath\\nSFT\\nGSM+MATH Synthesis by GPT4\\nWizardMath (Luo et al., 2023)\\n96K\\nMath\\nSFT\\nGSM+MATH Synthesis by GPT4\\nMathInstruct (Yue et al., 2023b)\\n262K\\nMath\\nSFT\\nMath datasets Synthesis by GPT4\\nMetaMathQA (Yu et al., 2023)\\n395K\\nMath\\nSFT\\nGSM+MATH Synthesis by GPT3.5\\nXwinMath (Li et al., 2024a)\\n1.4M\\nMath\\nSFT\\nGSM+MATH Synthesis by GPT4\\nOpenMathInstruct (Toshniwal et al., 2024)\\n1.8M\\nMath\\nSFT\\nGSM+MATH Synthesis by Mixtral\\nDataset\\n#Tokens\\nDomain\\nFormat\\nDataset Source\\nOpenWebMath (Paster et al., 2023)\\n12B\\nMath\\nLM\\nFiltered from Web\\nMathPile (Wang et al., 2023c)\\n10B\\nMath\\nLM\\nFiltered from Web\\nCosmopeida (Ben Allal et al., 2024)\\n25B\\nGeneral\\nLM\\nSynthesized by Mixtral\\nMINERVA (Lewkowycz et al., 2022)\\n38B\\nMath\\nLM\\nFiltered from Web\\nProof-Pile-2 (Azerbayev et al., 2023)\\n55B\\nMath\\nLM\\nOpenWebMath+Arxiv+Code\\nGalactica (Taylor et al., 2022)\\n106B\\nMath & Sci.\\nLM\\nFiltered from Web\\nDeepseekMath (Shao et al., 2024)\\n120B\\nMath\\nLM\\nRecalled from Web\\nWEBINSTRUCT\\n(10M) 5B\\nMath & Sci.\\nSFT\\nRecall and Extracted from Web\\nbut also ineffective due to the high noise ratio. WEBINSTRUCT, with roughly 5B tokens, strikes a\\ngood balance between scalability and quality. It approaches the scalability of common CT datasets\\nwhile maintaining high quality through the three-step construction pipeline. This makes our dataset\\nunique compared to other alternatives.\\n2.5\\nAdditional Public Instruction Datasets\\nTo further enhance the diversity and quality of our dataset, we fine-tune MAmmoTH2 on several open-\\nsource instruction tuning datasets. These datasets are carefully selected based on their relevance to\\ndifferent reasoning subjects. Additionally, we consider some chat datasets to balance reasoning ability\\nand general chat ability. The open-source datasets we incorporate are OpenHermes 2.5 (Teknium,\\n2023), Code-Feedback (Zheng et al., 2024c) and our Math-Plus, which is an augmented version of\\nMetaMathQA (395K) (Yu et al., 2023) and Orca-Math (200K) (Mitra et al., 2024). More details of\\nthe public datasets can be found in Appendix A.\\n3\\nExperimental Setup\\n3.1\\nTraining Setup\\nWe unify all the samples in our instruction dataset to conform to the structure of a multi-turn instruction\\ntuning dataset. This standardization ensures that the fine-tuned models can process data consistently,\\nregardless of the original dataset formats. We select the open-source models Mistral 7B (Jiang et al.,\\n2023), Mixtral 8×7B (Jiang et al., 2024), Llama-3 8B (Meta, 2024), and Yi-34B (Young et al., 2024)\\nas our base models. We fine-tune these models to validate our WEBINSTRUCT at multiple scales\\nusing the LLaMA-Factory (Zheng et al., 2024d) library. We use a learning rate of 5e-6 for Mistral 7B\\nand 1e-5 for Mixtral, Llama-3 8B, and Yi 34B. The global batch size is set to 512 with a maximum\\nsequence length of 4096. We employ a cosine scheduler with a 3% warm-up period for 2 epochs. To\\nefficiently train the models, we utilize DeepSpeed (Rasley et al., 2020) with the ZeRO-3 stage. All\\nthe models are trained with 32 A100 GPUs.\\n3.2\\nEvaluation Datasets\\nTo rigorously assess the capabilities of models in reasoning abilities across different domains, we\\nutilize several widely used datasets, GSM8K (Cobbe et al., 2021), MATH (Hendrycks et al., 2021b),\\nTheoremQA (Chen et al., 2023b), BIG-Bench Hard (BBH) (Suzgun et al., 2022), ARC-C (Clark\\n5\\n\\n\\nTable 2: Main results on reasoning datasets. Models without the ’-Instruct’ suffix refer to the released\\nbase models. Results are taken from official papers or blogs when available; otherwise, we use our\\nown evaluation script. Underscored results represent the best baseline scores under the size constraint.\\nAll models are inferred with few-shot CoT: TheoremQA (5-shot), MATH (4-shot), GSM8K (4-shot),\\nGPQA (5-shot), MMLU-STEM (5-shot), BBH (3-shot), and ARC-C (8-shot).\\nModel\\nTheoremQA\\nMATH\\nGSM8K\\nGPQA\\nMMLU-ST\\nBBH\\nARC-C\\nAVG\\nGPT-4-Turbo-0409\\n48.4\\n69.2\\n94.5\\n46.2\\n76.5\\n86.7\\n93.6\\n73.6\\nParameter Size between 20B and 110B\\nQwen-1.5-110B\\n34.9\\n49.6\\n85.4\\n35.9\\n73.4\\n74.8\\n91.6\\n63.6\\nQwen-1.5-72B\\n29.3\\n46.8\\n77.6\\n36.3\\n68.5\\n68.0\\n92.2\\n59.8\\nDeepseek-LM-67B\\n25.3\\n15.9\\n66.5\\n31.8\\n57.4\\n71.7\\n86.8\\n50.7\\nYi-34B\\n23.2\\n15.9\\n67.9\\n29.7\\n62.6\\n66.4\\n89.5\\n50.7\\nLlemma-34B\\n21.1\\n25.0\\n71.9\\n29.2\\n54.7\\n48.4\\n69.5\\n45.7\\nMixtral-8×7B\\n23.2\\n28.4\\n74.4\\n29.7\\n59.7\\n66.8\\n84.7\\n52.4\\nMixtral-8×7B-Instruct\\n25.3\\n22.1\\n71.7\\n32.4\\n61.4\\n57.3\\n84.7\\n50.7\\nIntern-Math-20B\\n17.1\\n37.7\\n82.9\\n28.9\\n50.1\\n39.3\\n68.6\\n46.4\\nTrained only with WEBINSTRUCT (All evaluations are held-out)\\nMAmmoTH2-34B\\n30.4\\n35.0\\n75.6\\n31.8\\n64.5\\n68.0\\n90.0\\n56.4\\n∆over Yi\\n+7.2\\n+19.1\\n+7.7\\n+2.1\\n+2.9\\n+1.2\\n+0.5\\n+5.8\\nMAmmoTH2-8x7B\\n32.2\\n39.0\\n75.4\\n36.8\\n67.4\\n71.1\\n87.5\\n58.9\\n∆over Mixtral\\n+9.2\\n+10.6\\n+1.0\\n+7.1\\n+7.4\\n+3.3\\n+2.8\\n+6.5\\nContinue trained with additional instruction datasets (All held-out except MATH and GSM8K)\\nMAmmoTH2-8x7B-Plus\\n34.1\\n47.0\\n86.4\\n37.8\\n72.4\\n74.1\\n88.4\\n62.9\\n∆over Qwen-1.5-110B\\n-0.8\\n-2.6\\n+1.0\\n+1.5\\n-1.0\\n-0.7\\n-4.0\\n-0.7\\nParameter Size = 7B or 8B\\nDeepseek-7B\\n15.7\\n6.4\\n17.4\\n25.7\\n43.1\\n42.8\\n47.8\\n28.4\\nQwen-1.5-7B\\n14.2\\n13.3\\n54.1\\n26.7\\n45.4\\n45.2\\n75.6\\n39.2\\nMistral-7B\\n19.2\\n11.2\\n36.2\\n24.7\\n50.1\\n55.7\\n74.2\\n38.8\\nGemma-7B\\n21.5\\n24.3\\n46.4\\n25.7\\n53.3\\n57.4\\n72.5\\n43.0\\nLlemma-7B\\n17.2\\n18.0\\n36.4\\n23.2\\n45.2\\n44.9\\n50.5\\n33.6\\nWizardMath-7B-1.1\\n11.7\\n33.0\\n83.2\\n28.7\\n52.7\\n56.7\\n76.9\\n49.0\\nAbel-7B-002\\n19.3\\n29.5\\n83.2\\n30.3\\n29.7\\n32.7\\n72.5\\n42.5\\nIntern-Math-7B\\n13.2\\n34.6\\n78.1\\n22.7\\n41.1\\n48.1\\n59.8\\n42.5\\nRho-1-Math-7B\\n21.0\\n31.0\\n66.9\\n29.2\\n53.1\\n57.7\\n72.7\\n47.3\\nDeepseek-Math-7B\\n25.3\\n34.0\\n64.2\\n29.2\\n56.4\\n59.5\\n67.8\\n48.0\\nDeepseek-Math-Instruct\\n23.7\\n44.3\\n82.9\\n31.8\\n59.3\\n55.4\\n70.1\\n52.5\\nLlama-3-8B\\n20.1\\n21.3\\n54.8\\n27.2\\n55.6\\n61.1\\n78.6\\n45.5\\nLlama-3-8B-Instruct\\n22.8\\n30.0\\n79.5\\n34.5\\n60.2\\n66.0\\n80.8\\n53.4\\nTrained only with WEBINSTRUCT (All evaluations are held-out)\\nMAmmoTH2-7B\\n29.0\\n36.7\\n68.4\\n32.4\\n62.4\\n58.6\\n81.7\\n52.8\\n∆over Mistral\\n+9.8\\n+25.5\\n+32.2\\n+7.7\\n+12.3\\n+2.9\\n+7.5\\n+14.0\\nMAmmoTH2-8B\\n32.2\\n35.8\\n70.4\\n35.2\\n64.2\\n62.1\\n82.2\\n54.3\\n∆over Llama3\\n+12.2\\n+14.5\\n+15.6\\n+8.0\\n+8.6\\n+1.0\\n+3.6\\n+8.8\\nContinue trained with additional instruction datasets (All held-out except MATH and GSM8K)\\nMAmmoTH2-7B-Plus\\n29.2\\n45.0\\n84.7\\n36.8\\n64.5\\n63.1\\n83.0\\n58.0\\nMAmmoTH2-8B-Plus\\n32.5\\n42.8\\n84.1\\n37.3\\n65.7\\n67.8\\n83.4\\n59.1\\n∆over best baseline\\n+7.2\\n+0.7\\n+1.5\\n+2.8\\n+5.5\\n+1.8\\n+2.6\\n+5.7\\net al., 2018), GPQA (Rein et al., 2023), MMLU-STEM (Hendrycks et al., 2021a). These datasets\\ncollectively enable a comprehensive assessment of language models’ reasoning prowess across a\\nspectrum of complexity and realism. The details of the evaluation datasets are in Appendix B.\\nWe further evaluate the models on additional code generation tasks (including HumanEval (Chen\\net al., 2021), MBPP (Austin et al., 2021) and their augmented version (Liu et al., 2024)), general\\nLLM benchmarks like MMLU (Hendrycks et al., 2021a) and its recent robust and challenging version\\nMMLU-Pro (TIGER-Lab, 2024). We also consider chat benchmarks like MT-Bench (Zheng et al.,\\n2024a), AlpacaEval 2.0 (Li et al., 2023), and Arena Hard (Li et al., 2024b) to demonstrate the\\ngeneralizability of WEBINSTRUCT and WEBINSTRUCT-PLUS on more general LLM benchmarks.\\n6\\n\\n\\n4\\nMain Results\\n4.1\\nExperimental Results on Reasoning Benchmarks\\nTable 2 presents our main results, with existing models partitioned into two tracks based on their\\nparameter size. For 7B parameter models, we observe that our model trained solely with WEBIN-\\nSTRUCT achieves significant improvements over the base models. For instance, MAmmoTH2-7B boosts\\nthe performance of Mistral-7B by an average of 14 points. Notably, WEBINSTRUCT does not contain\\nany training data from these evaluation benchmarks, making all evaluations essentially held-out. The\\nsubstantial performance gains demonstrate the strong generalization capabilities of MAmmoTH2-7B.\\nSimilarly, MAmmoTH2-8B boosts the performance of Llama-3-8B-base by an average of 8.8 points.\\nWe also experiment with larger models like Yi-34B and Mixtral to show that the performance gains\\nare consistent across the board. Notably, Yi-34B’s performance on MATH also increases by 19%\\nafter training on WEBINSTRUCT.\\nFurther tuning on several additional public datasets also significantly enhances performance. The\\nMAmmoTH2-Plus model family achieves state-of-the-art results across the board. For example,\\nMAmmoTH2-Plus’s performance on TheoremQA, GPQA, and ARC-C represents the best-known\\nresults for any model under 10B parameters. MAmmoTH2-7B-Plus’s performance on MATH and\\nGSM is also close to the best-known results. We also show the results of the models solely trained on\\nthe additional public datasets in Appendix E.\\nAn interesting comparison is between MAmmoTH2-8B-Plus and Llama3-Instruct, as both models\\nare trained from the Llama3-base. Llama-3-instruct was trained on a 10M human-annotated in-\\nstruction dataset along with public datasets, similar to WEBINSTRUCT combined with additional\\npublic datasets. Therefore, these two models are highly comparable. Our experiments show that\\nMAmmoTH2-8B-Plus outperforms Llama3-Instruct by an average of 6% across the benchmarks. This\\nsubstantial gain indicates that WEBINSTRUCT is highly cost-effective. For larger models, we found\\nthat MAmmoTH2-8x7B-Plus can even match the performance of Qwen-1.5-110B with only 13B active\\nparameters. These results demonstrate the effectiveness of our scalable instruction tuning approach.\\n4.2\\nAdditional Experimental Results\\nTo further demonstrate the capabilities of our models beyond the reasoning benchmarks presented\\nin Table 2, we conduct additional experiments to evaluate their performance on code generation,\\ngeneral language understanding, and instruction-following tasks. Table 3 showcases the results of var-\\nious models on code generation tasks. The MAmmoTH2-7B-Plus model exhibits strong performance,\\nachieving the highest average scores of 66.1 and 58.2 on HumanEval(+) and MBPP(+) datasets,\\nrespectively. It outperforms the official instruct counterparts like Mistral-7B-Instruct-v0.2 on these\\nmetrics, indicating its superior code generation abilities.\\nTo assess the general language understanding and instruction-following capabilities of our models, we\\nevaluate them on a range of benchmarks, as shown in Table 3. The MAmmoTH2-Plus models exhibit\\nstrong performance across these tasks, showcasing their versatility and robustness. For example,\\nMAmmoTH2-8×7B-Plus achieves the highest scores on AlpacaEval 2.0 and Arena Hard leaderboards,\\nsurpassing competitive models like GPT-3.5-Turbo and Tulu-2-DPO-70B (Ivison et al., 2023).\\n2M\\n4M\\n6M\\n8M 10M\\n# of Instructions\\n20\\n25\\n30\\nAccuracy (%)\\nMATH\\n2M\\n4M\\n6M\\n8M 10M\\n# of Instructions\\n15\\n20\\n25\\nAccuracy (%)\\nTheoremQA\\n2M\\n4M\\n6M\\n8M 10M\\n# of Instructions\\n72.5\\n75.0\\n77.5\\n80.0\\nAccuracy (%)\\nARC-C\\nExtracted QA (LM Loss)\\nRefined QA (LM Loss)\\nRefined QA (SFT Loss)\\nFigure 5: Mistral-7B model reasoning performance improves with scaling instructions. Additionally,\\nSFT Loss is a more effective learning approach compared to LM Loss.\\n7\\n\\n\\nTable 3: Evaluation of code generation, instruction-following and MMLU(-Pro) performance for\\nvarious models. We report the average of HumanEval(+) and MBPP (+) accuracy as the code\\ngeneration performance (breakdown results are in Appendix D). Baseline scores are sourced\\nfrom the original papers or the EvalPlus, MT-Bench, AlpacaEval 2.0, Arena Hard and MMLU-Pro\\nleaderboards. (“-”) indicates that the score is not available from the sources. MAmmoTH2-Plus\\nexhibits strong general conversational ability and excels at multitask language understanding across a\\nwide range of domains compared to their official instruct counterparts and larger models.\\nCode\\nGeneration\\nMT-Bench\\nAlpaca\\nEval 2.0\\nArena\\nHard\\nMMLU\\nMMLU-Pro\\nGPT-4-1106-preview\\n85.6 (77.5)\\n9.32\\n50.0\\n-\\n-\\n-\\nGPT-3.5-Turbo-1106\\n79.7 (70.2)\\n8.32\\n19.3\\n18.9\\n-\\n-\\nGPT-3.5-Turbo-0301\\n-\\n7.94\\n18.1\\n18.1\\n70.0\\n-\\nTulu-2-DPO-70B\\n51.2 (43.0)\\n7.89\\n21.2\\n15.0\\n67.8\\n40.5\\nLlama-2-70b-chat\\n31.4 (26.5)\\n6.86\\n14.7\\n11.6\\n63.0\\n33.6\\nYi-34B-Chat\\n38.7 (32.6)\\n7.86\\n27.2\\n23.1\\n73.5\\n42.1\\nMistral-7B-Instruct-v0.2\\n43.4 (36.5)\\n7.60\\n17.1\\n12.6\\n60.8\\n30.8\\nLlama-3-8B-Instruct\\n65.8 (58.0)\\n8.02\\n22.9\\n20.6\\n67.2\\n40.9\\nMixtral-8×7B-Instruct-v0.1\\n52.3 (44.7)\\n8.30\\n23.7\\n23.4\\n70.6\\n41.0\\nMAmmoTH2-7B-Plus\\n66.1 (58.2)\\n7.88\\n23.4\\n14.6\\n63.3\\n40.9\\nMAmmoTH2-8B-Plus\\n61.9 (53.3)\\n7.95\\n18.5\\n16.6\\n64.6\\n43.4\\nMAmmoTH2-8x7B-Plus\\n63.3 (55.3)\\n8.20\\n33.8\\n32.6\\n68.3\\n50.4\\nThe strong performance of MAmmoTH2 on code generation and general language understanding tasks,\\nas evidenced by Table 3, demonstrates that our method does not overfit to the reasoning benchmarks.\\nInstead, it shows the models’ ability to generalize well to a wide range of tasks, highlighting their\\nversatility and robustness. These additional experiments further validate the effectiveness of our\\nWEBINSTRUCT in developing powerful and flexible language models.\\n5\\nAblation Study\\n5.1\\nScaling Effect of Instructions\\nWe first investigate the impact of model scaling and loss functions on the performance of language\\nmodels across three representative tasks: MATH, TheoremQA, and ARC-C. We train models with\\nvarying training samples (1M to 10M) using extracted QA and refined QA data, and compare the\\neffectiveness of two training losses: LM loss and SFT loss. Figure 5 shows that increasing model\\nsize and using SFT Loss with synthetic data consistently improves accuracy across all tasks. These\\nfindings demonstrate the importance of model scaling and supervised fine-tuning with synthetic data\\nfor enhancing language model performance in various domains.\\n5.2\\nComparison of Two Refined Models\\nTable 4: Comparison of the two data-refining LLMs. We\\ntrain the three models with the same steps.\\nData\\nGSM\\nMATH\\nMMLU-S\\nTheo.\\nARC.\\nMixtral\\n62.9\\n29.1\\n56.5\\n26.1\\n78.3\\nQwen\\n65.4\\n28.9\\n60.6\\n23.5\\n80.8\\nMerged\\n65.6\\n31.0\\n60.5\\n24.8\\n81.8\\nTo assess the effectiveness of the Q-\\nA pair refinement process by different\\nLLMs, we conducted experiments by\\ntraining three mistral-7B models: one on\\nthe data refined by Mixtral-22B×8, an-\\nother on the data refined by Qwen-72B,\\nand a third on the merged samples re-\\nfined by both models. For a fair compari-\\nson, we trained the models with the same\\n9000 steps and a global batch size of 512. Our results show that the model trained on Mixtral-22B×8\\nrefined data achieves comparable performance to the one trained on Qwen-72B refined data. The\\nmodel trained on the merged samples consistently outperforms the models trained on data refined by\\nindividual LLMs. This demonstrates the effectiveness of using multiple LLMs for refinement, as it\\nleads to a more diverse and comprehensive dataset.\\n8\\n\\n\\n5.3\\nComparison of Different Domains and Sources.\\nTo understand how each domain (e.g., math, science, others) and data source (e.g., forum websites\\nand education websites) contribute to the training, we train Mistral 7B on the subsets of different\\ndomains and data sources. Details of how we obtain domain labels can be found in Appendix G.\\nTable 5: Impact of different data domains and sources.\\nData Source\\nGSM\\nMATH\\nMMLU-S\\nTheo.\\nARC.\\nBase\\n47.4\\n15.7\\n51.4\\n17.3\\n77.6\\nForum\\n51.0\\n24.0\\n54.7\\n21.0\\n78.2\\nEducation\\n58.0\\n24.8\\n54.3\\n23.2\\n79.5\\nMath\\n52.9\\n27.3\\n51.6\\n21.7\\n74.1\\nScience\\n54.4\\n23.7\\n58.9\\n21.0\\n83.6\\nOther\\n59.4\\n20.8\\n55.3\\n21.1\\n79.4\\nAs shown in Table 5, training on differ-\\nent domains and data sources leads to\\nvaried performance across the evaluation\\nbenchmarks. The education website data\\nsource consistently outperforms the fo-\\nrum data source, indicating the higher\\nquality of educational questions. Inter-\\nestingly, while the math domain excels\\non MATH, it does not lead to significant\\nimprovements on GSM8K, another math-\\nfocused dataset, suggesting that training\\non a single math dataset may not gener-\\nalize well to other math benchmarks. Furthermore, training solely on the math domain does not yield\\nsubstantial gains on science and STEM benchmarks, highlighting the need for diverse training. In\\ncontrast, the \\\"Other\\\" domain, which includes a diverse range of subjects, achieves the highest score\\non GSM8K, emphasizing the importance of diversity in the training data.\\n5.4\\nCase Study\\nFigure 6: Quality distribution of 50 sam-\\npled refined QA examples.\\nWe further conduct a case study examining the quality\\nof extracted and refined QA pairs from the dataset. We\\nshowcase some good and bad cases in Appendix J. We\\nobserve that the question/answer pairs extracted from well-\\nformed exam and education websites are of high quality.\\nThe common issue is that a large portion of extracted\\nanswers do not contain intermediate rationale (chain-of-\\nthought). This issue could lead to worse generalization.\\nTherefore, we prompt Mixtral and Qwen-72B to complete\\nthe intermediate steps. We observe that the success rate\\nof such completion is relatively high. However, there are\\ncases where the extracted question/answer pairs contain\\nserious formatting issues, which pose challenges for the\\nfollowing refinement step. Besides these issues, we also\\nobserve that LLMs can sometimes modify the intention of\\nthe originally extracted content, causing hallucinations.\\nTo quantify the error percentages, we randomly sample 50 refined QA examples and ask the human\\nannotators to compare whether the refined examples are correct and significantly better than the\\nextracted ones in terms of format and intermediate solutions. As we can see from Figure 6, 78%\\nexamples have been improved after refinement and only 10% examples introduce hallucinations after\\nrefinement. Overall, our case study reveals that the harvested instruction tuning dataset is generally\\naccurate with a low error rate.\\n6\\nConclusion\\nIn this paper, we argue that the web corpus contains a vast amount of high-quality instruction data\\nacross various domains. To mine this data, we develop a three-step pipeline consisting of recall,\\nextraction, and refinement steps. Through this pipeline, we harvest WEBINSTRUCT, a total of\\n10M diverse, high-quality instruction-response pairs and train language models. Our experiments\\ndemonstrate that MAmmoTH2 exhibits significantly enhanced science reasoning abilities compared to\\nthe baseline models. Our work showcases the potential of harnessing the vast amount of instruction\\ndata in the web corpus to democratize the development of LLMs with enhanced reasoning capabilities.\\n9\\n\\n\\nReferences\\nJ. Achiam, S. Adler, S. Agarwal, L. Ahmad, I. Akkaya, F. L. Aleman, D. Almeida, J. Altenschmidt,\\nS. Altman, S. Anadkat, et al. Gpt-4 technical report. ArXiv preprint, abs/2303.08774, 2023. URL\\nhttps://arxiv.org/abs/2303.08774.\\nA. Amini, S. Gabriel, S. Lin, R. Koncel-Kedziorski, Y. Choi, and H. Hajishirzi. MathQA: Towards\\ninterpretable math word problem solving with operation-based formalisms. In Proceedings of the\\n2019 Conference of the North American Chapter of the Association for Computational Linguistics:\\nHuman Language Technologies, Volume 1 (Long and Short Papers), pages 2357–2367, 2019. doi:\\n10.18653/v1/N19-1245. URL https://aclanthology.org/N19-1245.\\nJ. Austin, A. Odena, M. Nye, M. Bosma, H. Michalewski, D. Dohan, E. Jiang, C. Cai, M. Terry,\\nQ. Le, et al. Program synthesis with large language models. ArXiv preprint, abs/2108.07732, 2021.\\nURL https://arxiv.org/abs/2108.07732.\\nZ. Azerbayev, H. Schoelkopf, K. Paster, M. Dos Santos, S. M. McAleer, A. Q. Jiang, J. Deng,\\nS. Biderman, and S. Welleck. Llemma: An open language model for mathematics. In The Twelfth\\nInternational Conference on Learning Representations, 2023. URL https://openreview.net/\\nforum?id=4WnqRR915j.\\nJ. Bai, S. Bai, Y. Chu, Z. Cui, K. Dang, X. Deng, Y. Fan, W. Ge, Y. Han, F. Huang, et al. Qwen\\ntechnical report. ArXiv preprint, abs/2309.16609, 2023. URL https://arxiv.org/abs/2309.\\n16609.\\nL. Ben Allal, A. Lozhkov, G. Penedo, T. Wolf, and L. von Werra. Cosmopedia, 2024. URL\\nhttps://huggingface.co/datasets/HuggingFaceTB/cosmopedia.\\nT. B. Brown, B. Mann, N. Ryder, M. Subbiah, J. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam,\\nG. Sastry, A. Askell, S. Agarwal, A. Herbert-Voss, G. Krueger, T. Henighan, R. Child, A. Ramesh,\\nD. M. Ziegler, J. Wu, C. Winter, C. Hesse, M. Chen, E. Sigler, M. Litwin, S. Gray, B. Chess, J. Clark,\\nC. Berner, S. McCandlish, A. Radford, I. Sutskever, and D. Amodei. Language models are few-shot\\nlearners. In H. Larochelle, M. Ranzato, R. Hadsell, M. Balcan, and H. Lin, editors, Advances in\\nNeural Information Processing Systems 33: Annual Conference on Neural Information Processing\\nSystems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020. URL https://proceedings.\\nneurips.cc/paper/2020/hash/1457c0d6bfcb4967418bfb8ac142f64a-Abstract.html.\\nM. Chen, J. Tworek, H. Jun, Q. Yuan, H. P. d. O. Pinto, J. Kaplan, H. Edwards, Y. Burda,\\nN. Joseph, G. Brockman, et al.\\nEvaluating large language models trained on code.\\nArXiv\\npreprint, abs/2107.03374, 2021. URL https://arxiv.org/abs/2107.03374.\\nW. Chen, X. Ma, X. Wang, and W. W. Cohen. Program of thoughts prompting: Disentangling\\ncomputation from reasoning for numerical reasoning tasks. Transactions on Machine Learning\\nResearch, 2023a. URL https://openreview.net/forum?id=YfZ4ZPt8zd.\\nW. Chen, M. Yin, M. Ku, P. Lu, Y. Wan, X. Ma, J. Xu, X. Wang, and T. Xia. Theoremqa: A theorem-\\ndriven question answering dataset. In The 2023 Conference on Empirical Methods in Natural\\nLanguage Processing, 2023b. URL https://aclanthology.org/2023.emnlp-main.489/.\\nH. W. Chung, L. Hou, S. Longpre, B. Zoph, Y. Tay, W. Fedus, Y. Li, X. Wang, M. Dehghani,\\nS. Brahma, et al. Scaling instruction-finetuned language models. Journal of Machine Learning\\nResearch, 25(70):1–53, 2024. URL https://arxiv.org/pdf/2210.11416.\\nP. Clark, I. Cowhey, O. Etzioni, T. Khot, A. Sabharwal, C. Schoenick, and O. Tafjord. Think you have\\nsolved question answering? try arc, the ai2 reasoning challenge. ArXiv preprint, abs/1803.05457,\\n2018. URL https://arxiv.org/abs/1803.05457.\\nK. Cobbe, V. Kosaraju, M. Bavarian, M. Chen, H. Jun, L. Kaiser, M. Plappert, J. Tworek, J. Hilton,\\nR. Nakano, et al. Training verifiers to solve math word problems. ArXiv preprint, abs/2110.14168,\\n2021. URL https://arxiv.org/abs/2110.14168.\\nT. Computer. Redpajama: an open dataset for training large language models, 2023. URL https:\\n//github.com/togethercomputer/RedPajama-Data.\\n10\\n\\n\\nL. Gao, A. Madaan, S. Zhou, U. Alon, P. Liu, Y. Yang, J. Callan, and G. Neubig. Pal: Program-aided\\nlanguage models. In International Conference on Machine Learning, pages 10764–10799. PMLR,\\n2023. URL https://arxiv.org/pdf/2211.10435.\\nZ. Gou, Z. Shao, Y. Gong, Y. Yang, M. Huang, N. Duan, W. Chen, et al. Tora: A tool-integrated\\nreasoning agent for mathematical problem solving. ArXiv preprint, abs/2309.17452, 2023. URL\\nhttps://arxiv.org/abs/2309.17452.\\nD. Hendrycks, C. Burns, S. Basart, A. Zou, M. Mazeika, D. Song, and J. Steinhardt. Measur-\\ning massive multitask language understanding. In 9th International Conference on Learning\\nRepresentations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021, 2021a.\\nURL https:\\n//openreview.net/forum?id=d7KBjmI3GmQ.\\nD. Hendrycks, C. Burns, S. Kadavath, A. Arora, S. Basart, E. Tang, D. Song, and J. Steinhardt.\\nMeasuring mathematical problem solving with the math dataset. In Thirty-fifth Conference on\\nNeural Information Processing Systems Datasets and Benchmarks Track (Round 2), 2021b. URL\\nhttps://openreview.net/forum?id=7Bywt2mQsCe.\\nH. Ivison, Y. Wang, V. Pyatkin, N. Lambert, M. Peters, P. Dasigi, J. Jang, D. Wadden, N. A. Smith,\\nI. Beltagy, et al. Camels in a changing climate: Enhancing lm adaptation with tulu 2. ArXiv\\npreprint, abs/2311.10702, 2023. URL https://arxiv.org/pdf/2311.10702.\\nA. Q. Jiang, A. Sablayrolles, A. Mensch, C. Bamford, D. S. Chaplot, D. d. l. Casas, F. Bressand,\\nG. Lengyel, G. Lample, L. Saulnier, et al. Mistral 7b. ArXiv preprint, abs/2310.06825, 2023. URL\\nhttps://arxiv.org/abs/2310.06825.\\nA. Q. Jiang, A. Sablayrolles, A. Roux, A. Mensch, B. Savary, C. Bamford, D. S. Chaplot, D. d. l.\\nCasas, E. B. Hanna, F. Bressand, et al. Mixtral of experts. ArXiv preprint, abs/2401.04088, 2024.\\nURL https://arxiv.org/abs/2401.04088.\\nA. Joulin, E. Grave, P. Bojanowski, M. Douze, H. Jégou, and T. Mikolov. Fasttext. zip: Compressing\\ntext classification models. ArXiv preprint, abs/1612.03651, 2016. URL https://arxiv.org/\\nabs/1612.03651.\\nA. Lewkowycz, A. Andreassen, D. Dohan, E. Dyer, H. Michalewski, V. Ramasesh, A. Slone,\\nC. Anil, I. Schlag, T. Gutman-Solo, et al. Solving quantitative reasoning problems with language\\nmodels. Advances in Neural Information Processing Systems, 35:3843–3857, 2022. URL https:\\n//openreview.net/forum?id=IFXTZERXdM7.\\nC. Li, W. Wang, J. Hu, Y. Wei, N. Zheng, H. Hu, Z. Zhang, and H. Peng. Common 7b language\\nmodels already possess strong math capabilities. ArXiv preprint, abs/2403.04706, 2024a. URL\\nhttps://arxiv.org/abs/2403.04706.\\nT. Li, W.-L. Chiang, L. D. Evan Frick, B. Zhu, J. E. Gonzalez, and I. Stoica. From live data to\\nhigh-quality benchmarks: The arena-hard pipeline, April 2024b. URL https://lmsys.org/\\nblog/2024-04-19-arena-hard/.\\nX. Li, T. Zhang, Y. Dubois, R. Taori, I. Gulrajani, C. Guestrin, P. Liang, and T. B. Hashimoto.\\nAlpacaeval: An automatic evaluator of instruction-following models. https://github.com/\\ntatsu-lab/alpaca_eval, 2023.\\nZ. Lin, Z. Gou, T. Liang, R. Luo, H. Liu, and Y. Yang. Criticbench: Benchmarking llms for critique-\\ncorrect reasoning. ArXiv preprint, abs/2402.14809, 2024. URL https://arxiv.org/abs/2402.\\n14809.\\nJ. Liu, C. S. Xia, Y. Wang, and L. Zhang.\\nIs your code generated by chatgpt really correct?\\nrigorous evaluation of large language models for code generation. Advances in Neural Information\\nProcessing Systems, 36, 2024. URL https://openreview.net/pdf?id=1qvx610Cu7.\\nH. Luo, Q. Sun, C. Xu, P. Zhao, J. Lou, C. Tao, X. Geng, Q. Lin, S. Chen, and D. Zhang. Wizardmath:\\nEmpowering mathematical reasoning for large language models via reinforced evol-instruct. ArXiv\\npreprint, abs/2308.09583, 2023. URL https://arxiv.org/abs/2308.09583.\\n11\\n\\n\\nMeta. Introducing meta llama 3: The most capable openly available llm to date. https://ai.meta.\\ncom/blog/meta-llama-3/, April 2024.\\nA. Mitra, H. Khanpour, C. Rosset, and A. Awadallah. Orca-math: Unlocking the potential of slms\\nin grade school math. ArXiv preprint, abs/2402.14830, 2024. URL https://arxiv.org/abs/\\n2402.14830.\\nM. Nye, A. J. Andreassen, G. Gur-Ari, H. Michalewski, J. Austin, D. Bieber, D. Dohan,\\nA. Lewkowycz, M. Bosma, D. Luan, et al.\\nShow your work: Scratchpads for intermedi-\\nate computation with language models. In Deep Learning for Code Workshop, 2022. URL\\nhttps://openreview.net/forum?id=iedYJm92o0a.\\nL. Ouyang, J. Wu, X. Jiang, D. Almeida, C. Wainwright, P. Mishkin, C. Zhang, S. Agar-\\nwal,\\nK. Slama,\\nA. Ray,\\net al.\\nTraining language models to follow instructions\\nwith human feedback.\\nAdvances in neural information processing systems, 35:27730–\\n27744, 2022. URL https://proceedings.neurips.cc/paper_files/paper/2022/file/\\nb1efde53be364a73914f58805a001731-Paper-Conference.pdf.\\nK. Paster, M. Dos Santos, Z. Azerbayev, and J. Ba. Openwebmath: An open dataset of high-quality\\nmathematical web text. In The Twelfth International Conference on Learning Representations,\\n2023. URL https://openreview.net/pdf?id=jKHmjlpViu.\\nB. Peng, C. Li, P. He, M. Galley, and J. Gao. Instruction tuning with gpt-4. ArXiv preprint,\\nabs/2304.03277, 2023. URL https://arxiv.org/abs/2304.03277.\\nJ. Rasley, S. Rajbhandari, O. Ruwase, and Y. He. Deepspeed: System optimizations enable training\\ndeep learning models with over 100 billion parameters. In R. Gupta, Y. Liu, J. Tang, and B. A.\\nPrakash, editors, KDD ’20: The 26th ACM SIGKDD Conference on Knowledge Discovery and\\nData Mining, Virtual Event, CA, USA, August 23-27, 2020, pages 3505–3506, 2020.\\nURL\\nhttps://dl.acm.org/doi/10.1145/3394486.3406703.\\nD. Rein, B. L. Hou, A. C. Stickland, J. Petty, R. Y. Pang, J. Dirani, J. Michael, and S. R. Bowman.\\nGpqa: A graduate-level google-proof q&a benchmark. ArXiv preprint, abs/2311.12022, 2023.\\nURL https://arxiv.org/abs/2311.12022.\\nV. Sanh, A. Webson, C. Raffel, S. H. Bach, L. Sutawika, Z. Alyafeai, A. Chaffin, A. Stiegler, A. Raja,\\nM. Dey, M. S. Bari, C. Xu, U. Thakker, S. S. Sharma, E. Szczechla, T. Kim, G. Chhablani, N. V.\\nNayak, D. Datta, J. Chang, M. T. Jiang, H. Wang, M. Manica, S. Shen, Z. X. Yong, H. Pandey,\\nR. Bawden, T. Wang, T. Neeraj, J. Rozen, A. Sharma, A. Santilli, T. Févry, J. A. Fries, R. Teehan,\\nT. L. Scao, S. Biderman, L. Gao, T. Wolf, and A. M. Rush. Multitask prompted training enables\\nzero-shot task generalization. In The Tenth International Conference on Learning Representations,\\nICLR 2022, Virtual Event, April 25-29, 2022, 2022. URL https://openreview.net/forum?\\nid=9Vrb9D0WI4.\\nZ. Shao, P. Wang, Q. Zhu, R. Xu, J. Song, M. Zhang, Y. Li, Y. Wu, and D. Guo. Deepseekmath: Push-\\ning the limits of mathematical reasoning in open language models. ArXiv preprint, abs/2402.03300,\\n2024. URL https://arxiv.org/abs/2402.03300.\\nA. Srivastava, A. Rastogi, A. Rao, A. A. M. Shoeb, A. Abid, A. Fisch, A. R. Brown, A. Santoro,\\nA. Gupta, A. Garriga-Alonso, et al. Beyond the imitation game: Quantifying and extrapolating\\nthe capabilities of language models. Transactions on Machine Learning Research, 2023. URL\\nhttps://openreview.net/forum?id=uyTL5Bvosj.\\nL. Sun, Y. Han, Z. Zhao, D. Ma, Z. Shen, B. Chen, L. Chen, and K. Yu. Scieval: A multi-level large\\nlanguage model evaluation benchmark for scientific research. ArXiv preprint, abs/2308.13149,\\n2023. URL https://arxiv.org/abs/2308.13149.\\nM. Suzgun, N. Scales, N. Schärli, S. Gehrmann, Y. Tay, H. W. Chung, A. Chowdhery, Q. V. Le, E. H.\\nChi, D. Zhou, , and J. Wei. Challenging big-bench tasks and whether chain-of-thought can solve\\nthem. ArXiv preprint, abs/2210.09261, 2022. URL https://arxiv.org/abs/2210.09261.\\nZ. Tang, X. Zhang, B. Wan, and F. Wei. Mathscale: Scaling instruction tuning for mathematical\\nreasoning. ArXiv preprint, abs/2403.02884, 2024. URL https://arxiv.org/abs/2403.02884.\\n12\\n\\n\\nR. Taori, I. Gulrajani, T. Zhang, Y. Dubois, X. Li, C. Guestrin, P. Liang, and T. B. Hashimoto.\\nStanford alpaca: An instruction-following llama model. https://github.com/tatsu-lab/\\nstanford_alpaca, 2023.\\nR. Taylor, M. Kardas, G. Cucurull, T. Scialom, A. Hartshorn, E. Saravia, A. Poulton, V. Kerkez, and\\nR. Stojnic. Galactica: A large language model for science. ArXiv preprint, abs/2211.09085, 2022.\\nURL https://arxiv.org/abs/2211.09085.\\nG. Team, R. Anil, S. Borgeaud, Y. Wu, J.-B. Alayrac, J. Yu, R. Soricut, J. Schalkwyk, A. M.\\nDai, A. Hauth, et al. Gemini: a family of highly capable multimodal models. ArXiv preprint,\\nabs/2312.11805, 2023. URL https://arxiv.org/abs/2312.11805.\\nTeknium. Openhermes 2.5: An open dataset of synthetic data for generalist llm assistants, 2023.\\nURL https://huggingface.co/datasets/teknium/OpenHermes-2.5.\\nTIGER-Lab. Mmlu professional dataset. Hugging Face Dataset Hub, 2024. URL https://\\nhuggingface.co/datasets/TIGER-Lab/MMLU-Pro.\\nS. Toshniwal, I. Moshkov, S. Narenthiran, D. Gitman, F. Jia, and I. Gitman. Openmathinstruct-1:\\nA 1.8 million math instruction tuning dataset. ArXiv preprint, abs/2402.10176, 2024. URL\\nhttps://arxiv.org/abs/2402.10176.\\nH. Touvron, T. Lavril, G. Izacard, X. Martinet, M.-A. Lachaux, T. Lacroix, B. Rozière, N. Goyal,\\nE. Hambro, F. Azhar, et al. Llama: Open and efficient foundation language models. ArXiv preprint,\\nabs/2302.13971, 2023a. URL https://arxiv.org/abs/2302.13971.\\nH. Touvron, L. Martin, K. Stone, P. Albert, A. Almahairi, Y. Babaei, N. Bashlykov, S. Batra,\\nP. Bhargava, S. Bhosale, et al. Llama 2: Open foundation and fine-tuned chat models. ArXiv\\npreprint, abs/2307.09288, 2023b. URL https://arxiv.org/abs/2307.09288.\\nX. Wang, Z. Hu, P. Lu, Y. Zhu, J. Zhang, S. Subramaniam, A. Loomba, S. Zhang, Y. Sun, and\\nW. Wang. Scibench: Evaluating college-level scientific problem-solving abilities of large language\\nmodels. In The 3rd Workshop on Mathematical Reasoning and AI at NeurIPS’23, 2023a. URL\\nhttps://openreview.net/forum?id=u6jbcaCHqO.\\nY. Wang, S. Mishra, P. Alipoormolabashi, Y. Kordi, A. Mirzaei, A. Naik, A. Ashok, A. S.\\nDhanasekaran, A. Arunkumar, D. Stap, E. Pathak, G. Karamanolakis, H. Lai, I. Purohit, I. Mon-\\ndal, J. Anderson, K. Kuznia, K. Doshi, K. K. Pal, M. Patel, M. Moradshahi, M. Parmar,\\nM. Purohit, N. Varshney, P. R. Kaza, P. Verma, R. S. Puri, R. Karia, S. Doshi, S. K. Sampat,\\nS. Mishra, S. Reddy A, S. Patro, T. Dixit, and X. Shen. Super-NaturalInstructions: General-\\nization via declarative instructions on 1600+ NLP tasks. In Proceedings of the 2022 Confer-\\nence on Empirical Methods in Natural Language Processing, pages 5085–5109, 2022. URL\\nhttps://aclanthology.org/2022.emnlp-main.340.\\nY. Wang, Y. Kordi, S. Mishra, A. Liu, N. A. Smith, D. Khashabi, and H. Hajishirzi. Self-instruct:\\nAligning language models with self-generated instructions. In Proceedings of the 61st Annual\\nMeeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 13484–\\n13508, 2023b. URL https://arxiv.org/abs/2212.10560.\\nZ. Wang, R. Xia, and P. Liu. Generative ai for math: Part i–mathpile: A billion-token-scale pretraining\\ncorpus for math. ArXiv preprint, abs/2312.17120, 2023c. URL https://arxiv.org/abs/2312.\\n17120.\\nJ. Wei, M. Bosma, V. Y. Zhao, K. Guu, A. W. Yu, B. Lester, N. Du, A. M. Dai, and Q. V. Le.\\nFinetuned language models are zero-shot learners. In The Tenth International Conference on\\nLearning Representations, ICLR 2022, Virtual Event, April 25-29, 2022, 2022a. URL https:\\n//openreview.net/forum?id=gEZrGCozdqR.\\nJ. Wei, X. Wang, D. Schuurmans, M. Bosma, F. Xia, E. Chi, Q. V. Le, D. Zhou, et al. Chain-of-thought\\nprompting elicits reasoning in large language models. Advances in neural information processing\\nsystems, 35:24824–24837, 2022b. URL https://openreview.net/pdf?id=_VjQlMeSB_J.\\n13\\n\\n\\nC. Xu, Q. Sun, K. Zheng, X. Geng, P. Zhao, J. Feng, C. Tao, and D. Jiang. Wizardlm: Empowering\\nlarge language models to follow complex instructions. ArXiv preprint, abs/2304.12244, 2023. URL\\nhttps://arxiv.org/abs/2304.12244.\\nH. Ying, S. Zhang, L. Li, Z. Zhou, Y. Shao, Z. Fei, Y. Ma, J. Hong, K. Liu, Z. Wang, et al.\\nInternlm-math: Open math large language models toward verifiable reasoning. ArXiv preprint,\\nabs/2402.06332, 2024. URL https://arxiv.org/abs/2402.06332.\\nA. Young, B. Chen, C. Li, C. Huang, G. Zhang, G. Zhang, H. Li, J. Zhu, J. Chen, J. Chang,\\net al. Yi: Open foundation models by 01. ai. ArXiv preprint, abs/2403.04652, 2024. URL\\nhttps://arxiv.org/abs/2403.04652.\\nL. Yu, W. Jiang, H. Shi, Y. Jincheng, Z. Liu, Y. Zhang, J. Kwok, Z. Li, A. Weller, and W. Liu.\\nMetamath: Bootstrap your own mathematical questions for large language models. In The Twelfth\\nInternational Conference on Learning Representations, 2023. URL https://openreview.net/\\nforum?id=N8N0hgNDRt.\\nL. Yuan, G. Cui, H. Wang, N. Ding, X. Wang, J. Deng, B. Shan, H. Chen, R. Xie, Y. Lin, et al.\\nAdvancing llm reasoning generalists with preference trees. ArXiv preprint, abs/2404.02078, 2024.\\nURL https://arxiv.org/abs/2404.02078.\\nX. Yue, Y. Ni, K. Zhang, T. Zheng, R. Liu, G. Zhang, S. Stevens, D. Jiang, W. Ren, Y. Sun, et al.\\nMmmu: A massive multi-discipline multimodal understanding and reasoning benchmark for expert\\nagi. ArXiv preprint, abs/2311.16502, 2023a. URL https://arxiv.org/abs/2311.16502.\\nX. Yue, X. Qu, G. Zhang, Y. Fu, W. Huang, H. Sun, Y. Su, and W. Chen. Mammoth: Building math\\ngeneralist models through hybrid instruction tuning. In The Twelfth International Conference on\\nLearning Representations, 2023b. URL https://openreview.net/forum?id=yLClGs770I.\\nY. Zhang, Y. Luo, Y. Yuan, and A. C.-C. Yao. Automathtext: Autonomous data selection with\\nlanguage models for mathematical texts. ArXiv preprint, abs/2402.07625, 2024. URL https:\\n//arxiv.org/abs/2402.07625.\\nL. Zheng, W.-L. Chiang, Y. Sheng, S. Zhuang, Z. Wu, Y. Zhuang, Z. Lin, Z. Li, D. Li, E. Xing,\\net al. Judging llm-as-a-judge with mt-bench and chatbot arena. Advances in Neural Information\\nProcessing Systems, 36, 2024a. URL https://openreview.net/forum?id=uccHPGDlao.\\nT. Zheng, S. Guo, X. Qu, J. Guo, W. Zhang, X. Du, C. Lin, W. Huang, W. Chen, J. Fu, et al. Kun:\\nAnswer polishment for chinese self-alignment with instruction back-translation. ArXiv preprint,\\nabs/2401.06477, 2024b. URL https://arxiv.org/abs/2401.06477.\\nT. Zheng, G. Zhang, T. Shen, X. Liu, B. Y. Lin, J. Fu, W. Chen, and X. Yue. Opencodeinterpreter:\\nIntegrating code generation with execution and refinement. ArXiv preprint, abs/2402.14658, 2024c.\\nURL https://arxiv.org/abs/2402.14658.\\nY. Zheng, R. Zhang, J. Zhang, Y. Ye, Z. Luo, and Y. Ma. Llamafactory: Unified efficient fine-tuning\\nof 100+ language models. ArXiv preprint, abs/2403.13372, 2024d. URL https://arxiv.org/\\nabs/2403.13372.\\n14\\n\\n\\nA\\nDetails of Additional Public Instruction Tuning Datasets\\n• OpenHermes 2.5 (Teknium, 2023): The OpenHermes-2.5 dataset is a comprehensive collection\\nof diverse data sources for instruction tuning, including 1M examples from datasets in math,\\nscience, and coding, alongside synthetic and chat-based data. It incorporates diverse sources such\\nas Airoboros 2.2, CamelAI Domain Expert Datasets, ChatBot Arena, Collective Cognition, Evol\\nInstruct, Glaive Code Assistant, GPT4-LLM, GPTeacher, Medical Tasks, MetaMath, SlimOrca,\\nPlatypus, ShareGPT, and Unnatural Instructions GPT4. We remove TheoremQA from Platypus as\\nit is one of our test sets.\\n• Code-Feedback (Zheng et al., 2024c): The Code-Feedback dataset is a multi-turn code generation\\nand refinement dataset, containing 68,000 multi-turn interactions between users, code generation\\nmodels, and compiler systems. It includes initial user instructions followed by compiler and user\\nfeedback. This dataset significantly enhances the model’s multi-turn interaction coding ability.\\n• Math-Plus: This dataset combines public datasets such as MetaMathQA (395K) (Yu et al., 2023)\\nand Orca-Math (200K) (Mitra et al., 2024). Both of these datasets are generated by GPT-3.5/4\\nusing GSM/MATH and other math datasets as the seed data. To further augment the dataset, we\\nprompt GPT-4 to rewrite Q-A pairs from MATH training sets, adding an additional 300K examples\\nto enhance the challenging problems. The total size of the Math-Plus dataset is 894K examples.\\nTo ensure consistency and compatibility, we carefully align the format and structure of these additional\\ndatasets with WEBINSTRUCT. These supplementary datasets provide a rich resource for training\\nmodels to answer questions and provide explanations across a wide range of topics, enhancing their\\nversatility and applicability in real-world scenarios.\\nB\\nDetails of Evaluation Datasets\\nTo rigorously assess the capabilities of models in reasoning abilities across different domains, we\\nutilize several widely used datasets. Each of these datasets is designed to challenge the models in\\ndifferent aspects of reasoning.\\n• GSM8K (Cobbe et al., 2021): This test dataset contains 1.32K diverse grade school math problems,\\nintended to test basic arithmetic and reasoning ability in an educational context.\\n• MATH (Hendrycks et al., 2021b): Comprising 5000 intricate competition-level problems to\\nevaluate the models’ ability to perform complex mathematical reasoning.\\n• TheoremQA (Chen et al., 2023b): Focused on applying mathematical theorems to solve advanced\\nproblems in fields such as mathematics, physics, and engineering, TheoremQA includes 800\\nquestions that test the theoretical reasoning capabilities.\\n• BIG-Bench Hard (BBH) (Suzgun et al., 2022): Consisting of 23 tasks previously found challeng-\\ning for language models from BIG-Bench (Srivastava et al., 2023), BBH contains a total of 6511\\nchallenging problems examining the capability of LLMs to solve them.\\n• ARC-C (Clark et al., 2018): ARC includes questions derived from various grade-level science\\nexams, testing models’ ability to handle both straightforward and complex scientific queries. We\\nuse the challenge subset, which contains 1,172 test questions.\\n• GPQA (Rein et al., 2023): This dataset provides \\\"Google-proof\\\" questions in biology, physics, and\\nchemistry, designed to test deep domain expertise and reasoning under challenging conditions. We\\nuse the diamond subset containing 198 hard problems.\\n• MMLU-STEM (Hendrycks et al., 2021a): Spanning 57 subjects across multiple disciplines,\\nMMLU evaluates the breadth and depth of a model’s knowledge in a manner akin to academic and\\nprofessional testing environments. We select the STEM subset of MMLU with 3.13K problems.\\nThese datasets collectively enable a comprehensive assessment of language models’ reasoning\\nprowess across a spectrum of complexity and realism. We further evaluate the models on additional\\ncode generation tasks (including HumanEval (Chen et al., 2021), MBPP (Austin et al., 2021) and\\ntheir augmented version (Liu et al., 2024)), general LLM benchmarks like MMLU (Hendrycks\\net al., 2021a), and chat benchmarks like MT-Bench (Zheng et al., 2024a), AlpacaEval 2.0 (Li et al.,\\n2023), and Arena Hard (Li et al., 2024b) to demonstrate the generalizability of WEBINSTRUCT and\\nWEBINSTRUCT-PLUS on more general LLM benchmarks.\\n15\\n\\n\\nC\\nRelated Work\\nInstruction Tuning.\\nInstruction tuning is crucial for aligning large language models (LLMs) with\\nend tasks. There are two main types of instruction tuning data: (1) human-written data, such as\\nFLAN (Wei et al., 2022a), T0 (Sanh et al., 2022), and SuperNI (Wang et al., 2022), which assemble\\nlarge instruction-tuning datasets from existing human-labeled datasets; and (2) synthesized data, like\\nSelf-Instruct (Wang et al., 2023b), WizardLM (Xu et al., 2023), and GPT4-Alpaca (Peng et al., 2023),\\nwhich create instruction-tuning datasets by synthesizing from powerful LLMs like GPT-4 (Achiam\\net al., 2023). Both types of instruction-tuning data have advantages and disadvantages. Human-\\nwritten data is limited in size due to the high cost and in task diversity because existing human-labeled\\ndatasets mostly focus on a few NLP tasks. Although synthesized data can be generated at any scale,\\nthe high rate of hallucination can lead to significant quality degradation. Moreover, the diversity of\\nsynthesized data is heavily influenced by the seed data. Without a diverse seed dataset, the synthesized\\ndata will lack domain coverage.\\nMathematics Reasoning.\\nIn recent years, there has been a growing interest in enhancing the\\nmathematical reasoning abilities of large language models (LLMs). Three main approaches have\\nbeen proposed to improve LLMs’ mathematical reasoning skills:\\n• Prompting: Chain-of-thought-prompting (CoT) (Nye et al., 2022; Wei et al., 2022b) elicits LLMs’\\ninherent reasoning ability by demonstrating intermediate reasoning steps. Program-of-thoughts-\\nprompting (PoT) (Chen et al., 2023a; Gao et al., 2023) utilizes tools to further augment LLMs’\\nmath reasoning abilities. Subsequent work (Gou et al., 2023; Toshniwal et al., 2024; Yuan et al.,\\n2024) combines CoT and PoT to maximize LLMs’ reasoning ability.\\n• Continued Training: Enabling LLMs to solve mathematical problems has been a long-standing\\nchallenge. MINERVA (Lewkowycz et al., 2022) and Galactica (Taylor et al., 2022) were pioneers\\nin continued training of LLMs to adapt to scientific domains for math and science reasoning.\\nOpen-source models like Llemma (Azerbayev et al., 2023), DeepSeek-Math (Shao et al., 2024),\\nand Intern-Math (Ying et al., 2024) have surpassed MINERVA and Galactica on math benchmarks.\\nThese approaches mainly rely on using an efficient classifier to recall documents from Common\\nCrawl to retrieve a massive high-quality math-related corpus (>100B tokens) to enhance math\\nreasoning.\\n• Instruction Tuning: Instruction tuning aims to enhance LLMs’ math reasoning skills by efficiently\\ntraining on human-annotated public datasets like GSM8K (Cobbe et al., 2021), MATH (Hendrycks\\net al., 2021b), and MathQA (Amini et al., 2019). However, these datasets are often insufficient\\nin size and diversity. Therefore, recent work (Yu et al., 2023; Yue et al., 2023b; Toshniwal et al.,\\n2024; Luo et al., 2023; Li et al., 2024a) proposes augmenting them with strong commercial LLMs\\nlike GPT-4 (Achiam et al., 2023). These methods can significantly boost LLMs’ performance on\\nin-domain math benchmarks but may fall short of generalization.\\nOur work combines continued training with instruction tuning to exploit the benefits of both ap-\\nproaches. Specifically, our dataset is recalled from Common Crawl like DeepSeekMath. However,\\ndue to the significant level of noise in the raw corpus, we utilize a strong LLM to filter and clean the\\ncorpus to extract the instruction tuning pairs.\\nScience Reasoning.\\nIn addition to mathematical reasoning, there is growing interest in improving\\nLLMs’ general scientific reasoning ability in subjects like physics, biology, chemistry, computer\\nscience, etc. Several benchmarks, such as MMLU (Hendrycks et al., 2021a), TheoremQA (Chen et al.,\\n2023b), Sci-Bench (Wang et al., 2023a), SciEval (Sun et al., 2023), and GPQA (Rein et al., 2023),\\nhave been developed to measure LLMs’ reasoning ability on tasks beyond math. However, there\\nhas been less effort in curating high-quality training data for the science domain. Most datasets, like\\nOpenWebMath (Paster et al., 2023), Proof-Pile (Azerbayev et al., 2023), and MathPile (Zhang et al.,\\n2024), are heavily biased towards mathematics. In this work, we aim to generalize the pre-training\\ndata to broader subjects through our newly curated science seed data.\\n16\\n\\n\\nD\\nCode Generation Results\\nWe report the code generation results of our models and baselines in Table 6.\\nHumanEval\\nHumanEval+\\nMBPP\\nMBPP+\\nAverage\\nAverage+\\nMistral-7B\\n28.7\\n23.8\\n51.9\\n42.1\\n40.3\\n33.0\\nGemma-7B\\n26.8\\n20.1\\n52.6\\n43.4\\n39.7\\n31.8\\nLlama-3-8B\\n33.5\\n29.3\\n61.4\\n51.6\\n47.5\\n40.5\\nGemma-1.1-7B-Instruct\\n42.7\\n35.4\\n57.1\\n45.0\\n49.9\\n40.2\\nMistral-7B-Instruct-v0.2\\n75.0\\n70.1\\n44.7\\n37.0\\n59.9\\n53.6\\nLlama-3-8B-Instruct\\n61.6\\n56.7\\n70.1\\n59.3\\n65.9\\n58.0\\nMixtral-8×7B-Instruct-v0.1\\n45.1\\n39.6\\n59.5\\n49.7\\n52.3\\n44.7\\nMAmmoTH2– 7B-Plus\\n72.1\\n65.9\\n60.1\\n50.4\\n66.1\\n58.2\\nMAmmoTH2– 8B-Plus\\n63.4\\n57.9\\n60.4\\n48.6\\n61.9\\n53.3\\nMAmmoTH2– 8×7B-Plus\\n57.9\\n53.7\\n68.7\\n56.9\\n63.3\\n55.3\\nTable 6: Code generation results of different models.\\nBaseline results are copied from the\\nEvalPlus (Liu et al., 2024) leaderboard.\\nE\\nImpact of Additional Public Instruction Tuning Datasets\\nIn Appendix A, we introduce additional public instruction tuning datasets to further boost the model’s\\nreasoning performance. Here, we show the three setups of models trained on: 1) WEBINSTRUCT\\nonly; 2) Additional Public Datasets only; 3) WEBINSTRUCT + Additional Public Datasets (which\\nwe first trained on WEBINSTRUCT and then continued training on additional public datasets). The\\nresults are shown in Table 7.\\nData\\nTheoremQA\\nMATH\\nGSM8K\\nGPQA\\nMMLU-ST\\nBBH\\nARC-C\\nAVG\\nMistral 7B Base\\nWEBINSTRUCT\\n29.0\\n36.7\\n68.4\\n32.4\\n62.4\\n58.6\\n81.7\\n52.8\\nPUBLIC DATASETS\\n22.6\\n37.9\\n83.5\\n29.3\\n57.6\\n62.7\\n79.9\\n53.4\\nWEBINS.+PUBLIC.\\n29.2\\n45.0\\n84.7\\n36.8\\n64.5\\n63.1\\n83.0\\n58.0\\nMixtral 8x7B Base\\nWEBINSTRUCT\\n32.2\\n39.0\\n75.4\\n36.8\\n67.4\\n71.1\\n87.5\\n58.9\\nPUBLIC DATASETS\\n31.3\\n45.1\\n85.3\\n37.4\\n69.4\\n73.2\\n88.1\\n61.4\\nWEBINS.+PUBLIC.\\n34.1\\n47.0\\n86.4\\n37.8\\n72.4\\n74.1\\n88.4\\n62.9\\nTable 7: Impact of additional public instruction tuning datasets.\\nF\\nDistributions of Website Domains in WEBINSTRUCT\\nFigure 7 show the distribution of the top websites in WEBINSTRUCT.\\n17\\n\\n\\nFigure 7: The distribution of the top websites in our instruction dataset.\\nG\\nDomain Distribution of WEBINSTRUCT\\nFigure 8 presents a breakdown of the WEBINSTRUCT by subject domains and data sources, providing\\ninsights into the composition and diversity of the mined instruction-response pairs. The subject labels\\nare automatically annotated using the Llama-3-8B-Instruct model, while the distribution between\\neducation and forum data is obtained by analyzing the source URLs of the samples. The pie chart\\nreveals that WEBINSTRUCT is predominantly composed of science-related subjects, with 81.69%\\nof the data falling under the broad \\\"Science\\\" category. Within this category, Mathematics takes\\nup the largest share at 68.36%, followed by Physics, Chemistry, and Biology. This highlights the\\ndataset’s strong emphasis on mathematical problem-solving and scientific reasoning. The remaining\\nnon-science categories, such as Business, Art & Design, and Health & Medicine, contribute to the\\ndiversity of the dataset. In terms of data sources, the vast majority (86.73%) of the instruction-\\nresponse pairs come from exam-style questions, while forum discussions make up the remaining\\n13.27%. This source breakdown indicates that WEBINSTRUCT primarily consists of well-structured,\\neducational content, supplemented by real-world discussions and inquiries from forums. The diverse\\nsubject coverage and the combination of education and forum data enable WEBINSTRUCT to capture\\na wide range of reasoning tasks and problem-solving scenarios.\\nFigure 8: Breakdown of WEBINSTRUCT by subject domains and data sources.\\n18\\n\\n\\nH\\nLimitations of WEBINSTRUCT\\nDespite employing a three-step pipeline to ensure the quality of the mined instruction-response pairs,\\nthere may still be some noise and inaccuracies in the dataset, as mentioned in Figure 6. The extraction\\nand refinement steps rely on the performance of the LLMs used, which may introduce biases and\\nerrors. Future work could explore more advanced techniques for data cleaning and validation, such\\nas human-in-the-loop approaches or training a data selection model for filtering. Furthermore, while\\nWEBINSTRUCT covers a wide range of subjects, including math, science, and engineering, there\\nmay be specific subdomains or advanced topics that are underrepresented, such as humanities and\\nother daily chat topics. Expanding the coverage of the seed data to include broader and more diverse\\ninstruction-response pairs could further enhance the reasoning capabilities of LLMs in different areas.\\nI\\nBroader Social Impact\\nThe development of MAmmoTH2 and the WEBINSTRUCT has the potential to positively impact edu-\\ncation by providing the community with access to a large-scale, diverse set of instruction-response\\npairs across various subjects, particularly in mathematics and science. MAmmoTH2 can assist students\\nin their learning process by offering step-by-step solutions, explanations, and targeted feedback,\\nthus enhancing their understanding of complex concepts and problem-solving skills. Furthermore,\\nthe dataset and models can serve as valuable resources for educators to create more effective and\\nengaging educational content, assignments, and assessments. However, it is important to consider\\npotential limitations and biases in the dataset and the model. The quality and accuracy of the\\ninstruction-response pairs in WEBINSTRUCT may vary, and the model’s outputs may reflect these\\ninconsistencies. Therefore, it is crucial to employ rigorous data filtering and quality control measures\\nto ensure the reliability and trustworthiness of the dataset and the model.\\n19\\n\\n\\nJ\\nCase Study\\nIn this section, we aim to review some of the instances in WEBINSTRUCT. The data extracted from\\nthe website contains many issues. For example, the most common issue is that the answer is relatively\\nshort without any intermediate rationale, which could occur frequently from the quiz website with\\nmulti-choice questions. Another common issue is that the extraction destroys important formatting in\\nthe document, which leads to unrecoverable errors.\\nGood Case 1\\nExtracted:\\nQuestion: Find the distance from the point 3\\n2, 3\\n2 to the line −37x\\n10 −21y\\n10 −7\\n2 = 0.\\nAnswer: 61\\nq\\n2\\n905.\\nRefined:\\nQuestion:\\nCalculate the distance from the point ( 3\\n2, 3\\n2) to the line defined by the equation\\n−37\\n10x −21\\n10y −7\\n2 = 0.\\nAnswer: To find the distance ’d’ from a point (x0, y0) to a line given by Ax + By + C = 0, we use\\nthe formula:\\nd = |Ax0 + By0 + C|\\n√\\nA2 + B2\\n.\\nFor the point\\n 3\\n2, 3\\n2\\n\\u0001\\nand the line −37\\n10x −21\\n10y −7\\n2 = 0, substitute the coordinates into the formula:\\nd = | −37\\n10 · 3\\n2 −21\\n10 · 3\\n2 −7\\n2|\\nq−37\\n10\\n\\u00012 +\\n−21\\n10\\n\\u00012 .\\nSimplifying further, the exact simplified distance ’d’ is 61\\nq\\n2\\n905. Thus, the correct distance from the\\npoint to the line is 61\\nq\\n2\\n905.\\nFigure A1: In this Refined version, the expression of both the question and the answer is clearer and\\nmore precise. It employs standardized mathematical symbols and terms, such as representing the\\ncoordinates of the point and the equation of the line as (x0, y0) and Ax + By + C = 0, respectively.\\nMoreover, it explicitly provides the formula for calculating the distance. Through these revisions,\\nreaders can more easily understand how to compute the distance from a point to a line, making the\\nsolution process more transparent and easier to follow.\\nGood Case 2\\nExtracted:\\nQuestion: What are the two main ways that minerals are classified?\\nAnswer: They can be classified by luster, streak, breakage, and hardness.\\nRefined:\\nQuestion: What are the primary criteria used for classifying minerals in mineralogy?\\nAnswer: Minerals are primarily classified based on two main categories: physical properties and\\nchemical properties. The physical properties include luster, streak, crystal form, hardness, density, and\\ncleavage or breakage. Chemical properties involve the mineral’s chemical composition and reactions with\\nother substances. These characteristics help identify and distinguish different minerals in mineralogy.\\nFigure A2: Refining the extracted response provides a more comprehensive and accurate explanation\\nof mineral classification in mineralogy. By expanding on the initial response to include both physical\\nand chemical properties, the refined version offers a deeper understanding of how minerals are\\ncategorized and identified. This enriched content can enhance the model’s ability to generate\\ninformative responses related to mineralogy.\\n20\\n\\n\\nGood Case 3\\nExtracted:\\nQuestion: How do you find theasymptotes for Q(x) = (2x2)/(x2 −5x −6)?\\nAnswer: vertical asymptotes x=-1, x=6/n horizontal asymptote y=2 /n /n /n /n /n /n /n /n /n /n\\nRefined:\\nQuestion: How do you determine the vertical and horizontal asymptotes for the function Q(x) =\\n2x2\\nx2−5x−6?\\nAnswer: To find the vertical asymptotes, we need to identify the values of x that make the denominator\\nequal to zero:\\nx2 −5x −6 = (x −6)(x + 1) = 0\\nThis gives us the vertical asymptotes at x = −1 and x = 6.\\nFor the horizontal asymptote, as x approaches infinity or negative infinity, the dominant terms in the\\nnumerator and denominator are both x2. Thus, we compare their coefficients:\\n- Numerator’s highest degree coefficient: 2 - Denominator’s highest degree coefficient: 1\\nThe horizontal asymptote is given by the ratio of these coefficients:\\ny = 2\\n1 = 2\\nTherefore, the vertical asymptotes are at x = −1 and x = 6, and the horizontal asymptote is y = 2.\\nFigure A3: The refined answer provides a more detailed explanation for finding the asymptotes. It\\nincludes the steps for solving for the vertical asymptotes by factoring the denominator and determining\\nwhere it equals zero. It also explains how to find the horizontal asymptote by comparing the leading\\ncoefficients of the highest-degree terms in both the numerator and the denominator. The use of LaTeX\\nformatting makes the mathematical notation clearer and easier to understand.\\nGood Case 4\\nExtracted:\\nQuestion:Which of the following is not an example of biased language? a. “You are too short to reach\\nthat.” b. “Are you deaf?” c. “Move along, grandpa!” d. “I think I’ve been gypped.\\nAnswer: D. I think I’ve been gypped.\\nRefined:\\nQuestion: Which of the following statements does not exhibit biased language?\\na. “You are too short to reach that.”\\nb. “Are you deaf?”\\nc. “Move along, grandpa!”\\nd. “I think I’ve been gypped.”\\nAnswer: The statement that does not exhibit biased language is:\\nd. \\\"I think I’ve been gypped.\\\"\\nExplanation: Biased language refers to words or phrases that stereotype, discriminate, or show prejudice\\ntowards a particular group. In this case, options a, b, and c contain biases towards people’s physical\\nabilities (height), hearing ability, and age, respectively. However, \\\"I think I’ve been gypped\\\" is an\\ninformal expression meaning to be cheated or deceived, which, while potentially offensive, does not\\ndirectly target a specific group based on attributes like race, gender, or disabilities.\\nFigure A4: The refined version of the input presents the question and answers in a clearer, more\\nstructured format that improves readability and comprehension. Specifically, using a bulleted list\\nfor the options makes them distinct and easier to evaluate individually. Moreover, the addition of\\nan explanation provides context and justification for the selected answer, enhancing the educational\\nvalue of the content. This refined structure and the inclusion of an explanatory note make it a superior\\ntraining example for models, as it helps in understanding not just the answer but the rationale behind\\nit, promoting deeper learning and better pattern recognition in language processing tasks.\\n21\\n\\n\\nGood Case 5\\nExtracted:\\nQuestion: I am stucked on the following challenge: \\\"If the line determined by two distinct points\\n(x1, y1) and (x2, y2) is not vertical, and therefore has slope (y2 −y1)/(x2 −x1), show that the point-\\nslope form of its equation is the same regardless of which point is used as the given point.\\\" Okay, we\\ncan separate (x0, y0) from the form to get:\\ny(x2 −x1) −x(y2 −y1) = y0(x2 −x1) −x0(y2 −y1)\\nBut how exclude this point (x0, y0) and leave only x, y, x1, y1, x2, y2 in the equation? UPDATE: There\\nis a solution for this challenge:\\n(y1 −y2)x + (x2 −x1)y = x2y1 −x1y2\\nFrom the answer I found that\\ny2(x −x1) −y1(x −x2) = y(x2 −x1)\\n... but why this is true?\\nAnswer: Thanks to saulspatz, the solution is to simply show that, whether we are using (x1, y1) or\\n(x2, y2) as the given point, the equation does not change.\\nSo both equations:\\ny −y1 = m(x −x1)\\ny −y2 = m(x −x2)\\nreduce to:\\n(y1 −y2)x + (x2 −x1)y = x2y1 −x1y2.\\nRefined:\\nQuestion: Demonstrate that the point-slope form of the equation of a line determined by two distinct\\npoints (x1, y1) and (x2, y2), where the line is not vertical, remains consistent regardless of which point\\nis chosen as the reference. Why does the form of the equation not change when different reference\\npoints are used?\\nAnswer: To address this challenge, we need to confirm that the point-slope equation of a line remains\\nconsistent regardless of the point chosen to derive it. Given two points (x1, y1) and (x2, y2) with a\\nnon-vertical line passing through them, the slope m of the line is y2−y1\\nx2−x1 .\\nThe point-slope form of a line’s equation based on point (x1, y1) is:\\ny −y1 = m(x −x1)\\nSimilarly, using point (x2, y2) gives:\\ny −y2 = m(x −x2)\\nThese can be rewritten and compared to show their equivalence. Expanding both equations: - From the\\nfirst equation: y −y1 = y2−y1\\nx2−x1 (x −x1) - From the second equation: y −y2 = y2−y1\\nx2−x1 (x −x2)\\nWe simplify these to find a common form. Multiplying both sides by (x2 −x1) and rearranging terms,\\nwe find:\\ny2(x −x1) −y1(x −x2) = y(x2 −x1)\\nThis confirms that both forms collapse to the same linear equation, showing the consistency of the\\npoint-slope form irrespective of the chosen reference point. Thus, it is demonstrated that the structural\\nform of the equation remains unchanged, ensuring that the mathematical properties of the line—defined\\nby its slope and points through which it passes—are invariant to the choice of the reference point used\\nin its expression. This uniformity stems from the linearity and the constant slope defined by any two\\npoints on a straight line.\\nFigure A5: The original answer contains an irrelevant introductory sentence, which makes it less\\nfocused. In contrast, the refined version provides a clearer question by explicitly stating the problem\\nof demonstrating the invariance of the point-slope form. The explanation in the answer is expanded\\nto show step-by-step equivalence between the two forms and includes detailed reasoning about why\\nthe consistency holds. The added explanation reinforces the understanding of linear equations and\\nthe concept of constant slope, making the solution more comprehensive and pedagogically valuable.\\n22\\n\\n\\nBad Case 1\\nExtracted:\\nQuestion: Sort\\nn\\n−3π, 9, 17\\n√\\n3, −4, 47\\n7 , 3\\ne,\\n3\\n√\\n5\\no\\n.\\nAnswer:\\nn\\n−3π, −4, 3\\ne,\\n3\\n√\\n5, 47\\n7 , 9, 17\\n√\\n3\\no\\n.\\nRefined:\\nQuestion: Sort the following numbers in ascending order: −3π, 9, 17\\n√\\n3, −4, 47\\n7 , 3\\ne,\\n3\\n√\\n5.\\nAnswer: The sorted numbers in ascending order are: −3π, −4, 3\\ne,\\n3\\n√\\n5, 47\\n7 , 9, 17\\n√\\n3.\\nFigure A6: The refined example does not enhance the clarity or quality of the information. The\\noriginal formatting and question structure were already clear and concise, and the transformation\\ninto a slightly more verbose question-and-answer format does not add significant value. Additionally,\\nboth versions use proper LaTeX formatting for mathematical expressions, so there is no improvement\\nin readability or technical accuracy. Essentially, the refinement introduces additional words without\\nenhancing comprehension, which could potentially dilute the effectiveness of the model training by\\nfocusing on unnecessary stylistic alterations rather than content clarity or quality.\\nBad Case 2\\nExtracted:\\nQuestion: Which curve (AD or SRAS) will be affected and which direction (leftward or rightward)\\nwill it shift when Congress goes to war against Canada?\\nAnswer: When Congress falls into a war with Canada, the aggregate demand curve will be affected by\\nmoving to the left. Suppose Congress fights against Canada, then, it is likely that Congress will pass\\nlaws that advocate for increased tariffs on imports.\\nSpending on exports is an element of aggregate demand. Thus, its curve shifts rightwards, when its\\ncomponents, which are, spending on consumptions, government spending, or spending on investment\\nincrease.\\nOn the other hand, Canada will not do business with the USA as usual when they fall out with Congress.\\nFor example, the expenses on exports to Canada will reduce.\\nThus, the aggregate demand will fail to increase and shift on the left if there is less consumption from\\nhouseholds, falls of investments from firms or when the demand for exports from a country like Canada\\nfalls.\\nRefined:\\nQuestion: How does a war between Congress and Canada affect the Aggregate Demand (AD) curve,\\nand in which direction will it shift?\\nAnswer: When Congress declares war against Canada, the\\nAggregate Demand (AD) curve shifts to the left because Congress will implement increased tariffs on\\nimports. Spending on exports, which is a component of aggregate demand, decreases due to these tariffs.\\nThe Short Run Aggregate Supply (SRAS) curve, however, is not directly affected by this situation. It\\nmainly reflects changes in production costs and the availability of resources, which are not directly\\ninfluenced by international conflicts unless they lead to disruptions in the domestic production process.\\nIn summary, the AD curve shifts left due to decreased exports and potentially lower consumer and\\nbusiness spending, while the SRAS curve remains relatively stable unless there are indirect impacts on\\ndomestic production.\\nFigure A7: The refined answer, while more structured and clearer in terms of the specific economic\\ncurves discussed, introduces inaccuracies that were not present in the original. Specifically, the\\nrefined version inaccurately states that spending on exports decreases due to tariffs, which contradicts\\nthe fundamental economic concept that tariffs affect imports rather than exports. Furthermore,\\nthe original answer provides a broader analysis of potential economic impacts, such as changes\\nin household consumption and firm investment, which are omitted in the refined version. These\\nomissions reduce the depth and accuracy of the economic analysis provided in response to the effects\\nof war on economic curves.\\n23\\n\\n\\nBad Case 3\\nExtracted:\\nQuestion: Is there a tool (LaTeX, JavaScript, Mathematica..) that allows one to draw Venn diagram\\nautomatically from subsets relations, e.g. A ⊂A + B, A ⊂C, C ⊂C + D, B ̸⊂C would yield:\\n|\\n|\\n|\\nA+B\\n|\\n|\\n|\\n|\\n|\\n|\\n|\\n|\\n|\\n|\\nA\\n|\\n|\\n|\\n|\\n|\\n|\\n|\\n|\\nC+D\\n|\",\"difficulty\":\"hard\",\"domain\":\"Multi-Document QA\",\"length\":\"short\",\"question\":\"Regarding the comparison of the methods for improving math ability in these two articles, which of the following statements is incorrect?\",\"sub_domain\":\"Academic\"}","display_format":"text","language":"","answer_status":"published","assets":[],"source_url":"https://huggingface.co/datasets/zai-org/LongBench-v2","history":"initial import","indexing_mode":"noindex","subproblems":[],"grids":[]}