<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hamid Nafiyan on Medium]]></title>
        <description><![CDATA[Stories by Hamid Nafiyan on Medium]]></description>
        <link>https://medium.com/@hamid.n.d?source=rss-6acfbf0d8c9d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*W3D4dbe_vZ2h3W_SoNG5cA.jpeg</url>
            <title>Stories by Hamid Nafiyan on Medium</title>
            <link>https://medium.com/@hamid.n.d?source=rss-6acfbf0d8c9d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 05:12:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hamid.n.d/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ Self-Evolving World Models Paradigms, Self-learning to Self-Planning]]></title>
            <link>https://levelup.gitconnected.com/part-4-self-improvement-algorithms-lms-self-learning-to-self-reason-b586011c7c63?source=rss-6acfbf0d8c9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b586011c7c63</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Hamid Nafiyan]]></dc:creator>
            <pubDate>Tue, 30 Dec 2025 04:11:43 GMT</pubDate>
            <atom:updated>2026-06-21T11:07:18.569Z</atom:updated>
            <content:encoded><![CDATA[<h3>Self-Evolving World Models Paradigms, Self-learning to Self-Planning — Part 4</h3><h4>Agents’ Capabilities: Pre-Thinking, Meta-Judgment, and Self-Planning</h4><h4>Introduction</h4><p>In the space of estimations, using language for reasoning and communication doesn’t have to come from an LLM; that may turn out to be a means to an end. Maybe in a few years, we will move beyond LLMs, but the need for universal language understanding and production in agents will remain. Next to that, the current and anticipated state of LLMs’ reasoning requirements provides broader yet deeper insights into how to describe the ways it can be interacted with as well as the ways it can be interacted with. Given that that’s true, taking LLM’s capabilities for reasoning and planning into account, which itself stems from its own intermediate steps, which are somehow rooted in its implicit reasoning capabilities, sheds light on the broader responsibility of a language agent concerning self-learning various capabilities as a proven-essential Introspection skill, which has been a while focused profoundly on as a long-horizon paradigm. To enable such a great added value as an intrinsic skill into an LLM, I am going to delve deep into SoTA methods for approaching the long-horizon <strong><em>Self-Learning paradigms</em></strong>. So, as an aside again, how to apply such techniques and their where and the when is a useful best practice to shape such an aforementioned skill as an Introspection paradigm.</p><blockquote>Please refer to the references &amp; credits of the material covered in this article as well. Also note that all photos are screenshots taken from papers to which referred in this article.</blockquote><p><a href="https://medium.com/@hamid.n.d/075fcee90466">In Part 3, my previous article, I explored Iterative Reasoning approaches via Policy Optimization in the Loss Function, then dealt with optimization algorithms for doing so, including GRPO, Dr. GRPO, AGPO, and GSPO, over each of which we also made some comparisons</a>. I am now going to explore some further improvements of <strong>Advanced Self-improvement Algorithms</strong>, techniques &amp; approaches, <strong>focused optimizations particularly on empowering the Agent with capabilities of Pre-Thinking, </strong>Meta-Judgment, Self-Planning &amp; Self-Evaluation, as well as for handling unconstrained evaluation tasks, aiming still at enabling language agents with self-learning, Self-observation, self-reflection, self-searching, self-planning, and self-evaluation capabilities.</p><h4>Table of Contents:</h4><ul><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-df185c0601fc?postPublishedType=initial#:~:text=an%20Introspection%20paradigm.-,Debates,-There%20have%20still"><strong><em>Debates</em></strong></a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-df185c0601fc?postPublishedType=initial#:~:text=1%E2%80%932%E2%80%939)%20Thought%20Preference%20Optimization%20(TPO)"><strong><em>1–2–9) Thought Preference Optimization (TPO)</em></strong></a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-df185c0601fc?postPublishedType=initial#:~:text=1%E2%80%932%E2%80%9310)%20Self%2DEvaluation%20Optimization%20through%20LLM%2Das%2Da%2DMeta%2DJudge%20(Meta%2DJudging%20%26%20Meta%2DRewarding)"><strong><em>1–2–10) Self-Evaluation Optimization through LLM-as-a-Meta-Judge (Meta-Judging &amp; Meta-Rewarding)</em></strong></a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-df185c0601fc?postPublishedType=initial#:~:text=Self%2Drewarding%20vs.%20Meta%2DRewarding%3A"><strong><em>Self-rewarding vs. Meta-Rewarding</em></strong></a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-df185c0601fc?postPublishedType=initial#:~:text=Reinforcement%20Learning%20through,Plan%20for%20Evaluation"><strong><em>Reinforcement Learning through Synthetic Verifiable Reward &amp; Verifiable Tasks (RLVRT)<br>1–2–11) Self-Evaluation Optimization: Learning to Reason &amp; Plan for Evaluation</em></strong></a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-df185c0601fc?postPublishedType=repub#:~:text=Performance%20Evaluation%20Results%3A"><strong><em>Performance Evaluation Results</em></strong></a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-df185c0601fc?postPublishedType=repub#:~:text=Takeaways%20from%20self%2Devaluation%3A"><strong><em>Takeaways from self-evaluation</em></strong></a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-df185c0601fc?postPublishedType=initial#:~:text=3)%20Self%2DImprovement%20through%20Reasoning%2DPowered%20Planning%20Paradigms"><strong><em>3) Self-Improvement through Reasoning-Powered Planning Paradigms</em></strong></a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-df185c0601fc?postPublishedType=repub#:~:text=3%E2%80%931)%20Reactive%20Planning"><strong><em>3–1) Reactive Planning</em></strong></a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-df185c0601fc?postPublishedType=repub#:~:text=3%E2%80%932)%20Tree%20search%20with%20Real%20Interactions"><strong><em>3–2) Tree search with Real Interactions</em></strong></a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-df185c0601fc?postPublishedType=repub#:~:text=3%E2%80%933)%20Model%2Dbased%20planning%20or%20World%20Model"><strong><em>3–3) Model-based planning or World Model</em></strong></a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-df185c0601fc?postPublishedType=repub#:~:text=Conclusion%20and%20Takeaways%3A"><strong><em>Conclusion and Takeaways: Best Practices</em></strong></a></li></ul><h3>Debates</h3><p>There have still been controversial debates here and there in academic research, research institutes, big tech labs, industry, and engineering communities on common recent limitations of LLMs leading to performance drop or failure, the most important of which include:</p><ul><li><strong>Distraction</strong> (due to irrelevant problems) and distracting rules</li><li><strong>Risk of memorization or overfitting</strong></li><li><strong>Hallucination gives rise to inconsistency, absence of causality, and a lack of ground truth in the response</strong></li><li><strong>NIAH</strong> (reasoning in long contexts)</li><li>Lack of <strong>persistent</strong> memory</li><li>Long-term <strong>memory</strong></li><li><strong>Compositionality</strong> limits via distillation</li><li>Premise <strong>order</strong> of sentences (inability to go back and forth)</li><li><strong>Unability</strong> to reason</li><li><strong>Early stop</strong> reasoning</li><li><strong>Large input</strong> context problems</li><li><strong>Self-correction</strong></li><li>Search <strong>space</strong> <strong>scaling</strong> up</li><li>Effective <strong>test-time scaling</strong></li><li><strong>Local knowledge</strong> distillation</li><li><strong>Spatial</strong> reasoning</li><li><strong>Exponential Error</strong> Compounding in long-horizon tasks (sequential decision-making)</li><li><strong>Oracle</strong> feedbacks</li><li><strong>Gradient Ascent </strong>&amp; <strong>Likelihood</strong></li><li>Varied-level <strong>mathematical</strong> problem-solving (grade-school to IMO),</li><li><strong>Hierarchical &amp; Dynamical Planning </strong>in efficient <strong>state</strong> <strong>exploration</strong> and <strong>action space exploitation</strong></li><li>Imitated-reasoning of fundamental human <strong>cognitive functions</strong></li></ul><p>Taking the aforementioned ongoing issues above into account, and now that we have reviewed the essential concepts and basis, I am now going to get into the behind-the-scenes of LLMs’ reasoning via exploring fundamental reasoning techniques. This article also explores the potential solutions and improvements going on, the issues<strong> </strong>to come up with optimization and trade-off methods. Dealing with long-horizon reasoning and planning techniques, I started off in my previous articles with Inference-time techniques besides reasoning strategies, and then we made them excuses to discuss on the road to search and planning techniques. Now I am going to point out the SoTA post-training algorithms and methodologies, and by leveraging them, we delve deep into the <strong>Advanced Self-improvement Algorithms, Techniques &amp; Approaches</strong>, aiming at enabling language agents with <strong>self-learning, self-observation, self-reflection, self-searching, self-planning, and self-evaluation capabilities</strong>.</p><h4>1–2–9) Thought Preference Optimization (TPO)</h4><p>This method employs a technique for General Instruction Following with Thought Generation (Thinking LLMs, Tianhao Wu et al). It aims at training LLMs to think on non-verifiable tasks, and respond to all instructions following tasks, not just math. This optimization actually does exactly what its name suggests: <strong>first think, then iteratively optimize your thought over both instruction- and preference-tuning.</strong></p><p>The reason to apply TPO actually stems from the situations where the problem is, in fact, a <strong>non-verifiable task</strong>. That being said, <strong>better judges (with CoT)</strong> can help train to think about non-verifiable tasks. Therefore, TPO focuses its attention on optimizing merely the <strong>first instruction</strong> by early generating the models’ thought as its first CoT and response. This early thinking plays the key role based on which generating the next CoTs &amp; responses are <strong>optimized through preference tuning via a judge model</strong> in order for instruction following during instruction fine-tuning iterations. As an example, prompt: <strong>“</strong>Think in a comprehensive and detailed way (drafting and your evaluation) before responding<strong>”</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*PpzwM1PKsb6zJBDFy49tSg.png" /><figcaption>Example of a Specific Thought Prompt for TPO</figcaption></figure><p>To do with the way that TPO works, we use a cold-start model fine-tuned from e.g., Llama-3 or GPT-4o as initialization for the first iteration of TPO training. Giving the user a prompt (first instruction) to this model, we have the model think before responding. We then prepend the thought with the user instruction as the initial output. Then, given the first iteration’s output (instruction with CoT and response as early thought) over the next iterations, the same model is again used to generate CoTs and responses, applying DPO training by sending them to judge model to score them and generate preference pairs (chosen-rejected outputs), then providing them to the next iteration’s model to fine-tine the preferences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A7zk9R55CIyzKQbOpzVz9w.png" /><figcaption>Thought Preference Optimizations- Thinking LLMs, General Instruction Following with Thought Generation</figcaption></figure><p>Similar to previous optimization methods, since the initial CoT prompt doesn’t give good performance, it needs lots of iterations to optimize CoT! Therefore, iteratively, it generates CoT for all types of tasks (general, reasoning, math, code, …), but the difference here is that the reward model does not apply reward only for the final answer. On the contrary, it rewards all answers generated. Following are examples of TPO (Thinking LLMs, Tianhao Wu et al), answering questions, the model is trained with a specific thought prompt, so it writes a draft and evaluates it in the thought part (in green):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*mp0iFKxfcB6btd0_6heFfg.png" /><figcaption>Example of TPO, answering questions (1)</figcaption></figure><p>Performance-wise, during iterations for training chosen responses, although TPO has less performance gains in the first (or second) iteration, it demonstrates superior training efficiency over SFT baselines as it iterates further, achieving better win rate, fine-tuning its evaluations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*j_sgU2XePG22Je5YGdQXDA.png" /><figcaption>Evaluation results for Thought Preference Optimization technique(Thinking LLMs, Tianhao Wu et al)</figcaption></figure><p>In terms of supervised fine-tuning, its performance is better than the base SFT models (for greedy coding, direct answering, …). According to the experiments evaluated (Thinking LLMs, Tianhao Wu et al), it also gives gains on AlpacaEval (beating GPT-4 &amp; Llama3–70b) and ArenaHard benchmarks, as it gets 3rd on AlpacaEval benchmark leaderboard as well as best 8B model on Arena-Hard, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*_doPfC2jimbmXbtxUH0o5w.png" /><figcaption>Thought Preference Optimization technique gains better performance over SFT baselines in terms of win rate</figcaption></figure><h4>1–2–10) Self-Evaluation Optimization through LLM-as-a-Meta-Judge (Meta-Judging &amp; Meta-Rewarding)</h4><p>The motivation here (Meta Rewarding LLMs, Tianhao Wu et al) is that since self-rewarding focuses on improving responses, not judgment capabilities. And improvement is reported to be rapidly saturated during iterative training. So, the idea of this optimization method is the ability to evaluate itself, meaning LLM improves its own judgments by judging them (meta-judging its judgments iteratively). This method considers <strong>3 roles for the base LM involved</strong>: LM as an <strong>Actor</strong> for following instructions, <strong>LM as a</strong> <strong>Judge</strong> for judging responses to those instructions, and <strong>LM as a Meta-Judge</strong> for judging its own judgements. The first two roles are similar to those of the self-rewarding mechanism. Above all is the third role, which is actually applying the Meta-Rewarding technique that adds new training signals to train judgments on top of what we have in previous optimizations. Therefore, the pipeline here iterates 3 steps (Meta Rewarding LLMs, Tianhao Wu et al) as follows:</p><p>1. Create Actor data</p><p>2. Create Judge data</p><p>3. Train DPO on preference pairs to both learn to act (1) AND to judge (2)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*P9th9DgPpHmnC1o_fuD9VA.png" /><figcaption>Meta-Rewarding LLMs, 3 steps interation in the pipeline (Tianhao Wu et al)</figcaption></figure><p>As illustrated, the first step is to generate responses &amp; self-rewards (judgments) with LM. And the second is for generating meta-rewards over judgments with LLM-as-a-Meta-Judge. Now, to do with the way Meta-Judging works in this pipeline:</p><p>In each iteration, and inside the first step (instruction following), there is an <strong>extra workflow</strong> (as a <strong>recursive process</strong>) which generates multiple judgments for each sampled response via the second role (LLM as a Judge), making N judgments for a given pair of responses. Then these judgements are given to the third role (LLM as a Meta Judge) to be again supervised fine-tuned with them by judging the judgments, and then calculating pairwise meta-judgments. Here at this point, for creating pair-wise judgment, the meta-judge model scores the judgments by computing the Elo score of the judgments via a matrix, such that it creates the preference pairs along with rewards for each (meta-rewards). Following that, using a rule-based procedure, the better judgment is selected for each pair. These taken together lead to adding a new training signal to train judgments. And eventually, in the third step (of each iteration), <strong>the Meta Judge Data pairs</strong>, along with <strong>Actor Judge Data pairs, </strong>are both given to<strong> the DPO model (RL) </strong>to learn and fit the optimized responses (step 3) as the<strong> </strong>promising<strong> Preference Optimization process. </strong>With that, the pipeline goes to the <strong>next iteration</strong>. One thing to consider during the DPO training is that the pipeline also controls response length with a new LC method, selecting the DPO chosen that is shorter if two good responses have similar scores (Meta Rewarding LLMs, Tianhao Wu et al)<strong>. </strong>An example prompt for a meta-rewarding LLM is shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*xJgVGBZohbMrui5e1dn7Cg.png" /><figcaption>LLM as a Meta Judge Prompt, used by meta-judge model to compare two judgements (Meta Rewarding LLMs, Tianhao Wu et al)</figcaption></figure><h4>Self-rewarding vs. Meta-Rewarding:</h4><p>Self-rewarding leverages internally generated rewards to iteratively refine their response-generation policies, whereas meta-rewarding introduces a hierarchical evaluation mechanism where reward assignments themselves undergo a recursive judgement process.<br>Performance-wise, the Meta-rewarding method outperforms self-rewarding (with the same LC method), such that in iterations in which self-rewarding plateaus, the self-evaluating method (meta-rewarding), on the contrary, continues improving and scales well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*KE_yGdtVv63_uk6cQ0PVgQ.png" /><figcaption>Photo credited by (Meta Rewarding LLMs, Tianhao Wu et al)</figcaption></figure><p>Moreover, in the experiments conducted in the referenced paper, Meta-rewarding performs well compared to some production LLM models. And other evaluation results demonstrated that Meta-Rewarding has higher agreement with a GPT-4 judge, such that its better judgments can explain its improved performance at acting compared to Self-Rewarding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*ZBPGP59cTBaCbX25_pAsuw.png" /><figcaption>Photo credited by (Meta Rewarding LLMs, Tianhao Wu et al)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*rT_BftACT1WvEt3EgQbYvg.png" /><figcaption>Photo credited by (Meta Rewarding LLMs, Tianhao Wu et al)</figcaption></figure><h3>Reinforcement Learning through Synthetic Verifiable Reward &amp; Verifiable Tasks (RLVRT)</h3><h4>1–2–11) Self-Evaluation Optimization: Learning to Reason &amp; Plan for Evaluation</h4><p>In respect of the LM’s internal reasoning thought, the way CoTs as intermediate thoughts work for the model, multiple types of CoT (reasoning path) are, as such, treated during solving and evaluating the tasks, three of which include:</p><ul><li>For solving the task (solution CoT): iteratively acting and planning(react) to solve the task</li><li>For verifying the response (evaluation CoT): iteratively acting and planning (ReAct) for evaluating the quality of the response. CoT for one specific problem, in the first iteration is Act, and in the next iterations is ReAct (planning) on its previous Act/ReActs.</li><li>For executing the evaluation plan (execution CoT): iteratively acting and planning (ReAct) for executing a given evaluation</li></ul><p>With that in mind, with respect to effective reasoning traces (which has been still understudied), one implicit obligation with previous self-reasoning methods is that (Thinking-LLM-as-a-Judge, Swarnadeep et al), due to the lack of human-annotated CoTs for evaluation, previous approaches often (1) have to constrain reasoning traces to hand-designed components (such as a list of criteria, reference answers, or verification questions), and that is the reason why these approaches <strong>implicitly</strong> structure such constrains in a way the <strong>Planning (ReAct CoT)</strong> is intertwined with the reasoning for <strong>Evaluation (Response Eval CoT)</strong>.</p><p>That is, here the goal of optimization is mainly for evaluating the response quality, to do so, it aims (1) to capture the step-by-step reasoning behind the evaluation process, (2) to apply <strong>implicitly unconstrained evaluation plan</strong>, hopefully leading to better final verdicts (3) allowing LLM-as-a-Judge models to think before producing a judgment to improve evaluation accuracy and transparency. So, it is a <strong>Prerequisite </strong>for an implicitly unconstrained evaluation plan that here we want to remove planning-related parts (criteria) from the prompt, meaning <strong>as much unconstrained instruction as possible</strong>, having the model itself think about the planning on its own.</p><p>To meet such concerns here, an optimization algorithm called <strong>EvalPlanner</strong> (Thinking-LLM-as-a-Judge, Swarnadeep et al) is used as a preference optimization algorithm for evaluating the quality of the final response iteratively using <strong>Thinking-LLM-as-a-Judge</strong>, such that it first generates an unconstrained evaluation plan, followed by its execution, and then the final judgment. Taking this process in a self-training loop, EvalPlanner then iteratively optimizes over synthetically constructed evaluation plans and executions, until reaching better final verdicts. The following delineates the main generative process of such a system 2 to train a promising model for <strong>Understanding Evaluation Planning</strong> through building preference pairs of CoTs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*FBzRNLivWx4aUi8BmIHaAg.png" /></figure><p>Below is an example of a prompt for EvalPlanner (Swarnadeep et al):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*dRRDAc4ZtBbYpIuXy5Ensg.png" /><figcaption>Prompt Prompt for Generating Evaluation Plans, Input and Output of EvalPlanner</figcaption></figure><p><strong>Synthetic Training Data Generation and Preference Optimization: </strong>Based on a method demonstrated in the referenced paper, the model first takes a user instruction, and samples some evaluation plans for <strong><em>How-To-Evaluation Reasoning</em></strong> for evaluation <strong><em>(evaluation steps CoT)</em></strong> for a given solved problem. Such evaluation plans are, in fact, the <strong>implicit criteria (instead of the previously explicit)</strong> for verifying the quality of the responses. Then, given the same instruction this time with preference pairs (high &amp; low quality responses to that prompt), the model samples multiple executions for each just-generated plan so that, seeing a problem &amp; responses, it is expected to generate multiple <strong><em>How-To-Execute Reasonings</em></strong> for each plan <strong><em>(execution steps CoT)</em></strong> for executing the evaluation steps planned to solve a given problem. This means, given a problem with its responses (preference pairs) and its evaluation plans, with executing which evaluation plan, the model proposes which response as qualified <strong>(which response on account of which criteria?).</strong> In consequence, a preference tuning dataset (preference pairs of plans &amp; executions) is built to optimize over the CoTs, such that for each input instruction, given the preference pairs, the plans, and their executions, a “<strong>Thought</strong>” (CoT of evaluation) is considered correct if the corresponding (plan, execution, judgment) triplet leads to the correct verdict and incorrect otherwise. Now, for preference optimization via iterative training, by applying Reinforcement Learning using DPO training on the predicted Preference Pairs, the preference pairs are then iteratively optimized in a self-training loop. By doing so, the <strong>quality of its Thoughts (CoTs) as feedback</strong> is given to the judge model by itself again.</p><p>With this feedback, the judge model adds some vectors to itself and updates its parameters (<strong><em>Implicit Understanding),</em></strong> through which it is supervised and fine-tuned. And what it means is from now onward <strong>it learns how to ReAct (planning),</strong> i.e., how to improve its generalization <strong>without any human or explicit criteria</strong> exposed to it. With that, the pipeline training algorithm of EvalPlanner consists of a self-training loop, starting with a seed model M0 (e.g., an instruction-tuned LLM), doing supervised fine-tuning (SFT) on a subset of the ‘chosen’ CoTs to obtain a model <strong>MSFT1</strong>, followed by two iterations of Direct Preference Optimization (DPO) (Rafailov et al., 2024) on preference pairs of CoTs, leading to models <strong>MDPO1</strong> and <strong>MDPO2 </strong>for DPO on the preference pairs dataset, initialized from <strong>MSFT1 </strong>and DPO on the preference pairs dataset, initialized from <strong>MDPO1 </strong>respectively (Thinking-LLM-as-a-Judge, Swarnadeep et al). Going further iterations, the judge model is consecutively thinking and getting feedback to hopefully able to optimize preferences pairs consisting of evaluation plans to reach the quality responses as its verdicts per each problem. In doing so, here is a self-training loop that trains an LLM-as-a-Judge model by optimizing over both plans and executions, leading to better judgments at test time. The model generates CoTs in the structured form <strong><em>˜y = (˜z, ˜e, ˜y)</em></strong>, representing a plan, its execution, and the final verdict.<strong> Synthetic Training Data Generation and Preference Optimization: </strong>Based on a method demonstrated in the referenced paper, the model first takes a user instruction, and samples some evaluation plans for <strong><em>How-To-Evaluation Reasoning</em></strong> for evaluation <strong><em>(evaluation steps CoT)</em></strong> for a given solved problem. Such evaluation plans are, in fact, the <strong>implicit criteria (instead of the previously explicit)</strong> for verifying the quality of the responses. Then, given the same instruction this time with preference pairs (high &amp; low quality responses to that prompt), the model samples multiple executions for each just-generated plan so that, seeing a problem &amp; responses, it is expected to generate multiple <strong><em>How-To-Execute Reasonings</em></strong> for each plan <strong><em>(execution steps CoT)</em></strong> for executing the evaluation steps planned to solve a given problem. This means, given a problem with its responses (preference pairs) and its evaluation plans, with executing which evaluation plan, the model proposes which response as qualified <strong>(which response on account of which criteria?).</strong> In consequence, a preference tuning dataset (preference pairs of plans &amp; executions) is built to optimize over the CoTs, such that for each input instruction, given the preference pairs, the plans, and their executions, a “<strong>Thought</strong>” (CoT of evaluation) is considered correct if the corresponding (plan, execution, judgment) triplet leads to the correct verdict and incorrect otherwise. Now, for preference optimization via iterative training, by applying Reinforcement Learning using DPO training on the predicted Preference Pairs, the preference pairs are then iteratively optimized in a self-training loop. By doing so, the <strong>quality of its Thoughts (CoTs) as feedback</strong> is given to the judge model by itself again.</p><p>With this feedback, the judge model adds some vectors to itself and updates its parameters (<strong><em>Implicit Understanding),</em></strong> through which it is supervised and fine-tuned. And what it means is from now onward <strong>it learns how to ReAct (planning),</strong> i.e., how to improve its generalization <strong>without any human or explicit criteria</strong> exposed to it. With that, the pipeline training algorithm of EvalPlanner consists of a self-training loop, starting with a seed model M0 (e.g., an instruction-tuned LLM), doing supervised fine-tuning (SFT) on a subset of the ‘chosen’ CoTs to obtain a model <strong>MSFT1</strong>, followed by two iterations of Direct Preference Optimization (DPO) (Rafailov et al., 2024) on preference pairs of CoTs, leading to models <strong>MDPO1</strong> and <strong>MDPO2 </strong>for DPO on the preference pairs dataset, initialized from <strong>MSFT1 </strong>and DPO on the preference pairs dataset, initialized from <strong>MDPO1 </strong>respectively (Thinking-LLM-as-a-Judge, Swarnadeep et al). Going further iterations, the judge model is consecutively thinking and getting feedback to hopefully able to optimize preferences pairs consisting of evaluation plans to reach the quality responses as its verdicts per each problem. In doing so, here is a self-training loop that trains an LLM-as-a-Judge model by optimizing over both plans and executions, leading to better judgments at test time. The model generates CoTs in the structured form <strong><em>˜y = (˜z, ˜e, ˜y)</em></strong>, representing a plan, its execution, and the final verdict.</p><p><strong>Prompt Selection and Generating Response Pairs: </strong>That the preference Pairs in EvalPlanner method should be verifiable is an inevitable given in EvalPlanner. So the method is assuming access to some carefully-chosen input instructions as training data. To address this assumption for both purposes of general instruction-following and mathematical reasoning, the EvalPlanner work leverages Self-Taught Evaluators (Wang et al., 2024c), as well as applying Data Ablation so as to reach verifiable data. For general instruction-following prompts, the same approach as in Self-Taught Evaluators (Wang et al., 2024c) is used to generate response pairs, i.e., by first modifying the original instruction into a ‘noisy’ instruction and then generating a response to the noisy instruction. Consequently, the response to the original instruction becomes the chosen response, while the one for the ‘noisy’ instruction becomes the rejected response. That is, we address access to Verifiable data for instruction-following. On the other hand, for prompts specific to math reasoning, first by sampling multiple responses, the Self-Taught model selects responses with correct solutions as correct verdicts, becoming the chosen responses, while those with incorrect solutions as rejected responses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*2z6hrkLN6AWxtmlYAFcirg.png" /><figcaption>Self-Taught Evaluator Iterative Training for Prompt Selection and Generating Response Pairs in Synthetic LLM-as-a-Judge Data Creation Method</figcaption></figure><p>As shown above, in the recipe for creating verifiable data, for example, first the model generates a good response y to prompt x with LLM. It then generates a similar prompt to x as x’, and generates a good response to it y’. Then, in iterative training, it generates judgments as a reward such that y should be preferred over y’. Now, with that, we can train Thinking-LLM-as-a-Judge with this data and reward. Below shows making a similar (but different) prompt, asking the LLM to do it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DpM_NLlqcdWyOeaiKcyfpQ.png" /></figure><h4>Performance Evaluation Results:</h4><p>Performance-wise, <strong><em>thinking during the evaluation phase</em></strong> (as LLMs thought to generate CoTof reasoning and planning for evaluations) has been shown to have a much greater impact on the judge model’s accuracy. With regard to the experiments conducted in the referenced paper, the EvalPlanner achieves a considerable performance compared to other SOTA generative reward models. Having been conducted on the benchmarks (including reward modeling benchmarks — RewardBench, PPE, RM-Bench, JudgeBench, and FollowBenchEval) with various instructions (across categories of Chat, Safety, Code, Math, and fine-grained multi-level constraints), experiments for generative reward models (Swarnadeep et al), illustrated below, exhibited the SOTA overall scores surpassing SoTA models’ at the time. And in terms of complex prompts requiring evaluating multi-level constraints (additional experiments on PPE benchmarks), the Thinking LM-as-a-Judge algorithm likewise gains higher improvement compared to the leading model at the time. More importantly, though, is that the Thinking LM-as-a-Judge approach (EvalPlanner) outperformed baselines that train on far more data (up to 30x more), meaning EvalPlanner was trained on fewer preference pairs synthetically generated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*BhkaTWpT2aDmfHDf7tvSpA.png" /><figcaption>Experiments’ results of EvalPlanner on various benchmarks in terms of amount of training data, various tasks, and model size [Thinking-LLM-as-a-Judge, Swarnadee]</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*d4JRV4JjYgsyxbdEFxVxRg.png" /><figcaption>Performance of EvalPlanner compared to other large models, in terms of number of iterations of DPO, and also on challenging tasks for complex prompts with multi-level constraints [Thinking-LLM-as-a-Judge, Swarnadee]</figcaption></figure><p>In Addition to that, conducting a set of comprehensive ablations (on RewardBench using an EvalPlanner checkpoint, trained on 2.5K MATH instructions using Llama-3.1–70B-Instruct as the seed model) likewise highlights the effectiveness of EvalPlanner’s (1) unconstrained evaluation plans over constrained ones, (2) iterative optimization recipe of these plans, and (3) data-efficiency, allowing it to obtain competitive performance with as few as 5K synthetic preference pairs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*guDGgAHBOTYJkwfPMofOgw.png" /></figure><h3>Takeaways from self-evaluation:</h3><p>All things considered,</p><ul><li>In fact, the core gain of this optimization method (Learning to Plan &amp; Reason) is <strong>achieving verifiable tasks</strong>, meaning preferring a task that is done correctly over a task done incorrectly.</li><li>This optimization method (<strong>thinking during the evaluation phase</strong>, as LLMs thought to generate CoT of reasoning and planning for evaluations) focuses its attention on building Thinking-LLM-as-a-Judge models that scale up test-time compute for robust and transparent evaluation by learning to both plan and reason jointly.</li><li>Besides, one considerable merit of this approach over leading baselines is the capability of being trained on <strong>a much smaller amount of data</strong>, and second, on <strong>synthetically generated preference pairs </strong>rather than typically human-annotated data.</li><li>Another takeaway is also that EvalPlanner is trained on such synthetically generated data (from seed Llama models) that can reflect <strong>stereotypes, biases, and other negative traits</strong> present in their pre-training data (Weidinger et al., 2021), which <strong>we do not have control over</strong>.</li><li>This method has the potential to improve evaluation accuracy and transparency in various applications. In particular, it can potentially help advance the evaluation phase in Machine Learning, by allowing LLM-as-a-Judge models to <strong>think before producing a judgment</strong> (Swarnadeep et al), further highlighting the utility of <strong>both planning and reasoning</strong> for building <strong>robust LLM-as-a-Judge</strong> reasoning models.</li></ul><h3>3) Self-Improvement through Reasoning-Powered Planning Paradigms</h3><p>The simplified definition of planning is:</p><blockquote><strong>Given a Goal, the agent decides on a sequence of actions (a0, a1, a2, …, an) that will lead to a state that passes the goal test g(.)</strong></blockquote><p>The way planning should be done allows the model to break the problem into structured subproblems, solve them independently, and integrate partial solutions dynamically. In fact, planning is to support reasoning, so that reasoning can guide acting. This is a continuous cycle in which reasoning and action inform each other continuously. To do so, language agents should support (1) high expressiveness but fuzzy in goal specification (e.g., in natural language as opposed to formal language), as increasing as possible (2) a substantially expanded or open-ended action space.</p><p>One major pro of enabling it is that the fuzziness makes things more challenging, but for the better. Thus, if the model becomes as good at reasoning as possible, then it also becomes as better at planning as needed for much more realistic and useful scenarios (applications). However, because of the aforementioned agent’s properties (expressiveness &amp; fuzziness are inherent parts of this world), some major Issues are still considered here as well:</p><ul><li>It becomes increasingly hard to automate the goal test. We cannot simply write just a goal test beforehand (what is the desired goal state?).</li><li>Continual learning (much pervasive states)</li><li>Safety &amp; privacy issues</li><li>Inference-time cost issues</li></ul><p>As a common example, going to research space, surfing on the web using a web agent, when given a user’s search filter, action sequences vary. Because the actions are dynamically populated on each web page for any single search, at any time. Due to different elements, any different page has a different action space. Therefore, such tasks have a very big action space to discover on the fly. That’s why the goal test is also very hard. Or in travel planning, after implicit reasoning (CoT), the agent uses the toolbox to do planning step-by-step (based on its own CoT), such as city search, flight search, restaurant search, accommodation search, and so on and so forth. And moreover, one of the most challenging attempts in the research area is World Models of the Internet (Yu Su et al).</p><ul><li>By and large, from a language agent Planning perspective, there are some types of <strong>Planning Paradigms</strong>: <strong>Reactive planning, Tree search, and Model-based planning.</strong></li></ul><h4>3–1) Reactive Planning</h4><p>The most common paradigm is where the agent at each stage observes the environment, reasons about it, then makes a decision, commits to the decision, then gets to another state, and then just keeps doing this process. The pros include that it is fast and easy to implement. And the cons include that it is greedy, short-sighted, often finds itself stuck in some bad state, and there is no way out.</p><h4>3–2) Tree search with Real Interactions</h4><p>The agent tends to backtracking such that it maintains any state’s value on its search frontier, then explores the most promising branch, while at any point, if it finds that it is not promising, the agent can backtrack and then try to explore another branch. The pros here consist of more systematic exploration, and for the cons, in a real-world environment like the internet, it encounters the following problems (Model-based Planning for Web Agents, Yu Su et al):</p><ul><li>There are a lot of irreversible actions that make backtracking impossible or at least very hard.</li><li>A lot of these explorations could also be unsafe or at privacy risk</li><li>Inference time exploration could be slow and costly</li><li>How pervasive? In fact, there are many state-changing &amp; irreversible actions in the real world. E.g., on amazon.com, there are hundreds of states, also a risk of privacy at some stages, and so on so forth.</li><li>These all make tree search in a real-world environment hard.</li></ul><h4>3–3) Model-based planning or World Model</h4><p>So, ideally, we want a model-based planning approach. A world model that can be triggered at each stage to simulate the outcome of each candidate action. Leveraging such an approach, an agent can evaluate a long-term value and the safety of each candidate action before committing to it. That way, the agent can find the most promising candidate action through simulation, then commit to it, take it, assuming it’s safe, then it gets to another stage, then do this all over again. The advantages of world models can include that they are faster and safer compared with tree search, and also, they can still do systematic exploration. Even so, the challenge, or say con here, is in fact how to get a world model (Yu Su et al.)? <strong>A Robust World Model.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zjlbFUtKvliND-CgH6CIdQ.png" /><figcaption>Planning paradigms for language agents</figcaption></figure><p>A world model is a computational model of environment transition dynamics:</p><h4>𝑇:𝒮×𝒜→𝒮</h4><p>If I do this (𝑎𝑡) right now (𝑠𝑡), what would happen next (𝑠𝑡+1)?</p><p>Although in classical deep reinforcement learning, doing millions of times of trails in a simple simulated environment can learn a world model specific for that simple environment, even so, training a world model in real-world environment is much more complicated even just for a single website (Model based Planning for Web Agents, Yu su et al). there could be hundreds of different webpages and on a single web page there could also be hundreds of different actions, and they can be constantly changing (because the backend and database is changing. Furthermore, its compound complexity is that there are billions of other websites on the Internet!</p><p>Therefore, the goal here could be a <strong>Generalist World Model</strong> for the internet to come up with a solution. The idea relies on LLMs able to predict state transitions. Due to the fact that LLMs are trained on the internet, they have this world knowledge (e.g., website contents), therefore they can do reasoning for prediction as a reasonable job (far from perfect, but reasonable). In doing so, they can select an action (as a candidate) which (1) conforms to the context and (2) is roughly (or to a great extent) similar to the promising action.</p><p>WebDreamer, for instance, is a world model simulated and trained using GPT4–4o. Rather than clicking merely next action, it instead simulates (predicts) the next click. It is possible to simulate multiple next stages such that each route is given a score, meaning “How much progress you would make, going down that pass”. This way, a user can then choose the highest valued action amongst, and consequently goes to the next stage to do this all over again. Despite significant recent improvements, Webdreamer is still far from perfect but has been a reasonable starting point for a model-based planning approach.</p><p>Performance-wise, model-based planning appeared to be more accurate than reactive planning and slightly trails tree search (tree search is only possible in a sandbox environment, but in a real-world website, backtracking becomes hard). Moreover, model-based planning is much cheaper and more efficient than tree search in terms of action steps. Model-based planning is much faster than tree search in terms of clock time. Reactive planning is faster and more efficient, but has the least accuracy. The best planning strategy is dependent on the LLM; stronger base LLMs (R3,4o) may require less scaffolding (i.e., the planning strategy could be more reactive).</p><blockquote>In model-based approaches, one major goal, given the quality training data (e.g., through IF, VR, VT), is to resort to the implicit capabilities of language models to build a promising, effective world model, such that it inherently enables latent planning capabilities of Hierarchical Planning and Dynamic Planning, while simultaneously adopting explicit approaches (e.g., hybrid intelligenc as human/AI in the loop), aiming at fulfilling Reasoning-Powered Planning Paradigms.</blockquote><p>Taken together, to reach the paradigm for building a <strong>Robust World Model capable of Hierarchical and Dynamical Planning</strong> has given rise to some <strong>issues</strong>, including but not restricted to:</p><ul><li>How to build better world models instead of just a simulator one?</li><li>How to balance reactive and model-based planning? Because we don’t really want to do a simulation at every single step, that is very costly. We don’t want to do a simulation for every single decision, but only for those difficult ones.</li><li>How to sustain a long horizon without losing focus?</li><li>And On Safety:</li><li>Endogenous risks: these risks originate from within (from the agent itself). Usually, it is because of the incompetence of the agent. Meaning the agent can mistakenly take some irreversible actions that do harm.</li><li>Exogenous risks: the risks from the external environment</li><li>The attack surface of a language agent is actually that environment. E.g., the web agent’s attack surface is essentially the entire internet! E.g., someone can embed something on a seemingly benign website, and the agent (e.g., OpenAI Deep research) can go there and get tricked by it, and then may reveal your private information.</li><li>How to improve planning in LLMs is still largely an open question.</li></ul><h3>Conclusion and Takeaways:</h3><blockquote><strong><em>How to design Effective Reasoning &amp; Planning &amp; Evaluating Capabilities as a Self-Introspection Paradigm?</em></strong></blockquote><h4>General Principle</h4><p>The Bitter Lesson from Richard Sutton (again) is an important guideline for designing reasoning techniques, including all inference-time, training-time, and test-time algorithms:</p><blockquote>“The biggest lesson that can be read from 70 years of AI research is that general methods that leverage computation are ultimately the most effective, and by a large margin.”</blockquote><h4>Best Practices</h4><p>With regard to previous inference time techniques discussed so far (in my articles), in consequence of how to combine all these inference-time techniques, the best practice to interact with an LLM should be adapted according to the model’s underlying capabilities, as well as the task to design, an efficient &amp; effective paradigm for the task:</p><ul><li>From the bitter lesson, the great power of general-purpose methods (along both the Scaling Law &amp; Specific-Driven), of methods that continue to scale with increased computation, even as the available computation becomes very great. What it means is that those general-purpose methods are efficient and effective, and are sustainable over a variety of computations. Therefore, they as such should continue to scale with such computations. So, we should design algorithms that are (1) not specific purpose (but general-purpose), and (2) as the computation increases, we should be able to scale the algorithm such that no need is required to redesign them in order to support and handle new scale demand coming out.</li><li>Concern with AI agents, we want agents that can discover like we can, not which contain what we have discovered. And what it means is that the agents are able to discover, like us, humans. We can have the agent discover what we are looking for to discover. Not that, it would be a model proving to us again what we have discovered so far! In which case, building on our discoveries only makes it harder to see how the discovery process can be done. Therefore, it is essential to train a model by which (by this brain) an agent is able to perceive how to self-improve, and to reflect on problem-solving methods, and so also to plan the tailored reasoning execution even as evolutionarily.</li><li>In respect of self-improvement, for instance, the model’s abilities/limitations on <strong><em>Self-Reasoning</em></strong> (from self-learning to self-observation &amp; self-searching to self-reflection &amp; self-refinement), besides the long horizon capabilities/deficiencies of <strong>Self-Rewarding</strong> (Synthetic- &amp; Self-Rewarding and oracle evaluation), and <strong>Self-Planning</strong> (Robust Dynamical planning, fast &amp; inexpensive hierarchical planning, and so on) as well as <strong>Self-Evaluating</strong>, all considered to fulfill <strong>Self-Learning &amp; Self-Training along with Hybrid human-inspired</strong> approaches.</li><li>Doing trade-offs is always adhering to. Various trade-offs from pretraining stages (warm-up) to post-training to test-time scaling have been proven to be a controllable mechanism desired to end up with as promising a model as possible. Some spectrums give us a hint of improvement clues, for the sake of self-improvement, especially by embracing nuanced modifications in bespoke calculations, the model can gain further improvement (e.g., trade-off to balance between throughput and memory usage or trade-off for longer reasoning efficiency). Even so, against all odds, it is sometimes more than just changing the algorithm for performance tuning. Change in quality of data(trade-off between diversity &amp; difficulty &amp; comprehensiveness) has been so far proven to have likewise inevitable impacts on performance! Where the MoEs become more beneficial. However, when plateaued, it might not look like how you would expect it to look like, even with quality data, or it might be exacerbated when the model has an overly biased view of the given trained data! Or when dealing with fuzzy worlds, how to work without getting reliable rewards? Or when it comes to more algorithmic design approaches, introduce us to employing other types of modifications, of thinking during the evaluation phase (trade-off for the capability of being trained on a much smaller amount of data). And this is where nascent approaches emerged and started evolving via substantial modifications to further push the progress, kind of a landscape of a broader view of the current and anticipated state of Self-Learnt &amp; Self-Planned Models. Via e.g., modality of iterative reasoning &amp; planning, effortful thinking dealing with sycophancy or bias issues, learning from interaction (hybrid intelligence) as and when required, or leveraging physics-inspired empirical truth, and etc. all in all, Still putting ourselves in the mindset of a model trying to learn how to self-improve, to better reason, and to infer how to solve tasks, there are even argues about prospect of self-awareness, that we should drop the agent in the fuzzy situations, lest its creativity is restricted by its, while reinforcing the factual sided not overlooking hallucination. Such analogies could provide greater insights into how we expect the promising agent to be a quality autonomous yet responsible for its actions.</li></ul><blockquote><strong>All things considered, though, in the space of estimations, it is now worthwhile thinking that sometimes it is more of an art than a science. “The truth always turns out to be simpler than you thought.” — Richard P. Feynman — from the perspective of humans’ intrinsic cognitive functions, there should be physics-inspired empirical computations to be dedicated in order to achieve more optimal ways of agent thinking.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b586011c7c63" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/part-4-self-improvement-algorithms-lms-self-learning-to-self-reason-b586011c7c63"> Self-Evolving World Models Paradigms, Self-learning to Self-Planning</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Self-Improving LM's Self-learning to Self-Reason — Part 3]]></title>
            <link>https://levelup.gitconnected.com/introspection-self-improvement-algorithms-lms-self-learning-to-self-reason-part-3-075fcee90466?source=rss-6acfbf0d8c9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/075fcee90466</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Hamid Nafiyan]]></dc:creator>
            <pubDate>Tue, 16 Dec 2025 17:21:15 GMT</pubDate>
            <atom:updated>2026-06-08T07:30:33.055Z</atom:updated>
            <content:encoded><![CDATA[<h3>Self-Improvement Algorithms: Language Reasoning Agents Self-learning to Self-Reason — Part 3</h3><h4>Iterative Reasoning for Self-Rewarded Preference Tuning via Policy Optimization in Loss Function</h4><h4>Introduction</h4><p>In the space of estimations, using language for reasoning and communication doesn’t have to come from an LLM; that may turn out to be a means to an end. Maybe in a few years, we will move beyond LLMs, but the need for universal language understanding and production in agents will remain. Next to that, the current and anticipated state of LLMs’ reasoning requirements provides broader yet deeper insights into how to describe the ways it can be interacted with as well as the ways it can be interacted with. Given that that’s true, taking LLM’s capabilities for reasoning and planning into account, which itself stems from its own intermediate steps, which are somehow rooted in its implicit reasoning capabilities, sheds light on the broader responsibility of a language agent concerning self-learning various capabilities as a proven-essential Introspection skill, which has been a while focused profoundly on as a long-horizon paradigm. To enable such a great added value as an intrinsic skill into an LLM, I am going to delve deep into SoTA methods for approaching the long-horizon <strong><em>Self-Learning paradigms</em></strong>. So, as an aside again, how to apply such techniques and their where and the when is a useful best practice to shape such an aforementioned skill as an Introspection paradigm.</p><p><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301">In Part 2, my previous article, we explored Self-Rewarding for Preference Tuning via RLAIF approach, then dealt with optimization algorithms for self-rewarding, including PPO, DPO, iterative PRO through verifiable rewards using DPO plus NLL, and iterative RPO via RLVR, over each of which we also made some comparisons.</a> I am now going to explore some further improvements of <strong>Advanced Self-improvement Algorithms</strong>, techniques &amp; approaches, <strong>focused optimizations particularly on modifying loss function and policy calculation</strong>, aiming still at enabling language agents with self-learning, Self-observation, self-reflection, self-searching, self-planning, and self-evaluation capabilities.</p><h4>Table of Contents:</h4><ul><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-8771cc97f563#:~:text=an%20Introspection%20paradigm.-,Debates,-There%20have%20still">Debates</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-8771cc97f563#:~:text=1%E2%80%932%E2%80%935)%20Switching%20from%20PPO%20to%20GRPO%20(Group%20Relative%20Policy%20Optimization)">1–2–5) Learning to Self-Improve (Self-Training for Self-Reasoning) via Iterative Reasoning Policy Optimization: Switching from PPO to GRPO (Group Relative Policy Optimization)</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-8771cc97f563#:~:text=Further%20optimization%20on%20GRPO%3A">Further optimization on GRPO: Aha moment</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-8771cc97f563#:~:text=and%20DeepSeek%2DV3-,1%E2%80%932%E2%80%936)%20Dr.%20GRPO%3A,-Biased%20Optimization%20or">1–2–6) Dr. GRPO</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-8771cc97f563#:~:text=1%E2%80%932%E2%80%937)%20Adaptive%20Group%20Policy%20Optimization%20(AGPO)">1–2–7) Adaptive Group Policy Optimization (AGPO)</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-8771cc97f563#:~:text=1%E2%80%932%E2%80%938)%20Group%20Sequence%20Policy%20Optimization%20(GSPO)">1–2–8) Group Sequence Policy Optimization (GSPO)</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-self-improvement-algorithms-language-reasoning-agents-self-learning-to-self-reason-8771cc97f563#:~:text=References%20%26%20Credits%3A">References &amp; Credits</a></li></ul><h4>Debates</h4><p>There have still been controversial debates here and there in academic research, research institutes, big tech labs, industry, and engineering communities on common recent limitations of LLMs leading to performance drop or failure, the most important of which include:</p><ul><li><strong>Distraction</strong> (due to irrelevant problems) and distracting rules</li><li><strong>Risk of memorization or overfitting</strong></li><li><strong>Hallucination gives rise to inconsistency, absence of causality, and a lack of ground truth in the response</strong></li><li><strong>NIAH</strong> (reasoning in long contexts)</li><li>Lack of <strong>persistent</strong> memory</li><li>Long-term <strong>memory</strong></li><li><strong>Compositionality</strong> limits via distillation</li><li>Premise <strong>order</strong> of sentences (inability to go back and forth)</li><li><strong>Unability</strong> to reason</li><li><strong>Early stop</strong> reasoning</li><li><strong>Large input</strong> context problems</li><li><strong>Self-correction</strong></li><li>Search <strong>space</strong> <strong>scaling</strong> up</li><li>Effective <strong>test-time scaling</strong></li><li><strong>Local knowledge</strong> distillation</li><li><strong>Spatial</strong> reasoning</li><li><strong>Exponential Error</strong> Compounding in long-horizon tasks (sequential decision-making)</li><li><strong>Oracle</strong> feedbacks</li><li><strong>Gradient Ascent </strong>&amp; <strong>Likelihood</strong></li><li>Varied-level <strong>mathematical</strong> problem-solving (grade-school to IMO),</li><li><strong>Hierarchical &amp; Dynamical Planning </strong>in efficient <strong>state</strong> <strong>exploration</strong> and <strong>action space exploitation</strong></li><li>Imitated-reasoning of fundamental human <strong>cognitive functions</strong></li></ul><p>Taking the aforementioned ongoing issues above into account, and now that we have reviewed the essential concepts and basis, I am now going to get into the behind-the-scenes of LLMs’ reasoning via exploring fundamental reasoning techniques. This article also explores the potential solutions and improvements going on, the issues<strong> </strong>to come up with optimization and trade-off methods. Dealing with long-horizon reasoning and planning techniques, I started off in my previous articles with Inference-time techniques besides reasoning strategies, and then we made them excuses to discuss on the road to search and planning techniques. Now I am going to point out the SoTA post-training algorithms and methodologies, and by leveraging them, we delve deep into the <strong>Advanced Self-improvement Algorithms, Techniques &amp; Approaches</strong>, aiming at enabling language agents with <strong>self-learning, self-observation, self-reflection, self-searching, self-planning, and self-evaluation capabilities</strong>.</p><blockquote><em>Please refer to the references &amp; credits of the material covered in this article as well. Also note that all photos are either compiled or screenshots taken from papers to which referred in this article.</em></blockquote><h3>Learning to Self-Improve (Self-Training for Self-Reasoning) via Iterative Reasoning Policy Optimization</h3><h4>1–2–5) Switching from PPO to GRPO (Group Relative Policy Optimization)</h4><p>From the perspective of diverse and difficult reasoning and math tasks, however, despite this progress, as mentioned in the previous methods, a major challenge still remains. We still don’t trust the SFT-enabled LLMs on the math tasks as much! The problem with sophisticated math and reasoning tasks (such as competition-level mathematics and programming) is when self-reward models tend to give less gains in performance as the tasks become much more difficult.<br>On the other hand, the fact that PPO is an actor-critic style algorithm makes it memory inefficient and increases the computational requirements during training, in the sense that it requires training a separate critic (value) network, which is often the same size as the policy model. It also depends a lot on the quality of the critic model, which can be slow to learn and not so good at generalizing. After all, in long language tasks, like step-by-step math solutions, PPO’s token-level update and value estimates can also plateau.</p><p>Throughput-wise, for the effective use of GPU memory on one hand, and increasing compute during inference on the other, there has been a Trade-off to balance its overall efficiency. An idea brought to attention was removing the extra critic network and finding a way to replace it with something more effective.</p><p>In April 2024, DeepSeek created the GRPP algorithm (Group Relative Policy Optimization) as their own alternative to PPO and other methods, referenced papers (DeepSeekMath paper: DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models, Shao et al.) and (Incetivizing Reasoning Capability in LLM via Reinforcement Learning, DeepSeekAI). GRPO is a variant of Proximal Policy Optimization (PPO), which can notably improve mathematical reasoning capabilities with less memory consumption (optimizing the memory usage of PPO). GRPO is a twist on and alternative to the traditionally used reinforcement learning methods like PPO (Proximal Policy Optimization), which required a value (critic) model, as well as high memory and compute usage. It is exhibited to be a more efficient and faster method in Math reasoning tasks.</p><p>GRPO was first used in the powers training DeepSeek-R1 and DeepSeek-R1-Zero models, helping to adapt reinforcement learning (RL) in them. At the time of writing the referenced papers, the performance of open-source models relative to closed ones on the competition-level MATH benchmark (Hendrycks et al., 2021) was evaluated without the use of external toolkits and voting techniques. And Deepseek-7B could enhance mathematical reasoning abilities with fewer parameters compared to other open models in the same setting, nearly reaching the performance of closed, large ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*uNrTBn4hP0YrUjyCfkOSJg.png" /></figure><p>GRPO is actually an RL algorithm that entirely drops the critic network. It judges model outputs relative to each other in groups, rather than to an absolute value estimate. This trick yields a strong learning signal for complex reasoning, removes the overhead of training an extra network, and optimizes the memory usage.</p><p>As stated in the reference paper (DeepSeekMath paper, Shao et al.), the GRPO objective is very similar to the PPO objective. The following is the loss function of GRPO:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bwlf9B_o_IDPg41WMhaXXw.png" /><figcaption>Loss Function in DeepSeek GRPO Training</figcaption></figure><p>GRPO algorithm, in fact, aims at using multiple answers (i.e., actions) per prompt (i.e., state) to estimate rewards for our outcome-oriented problems. GRPO obviates the need for additional value function approximation (as in PPO), and instead uses the average reward of multiple sampled outputs, produced in response to the same question, as the baseline. More specifically, for each question, GRPO samples a group of outputs {𝑜1, 𝑜2, · · ·, 𝑜𝐺} from the old policy 𝜋𝜃𝑜𝑙𝑑 and then optimizes the policy model by maximizing the above loss function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*0XJYw8jAw5tzZKEgijs_pA.png" /><figcaption>GRPO vs PPO, GRPO obviates the need for additional value approximation model, instead uses Generalized Advantage Estimation function for estimating the baseline from group scores, significantly reducing training resources.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*ywaT9OCceXv0Ju3EqWrSkA.png" /><figcaption>Iterative Group Relative Policy Optimization Algorithm, from DeepSeek</figcaption></figure><p>Here 𝐴𝑖𝑡 is the advantage function, which is computed by applying Generalized Advantage Estimation (GAE) (Schulman et al., 2015), in the loss. The idea of 𝐴𝑖𝑡 is bootstrapping advantages from multiple answers to the same prompt. This means in comparison to PPO, GRPO not only removes the critic-model but, unlike PPO, it trains multiple answers (completions) for each prompt per mini-batch as well. And then it calculates the average reward from them. And consequently, by collecting the rewards of those answers along with the average reward, it eventually calculates the advantage value gained from the collective rewards of selective answers.<br>Moreover, instead of adding a KL penalty in the reward (as with PPO), GRPO regularizes by directly adding the KL divergence (the magnitude of the penalty or reinforcement for the data) between the trained policy and the reference policy to the loss, avoiding complicating the calculation of 𝐴𝑖𝑡. This means for estimating the KL divergence, GRPO uses the unbiased estimator (Schulman, 2020) as D𝐾𝐿.</p><h4>Performance Evaluations:</h4><p>According to the original papers (DeepSeekMath, Shao et al.), the Authors evaluated the mathematical capabilities of DeepSeekMath-Base-7B by conducting a comprehensive assessment focusing on its ability to produce self-contained mathematical solutions without relying on external tools, to solve mathematical problems using tools, and to conduct formal theorem proving. In addition to these assessments, the model’s performance in natural language understanding, reasoning, and programming skills was evaluated as well. For math evaluation covering diverse fields of mathematics from elementary to college-level complexity, the DeepSeekMath-Base-7B model was tested across. It is a base model with strong reasoning abilities, especially in mathematics. Performance of DeepSeekMath-Base-7B using few-shot chain-of-thought prompting for Mathematical Problem Solving with Step-by-Step Reasoning, across eight benchmarks in English and Chinese, including quantitative reasoning (e.g., GSM8K, MATH, and CMATH) and multiple-choice problems (e.g., MMLU-STEM and Gaokao-MathQA). And the results showed that the DeepSeekMath-Base-7B gained higher performance compared to other open &amp; closed source models in this setting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*8Fcfyw3krABWCtqXiDdLpA.png" /><figcaption>Performance of Open- and Closed-Source models with both Chain-of-Thought and Tool-Integrated Reasoning on English and Chinese Benchmarks</figcaption></figure><p>And for assessing formal Mathematics for formal proof automation, the accuracy and reliability of DeepSeekMath-Base 7B in the task of informal-to-formal proving (to generate a formal proof based on an informal statement, a formal counterpart of the statement, an informal proof, proof sketches, and execute the off-the-shelf automated prover to fill in the missing details) was evaluated. The assessments were conducted on benchmarks, including miniF2F, a benchmark for formal Olympiad-level mathematics, and generated a formal proof in Isabelle for each problem with few-shot prompting. The results below depict DeepSeekMath-Base 7B demonstrated strong performance in proof autoformalization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*_xAVcWaY1aCP-Mn5AQLWDg.png" /><figcaption>The performance of DeepSeekMath-Base-7B in autoformalization (formal Mathematics for formal proof automation)</figcaption></figure><p>Similarly, in coding tasks, for example, for LeetCode problems, a compiler can be used as a reward model to generate feedback (whether the response is correct) based on predefined test cases (referenced paper: Incetivizing Reasoning Capability in LLM via Reinforcement Learning, DeepSeekAI)</p><p>And in terms of chain-of-thought reasoning &amp; instruction following general in-domain and out-of-domain tasks, DeepSeekMath-RL-7B was evaluated using benchmarks GSM8K and MATH. The results showed that DeepSeekMath-RL surpasses all open-source models and gains further performance compared to the majority of closed-source models. In this case, the results actually showcase the effectiveness of reinforcement learning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*w3ReVgD9_7SmObwwh2eLJA.png" /><figcaption>Performance of DeepSeekMath-Base-7B compared to strong base models in of chain-of-thought reasoning &amp; instruction following general tasks</figcaption></figure><p>Following is an example of a Prompt for checking the model’s question-answering ability:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*7yfQ3InKDtPyJA4IHPYLCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*2y2MXpbBq1rZvBgQnZY-Ng.png" /></figure><p>From the perspective of the iterative RL, the experiments conducted to evaluate the performance of DeepSeekMath-Instruct 7B on two benchmarks, as shown below, indicated that the iterative RL significantly improves the performance, especially at the first iteration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*VxqXhgGm3bcepVKlet5dLQ.png" /><figcaption>Performance of iterative reinforcement learning with DeepSeekMath-Instruct-7B on</figcaption></figure><p>And in some experiments by Ai2 reveals that by applying GRPO in Tulu3 trained using QwenMath, Tulu3 has a higher performance compared to Tulu3–405B, showcasing further improvement:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*x9ejDTBYnizf9nQq5y7JjA.png" /><figcaption>Applying GRPO in Tulu3 trained using QwenMath, gaining higher performance comparing with Tulu3–405B</figcaption></figure><h4>Further optimization on GRPO:</h4><p>According to a paper “Understanding R1-Zero-Like Training: A Critical Perspective”(Zichen Liu et al), the reasoning LLM capabilities can be further enhanced by RL at scale even without supervised fine-tuning, meaning in situations where we don’t use prompt templates. This work conducted an analysis to investigate how pretraining characteristics influence RL performance. These can be achieved by two techniques called “<strong>Aha moment</strong>” and “<strong>Dr.GRPO”</strong>. The results said DeepSeek-V3-Base already exhibits “Aha moment”, while Qwen2.5 base models demonstrate strong reasoning capabilities even without prompt templates, suggesting potential pretraining biases.</p><blockquote>Aha moment;</blockquote><blockquote>Emergence of Self-reflection Behaviors, from Memorization to Well-Generalization</blockquote><p>Taking the <strong>Budget-Forcing</strong> approach at test-time, we can let the model think more. But how?</p><p>There is an underlying method to do so, that leverages system instruction as an internal hint token in order to tell the model “Wait! you are not sure if your answer incorrect/incomplete/uncertain” and with that we force the model to generate more tokens which in turn leads it to think longer and longer ending up with a more accurate answer, i.e., scaling performance without adding any extra prompt templates (meaning without explicit instruction-tuning via SFT). In DeepSeek, this internal mechanism is called “Aha moment,” by which the model itself has learnt to understand its mistakes and therefore rethink them and then fix them, by saying like “Wait, wait! …” which is an aha moment it can flag here. Following this flag, the model starts to generate new CoT to reach a verifiable answer, meaning quality performance. In fact, during the “Aha moment”, the model learns emergent skills such as self-reflection.</p><p>On the other hand, the paper showed a new simple paradigm that demonstrated the RL scaling phenomenon, in which by directly applying RL to base LLMs without relying on supervised fine-tuning (SFT) as a preliminary step, the model’s reasoning capabilities can improve along with a continual increase in the model’s response length. This paradigm is also accompanied by the “Aha moment”, at which the model learns emergent skills such as self-reflection. The DeepSeek-V3-Base model already exhibits the so-called “aha moment” even before the RL-tuning. And nearly all base models already exhibit the “Aha moment”. That is, one of the most inspiring results of DeepSeek-R1-Zero is the emergence of self-reflection behaviors, a.k.a., Aha moment, through pure RL training. This work observes that DeepSeek-V3-Base also generates a decent amount of self-reflections, further validating the claims of Liu et al. (2025b). The examples in the referenced paper show where DeepSeek-V3-Base generates keywords such as “Aha” and “wait”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*8QGCfhfU7rrVaVnlc21e6w.png" /><figcaption>DeepSeek-V3-Base model already exhibits the “aha moment” even before the RL-tuning</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*KmTUXfa7SwIt3-77Y5oCbw.png" /></figure><p>Below is an example of a Prompt for LLM-based detection to determine whether a response contains self-reflection behaviors (<strong>as an aside, also consider a list of different self-reflection keywords</strong>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*SHnqSBmcSSs1VmFiMAc8oA.png" /></figure><p>In the referenced papers (DeepSeekMath, and Understanding R1-Zero-Like Training, Shao et al.) and (Incetivizing Reasoning Capability in LLM via Reinforcement Learning, DeepSeekAI) are other evaluations that are recommended and worth studying further, how model reasoning capabilities improve along with a continual increase in model’s response length (long-CoT) and how different prompt templates affect the RL training. How these lead to the emergence of self-reflection behaviors, showcasing the role of “aha moments” during RL training, and the effect of self-reflection keywords, each. And how accuracy may change w/ or w/o self-reflection. Taken together, how these factors affect the model to learns emergent skills such as self-reflections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*JhNX4UOkBxuf-og3O9nihg.png" /><figcaption>Effect of Factors such as Long CoT, Response Length, Different Temperatures, Different Templates on Model’s Self-Reflection Behavior, Token Efficiency and Output Accuracy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*zSA230_iiqProm4rJcmjAw.png" /></figure><p>Moreover, from the perspective of AI safety, the model’s helpfulness and harmlessness, to further align the model with human preferences, a secondary RL stage can be implemented. In the referenced work (Incetivizing Reasoning Capability in LLM via Reinforcement Learning, DeepSeekAI), this mechanism is aimed at improving the model’s helpfulness and harmlessness in such a way that the model still excels in refining its reasoning capabilities while simultaneously prioritizing helpfulness and harmlessness. In this method, for general reasoning capability (in math, code, and logical, domain) a rule-based reward model is employed via a setting of DeepSeek-R1-zero, and at the same time for improving helpfulness and harmlessness the reward model is leveraged via a DeepSeek-v3 pipeline to capture human preferences in complex and nuanced scenarios, of course in a similar distribution for both preference pairs and training prompts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*TBJJpChLgg5MLXTmKIkYQQ.png" /><figcaption>AI Safety by enabling helpfulness and harmlessness while enhancing general reasoning via a setting of DeepSeek-R1-zero and DeepSeek-V3</figcaption></figure><h4>1–2–6) Dr. GRPO:</h4><p><strong><em>Biased Optimization or Overoptimization due to Overthinking!</em></strong></p><p>Due to a bias in Group Relative Policy Optimization (GRPO), which artificially increases response length (especially for incorrect outputs) during training, an <strong>unbiased optimization</strong> method, Dr. GRPO, is introduced by this work (Sea AI Lab et al.) that improves token efficiency while maintaining reasoning performance.</p><p>The paper (Zichen Liu et al) introduced a response-level length bias in GRPO. The study reveals that when the response generation reaches the maximum token budget, meaning the sequence length of the answers blows up to the maximum allowed in the training setup, then it can lead the performance on downstream evaluation to drop to 0. And due to this, GRPO can fail when generating very long responses. This situation especially takes place when dealing with diversity, difficulty, and the complexity of tasks. This is where the model tends to do overthinking (Chen et al., 2024). identifying such bias in optimization of GRPO (Shao et al., 2024), which may lead to progressively longer incorrect responses, i.e., GRPO Leads to Biased Optimization (overoptimization due to overthinking!). However, the observed increase in response length may be brought about by a bias inherent in the GRPO (Shao et al., 2024). Based upon the evaluations in the referenced paper (Zichen Liu et al), GRPO basically introduces two biases:</p><ul><li>Response-level length bias, which comes from the observation that longer incorrect responses are penalized less than shorter correct ones, leading to a bias against longer &amp; high-reward sequences (which may be incorrect!)</li><li>Question-level difficulty bias due to the fact that while normalization (here, question-level normalization) is a common advantage in RL, questions (too easy or too hard) with lower std &amp; outcome rewards being almost all 1 or 0, are given higher weights during policy updates, across an entire batch, likewise leading to a difficulty bias in optimization!</li></ul><p>Meanwhile, while higher entropy (i.e., exploration/randomness) in training is desirable, longer responses (more tokens) may have repetitive words, which makes the model to although tend to effectively penalize those low-quality patterns, due to lower contribution of those responses to the overall loss, leads to an undesirable increase in entropy, impeding the model to learn reasoning-relevant patterns.</p><p>For suggesting that an unbiased optimizer also mitigates overthinking, Dr. GRPO is introduced to being able to effectively mitigate the optimization bias and lead to better token efficiency. To resolve these two aforementioned optimization biases in GRPO, Dr.GRPO proposes the following modifications:</p><ul><li>To avoid Response-level length bias, it removes the length normalization term <strong><em>|oi|</em></strong></li><li>To eliminate Question-level difficulty bias, it removes the reward normalization term <strong><em>std({R(q, o1), . . . , R(q, oG)})</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*hzn0bbd2YCUs95Agx5Eanw.png" /><figcaption>Modifications in Dr. GRPO vs GRPO to resolve optimization biases by removing the length and std normalization terms</figcaption></figure><p>Dr. GRPO effectively fixes GRPO’s bias in optimization, to get GRPO Done Right (Dr. GRPO), achieving better token efficiency. The following experiments show the evaluation results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l7z160ARqkxFlNQeA9_pEA.png" /></figure><p>In addition, for further Improvements, the extensive ablation on the training dataset (DeepSeekMath paper) offered significant potential for high-quality mathematical data. The ablation mechanisms are conducted, such as:</p><ul><li>Clipping hyperparameter tuning (clipping higher)</li><li>Changing the sampling temperature for the model during RL training (minor variations, but T=1 is best)</li><li>Changing the RL hyperparameters, such as GAE lambda or KL penalties</li><li>Changing batch sizes and update rules.</li><li>Removing unnecessary samples from the batch</li><li>Token-level policy gradient. The evaluation results show that while the model keeps higher entropy (i.e., exploration/randomness) as training goes on, it maintains stability and at the same time offers even significant performance enhancement.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*ko3hizPdC-TA1-6ITZeEFQ.png" /><figcaption>Ablation results on the two bias terms in GRPO.</figcaption></figure><p>In the referenced papers (DeepSeekMath and Understanding R1-Zero-Like Training), there are other evaluations that are recommended and worth studying further.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*q5QgJuo-luG3unbcxp4Crg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*7kMo-plyTDK7iUyxwxOGNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*Hb6sC6UtFXNFRcGqxQ7-iA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*Nq8fyrFMfIayrbiwPWvYBA.png" /></figure><h4>1–2–7) Adaptive Group Policy Optimization (AGPO)</h4><p>GRPO is in some situations appeared to introduce two challenges that can affect <strong>stable training</strong> and <strong>inference efficiency</strong> (HPC-AI Tech, Chen Li et al). in this work, the authors investigated that despite applying negative losses happen in RL training, in GRPO when all rewards within a group are identical, then the normalized advantage might approach zero, causing miscomputing in loss signal and confusing training signal. They also observe that since GRPO models tend to reward concise and effective reasoning (which is essential to improve token efficiency), it might lead to inefficient CoT length, discouraging excessively long chain-of-thought. Taken together, the paper proposes an enhanced training algorithm, Adaptive Group Policy Optimization (AGPO), to address these issues.</p><p>Therefore, adaptive loss function claims to address the scenarios of zero advantage and negative losses, to ensure continuous and effective learning (Training Stability) and Token Efficiency. AGPO focuses on adaptive loss by applying basically two losses, including loss mask and loss clip, while at the same time helping to avoid entropy collapse while training. Although the response length for AGPO is similar to GRPO at the early training stage (the initial model parameters are similar for both), it eventually becomes shorter at the middle and final stages compared with the GRPO baseline. Therefore, Performance fluctuation and entropy collapse always happen in the later stage of GRPO training. The core idea here is to tackle it from the perspective of the loss function. Why loss function? The potential issue is that, in GRPO, in a situation when the groups with all-correct or all-wrong responses might not effectively be ignored during optimization, because the mean loss of a batch is used for model update, zero losses in the batch may lead to misestimation of the scale (Zero advantage and thus zero loss). On the other hand, entropy drops in collapses are observed when causing the policy model to apparently desist exploring, making the model overconfident and tend to ignore incorrect samples in the batch. Hence, to tackle these issues as shown below, the paper proposes replacing the original objective in the loss function with an adaptive loss:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*-1Q2o7nynlT38JssNT7Cfw.png" /><figcaption>Adaptive Loss Function of LPO consisting to losses, Loss Mask ans Loss Clip</figcaption></figure><p>Its aim is to focus on useful information in the batch and <strong>normalize the loss for stable training</strong>, which hopefully brings <strong>performance improvement and token efficiency</strong>. To do so, the adaptive loss mechanism, as in the formula, consists of two terms:</p><ul><li><strong>Loss Mask (Group Exclusion):</strong> It is the first term; it actually does not aim to reduce the percentage of such groups, but to avoid including them in the loss computation. This means excluding invalid samples in the mean operation of sample losses.</li><li><strong>Loss Clip (Entropy Collapse Elimination):</strong> to penalize the overconfidence aforementioned, this loss aims at clipping negative batch loss to zero, which appeared to be an effective way to improve performance. Another work (Zhu et al., 2025) has a similar conclusion (training with only negative samples can be highly effective).</li></ul><p>Performance-wise, the experiment results of evaluation on the aforementioned situations showed that the adaptive loss in AGPO in some situations implicitly improves token efficiency compared with GRPO baselines, achieving better performance, in some cases, that is almost akin to GRPO.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*5EFlbbKixkqwYxtWcRH7Zw.png" /><figcaption>Actor entropy curves of GRPO and AGPO for Qwen-2.5–7B (left) and Qwen-2.5–14B (right)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lWby9S9dqxIpk-EFBhR36w.png" /><figcaption>Response length curves of GRPO and AGPO for Qwen2.5–14B (lesft) and Qwen2.5–7B (right)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fG-skv0nsHDcJh0eiAH-yQ.png" /><figcaption>Reward score curves of GRPO and AGPO for Qwen2.5–7B (left) and Qwen2.5–14B (right)</figcaption></figure><h4>1–2–8) Group Sequence Policy Optimization (GSPO)</h4><p>GSPO is another reinforcement learning algorithm introduced by Qwen for training LLMs. It is likewise working on RL infrastructure modification. In the Qwen reference paper (Group Sequence Policy Optimization, Zheng et al), this work identifies some other stability issues when training gigantic language models, often resulting in model collapse, in particular, the stability challenges in the RL training of large Mixture-of-Experts (MoE) models (sparsity in Mixture-of-Experts models). Such instability of GRPO-trained models appeared to stem from the fundamental way that the importance sampling weights procedure works in the GRPO algorithmic design.</p><p>One main reason thought contributed to such an issue comes from a motivational factor! Strictly speaking, 1-that the growth in model size, sparsity (e.g., in- Mixture-of-Experts models), and response length required a large rollout batch size to maximize hardware utilization during RL, and also 2-that to improve sample efficiency, a standard practice is to partition a large batch of rollout data into multiple mini-batches for gradient updates, inevitably causes an off-policy learning setting, where responses y are sampled from an old policy <strong><em>πθ</em>old</strong> rather than the current policy <strong><em>πθ</em></strong> being optimized. This also explains the necessity of the clipping mechanism in PPO and GRPO, which prevents overly “off-policy” samples from being involved in gradient estimation (Zheng et al). similar to AGPO (HPC-AI Tech, Chen Li et al), due to entropy collapse during training, this paper likewise identifies such issue in clipping mechanism (which is responsible for managing this off-policy discrepancy). And by the same evidence, this problem becomes particularly acute when training large models on long-response tasks, which leads the model to collapse. Infrastructure-wise, in GRPO, during training gradients, importance sampling weights by importance ratio (probability ratio term as <strong>ri,t(θ)</strong> or <strong>wi,t(θ)</strong>), are accumulating high-variance noise, which, in the case of long sequences, might more likely be amplified. In that case, the model is observed in evaluations to be collapsed. Therefore, in the token-level importance mechanism (by term <strong>wi,t(θ)</strong>), since the reward is granted to the entire sequence (which is as such due to a basis that says “the unit of optimization objective should match the unit of reward”), applying off-policy correction at the token level appears problematic. In consequence, these core limitations introduce high-variance training noise that progressively accumulates with increased response length and is further amplified by the clipping mechanism, ultimately leading the model to collapse. So, the goal of resolving this is to successfully scale RL with greater computational investment; the foremost prerequisite is maintaining stable and robust training dynamics. Previous algorithms adopt an importance ratio based on token-level, while GSPO, to address these limitations, focuses on revising the importance ratio. This means GSPO defines the importance ratio based on sequence likelihood, by which it aims to perform sequence-level clipping, sequence-level rewarding, and sequence-level optimization. Strictly words, it does so via a theoretically grounded definition based on sequence likelihood (Zheng et al., 2023), at the same time, aligning with the basic principle of importance sampling. Moreover, if still taking the advantages of multiple responses to a query into account, GSPO also computes the normalized rewards in order for its sequence-level rewarding to still maintain optimization. All things considered, the GSPO algorithm makes modifications in the rt(θ) term in the GRPO loss function, by replacing the token-level importance ratio with sequence-level importance weight as <strong>si(<em>θ</em>)</strong> term based on sequence likelihood (Zheng et al., 2023), and adopting the group-based advantage estimation as Ai term, and finally proposes its loss function as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*k7Pjw61BUFNoEnBQVsK2Yw.png" /><figcaption>GSPO (Group Sequence Policy Optimization) loss function</figcaption></figure><p>In fact, sequence-level importance ratio reflects how far the response y sampled from <strong><em>πθ</em>old</strong> (·|x) deviates from <strong><em>πθ</em></strong>(·|x), which naturally aligns with the sequence-level reward and can also serve as a meaningful indicator of the clipping mechanism. by doing so Therefore, clipping is applied to entire responses instead of individual tokens to exclude the overly “off-policy” samples from gradient estimation, in which case matches both the sequence-level rewarding and optimization (Zheng et al).</p><h4>Evaluation results:</h4><p>Performance-wise, the empirical evaluation in the reference paper (as shown below) demonstrates that GSPO can achieve significant improvement in training stability, efficiency, and performance compared to the GRPO algorithm, notably stabilizes Mixture-of-Experts (MoE) RL training, and has the potential for simplifying the design of RL infrastructure. These merits of GSPO have contributed to the remarkable improvements in the latest Qwen3 models. As an aside, these merits of GSPO ultimately contributed to the significant performance improvements in the latest Qwen3 models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*1aAiyxzT9coZRB-5EnWN_Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*EgYzA-MYR6AYSYpTL1TvDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*qFygUB_s3PvXDhRBk4vtGw.png" /></figure><p><strong><em>Takeaway from optimizations through all three GRPO, Aha Moment, Dr. GRPO, AGPO, and GSPO:</em></strong></p><blockquote><strong><em>As already explained, GRPO is very similar to PPO in terms of Reinforcement and Gradient Ascent Algorithm, and on the other spectrum, likewise, Dr. GRPO, AGPO, and GSPO all employ modifications to revise the loss function and policy. But a key note taken away from this is that while small algorithmic details and research ideas are crucial to understand to push the limits of current problems, decisions around infrastructure and batching, as well as test-time and behavioral patterns, sometimes matter as much for undertaking deeper and longer reasoning processes, and can potentially make a difference when trade-offing for efficiency.</em></strong></blockquote><h3>Further Improvements:</h3><p>There are more optimization algorithms for Iterative Reasoning, particularly aiming at further scaling accuracy, enhancing self-planning and self-evaluation for empowering agents with meta-judgment, pre-thinking, and self-planning capabilities, as well as for handling unconstrained evaluation tasks. We are going to explore them in my next articles ahead, continuing the progress of this subject “Introspection &amp; Self-Improvement Algorithms: LM’s Self-learning to Self-Reason”.</p><h3>References &amp; Credits:</h3><p><a href="https://rdi.berkeley.edu/">The Berkeley Center for Responsible, Decentralized Intelligence (RDI)</a></p><p><a href="https://arxiv.org/abs/2401.10020">Self-Rewarding Language Models</a></p><p><a href="https://arxiv.org/html/2506.10943v1">Self-Adapting Language Models</a></p><p><a href="https://rdi.berkeley.edu/adv-llm-agents/sp25">Berkeley RDI, Advanced LLM Agents</a></p><p><a href="https://arxiv.org/abs/2404.19733">Iterative Reasoning Preference Optimization</a></p><p><a href="https://deepmind.google/research/">Google DeepMind Researc</a>h</p><p><a href="https://ai.meta.com/research/">Meta FAIR</a></p><p><a href="https://hai.stanford.edu/research">Stanford HAI, human centered artificial intelligence</a></p><p><a href="https://nlp.stanford.edu/">The Stanford natural language processing group</a></p><p><a href="https://arxiv.org/html/2503.15952v3">Adaptive Group Policy Optimization: Towards Stable Training and Token-Efficient Reasoning</a></p><p><a href="https://arxiv.org/abs/2503.20783">Dr. GRPO, Understanding R1-Zero-Like Training: A Critical Perspective</a></p><p><a href="https://arxiv.org/html/2503.20783v2">Understanding R1-Zero-Like Training: A Critical Perspective</a></p><p><a href="https://arxiv.org/abs/2507.18071">Group Sequence Policy Optimization</a></p><p><a href="https://arxiv.org/pdf/2503.19470">ReSearch: Learning to Reason with Search for LLMs via Reinforcement Learning</a></p><p><a href="https://arxiv.org/html/2509.17765v1">Qwen3-Omni Technical Report</a></p><p><a href="https://arxiv.org/abs/2510.22115">Every Activation Boosted: Scaling General Reasoner to 1 Trillion Open Language Foundation</a></p><p><a href="https://arxiv.org/pdf/2506.05176">Qwen3 Embedding: Advancing Text Embedding and Reranking Through Foundation Models</a></p><p><a href="https://arxiv.org/abs/2506.13585">MiniMax-M1: Scaling Test-Time Compute Efficiently with Lightning Attention</a></p><p><a href="https://huggingface.co/papers/2505.09388">Qwen3 Technical Report</a></p><p><a href="https://arxiv.org/abs/2501.12948">DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning</a></p><p><a href="https://arxiv.org/abs/2402.03300">DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models</a></p><p><a href="https://openai.com/index/learning-to-reason-with-llms/">OpenAI, Learning to reason with LLMs</a></p><p><a href="https://qwenlm.github.io/blog/qwq-32b/">Team Qwen: Embracing the Power of Reinforcement Learning</a></p><p><a href="https://arxiv.org/abs/2506.04374">A Statistical Physics of Language Model Reasoning</a></p><p><a href="https://github.com/tatsu-lab/alpaca_eval">AlpacaEval: An Automatic Evaluator of Instruction-following Models</a></p><p><a href="https://tatsu-lab.github.io/alpaca_eval/">AlpacaEval-github: An Automatic Evaluator of Instruction-following Models</a></p><p><a href="https://arxiv.org/abs/2411.19146">Puzzle: Distillation-Based NAS for Inference-Optimized LLMs</a></p><p><a href="https://arxiv.org/abs/2103.03874">Measuring Mathematical Problem Solving With the MATH Dataset</a></p><p><a href="https://arxiv.org/abs/2110.14168">Training Verifiers to Solve Math Word Problems</a></p><p><a href="https://arxiv.org/html/2508.13743v1">Sycophancy under Pressure: Evaluating and Mitigating Sycophantic Bias via Adversarial Dialogues in Scientific QA</a></p><p><a href="https://arxiv.org/html/2404.04475v1">Length-Controlled AlpacaEval: A Simple Way to Debias Automatic Evaluators</a></p><p><a href="https://www.allenai.org/">Allen Institute Ai2</a></p><p><a href="https://arxiv.org/abs/1506.02438">High-Dimensional Continuous Control Using Generalized Advantage Estimation</a></p><p><a href="https://arxiv.org/abs/1707.06347">Proximal Policy Optimization Algorithms</a></p><p><a href="https://arxiv.org/abs/2305.18290">Direct Preference Optimization: Your Language Model is Secretly a Reward Model</a></p><p><a href="https://arxiv.org/abs/2405.14734">SimPO: Simple Preference Optimization with a Reference-Free Reward</a></p><p><a href="https://arxiv.org/abs/2304.05128">Teaching Large Language Models to Self-Debug</a></p><p><a href="https://arxiv.org/abs/2309.11495">Chain-of-Verification Reduces Hallucination in Large Language Models</a></p><p><a href="https://arxiv.org/abs/2305.20050">Let’s Verify Step by Step</a></p><p><a href="https://arxiv.org/pdf/2504.1296">THINKPRUNE: Pruning Long Chain-of-Thought of LLMs via Reinforcement Learning</a></p><p><a href="https://arxiv.org/abs/2306.05685">Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena</a></p><p><a href="https://arxiv.org/abs/2206.07682">Emergent Abilities of Large Language Models</a></p><p><a href="https://arxiv.org/abs/2310.13548">Towards Understanding Sycophancy in Language Models</a></p><p><a href="https://arxiv.org/abs/2508.02087">When Truth Is Overridden: Uncovering the Internal Origins of Sycophancy in Large Language Models</a></p><p><a href="https://arxiv.org/abs/2509.16533">Challenging the Evaluator: LLM Sycophancy Under User Rebuttal</a></p><p><a href="https://arxiv.org/html/2508.13743v1">Sycophancy under Pressure: Evaluating and Mitigating Sycophantic Bias via Adversarial Dialogues in Scientific QA</a></p><p><a href="https://arxiv.org/abs/2308.03958">Simple synthetic data reduces sycophancy in large language models</a></p><p><a href="https://huggingface.co/blog/Rakshit122/sycophantic-ai">Detecting and Evaluating Sycophancy Bias: An Analysis of LLM and AI Solutions</a></p><p><a href="https://arxiv.org/abs/2402.03620">Self-Discover: Large Language Models Self-Compose Reasoning Structures</a></p><p><a href="https://arxiv.org/abs/2309.03409">Large Language Models as Optimizers</a></p><p><a href="https://arxiv.org/abs/2310.01798">Large Language Models Cannot Self-Correct Reasoning Yet</a></p><p><a href="https://arxiv.org/abs/1706.03741">Deep reinforcement learning from human preferences</a></p><p><a href="https://arxiv.org/abs/1706.03762">Attention Is All You Need</a></p><p><a href="https://arxiv.org/abs/2206.07682">Emergent Abilities of Large Language Models</a></p><p><a href="https://arxiv.org/abs/2204.05862">Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedback</a></p><p><a href="https://arxiv.org/abs/2203.02155">Training language models to follow instructions with human feedback</a></p><p><a href="https://www.nature.com/articles/nature14236">Human-level control through deep reinforcement learning</a></p><p><a href="https://arxiv.org/abs/1708.02709">Recent Trends in Deep Learning Based Natural Language Processing</a></p><p><a href="https://arxiv.org/abs/1810.04805">BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding</a></p><p><a href="https://arxiv.org/abs/1506.02438">High-Dimensional Continuous Control Using Generalized Advantage Estimation</a></p><p><a href="https://arxiv.org/abs/1409.0473">Neural Machine Translation by Jointly Learning to Align and Translate</a></p><p><a href="https://arxiv.org/abs/1802.04630">A probabilistic framework for multi-view feature learning with many-to-many associations via neural networks</a></p><p><a href="https://arxiv.org/abs/1802.04712">Attention-based Deep Multiple Instance Learning</a></p><p><a href="https://arxiv.org/abs/1802.06455">Bayesian Uncertainty Estimation for Batch Normalized Deep Networks</a></p><p><a href="https://arxiv.org/abs/1711.11157">A Semantic Loss Function for Deep Learning with Symbolic Knowledge</a></p><p><a href="https://proceedings.mlr.press/v80/balestriero18b/balestriero18b.pdf">A Spline Theory of Deep Networks</a></p><p><a href="https://arxiv.org/abs/1807.00263">Accurate Uncertainties for Deep Learning Using Calibrated Regression</a></p><p><a href="https://arxiv.org/abs/1803.01299">An Optimal Control Approach to Deep Learning and Applications to Discrete-Weight Neural Networks</a></p><p><a href="https://arxiv.org/abs/1803.00047">Analyzing Uncertainty in Neural Machine Translation</a></p><p><a href="https://arxiv.org/abs/1807.01613">Conditional Neural Processes</a></p><p><a href="https://proceedings.mlr.press/v80/mirman18b/mirman18b.pdf">Differentiable Abstract Interpretation for Provably Robust Neural Networks</a></p><p><a href="https://arxiv.org/abs/1804.02464">Differentiable plasticity: training plastic neural networks with backpropagation</a></p><p><a href="https://arxiv.org/abs/1805.10636">Contextual Graph Markov Model: A Deep and Generative Approach to Graph Processing</a></p><p><a href="https://proceedings.mlr.press/v80/adel18a.html">Discovering Interpretable Representations for Both Deep Generative and Discriminative Models</a></p><p><a href="https://arxiv.org/abs/2005.08110">Generalized Bayesian Posterior Expectation Distillation for Deep Neural Networks</a></p><p><a href="https://arxiv.org/abs/1709.07432">Dynamic Evaluation of Neural Sequence Models</a></p><p><a href="https://arxiv.org/abs/1805.04770">Born Again Neural Networks</a></p><p><a href="https://arxiv.org/abs/1806.11416">Bounds on the Approximation Power of Feedforward Neural Networks</a></p><p><a href="https://arxiv.org/abs/1803.06969">Comparing Dynamics: Deep Neural Networks versus Glassy Systems</a></p><p><a href="https://arxiv.org/abs/1802.10399">Compressing Neural Networks using the Variational Information Bottleneck</a></p><p><a href="https://arxiv.org/abs/1708.00260">Deep Asymmetric Multi-task Feature Learning</a></p><p><a href="https://arxiv.org/abs/1611.02344">A Convolutional Encoder Model for Neural Machine Translation</a></p><p><a href="https://www.nature.com/articles/nature14236">Human-level control through deep reinforcement learning</a></p><p><a href="https://arxiv.org/abs/1502.05698">Towards AI-Complete Question Answering: A Set of Prerequisite Toy Tasks</a></p><p><a href="https://arxiv.org/abs/1503.08895">End-To-End Memory Networks</a></p><p><a href="https://arxiv.org/abs/1409.3215">Sequence to Sequence Learning with Neural Networks</a></p><p><a href="https://arxiv.org/abs/1410.5401">Neural Turing Machines</a></p><p><a href="https://aclanthology.org/D13-1170.pdf">Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank</a></p><p><a href="https://arxiv.org/abs/1301.3781">Efficient Estimation of Word Representations in Vector Space</a></p><p><a href="https://proceedings.neurips.cc/paper_files/paper/2012/file/c399862d3b9d6b76c8436e924a68c45b-Paper.pdf">ImageNet Classification with Deep Convolutional Neural Networks</a></p><p><a href="https://arxiv.org/abs/1103.0398">Natural Language Processing (almost) from Scratch</a></p><p><a href="https://ronan.collobert.com/pub/2008_deep_icml.pdf">Deep Learning via Semi-Supervised Embedding</a></p><p><a href="https://www.cs.toronto.edu/~ranzato/publications/ranzato-icml08.pdf">Semi-supervised Learning of Compact Document Representations with Deep Networks</a></p><p><a href="https://icml.cc/Conferences/2008/papers/573.pdf">On the Quantitative Analysis of Deep Belief Networks</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=075fcee90466" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/introspection-self-improvement-algorithms-lms-self-learning-to-self-reason-part-3-075fcee90466">Self-Improving LM&#39;s Self-learning to Self-Reason — Part 3</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part2 - Introspection & Self-Improvement Algorithms: LM's Self-learning to Self-Reason]]></title>
            <link>https://levelup.gitconnected.com/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301?source=rss-6acfbf0d8c9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ae3a7250301</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[math]]></category>
            <dc:creator><![CDATA[Hamid Nafiyan]]></dc:creator>
            <pubDate>Wed, 19 Nov 2025 16:18:58 GMT</pubDate>
            <atom:updated>2025-12-09T13:14:18.265Z</atom:updated>
            <content:encoded><![CDATA[<h3>Part 2— Introspection &amp; Self-Improvement Algorithms: Language Reasoning Agents Self-learning to Self-Reason</h3><h4>Self-Rewarding for Preference Tuning via RLAIF</h4><h4>Introduction</h4><p>In the space of estimations, using language for reasoning and communication doesn’t have to come from an LLM; that may turn out to be a means to an end. Maybe in a few years, we will move beyond LLMs, but the need for universal language understanding and production in agents will remain. Next to that, the current and anticipated state of LLMs’ reasoning requirements provides broader yet deeper insights into how to describe the ways it can be interacted with as well as the ways it can be interacted with. Given that that’s true, taking LLM’s capabilities for reasoning and planning into account, which itself stems from its own intermediate steps, which are somehow rooted in its implicit reasoning capabilities, sheds light on the broader responsibility of a language agent concerning self-learning various capabilities as a proven-essential Introspection skill, which has been a while focused profoundly on as a long-horizon paradigm. To enable such a great added value as an intrinsic skill into an LLM, I am going to delve deep into SoTA methods for approaching the long-horizon <strong><em>Self-Learning paradigms</em></strong>. So, as an aside again, how to apply such techniques and their where and the when is a useful best practice to shape such an aforementioned skill as an Introspection paradigm.</p><blockquote><em>Part 2:</em></blockquote><ul><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301#:~:text=an%20Introspection%20paradigm.-,Debates,-There%20have%20still">Debates</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301#:~:text=Learning%20to%20Self%2DImprove%20(Self%2DTraining%20for%20Self%2DReasoning)">Learning to Self-Improve (Self-Training for Self-Reasoning)</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301#:~:text=Reward%20Modelling%20Phase%3A">Reward Modelling Phase</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301#:~:text=RL%20Fine%2DTuning%20Phase%3A">RL Fine-Tuning Phase</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301#:~:text=given%20a%20state.-,Loss%20Aggregation%3A,-In%20terms%20of">Loss Aggregation</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301#:~:text=Preference%20Tuning%20Optimizations%3A%20Optimization%20Algorithms%20for%20Self%2DRewarding%20via%20RLAIF">Preference Tuning Optimizations: Optimization Algorithms for Self-Rewarding via RLAIF</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301#:~:text=1%E2%80%932%E2%80%931)%20Proximal%20Policy%20Optimization%20(PPO)">1–2–1) Proximal Policy Optimization (PPO)</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301#:~:text=1%E2%80%932%E2%80%932)%20Direct%20Preference%20Optimization%20(DPO)">1–2–2) Direct Preference Optimization (DPO</a>)</li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301#:~:text=Comparison%3A%20DPO%20vs.%20PPO%20for%20Selection%3A">Comparison: DPO vs. PPO for Selection</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301#:~:text=Self%2DRewarding%20Optimizations%20through%20Iterative%20Reasoning%20Preference%20Optimization%20(Iterative%20RPO)">Self-Rewarding Optimizations through Iterative Reasoning Preference Optimization (Iterative RPO)</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301#:~:text=1%E2%80%932%E2%80%933)%20Iterative%20PRO%20through%20Verifiable%20rewards%20using%20DPO%20with%20Negative%20Log%20Likelihood">1–2–3) Iterative PRO through Verifiable rewards using DPO with Negative Log Likelihood</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301#:~:text=1%E2%80%932%E2%80%934)%20Iterative%20RPO%20via%20Reinforcement%20learning%20with%20verifiable%20rewards%20(RLVR)">1–2–4) Iterative RPO via Reinforcement learning with verifiable rewards (RLVR)</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301#:~:text=References%20%26%20Credits%3A">References &amp; Credits</a></li></ul><h4>Debates</h4><p>There have still been controversial debates here and there in academic research, research institutes, big tech labs, industry, and engineering communities on common recent limitations of LLMs leading to performance drop or failure, the most important of which include:</p><ul><li><strong>Distraction</strong> (due to irrelevant problems) and distracting rules</li><li><strong>Risk of memorization or overfitting</strong></li><li><strong>Hallucination gives rise to inconsistency, absence of causality, and a lack of ground truth in the response</strong></li><li><strong>NIAH</strong> (reasoning in long contexts)</li><li>Lack of <strong>persistent</strong> memory</li><li>Long-term <strong>memory</strong></li><li><strong>Compositionality</strong> limits via distillation</li><li>Premise <strong>order</strong> of sentences (inability to go back and forth)</li><li><strong>Unability</strong> to reason</li><li><strong>Early stop</strong> reasoning</li><li><strong>Large input</strong> context problems</li><li><strong>Self-correction</strong></li><li>Search <strong>space</strong> <strong>scaling</strong> up</li><li>Effective <strong>test-time scaling</strong></li><li><strong>Local knowledge</strong> distillation</li><li><strong>Spatial</strong> reasoning</li><li><strong>Exponential Error</strong> Compounding in long-horizon tasks (sequential decision-making)</li><li><strong>Oracle</strong> feedbacks</li><li><strong>Gradient Ascent </strong>&amp; <strong>Likelihood</strong></li><li>Varied-level <strong>mathematical</strong> problem-solving (grade-school to IMO),</li><li><strong>Hierarchical &amp; Dynamical Planning </strong>in efficient <strong>state</strong> <strong>exploration</strong> and <strong>action space exploitation</strong></li><li>Imitated-reasoning of fundamental human <strong>cognitive functions</strong></li></ul><p>Taking the aforementioned ongoing issues above into account, and now that we have reviewed the essential concepts and basis, I am now going to get into the behind-the-scenes of LLMs’ reasoning via exploring fundamental reasoning techniques. This article also explores the potential solutions and improvements going on, the issues<strong> </strong>to come up with optimization and trade-off methods. Dealing with long-horizon reasoning and planning techniques, I started off in my previous articles with Inference-time techniques besides reasoning strategies, and then we made them excuses to discuss on the road to search and planning techniques. Now I am going to point out the SoTA post-training algorithms and methodologies, and by leveraging them, we delve deep into the <strong>Advanced Self-improvement Algorithms, Techniques &amp; Approaches</strong>, aiming at enabling language agents with <strong>self-learning, self-observation, self-reflection, self-searching, self-planning, and self-evaluation capabilities</strong>.</p><blockquote><em>Please refer to the references &amp; credits of the material covered in this article as well. Also note that all photos are either compiled or screenshots taken from papers to which referred in this article.</em></blockquote><p><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8">In Part 1, my previous article, we at first investigated the Iterative Reasoning through Instruction Following and Self-Rewarding, then we dealt with Iterative Evaluation with Self-Rewarding Model (AI-in-the-loop), and finally got into Instruction Following Training (or Preference Tuning)</a>. I will now get into the <strong>Advanced Self-improvement Algorithms</strong>, techniques &amp; approaches, aiming at enabling language agents with self-learning, Self-observation, self-reflection, self-searching, self-planning, and self-evaluation capabilities.</p><h3>Learning to Self-Improve (Self-Training for Self-Reasoning)</h3><p>There are optimization algorithms for RLAIF, particularly aiming at preference tuning optimization; we are going to explore them from here on. But before we get into them, let’s get an overview of them helpful background when dealing with the optimizations.</p><h4>Reward Modelling Phase:</h4><p>There are a number of approaches used to model preferences in RL, two of which are the Bradley-Terry (BT) and Plackett-Luce. Plackett-Luce ranking models are compatible with the framework if we have access to several ranked answers. Although Plackett-Luce is more general, BT models have become a more popular choice. Based on The BT model the human preference distribution can be demonstrated as below (Eq. 1) which is considered for SFT through human feedback in RL (Rafael Rafailov et al). Parametrizing a reward model <strong><em>rϕ(x, y)</em></strong> and estimating the parameters via maximum likelihood, and then framing the problem as a binary classification (Sutton &amp; Barto, 2018), we have the negative log-likelihood loss (DPO, Rafael et al) as the first objective (Eq. 2, 3, 4):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*2aufdVRzw4To2vOKfusnDg.png" /><figcaption>Loss Funciton in Supervise Fine Tuning through preferences</figcaption></figure><h4>RL Fine-Tuning Phase:</h4><p>During the RL Fine-Tuning phase, the learned reward function is used to provide feedback to the language model, thereby. The objective of Supervised Fine-tuning is maximizing the above loss function as below (Eq. 5). And maximizing the loss function is through Gradient Ascent, which is also used for LLM post-training. In fact, the Policy gradient method directly models and optimizes the policy (for any differentiable policy) [Sutton &amp; Barto, 2018]. The gradient of <strong><em>J</em></strong>𝑆𝐹𝑇(𝜃) is as follows (Eq. 6 or Eq. 7):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*nsBNpMYplFgAqpNIIxKXOw.png" /><figcaption>Policy Gradient in Supervise Fine Tuning through RL Fine Tuning</figcaption></figure><p>Where advantage <strong><em>At</em></strong> is the Advantage factor, which defines how much better a specific action is, compared to the average action given a state.</p><h4>Loss Aggregation:</h4><p>In terms of loss aggregation in Reinforcement Learning, there are two approaches for problems: one is the Markov Decision Process (MDP) and the other is the Bandit approach. The RL problems are often typically formulated based on either. In a language model, a token-level action (or say next token generation) is formulated as an MDP. In contrast, sequence-level action is treated as the Bandit approach (Sutton &amp; Barto, 2018). The main differences of MDP vs Bandit actually rely on implementation detail over how the loss is aggregated per-sample, determining which formulations to choose (<a href="https://rlhfbook.com/">https://rlhfbook.com/</a>):</p><ul><li>In an MDP approach, each token in the response is a separate action with state (the running prefix), in which case enables token-level credit assignment. Therefore, MDP for estimating Generalized Advantage, computes it as Generalized Advantage Estimation (GAE), that as such, for regularization, often subtracts KL (add a per-token KL penalty) inside the reward. PPO algorithm (explaining in a bit later) uses MDP formulation in the RL problems.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNQRjn6wmnkW-TpYQwNgbQ.png" /><figcaption>MDP approach, enabling token level credit assignment for loss function, regularizing reward with KL penalty</figcaption></figure><ul><li>A Bandit approach takes a mean that assigns the same loss to every token, meaning all the tokens in response(completion) are treated as one action, or i.e., treating the whole completion as a single action with one scalar reward(R) in code. And therefore, these tokens will be given the same loss. Therefore, for estimating Advantage here, Bandit computes it as a Sequence-Level Advantage, and multiplying it by the sum of per-token log-probs (length-normalized), thereby broadcasting the same learning signal to every token, thereby, as such, for regularization, unlike MDPs, instead of adding a KL penalty in the reward, Bandit adds the separate per-token KL divergence (between the trained policy and the reference policy) to the loss function. DPO and GRPO, other direct alignment algorithms, as well as GRPO and GSPO algorithms in their implementations, use this formulation in the RL problems.</li></ul><h3>Preference Tuning Optimizations: Optimization Algorithms for Self-Rewarding via RLAIF</h3><h4>1–2–1) Proximal Policy Optimization (PPO)</h4><p>One of the goals of using the RLAIF structure has been that we want policies to become as close as possible to preferences. This means gaining the RLHF objective. The core idea is getting the maximum likelihood of reward through similarity, meaning how close the preference data is to that policy. Proximal Policy Optimization (PPO) was introduced by OpenAI in 2017. PPO is one of the <strong>policy-gradient algorithms</strong>, an RL algorithm used to teach models and agents how to make good decisions by interacting with an environment. Its general goal is to optimize the model and align its outputs with desired behaviors (or say policy), thereby it uses a clipped surrogate objective for policy optimization (Schulman et al., 2017). Later, PPO became classic and widely used in robotics, autonomous systems, and training agents to play games like Atari and more. PPO uses a loss function to estimate how good each action was by (actual reward — expected reward). Generalized Advantage Estimation (GAE) helps smooth this by combining short and long-term reward signals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jSYoYvx50uyYmCKU3yUrnQ.png" /><figcaption>Proximal policy optimization algorithm to train the policy model</figcaption></figure><blockquote>π: LLM policy</blockquote><blockquote>π<strong>θ</strong>: base LLM</blockquote><blockquote>x: prompt</blockquote><blockquote>y: completion</blockquote><p>PPO compares the new policy to the old one using a probability ratio. To ensure it clips this ratio to stay within a trusted range (typically 0.8 to 1.2), avoiding large and risky updates. (<strong>Clipping is PPO’s main feature, aiming to manage the off-policy discrepancy to keep the updates stable and under control</strong>!) If the change is too large, PPO ignores the extra gain, and if the change can hurt performance, PPO keeps the penalty. It may also monitor KL divergence to ensure the new policy doesn’t drift too far from the old one. Joint Optimization is also a mechanism by which PPO updates three objectives together:1-Policy improvement via the clipped objective, 2-Value function as advantage function (GAE, Schulman et al., 2015), (GAE) for better reward prediction, 3-Entropy bonus to maintain exploration. Then, PPO iteratively trains the model Over Epochs, splitting the data into mini-batches and improving the policy and value networks using gradient ascent. Through a proximal policy optimization mechanism as the training algorithm for the policy model, we try to optimize reward inspired by human preferences. In fact, PPO algorithm constrains the policy model to stay close to the base LM (preferences are hard to model), in the sense that the policy model (PPO algorithm) when receiving each reward, first compare it to its learnt internal policies, then if the reward is close to a learnt policy in terms of proximal or say similarity, then the policy model also learns such reward to trigger next actions (next tokens).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*td__0JzkyVbXkBcthnmMdA.png" /><figcaption>PPO algorithm aims to optimize reward with RLHF objective as well as constrain the model to stay close to the base LM</figcaption></figure><p>That is, the policy model is likewise trying to stay close to its base model, besides learning from rewards to improve its performance of understanding the state of the world (the task problems to solve). Following is the updated version of RLAIF by enabling the policy model as the PPO model (refer to [Shulman et al., 2017]).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*ZTzdUrE2JeQprBILW6hurw.png" /><figcaption>RLAIF based on PPO as policy model, [Shulman et al., 2017]</figcaption></figure><h4>1–2–2) Direct Preference Optimization (DPO)</h4><p>What if we just use gradient ascent on this equation? The answer, with some math, is Direct Preference Optimization (DPO to fine-tune an implicit reward model as a ranking model based on using <strong>gradient ascent</strong>. To study the reference paper about DPO, you can refer to “Direct Preference Optimization: Your Language Model is Secretly a Reward Model”[Rafailov, Sharma, Mitchell et al. 2023].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*syx8SzSGYJ9OPrPMwEjPLw.png" /><figcaption>Direct Preference Optimization (DPO) Algorithm</figcaption></figure><p>But from the perspective of the RLAIF structure, the core idea here is having one model both for learning policies and preferences, meaning a base model trained to be both a policy model and a reward judge model. The goal is still the same as RLAIF, maximizing reward; we want to get the maximum reward possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*qvufQtOELvBcCSqi20OQRQ.png" /><figcaption>DPO training, only one base model to be fine-tuned for policy &amp; preference trainig</figcaption></figure><p>It actually predicts a reward for each response, meaning it learn samples from <strong>EFT selection</strong> <strong><em>{ XI, ywin , yloss , rwin , rloss }</em></strong>, such that for each sample it can predict some <strong>optimized responses</strong> which are both <strong>more relevant to the task context</strong> and also have <strong>better reasoning</strong>. The output up to here is <strong><em>{ XI , y’ }. </em></strong>It does so based on the optimal policy which best meets the relation of (response pairs, preference pairs). Therefore, it goes directly from preference data to the final policy so that it trains and fits a new reward model. Its optimization is based on gradient ascent for <strong>maximum likelihood of reward through similarity</strong>, meaning how close the preference data is to that policy. However, this optimal policy mechanism of DPO can be performed as <strong>LLM-as-a-Judge</strong> (or Branch-Solve-Merge).</p><p>DPO is not an explicit reward model, and does not do preference learning in the RLHF. The idea here is that using an implicit reward model by removing the need for explicit external rewarding, making sure that we are still aligned with the preferences given; however, don’t go too far from our originally trained base model. This is actually a trade-off between the closed-form and fine-tuned form of the base model. In fact, in order for an LLM to be fine-tuned based on rewards (external observations), RL is not just a given. We don’t have to leverage only RL for reward function gains. DPO, as a non-parametric optimization method, is for achieving reward-based functionalities in policy optimization when fine-tuning an implicit reward model. DPO replaces traditional reinforcement learning (reward model) with a closed-form classification objective that implicitly models human preferences, directly optimizing the policy without requiring an explicit reward function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/227/1*3U1zK5LMQOm4cOtLNxFRBw.png" /><figcaption>Optimize a policy against the reward model using reinforcement learning</figcaption></figure><p>In the iterative process for self-training that we have considered so far, likewise, with the output we have from the selection of winning &amp; losing responses based on ranking score <strong><em>{ XI , ywin , yloss , rwin , rloss }</em></strong>, then we can conduct a <strong>DPO </strong>training<strong> </strong>algorithm training on those pairs to get the reward model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*3k6Pu2WoIqIrlVBnjGNszw.png" /><figcaption>DPO Training to conduct Instruction Following Training at the end of the Loop to Seed the next iterations</figcaption></figure><p>If in all stages, instead of having two or three base models to work with, we want to work with only one pre-trained model for <strong>DPO training</strong> or <strong>LM-as-a-judge</strong>, such a model can then iteratively be used as a DPO model for <strong>both reward &amp; policy learning &amp; improving</strong>. E.g., Llama-405B, LLama-70B or GPT-4o are used as the base model to learn DPO in the experiments to which are referred to in the references section. Also, “Tulu SFT” is the Allan Institute’s Post-trained LLM, which can be used directly as a DPO model.</p><p>Note that there are other optimizations for preference tuning via self-rewarding in RLAIF. For example, <strong>Length-normalized DPO</strong> that normalizes the same log-likelihoods of preferred and rejected responses by their lengths. And <strong>SimPO</strong> (Meng et al., 2024) makes the RLAIF even more simplified, such that it does not use a reference model.</p><h4>Comparison: DPO vs. PPO for Selection:</h4><p>But for comparison between PPO and DPO, PPO appears to be better than DPO in performance in almost all cases. But DPO is actually much cheaper, making it more practical for development. i.e., although PPO consistently outperforms DPO, there are costs on the other hand for PPO, including:</p><ul><li>Implementation complexity: PPO is much more complicated to implement than DPO.</li><li>Memory usage, and Throughput: PPO particularly needs a larger model, because we need to have 2 models (reward model &amp; policy model)</li></ul><p>PPO enhances performance by first training an explicit reward model using preference data and then employing RL to iteratively optimize the policy. This process results in consistently superior outcomes compared to DPO, which directly optimizes the policy on the preference dataset without a reward model. However, these gains come at the expense of increased implementation complexity, higher memory usage, and reduced throughput.</p><p>All things considered, selecting which algorithm really depends on the developer’s constraints. In some cases, by replacing DPO with PPO, with the same data, one can normally get ~1% improvement from switching from DPO to PPO! However, using a bigger reward model (scaling reward models) helps yield better downstream models, but it does not necessarily lead us to see much improvement. Even so, by applying preference data and then doing better data selection through data ablation and data curation of preference data, DPO has gradually gained a significant boost (DPO does data ablation, but PPO does not). The other end of this spectrum says that by using mixed prompts, again, we do not see much gain! But, using domain-specific prompts for some capabilities (specific to the task) plays a really important role and yields further performance improvements. For more study on the comparison of DPO and PPO, you can refer to the paper titled “Unpacking DPO and PPO: Disentangling Best Practices for Learning from Preference Feedback”, [Hamish et al].</p><blockquote><em>Above all, it appears that it is more than just changing the algorithm itself for performance tuning. Change in data (selection, curation, and ablation) has been so far proven to have more impact in boosting performance! Therefore, the most important factor is high-quality data. Refer to [Ivison, Wang et al. 2023; Ivison, Wang et al. 2024]</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YTTgyMZYv2B2awxxrIdmMg.png" /><figcaption>DPO vs PPO, change in Data vs changing the algorithm and model</figcaption></figure><p>For example, in an experiment conducted by Ai2 for the Tulu SFT model ([Cui et al., 2023] and [Meng et al., 2024]), with seeding SFT &amp; OOD new prompts, while responses are sampled from different models for each prompt (from off-policy sources to on-policy Tulu STF ones), and by using optimizations from SimPO to length-normalized DPO, the results showed that the aggregated performance often scales with new OOD prompts with DPO on-policy/combined. The base models (as initially STF trained) included GPT-4o, Llama 3.1 405B, GPT-4 Turbo, GPT-4o Mini, and Llama 3.1 70B. The following illustrates some evaluation results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o5WOHep2TrushEi-K5WGiw.png" /><figcaption>An experiment for Tulu 3 Preference tuning, [Cui et al., 2023] and [Meng et al., 2024], photo credit from Ai2</figcaption></figure><p>In the iterative process, in the case of only one model as DPO judgment, our model in each iteration starts from the state <strong><em>Mt</em></strong>, seeding IFT and EFT data, and then, after DPO training (on those selected preference pairs), gets the state <strong><em>Mt+1</em></strong>, seeding optimized preferences. This means that in the first stage, the model’s responses and then response rankings are both given to itself so that it can understand both preferences and policies, yet even so, it does not go far from the original knowledge trained on (IFT data). i.e., even though the base mode is super-finetuned with preferences and policies (via classification), its parameters (model’s weights) are not updated as much, and can stay as close as possible to the base model in order for its IFT knowledge not to be changed as much as possible. Then, in the next iterations, given such newly trained optimal responses along with their prompts, it continues to further training on new pairs (prompts, responses-shot scores) besides newly trained pairs (prompts, optimal responses) up until it achieves an optimal performance to eventually generate hopefully an <strong>optimal CoT with final answer</strong> for each given task prompt. All things considered, in iterative methods, the <strong>next iteration model</strong> is assumed and expected to be the <strong>better model</strong>. Depending on which base LLM is used, the trained model is generally expected to take 2 or 3 iterations to reach its optimal performance (giving <strong><em>M2 and M3</em></strong>), but specifically when training MoE models, they are expected to take more iterations to achieve so (refer to reference papers to get more information on the experiments).</p><p>Performance-wise, in the experiments conducted in the referenced paper titled “LLM improves itself by assigning rewards to own outputs and optimizing” (Jason Weston et al), the performance of such self-rewarding models is evaluated in two criteria: first, the ability to follow instructions, and second, for its ability as a reward model (ability to evaluate responses). The benchmark setting included 256 prompts from diverse sources, using the pre-trained LLAMA-70b, AlpacaEval 2.0, and MT-Bench in the test bed. The evaluation results for the ability to follow instructions showed that the reward model is continuously improved through iterative training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-r3TyDdWllhbj5lFqgHEjw.png" /><figcaption>Evaluation Results of the Self-Reward Model. SFT Baseline here is obtained by training the pre-trained LLAMA-70b</figcaption></figure><p>Moreover, in terms of the type of tasks, based on scores on a scale of 10, in general writing tasks, the model shows better performance compared with tasks like Math, Code &amp; Reasoning during the next iterations, but even so, in both types of tasks, the self-reward model is still continually improved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*rIeGoqxiuiU3_-TNvVPg1A.png" /><figcaption>Evaluation results through iterations in general writing tasks compared to math, code &amp; reasoning tasks</figcaption></figure><p>In addition, from the perspective of diverse skills and comprehensive knowledge, the self-reward model gives gains across several topics, but tends to give less gains in mathematical and reasoning results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*bA0y8-wgfeLoPi8GT0i52g.png" /><figcaption>Evaluation results of self-rewarding model for diverse categories of skills, via AlpacaEval win rate breakdown</figcaption></figure><p>And for example, compared with GPT-4 0314 (a pretrained LLM with extensive RLHF for better accuracy), through two self-rewarding training loops, the self-reward model can almost match the performance of GPT-4 0314</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*33MqPVDpzqPVBZohHz01Ow.png" /><figcaption>Evaluation Results of the Self-Reward Model Through Iterations, compared with GPT-4 0314</figcaption></figure><p>On the other hand, for the second ability, as a reward model (ability to evaluate responses), the self-rewarding model was tested on the OpenAssistant validation set. Here, the self-rewarding models in particular are used to assign a score to each (instruction, response) pair. Compared to human judgements, the model judgements of the self-reward model are continually improved in evaluation capabilities as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*tPkenxgxsEPOXjDF6geVgQ.png" /><figcaption>Evaluation Results of the Self-Reward Model’s judgements compared with human’s on the OpenAssistant validation</figcaption></figure><p>Even so, since SFT assigns similar probability to chosen and rejected generations from DPO pairs, it also fits wrong responses (with the same log probability) as well; therefore, it affects the performance and makes it worse. As can be seen from the evaluation results, although the self-rewarding model can gain some hopeful performance in an iterative training way, it still cannot achieve as much as expected as optimal. So, the question here could be How can we make it improve more on reasoning tasks? To cope with this limitation, we need more optimizations in order to approach our fundamental goal, <strong>self-learning to self-improvement in self-reasoning</strong>. There are a lot of discussions here, one of which can be noted here is the <strong>Reinforcement Learning Through Verifiable Rewards</strong>.</p><h3>Self-Rewarding Optimizations through Iterative Reasoning Preference Optimization (Iterative RPO)</h3><p>With the experiments we have already evaluated, to get a qualitative comparison between the <strong>RLHF</strong> and <strong>Iterative Reasoning</strong>, in terms of ability to follow instructions, the self-reward model is demonstrated to continuously improve through iterative training and fairly match human rankings compared to the SFT baseline. And through two self-rewarding training loops, we can almost match the performance of GPT-4o. On IFT. Comparing the self-rewarding model judgements to human judgements, our self-reward model is continually improved in evaluation capabilities and has better performance vs human judgements results, and then it plateaus. But the challenge is when we need to improve more on reasoning tasks, in the sense that the self-reward model is continually improved in both types of tasks, but more in general writing tasks. Besides, the self-reward model has less/worse performance on mathematics and reasoning tasks. Taking an iterative reasoning approach, the challenge with more complex tasks (instruction following, reasoning, …) is that the model has scaled to some point, and as it goes further, it falls into overperformance over time. This means, for example, after 2000 iterations, either its performance (accuracy) would plateau or we would see a drop in performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tSnMBBoALU5tEkCcXgQENg.png" /><figcaption>Perils of over-optimization for iterative reasoning on more complex tasks</figcaption></figure><p><strong>Problem: Incorrect/Inaccurate Subjective</strong> <strong>CoTs: </strong>A very important question to this problem is the ranking/scoring mechanism inside the reward model;</p><ul><li>a <strong>Gold standard</strong> of saying what is more likely the outcome?What is the intuition behind the score that RM is giving us?</li><li>Strictly speaking, what is a <strong>good score</strong> for the completion? I.e., supposing the RM, e.g., inferred that the completion1 is chosen with score=10, so given its preferred is correct, then is even just its scoring (10) <strong>accurate</strong> (say standard)?</li><li>Or there might be even <strong>higher variance</strong> in its scoring. E.g., it preferred some answers as good, giving them a score of 10, yet some others as good, so they are given a score of 1000!</li><li>Anyway, are the reward model’s scores (NNs or humans’ feeds) as certain as they can be <strong>reliable to trust </strong>as a standard? Because the main and underlying concern is that the generated CoTs might be incorrect, in the sense that even human feedbacks can be incorrect (human mistakes), and <strong>Subjective</strong>, in contrast to <strong>Objective</strong> or say <strong>Golden Standard </strong>(Human Feedback IS NOT Gold Standard, Hosking et al). I.e., problems (e.g., math) have ground truth answers, but no good thinking process!</li></ul><blockquote><em>All in all, the core problem can be exposed as: Human/RM feedback is not the gold standard and is subjective (A Long Way to Go: Investigating Length Correlations in RLHF, Singhal et al).</em></blockquote><p><strong>Solution: Optimizations through Verifiable Answer </strong>(<strong>Golden Standard</strong>): To come up with a solution, taking the golden standard feedback into consideration, there are some optimizations, here trying to boost the performance in reasoning tasks:</p><h4>1–2–3) Iterative PRO through Verifiable rewards using DPO with Negative Log Likelihood</h4><p>When it comes to reasoning, due to the fact that the SFT model knows only how much a final answer is correct, i.e., the correctness of answers, not COTs (solutions), we should evaluate the solutions. The idea here would be to match and compare gold labels (from inputs) with generated final answers, which can lead to extracting the reward. With that, the model can, during the preference selection step, likewise filter winning and losing CoT along with responses! EFT selection here would be <strong><em>{ XI , ywin , yloss , rwin , rloss , Cwin , Closs }</em></strong>. This way, we have eventually some optimal responses that are more relevant to the task context, and more importantly, have a better reasoning path (CoT or solution). So, this optimization method uses a technique for reasoning tasks. The idea here is that rewards are not going to be done by LLM-as-a-Judge anymore, in the sense that we don’t trust the LLM on the math tasks as much! Instead, its focus is on using the fixed training set with gold labels. To do so, we just use a bunch of math training data where we know the answer, and thus, in fact, use these promising answers as the gold labels. Therefore, we train the base model on such a training set. Then, through the iterative RPO system 2 that we have already designed, the fin-tuned base model generates multiple CoTs outputs again, with final answers per train example. Then the agent builds preference pairs based on the correct vs incorrect answers. It is now the gold labels’ turn, when by extracting the model’s generated final answers, we then try to get a qualitative match between the two answers, the generated final answers &amp; golden labels, each by each. Instead of using RL, the agent does so by training DPO with a likelihood term (for correct answers) to evaluate how well gold labels and final answers match each other. To further elucidate, the NLL (Negative log likelihood) algorithm as a second loss function is to power computing the reward. According to the method conducted in the paper titled “Iterative Reasoning Preference Optimization”, [Weston et all], accessing to a base pretrained (or instruction-tuned) language model, and also a set of training inputs, , and assuming having the ability to judge the correctness of the final outputs, then given a training input, the language model generates a set of reasoning steps (CoT), followed by a final answer to the given problem. Again, based on our premise that the model has access to a correctness measure only for the final answer, and not for the correctness of the reasoning steps used to reach that answer, In the experiments, they thus considered datasets where gold labels are provided for training inputs, and a binary reward is derived by the exact match between these labels and the final answer generations.</p><p>With that, then given the preference pairs, a new mode is trained and updated iteratively with a loss function that combines the DPO loss [Rafailov et al., 2023] for learning from the preference pairs, and the negative log-likelihood (NLL) loss for learning over the winning response from each pair. The loss corresponding to each preference pair is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*vX_va4uOLuzRGBib0Zzb4A.png" /><figcaption>DPO + Negative Log Likelihooh as a loss function to train the base model to reach the gold reasoning paths + correct answers</figcaption></figure><p>Iteratively, we then repeat the above steps with this new model, <strong><em>Mt</em></strong>, to be updated and, in turn, to get our next model, <strong><em>Mt+1</em></strong>, and again through steps to seed a better model. This way, a <strong>gold CoT solution</strong> is provided for each problem, and the gold answers can be matched uniquely to predicted answers after normalization to compute rewards. In this method, compared to RLVR, the model is capable of <strong>self-reward to both final answers and CoTs</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lKmsvTLjF0aPhAMhonA_zA.png" /><figcaption>Iterative PRO through Gold Standard using DPO with Negative Log Likelihood</figcaption></figure><p>The evaluation results (Iterative RPO, Weston et al.), using GSM8K, for comparing Iterative RPO against other baselines, show that Iterative RPO improves over baselines. Iterative RPO outperforms zero-shot CoT, supervised fine-tuning (SFT) on the gold (dataset-provided) CoT solutions, and variants of DPO by a wide margin. SFT gives a boost in performance compared to zero-shot CoT but still far from the performance of Iterative RPO. by applying standard DPO to the same set of preference pairs as used in the first iteration, whether initializing from Llama-2–70b-chat (M0) or from SFT training on the chosen (winner) examples, DPO performance, while being better than zero-shot CoT, is no better than the SFT model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*_MbFZcsO4DJgHD7oIJjspw.png" /><figcaption>Comparing Iterative RPO against other baselines, evaluations on GSM8k</figcaption></figure><p>The following curves show the Effect of DPO+NLL training (initialized from Llama) in four settings. Although using SFT training is only on chosen sequences, the rejected sequence log probabilities also increase and are close to the chosen sequence probabilities. In contrast, our DPO+NLL training manages to decrease the rejected probabilities while increasing the chosen probabilities. This observation could potentially help explain why SFT-only performance lags significantly behind Iterative RPO Iteration 1 performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*2GJKSltL0TVu6kRJJafCbw.png" /><figcaption>Comparing training SFT vs DPONLL on chosen &amp; rejected sequences</figcaption></figure><p>Another observation is that where SFT is trained on gold CoTs (dataset-provided), Chosen and rejected sequence probabilities are still close to each other (but with a slightly bigger gap). And that the chosen sequence probabilities barely increase, and they actually tend to plateau.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*N0DLp9KCB5Oi48eUMhkNXQ.png" /><figcaption>comparing training SFT on gold CoT, chosen vs rejected</figcaption></figure><p>And when comparing DPO only with DPO+NLL (training using GSM8k), the evaluations in four settings depict the effect of the NLL loss term makes the model increase the log probability of the chosen. As can be seen, in standard DPO without NLL loss, the log probability of chosen sequences decreases over training steps. However, when using DPO with NLL loss, they increase over training steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G-7Ro7OI57Vnh811VbIxnQ.png" /><figcaption>Comparing training DPO vs DPO+NLL using GSM8K</figcaption></figure><p>And in terms of <strong>scientific tasks</strong>, the evaluation is on ARC, which contains multiple science subjects. As an aside, in the ARC dataset, Questions are multiple-choice, for example:</p><p>“A fold observed in layers of sedimentary rock most likely resulted from” with four possible answers, e.g., “(A) cooling of flowing magma, (B) converging of crustal plates, © deposition of river sediments, or (D) solution of carbonate minerals”.</p><p>The training dataset contains 7.7k questions split into easy and challenge sets. There is no gold chain-of-thought reasoning provided for training examples in this task. However, this method (IRPO) does not have that requirement either, and hence can still be applied as the rewards are only computed based on the final answer. One consequence, however, is that if there is no model-generated correct solution for a question, then that question is not included in our training. Overall results of the evaluations on the ARC-Challenge test set (which has 1172 examples) showed that Iterative RPO exhibits increased performance across iterations over three iterations (Iterative RPO, Weston et al.). Majority voting using the model in the third iteration (32 samples, temperature 0.8) leads to another small boost. These results outperform zero-shot CoT, SFT on chosen sequences, and standard DPO.</p><p>In addition, the evaluations for math problems using the MATH dataset showed that Iterative RPO likewise provides increased performance across iterations over three iterations. Majority voting (32 samples, temperature 0.8) leads to a significant boost in performance. These results outperform few-shot CoT, SFT on chosen sequences, and standard DPO.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fp82PHCAZZNsitJie94Usw.png" /><figcaption>Comparing Iterative RPO against other baselines, evaluations on sience subjects (ARC)</figcaption></figure><p>The evaluation results show the comparison in four settings. The effect of the NLL loss term here also poses to increase the log probability. Similar to GSM8K, in ARC-Challenge and MATH, the log probabilities of chosen sequences barely increase over training steps when training with DPO. However, when training with DPO with NLL loss, the log probabilities increase over training steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DwVXpSzc5RpaAgisvJ-SXQ.png" /><figcaption>Comparing training DPO vs DPO+NLL, using ARC and MATH</figcaption></figure><blockquote><em>Therefore, it turns out DPO+NLL loss gives high inference and test accuracy in the experiments. And more importantly, in all settings, the margin between the two curves (chosen, rejected) continues increasing. Another discussion that can be noted here is the task type (Iterative RPO, Weston et al.). Even though the results of ARC and MATH arrive at similar conclusions to the ones from GSM8K, these results are especially noteworthy due to the multiple-choice nature of the task. As there are typically only four possible answers, the generated data in step (i) of Iterative RPO may provide a CoT and a final answer that is correct by luck (as random guessing is correct 25% of the time). Hence, the nature of the task may introduce a significant amount of noise in the CoT generations used in preference optimization in step (ii). Nevertheless, the method seems robust to this issue, and we still observe performance gains. And in terms of task difficulty, it can be concluded that on all three distinct tasks, from simpler to more difficult, similar observations on performance have been gained by this method.</em></blockquote><h4>1–2–4) Iterative RPO via Reinforcement learning with verifiable rewards (RLVR)</h4><p>Another question raised is whether we can just remove these complex setups (PPO, DOP, and DPO+NLL) and instead use simpler models? If so, the goal is actually to simplify the reward model. And what it means is that instead of using a reward model, it is better to use a much simpler mechanism for tasks, the outputs of which can be verified. Supposing a prompt is given to the model, getting updated, then generating an action (next token) as a response, sending it to RM, which tells what the good score associated with this generation is. Now, in problems like Math reasoning, where the answer can be achieved by using ground truthing, while here using RM, the score quality given from the RM may not be as good as ground truth. And what it means is that here might be no good RM’s thinking process! So, in such problems, it is better and reliable to use rule-based methods, where the gold answer is the ground truth answer.</p><p>To give an intuitive comparison of <strong>RLHF vs. RLVR:</strong></p><p>RLHF relies on human annotators to provide preference rankings or explicit feedback on model outputs, which are then used to train a reward model that guides policy optimization. In contrast, RLVR replaces human feedback with a set of programmatically verifiable rewards, ensuring that the model is trained on objective, deterministic criteria rather than subjective human evaluations. One idea for doing so is rule-based rewards, which are verifiable and objective (and of course, scientific). Thus, by replacing the reward model with something rule-based as a verification function, we can not only adopt fine-tuning for complex domain-specific tasks, but also maintain accuracy addressing, along with taking advantage of regularizing scores as well. The following is an example of a simple verification function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*pTUQEOV-o-t4u8oiX1rnyg.png" /></figure><p>This way, the base model is still supervised-trained, but with ground truth answers already, and without any thinking process. So, we give a reward only for final answers, not CoTs. We don’t need any more intermediate CoTs to fuzzy-score; we just need a final answer to binary-rank by extracting the verifiable reward after the final answer. And in other words, rewarding just the final answer means just rewarding <strong>at the end instead of intermediate iterative rewarding</strong>. E.g., OpenAI-o1, deepseek-r1, and also Ai2-Tulu3 use RLVR as the policy for optimization of their SFT method.</p><p>In this structure, we use <strong>gold final answers</strong> or <strong>verifiable constraints</strong> as a <strong>proxy for the environment</strong> (previously RM). We furthermore adopt the model by SFT to excel at specific tasks (reasoning, math, precise instruction following, etc). We have the SFT model’s regularized score as well. Because without the capability to regularize scores, if the RM’NN were to be used to score this answer, it might have given us another score like 1000 or 5.5. Therefore, its rule understanding avoids generating high variance, yet enables <strong>scalar reward regularized</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tNVVIUiYgIEL2NClMp-kPg.png" /><figcaption>RL with verifiable rewards, instead of reward model</figcaption></figure><p>For example, in the experiments conducted by Ai2, the setup using Tulu-3-DPO-SFT was designed and trained based on this method (RLVR). Upon the benchmarks GSM8k, MATH, IFEval, and BBH, the model was trained on the domain datasets to verify exact match against extracted answer or verification by prompt-specific verifiers. They then applied PPO as the classical RL algorithm for optimization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*OI9nDMf73GWcWuVvyjb-MQ.png" /><figcaption>Ai2 Tulu-DPO-SFT model uses RLVR with PPO for optmization</figcaption></figure><p>For the rule-based part of the structure, some verification functions are implemented for each domain (dataset-specific) to verify the matching of the model answer and a ground truth answer (constraint or proxy), as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*rKvV669WRg_3UweyurmUAw.png" /><figcaption>Tulu’s Verification function used for specific domain, gsm8k dataset</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*sw08SGgoEds3Leku2pvwpA.png" /><figcaption>Tulu’s Verification functions used for specific domain, ifeval dataset</figcaption></figure><p>And performance-wise, as shown in the following, in MATH tasks, RLVR works better at scale than just DPO training:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TNp2va-uLtRGfMv1r01GKg.png" /><figcaption>RLVR in MATH tasks, works better at scale than DPO</figcaption></figure><p>This method has good performance in almost all tasks over training steps(iterations). And gains a significant boost in some. However, after a bunch of episodes, it plateaus. E.g., the performance results of Tulu3–405B (applied on Llama-405B) by SFT, DPO, and RLVR compared with Deepseek-v3 and GPT-4o on average are very close to GPT-4o and better than Deepseek-v3. It also goes roughly true for the smaller models (mini versions) of those. Although RLVR is not really new, it is <strong>a classical method</strong>. This method is the simplest way of using RL! But even so, the reason why it worked now is that the Base model itself is actually strong. The classical RL did not have good performance with old models like GPT-2, because the base models did not have good performance, and so RL did not add much performance either. But, with the newer bae model (GPT-4o), we see the difference, classical RLVR performed well with them and gained a noticeable performance.</p><p>And per specific domain, it can be seen from RL finetuning Training curves that the performance of verifiable reward SFT mechanism still also showed higher accuracies compared to DPO training across other optimization algorithms and specific tasks (https://github.com/allenai/open-instruct).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HaOTBZIMLHqDz__Db6GNuA.png" /><figcaption>Performance of RLVR SFT vs DPO training across other algorithms and specific tasks</figcaption></figure><p>One thing, though, doing RL iteratively against binary/sparse signals is not that new, and has been used in past training methods. As shown in the following curve, what has changed is not just for verifiable rule-based reward, but for the base model quality and knowledge of CoT as well. e.g., performance of GRPO compared to GPT-2 shows a higher correction in terms of verification rate. So, in fact, RLVR optimizations make it easier to further scale the performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*dOvmOVYtTJXq4_PYfp_W1g.png" /><figcaption>Performance optimization using RLVR, in terms of capability of base models</figcaption></figure><p>The comparison for those large scales exhibits that the performance of all large models in the benchmarks is different across domain tasks as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tkgr6cRQI93wMc1uh_Cy6Q.png" /><figcaption>Tulu models performance via RLVR, DPO, SFT vs other LLMs</figcaption></figure><p>In Math problems, over-training steps, bigger models (e.g., 405B) have better performance improvement compared to the smaller (70B), meaning RLVR didn’t work that well with weaker base models. However, SLM-wise, the comparison for small-scale models (lower parameters) depicts Tulu3 trained by RLVR SFT usually surpassing the other light models in the same scale.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NP5JLhtcvYMhynsCcAuGqA.png" /><figcaption>SLMs performance across domain specfic tasks VS Tulu3 small models</figcaption></figure><blockquote><strong><em>SLMs appeared to be potentially expert models (MoE) for future improvements in terms of domain-specific skills and diversity concerns within and across tasks!</em></strong></blockquote><h3>Further Improvements:</h3><blockquote><strong><em>There are optimization algorithms for Iterative Reasoning via Policy Optimization, particularly aiming at further scaling accuracy, enhancing self-awareness for handling sophisticated math and reasoning tasks, while optimizing throughput and memory usage. We are going to explore them in my next articles ahead, continuing the progress of this subject “</em>Introspection &amp; Self-Improvement Algorithms: LM’s<em> </em>Self-learning to Self-Reason”.</strong></blockquote><h3><strong>References &amp; Credits:</strong></h3><p><a href="https://arxiv.org/abs/2309.16349">Human Feedback is not Gold Standard</a></p><p><a href="https://rdi.berkeley.edu/">The Berkeley Center for Responsible, Decentralized Intelligence (RDI)</a></p><p><a href="https://arxiv.org/abs/2401.10020">Self-Rewarding Language Models</a></p><p><a href="https://arxiv.org/abs/2404.19733">Iterative Reasoning Preference Optimization</a></p><p><a href="https://arxiv.org/html/2506.10943v1">Self-Adapting Language Models</a></p><p><a href="https://rdi.berkeley.edu/adv-llm-agents/sp25">Berkeley RDI, Advanced LLM Agents</a></p><p><a href="https://www.allenai.org/">Allen Institute Ai2</a></p><p><a href="https://arxiv.org/abs/2402.00838">OLMo: Accelerating the Science of Language Models</a></p><p><a href="https://arxiv.org/abs/2411.15124">Tulu 3: Pushing Frontiers in Open Language Model Post-Training</a></p><p><a href="https://arxiv.org/abs/2406.09279">Ai2, Unpacking DPO and PPO: Disentangling Best Practices for Learning from Preference Feedback</a></p><p><a href="https://arxiv.org/abs/1506.02438">High-Dimensional Continuous Control Using Generalized Advantage Estimation</a></p><p><a href="https://arxiv.org/abs/1707.06347">Proximal Policy Optimization Algorithms</a></p><p><a href="https://arxiv.org/abs/2305.18290">Direct Preference Optimization: Your Language Model is Secretly a Reward Model</a></p><p><a href="https://arxiv.org/abs/2405.14734">SimPO: Simple Preference Optimization with a Reference-Free Reward</a></p><p><a href="https://arxiv.org/abs/2306.06070">Mind2Web: Towards a Generalist Agent for the Web</a></p><p><a href="https://arxiv.org/abs/2304.05128">Teaching Large Language Models to Self-Debug</a></p><p><a href="https://arxiv.org/abs/2306.04751">How Far Can Camels Go? Exploring the State of Instruction Tuning on Open Resources</a></p><p><a href="https://arxiv.org/abs/2311.10702">Camels in a Changing Climate: Enhancing LM Adaptation with Tulu 2</a></p><p><a href="https://arxiv.org/abs/2309.11495">Chain-of-Verification Reduces Hallucination in Large Language Models</a></p><p><a href="https://arxiv.org/abs/2305.20050">Let’s Verify Step by Step</a></p><p><a href="https://arxiv.org/pdf/2504.1296">THINKPRUNE: Pruning Long Chain-of-Thought of LLMs via Reinforcement Learning</a></p><p><a href="https://arxiv.org/abs/2306.05685">Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena</a></p><p><a href="https://arxiv.org/abs/2206.07682">Emergent Abilities of Large Language Models</a></p><p><a href="https://arxiv.org/abs/2310.13548">Towards Understanding Sycophancy in Language Models</a></p><p><a href="https://arxiv.org/abs/2508.02087">When Truth Is Overridden: Uncovering the Internal Origins of Sycophancy in Large Language Models</a></p><p><a href="https://arxiv.org/abs/2509.16533">Challenging the Evaluator: LLM Sycophancy Under User Rebuttal</a></p><p><a href="https://arxiv.org/html/2508.13743v1">Sycophancy under Pressure: Evaluating and Mitigating Sycophantic Bias via Adversarial Dialogues in Scientific QA</a></p><p><a href="https://arxiv.org/abs/2308.03958">Simple synthetic data reduces sycophancy in large language models</a></p><p><a href="https://huggingface.co/blog/Rakshit122/sycophantic-ai">Detecting and Evaluating Sycophancy Bias: An Analysis of LLM and AI Solutions</a></p><p><a href="https://arxiv.org/abs/2402.03620">Self-Discover: Large Language Models Self-Compose Reasoning Structures</a></p><p><a href="https://arxiv.org/abs/2309.03409">Large Language Models as Optimizers</a></p><p><a href="https://arxiv.org/abs/2310.01798">Large Language Models Cannot Self-Correct Reasoning Yet</a></p><p><a href="https://arxiv.org/abs/1706.03741">Deep reinforcement learning from human preferences</a></p><p><a href="https://arxiv.org/abs/1706.03762">Attention Is All You Need</a></p><p><a href="https://arxiv.org/abs/2206.07682">Emergent Abilities of Large Language Models</a></p><p><a href="https://arxiv.org/abs/2204.05862">Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedback</a></p><p><a href="https://arxiv.org/abs/2203.02155">Training language models to follow instructions with human feedback</a></p><p><a href="https://www.nature.com/articles/nature14236">Human-level control through deep reinforcement learning</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ae3a7250301" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/introspection-algorithms-self-learning-to-self-reason-part-2-6ae3a7250301">Part2 - Introspection &amp; Self-Improvement Algorithms: LM&#39;s Self-learning to Self-Reason</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introspection & Self-Improvement Algorithms: LM's Self-learning to Self-Reason — Part 1]]></title>
            <link>https://levelup.gitconnected.com/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8?source=rss-6acfbf0d8c9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/708454126ad8</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[math]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Hamid Nafiyan]]></dc:creator>
            <pubDate>Wed, 19 Nov 2025 15:44:38 GMT</pubDate>
            <atom:updated>2025-12-05T03:53:59.975Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introspection &amp; Self-Improvement Algorithms: Language Reasoning Agents Self-learning to Self-Reason — Part 1</strong></h3><h4>Instruction Tuning and Instruction Following through AI in the Loop</h4><h4>Introduction</h4><p>In the space of estimations, using language for reasoning and communication doesn’t have to come from an LLM; that may turn out to be a means to an end. Maybe in a few years, we will move beyond LLMs, but the need for universal language understanding and production in agents will remain. Next to that, the current and anticipated state of LLMs’ reasoning requirements provides broader yet deeper insights into how to describe the ways it can be interacted with as well as the ways it can be interacted with. Given that that’s true, taking LLM’s capabilities for reasoning and planning into account, which itself stems from its own intermediate steps, which are somehow rooted in its implicit reasoning capabilities, sheds light on the broader responsibility of a language agent concerning self-learning various capabilities as a proven-essential Introspection skill, which has been a while focused profoundly on as a long-horizon paradigm. To enable such a great added value as an intrinsic skill into an LLM, I am going to delve deep into SoTA methods for approaching the long-horizon <strong><em>Self-Learning paradigms</em></strong>. So, as an aside again, how to apply such techniques and their where and the when is a useful best practice to shape such an aforementioned skill as an Introspection paradigm.</p><ul><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=an%20Introspection%20paradigm.-,Debates,-There%20have%20still">Debates</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=Learning%20to%20Self%2DImprove%20(Self%2DTraining%20for%20Self%2DReasoning)">Learning to Self-Improve (Self-Training for Self-Reasoning)</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=Iterative%20Reasoning%20through%20Instruction%20Following%20and%20Self%2DRewarding">1) Iterative Reasoning through Instruction Following and Self-Rewarding</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=Iterative%20Evaluation%20with%20Self%2DRewarding%20Model%20(AI%2Din%2Dthe%2Dloop)">Iterative Evaluation with Self-Rewarding Model (AI-in-the-loop)</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=Self%2DInstruction%20Creation%20(Sourcing%20Data%20or%20Bootstrapping%20Data)">1–1-) Self-Instruction Creation (Sourcing Data or Bootstrapping Data)</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=Self%2DInstruction%20Optimizations%20(Instruction%2Dtuning)">Self-Instruction Optimizations (Instruction-tuning)</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=1%E2%80%931%E2%80%931)%20Data%20Curation%20Optimization">1–1–1) Data Curation Optimization</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=1%E2%80%931%E2%80%932)%20Data%20Mixing%20Optimization">1–1–2) Data Mixing Optimization</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=1%E2%80%931%E2%80%933)%20Optimization%20through%20Hybrid%20Data%20Creation%20%26%20Persona%2DDriven%20Data%20Generation%20Approaches">1–1–3) Optimization through Hybrid Data Creation &amp; Persona-Driven Data Generation Approaches</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=1%E2%80%931%E2%80%934)%20Data%20Ablation%20Optimization">1–1–4) Data Ablation Optimization</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=1%E2%80%931%E2%80%935)%20Capability%2DDriven%20Data%20Approach">1–1–5) Capability-Driven Data Approach</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=1%E2%80%932)%20Instruction%20Following%20Training%20(or%20Preference%20Tuning)">1–2) Instruction Following Training (or Preference Tuning)</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=Preference%20Tuning%20Optimization%20via%20RLAIF">Preference Tuning Optimization via RLAIF</a></li><li><a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=References%20%26%20Credits%3A">References &amp; Credits</a></li></ul><h4><strong>Debates</strong></h4><p>There have still been controversial debates here and there in academic research, research institutes, big tech labs, industry, and engineering communities on common recent limitations of LLMs leading to performance drop or failure, the most important of which include:</p><ul><li><strong>Distraction</strong> (due to irrelevant problems) and distracting rules</li><li><strong>Risk of memorization or overfitting</strong></li><li><strong>Hallucination gives rise to inconsistency, absence of causality, and a lack of ground truth in the response</strong></li><li><strong>NIAH</strong> (reasoning in long contexts)</li><li>Lack of <strong>persistent</strong> memory</li><li>Long-term <strong>memory</strong></li><li><strong>Compositionality</strong> limits via distillation</li><li>Premise <strong>order</strong> of sentences (inability to go back and forth)</li><li><strong>Unability</strong> to reason</li><li><strong>Early stop</strong> reasoning</li><li><strong>Large input</strong> context problems</li><li><strong>Self-correction</strong></li><li>Search <strong>space</strong> <strong>scaling</strong> up</li><li>Effective <strong>test-time scaling</strong></li><li><strong>Local knowledge</strong> distillation</li><li><strong>Spatial</strong> reasoning</li><li><strong>Exponential Error</strong> Compounding in long-horizon tasks (sequential decision-making)</li><li><strong>Oracle</strong> feedbacks</li><li><strong>Gradient Ascent </strong>&amp; <strong>Likelihood</strong></li><li>Varied-level <strong>mathematical</strong> problem-solving (grade-school to IMO),</li><li><strong>Hierarchical &amp; Dynamical Planning </strong>in efficient <strong>state</strong> <strong>exploration</strong> and <strong>action space exploitation</strong></li><li>Imitated-reasoning of fundamental human <strong>cognitive functions</strong></li></ul><p>Taking the aforementioned ongoing issues above into account, and now that we have reviewed the essential concepts and basis, I am now going to get into the behind-the-scenes of LLMs’ reasoning via exploring fundamental reasoning techniques. This article also explores the potential solutions and improvements going on, the issues<strong> </strong>to come up with optimization and trade-off methods. Dealing with long-horizon reasoning and planning techniques, I started off in my previous articles with Inference-time techniques besides reasoning strategies, and then we made them excuses to discuss on the road to search and planning techniques. Now through a 4-part article, from here onward, I am going to point out the SoTA post-training algorithms and methodologies, and by leveraging them, we delve deep into the <strong>Fundamental and Advanced Self-Improvement Algorithms, Techniques &amp; Approaches</strong>, aiming at enabling language agents with <strong>self-learning, self-observation, self-reflection, self-searching, self-planning, and self-evaluation capabilities.</strong></p><blockquote><em>Please refer to the references &amp; credits of the material covered in this article as well. Also note that all photos are screenshots taken from papers to which referred in this article.</em></blockquote><h3><strong>Learning to Self-Improve (Self-Training for Self-Reasoning)</strong></h3><p>The desired goal at this point forward could be developing a model that autonomously learns all the reasoning techniques we have introduced [<a href="https://medium.com/@hamid.n.d/on-llm-reasonings-inference-time-prompting-techniques-bf9d590ca554">1</a>, <a href="https://medium.com/@hamid.n.d/search-and-selection-inference-time-techniques-for-language-reasoning-agents-0e64d419bef6">2</a>, <a href="https://medium.com/@hamid.n.d/on-lms-reasoning-strategies-approaches-f843651b7bf8">3</a>] while addressing all the limitations we have identified [<a href="https://medium.com/@hamid.n.d/on-lms-reasoning-strategies-approaches-f843651b7bf8">1</a>, <a href="https://medium.com/@hamid.n.d/search-and-selection-inference-time-techniques-for-language-reasoning-agents-0e64d419bef6">2</a>, <a href="https://medium.com/@hamid.n.d/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8#:~:text=an%20Introspection%20paradigm.-,Debates,-There%20have%20still">3</a>]. So, looking at this through a little more detail, let’s put ourselves in the mindset of a model trying to learn how to self-improve and to better reason. An AI that “trains” itself as much as possible. The problem with the classical training methods was that it was difficult to define a loss function that actually matches the thing we want to do. With the way the loss function was, the simple idea is that we have a bunch of sequences and use the next token (prediction) as the loss function to train a model, which is not exactly tied to the final result. Here, an optimization that can be taken advantage of is Reinforcement Learning methods. Meaning leveraging RL for defining a much more sophisticated loss function in a more principled way. RL has the model do some predictions and then look at the end of the horizon, and then provide feedback about the quality of the end result. Doing so, RL not only allows us to have a principled way to define a loss function, but unlike the classical training with a fixed dataset, RL helps the model get more knowledge, a.k.a here reasoning abilities. Its conventional base mechanism includes:</p><ul><li>A model trains itself from feedback</li><li>Creates new tasks to train on, challenging itself (self-challenging or self-instruction)</li><li>Evaluates itself whether it’s getting the task right (self-rewarding)</li><li>Updates itself based on what it understands (Self-aware model), more able to understand what it knows and what it doesn’t know (the evaluation)</li><li>Learning from interactions (people+world or internet+itself)</li></ul><p>Here’s the basic schema for that, but we are going to be going further through the optimizations in later parts, a bit ahead:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xc1IBo5Gj0gk1Py0jOLgHA.png" /><figcaption>Iterative improvement, an AI that trains itself as much as possible [Iterative Reasoning Preference Optimization, JasonWeston et al]</figcaption></figure><p>Here, specific questions are raised if it is a path to superhuman AI? can even this help it become superhuman? So, again, let’s go further through self-improving optimization algorithms.</p><h3><strong>1) Iterative Reasoning through Instruction Following and Self-Rewarding</strong></h3><p>The model’s main goal here emphasizes being good at end-to-end reasoning, not just prompting. Taking the idea and concepts from Reinforcement Learning, we aim for learning how the model it given a prompt (as a task), is able to improve its reasoning on its own, via generating multiple responses (as Actions) and receiving feedback on those responses, meaning its actions’ feedback (as Rewards). That being said, LLM improves itself by assigning rewards to its own outputs and optimizing (Self-training for self-improving). As an aside here,</p><blockquote><em>what with the way the current LLMs are approaching human-level performance on a variety of tasks, there is reason to believe that future LLMs will surpass human performance. So, taking this approach if fulfilled gives us a hint of the “</em><strong><em>Superalignment challenge</em></strong><em>”, a core challenge for aligning future superhuman AI systems. It says humans will need to supervise AI systems much smarter than them!</em></blockquote><p>It has hence broadened the focus from just standard reinforcement learning (known as RLHF) to include Self-Rewarding mechanisms, in the sense that it is obvious that humans need to read the responses carefully in order to make decisions, leading RLHF to be costly, time-consuming, and high-variance. And of course, these reasons are basically brought about by the fact that the original data comes from different sources in different forms, and more importantly, targeting different capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*uDzTit-mKVfZP7UQ_qqfIQ.png" /><figcaption>Post Training for Alignment with Human Preferences- [Photo by <a href="http://twitter.com/FanaHOVA">@FanaHOVA</a> on X]</figcaption></figure><p>Since, as LLMs write better and better responses, it becomes harder and harder for humans to process them, especially those that are lengthy and require domain expertise! This is where the long-horizon <strong>Synthetic- &amp; Self-Rewarding </strong>and its methods like <strong>RLAIF (LLM-as-a-Judge)</strong>, <strong>Gradient Optimizations</strong>, <strong>RLVR, RLVRT, and others </strong>come into play.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*S03k0DqaLrAA5d837tTl4A.png" /><figcaption>Three Types of Rewarding Mechanisms, RLHF, RLAIF, and PPO</figcaption></figure><blockquote><em>Quantitatively, there have been research that have shown improvements on model outputs either by iterative RLHF judgments or by LLM-as-a-Judge in the evaluation loop, although in the path toward superalignment, self-rewarding turns out to need more of them, posing to motivate the idea of combining these methods (RLHF and LLM-as-a-judge) together to form promising self-rewarding mechanism internally in system 2 in order to improve reasoning in a self-learning internal way.</em></blockquote><p>So, in order for an LLM to have the capability of self-rewarding, we should therefore train it as a self-rewarding language model. And to train a self-rewarding language model, it should have the following two capabilities:</p><h4><strong>A. Instruction Following (IFT of Instruction Fine-tuning)</strong></h4><p>The desired LLM should have the ability to follow instructions. It means that given a user instruction, the LLM can respond to it appropriately. For example, if a user gives a model a bunch of CONSTRAINTS like “make sure to start the sentence with S” or “to write a poem that has 5 words”, we could verify if the generated outcome follows these CONSTRAINTS or not, and then we can easily evaluate/verify how good the generated outcome is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*TpxxTHhYuCcBMFhFDfL84g.png" /><figcaption>Example of lack of ability to follow user instructions</figcaption></figure><h4><strong>B. Evaluation Capability (EFT or Evaluation Fine-tuning)</strong></h4><p>The promising LLM as a reward model should have the ability to evaluate responses. It means that given a user instruction with one or more responses, it can judge the quality of those responses (RLAIF).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*JBlpPiSooECQ8OKdqvhIoA.png" /><figcaption>Softmax function in Distillation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*Qc6LE-KXFT48CYbIctMQMA.png" /><figcaption>Trainig and evaluation tasks, instructed to the model- NaturalInstructions[Mishra et al 2022]</figcaption></figure><h4><strong>Iterative Evaluation with Self-Rewarding Model (AI-in-the-loop)</strong></h4><p>In order for LLMs to have such capabilities as a reward model, the improvement process should be performed iteratively and end-to-end. And what it means <strong>empirically</strong> is that LLM generates its responses (which are not necessarily accurate) and has to be improved. To do so, without any human interference, this LLM (or another LLM in system 2), as a reward model (as a judge) for evaluation, gives rewards to generated responses (next tokens). This reward is going to be done iteratively as long as the response’s quality reaches the desired accuracy. Then this base model can go through an iterative process of data “creation/curation” and “training on new data”. This way, the model can get better in terms of both instruction following and evaluation capabilities in each cycle. This system 2 LLM employs RL to iteratively refine its reasoning such that through both the training loop &amp; self-rewarding loops, the self-reward model is continuously improved through iterative training. Consequently, this iteration results <strong>empirically</strong> in fairly matching human rankings compared to the SFT baseline. That is, LLM can <strong>hopefully</strong> gain the ability to evaluate itself. An iterative process leverages a pre-trained model in order to <strong>multitask-train</strong> this model using seed IFT and EFT. In this base system 2 reasoning comprises iterating on 2 steps to gain the aforementioned self-training capabilities:</p><ul><li>Self-Instruction Creation</li><li>Instruction Following Training</li></ul><p>Iterations on these steps are expected to improve instruction following and reward modeling ability.</p><h4><strong>1–1)</strong> <strong>Self-Instruction Creation (Sourcing Data or Bootstrapping Data)</strong></h4><p>Assuming we have a pool of prompts that represent user requirements, these newly created prompts are supposed to be used to generate candidate responses. These prompts, though, should themselves come from real-world users interacting with LLMs. That is, these prompts can be created manually by human labelers (expert curated samples), or created by few-shot prompting to ask some model to generate new instructions, or loaded by a RAG interface from a prompt dataset. They can also be sampled by multiple models. E.g., 20 models from small to big ones (can also include the base model we want to improve later), give each prompt multiple completions (Xi , yi). In any case, these exemplars are given to the base LM so that it learns them and becomes fine-tuned, such that we can compare the responses later to select which is better preferred.</p><p>In case they were generated by a model, this step could be done in multiple epochs iteratively so that we get a large set of tasks (user instructions). E.g., from the OpenAssistant dataset to bootstrap instructions(multitasks) using GPT-4o, or a ChatLLama-70B or Ai2Tulu3 as the base models (LLM improves itself by assigning rewards to its own outputs and optimizing, Jason Weston et al), and also the Alen Institute Ai2 papers on preference tuning. Now, for <strong><em>Candidate-Response Generation (Completion)</em></strong> via SFT (or instruction-tuning), all instructions generated in the aforementioned way are given to a model called<em> the </em><strong><em>Seed model,</em> </strong>which is to generate(seed) multiple responses as candidates or completions (<strong>IFT Data</strong>) for those instructions. The base LM, as <strong>Analogical Reasoner,</strong> carries out so by an analogical approach. For further reading on Analogical Reasoning, you can refer to my paper article on “<strong><em>LLMs’ Reasoning Strategy Approaches” section titled Analogical Reasoning.</em></strong> The seed model is likewise can still be through for example OpenAssistant dataset using a pre-trained GPT-4o, or a LLama-70B base model (or e.g., Ai2Tulu3), finetuned with the generated prompts. The result here would be pairs of instructions and responses a<em>s:</em></p><blockquote><strong>SeedModel(Xi) → { Xi , y1 , … , yk }</strong></blockquote><blockquote><strong>Input</strong>: <strong>Xi </strong>is user instructions</blockquote><blockquote><strong>Output</strong>: <strong>yi </strong>is ith candidate response for <strong>X </strong>, <strong>K </strong>is the number of responses generated</blockquote><p>Then,<strong> </strong>for<strong><em> </em>Self-Instruction evaluation, </strong>there is a self-loop via a prompt/task pool (or RAG) with another model as <strong>LLM-as-a-Judge</strong> (or <strong>Ranker Model</strong> or <strong>Labeler Model)</strong> to generate early scores (best to worst) as <strong>EFT data</strong> to assign to each sample response, meaning predicts ranking for each response via again a SFT way to tell us which of these completions are better. To do so, we instruct the judge model to evaluate the response using some additive criteria (relevance, coverage, usefulness, clarity and expertise, helpfulness, instruction-following, trustfulness, honesty, to name a few) and select its preferred completions. As an aside for further reading on additive criteria evaluation, refer to my pat article on “<strong><em>LLMs’ Reasoning Strategy Approaches” section titled Branch-Solve-Merge Approach (LLM-as-a-Judge)</em></strong><em>.</em> Again, the Judge model is likewise can still be through for example OpenAssistant dataset and using a pre-trained GPT-4o, or a Llama-70 B, so that OpenAssistant only provides ranking information for different responses, finetuning the pretrained GPT-4o, or a Llama, with both generated prompts-responses and scores, as preference feedback, meaning preference data which are pairs of responses alongside their preferences each. The result up to here would be as:</p><blockquote><strong>JudgeModel(XI , { y1 , … , yk } ) → { XI , y1 , … , yk , ri , … , rk }</strong></blockquote><blockquote><strong>Input: Xi </strong>is the user instruction, <strong>yi </strong>is the seed candidate responses</blockquote><blockquote><strong>Output: ri </strong>is the given score(ranking) for <strong>yk</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*y411tX5Yt8DUMouPeRjtHA.png" /><figcaption>Self-Instruction Creation to Seed IFT &amp; EFT Data</figcaption></figure><p>There may be specific situations where, given an instruction and four responses, if the model assigned scores to the four responses that perfectly match human rankings, then all of those four samples are kept; otherwise, all of them are discarded. All in all, we have at this stage a dataset of <strong>Preference Pairs</strong> as the result set.</p><h4><strong>Self-Instruction Optimizations (Instruction-tuning)</strong></h4><p>There are optimizations for the first step of iterative evaluation in order for the base model to have a <strong>better capability of instruction-following</strong> in terms of performance. On the research conducted by Allen Institute for AI (Ai2), introducing open training recipes for reasoning in language models, motivated by providing fully open models (Transparent, Reproducible, Accessible), which inspired by the paradigm of Open Ecosystem to accelerate innovation in language models, have some optimization methods in all phases of pre-training, post-training, and test-time scaling (refer to the papers in the references and credits). Here, we explore some of them, applied for Instruction-following capability as Instruction-tuning <strong>methodological approaches</strong>.</p><p>The problem with sourcing bootstrapping data when self-instruction creation is: How to use the right data in the right way? In the sense that the original data comes from different sources in different forms, and more importantly, targeting different capabilities! On the other hand, though, <strong>Successful Adaptation</strong> is empirically proven to start with <strong>meaningful evaluations for targeted skills</strong>, prompts of <strong>representative queries</strong> for said skills, and checks for <strong>licenses</strong> as well as <strong>decontamination</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*FLWCxkrT2PvmYWxvpntalg.png" /><figcaption>Prompts Datasets, used for training and evaluation in Ai2’s post-trainig experiments</figcaption></figure><p>So taken together, to address both this how question and the adaptation concerns, the fundamental goal here is building a higher-quality subset of data with enhanced task <strong>diversity and difficulty</strong> balance while meeting the open paradigm. This makes data more trustworthy, replicable, and comprehensive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*mQTRA8KJ8S9I1ol6DASwxg.png" /><figcaption>Diverse skills (MoE) needed to further curating data- Super-NaturalInstructions,[Wang et al. 2022]</figcaption></figure><p>There are lots of instruction datasets, as shown here, to use for curating data in terms of either diverse skills or comprehensive skills:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*yMOnHYXW7EhQmp_5H_1Mkw.png" /><figcaption>some examples of Instruction datasets</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*V03W9aSpEL9PMxCxL8JJLw.png" /><figcaption>some examples of Instruction datasets for different skills- FLAN_v1,[Wei et al 2022]</figcaption></figure><p>The following optimizations are still being made through SFT is trying to improve the trained seed model’s performance, approaching toward <strong>Capability-Driven Data Approach:</strong></p><ul><li><strong>Data Curation</strong></li><li><strong>Synthetic Data</strong></li><li><strong>Data Mixing</strong></li><li><strong>Hybrid Data Creation &amp; Persona-Driven Data Generation</strong></li><li><strong>Data Ablation</strong></li></ul><h4><strong>1–1–1) Data Curation Optimization</strong></h4><p>One of the methodological approaches for filtering a qualified subset of data to do SFT optimization. Although the original data sources should still be a representative of data exhibiting all types of problems and skills (<strong>general proxy</strong>), the promising subset of sample tasks would be curated as diversity of skills &amp; problems in order for LMs to be used potentially as<strong> a Mixture of Experts</strong> (generalist but specialist as often as possible). Data curation is likewise carried out<strong> </strong>through supervised finetuning (on instruction tuning) a pretrained LM with prompts and responses, as well as scores, in the same way as the self-instruction, but resulting in more curated data with a generalist-specialist model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*BK5_FY4QhEN-TDjekwwOkA.png" /><figcaption>Data Curation, for filtering qualified subset of data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nudX0IGH_BueSAdUr7Aarg.png" /><figcaption>Filtering subset of samples- Self-Instruct [Wang et al. 2023]</figcaption></figure><p>In turn, curated sample problems should consist of data that not only includes samples (questions or tasks) with responses, some of which include CoT, but actually capable of diverse skills as well. More data curation can be applied in order to build the specific-skill datasets as a <strong>specific proxy</strong>, like math reasoning at high school or college level, coding, safety, etc. “<strong>Very curated data</strong>” is also meant as a higher level of reasoning and much more complex data, which is beyond the SFT/IF curated data. E.g., a very large collection of math, logical reasoning, probability questions, olympiad competition-type data, and so on.</p><p>A best practice to achieve better curated data is through <strong>Synthetic Data Collection</strong>. Due to the fact that, on the one hand, human-generated instructions are costly, time-consuming, and high-variance, and on the other hand, the self-instruction creation method via a pretrained base LM, despite being sufficient in many cases, might likewise be noisy and get biased to the base LM we generate data with, therefore, the optimal method could be a combination of these two methods (human-annotated &amp; model-generated), combining data coming from human annotation and data generated from other LMs to gain <strong>Hybrid Preferences</strong>.</p><h4><strong>1–1–2) Data Mixing Optimization</strong></h4><p>Data curation and data mixing are both repeated and parallelizable tracks, ongoing. While data curation curates data given targeted capabilities, data mixing mixes data across capabilities.</p><p>There is a challenge for the <strong>Role</strong> <strong>of Data</strong>, even with data curation! So, this is a very challenging task because it requires substantial effort in filtering data such that we are getting high accuracy with regard to the relevant capabilities (<strong>not task-specific</strong> <strong>only</strong>). As an example, if we collect a lot of data about a poem, we lose the capability of Math reasoning. Or likewise, if we add a lot of data from math then we lose the capability of doing creative tasks like a poem. There is actually a <strong>trade-off between</strong> <strong>diversity &amp; comprehensiveness.</strong> That is why data mixing is a substantial effort in filtering data while maintaining performance. Here is important to get the best of both worlds! This means gaining the <strong>highest accuracy across any or at least many types of skill</strong>. Data mixing starts fully with mixing before curation. Mixing data can be either created by humans (manual empirical analysis) or synthesized with a base LM (automated mixing). SuperNI, CoT, Flan V2, Dolly, OpenAssistant 1 are datasets created by humans. And Self-instruct, Unnatural Instructions, Alpaca, Code-Alpaca, GPT4-Alpaca, Baize, ShareGPT are examples of synthetic ones. Eventually, we conduct instruction-tuning using SFT on mixed &amp; combined data for different tasks (diversity &amp; comprehensiveness) so that the model could achieve higher performance than when data curating only. This way, through the combined data, we must get the highest accuracy across any or at least many types of skill, e.g., Chat, Knowledge Reasoning, Coding, Multilinguality, Safety, etc. The following shows the evaluation results of Experiments for the Tulu1 model conducted by Ai2 for instruction tuning data mixing in terms of task-specific accuracy (highest accuracy) as well as average accuracy for the multitasks on mixed relevant data combined via human-annotated or model-synthetic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oiBazhIBGBjU9OkcTjyQKA.png" /><figcaption>Tülu1 model from Ai2 — accuracy of instruction tuning data mixing for task-specific and average all</figcaption></figure><h4><strong>1–1–3) Optimization through Hybrid Data Creation &amp; Persona-Driven Data Generation Approaches</strong></h4><p>Even with applying data curation and data mixing, there definitely could be situations where such optimizations do not affect as much on task performance. So, the question here is what other type of data is useful for reasoning? In fact, for example, in reasoning tasks, it is more than just a simple final answer to respond to reasoning queries, and so “Chain-of-thought data” is crucially important for reasoning tasks to perform well. Because, as proven, CoT data:</p><ul><li>helps models handle complex, multi-step problems easier</li><li>reveals the model’s reasoning process</li><li>makes it easier to spot errors in logic, thus more trustworthy</li><li>resembles the human thought process</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KgeBR5BY5Z_FnTKS9dPYIA.png" /><figcaption>Chain-of-thought data is crucially important for reasoning tasks to perform well</figcaption></figure><p>And again, as we know, despite manual human annotation (e.g., GSM8K dataset: Annotators write step-by-step solutions) contains high-quality reasoning traces, it has challenges as well. As it is time and cost-intensive, and it often requires expert annotations (e.g., in more challenging math problems, there needs to have expert annotators Therefore, manual annotation is time-consuming and expensive. Next to these, it is difficult to scale and not diverse enough, and actually is still lacking in diversity in reasoning styles, in the sense that it is very hard to boost diversity of skills (Limited scale, only 7K). Although there are other approaches to generate CoT, they also have their cons as well. For example, Program-Aided Language Models (PAL), which convert math problems into Python code execution traces, guarantee correctness through execution, but have less natural language reasoning and so are less intuitive. It is likewise limited to problems that can be coded.</p><p>For these reasons, there are other important considerations that should be made when generating and tuning instructions. With that caveat in mind, we should provide the model with suitable reasoning samples (CoT samples).</p><p>To do so, via Allen Institute Ai2 Recipe, such CoT samples are treated along with data mixing and curation steps based on an approach called <strong>Hybrid Data Creation</strong>, inside of which, through another approach called <strong>Persona-driven Data Synthesis, </strong>is applied for scaling and boosting diversity of problems and skills. For now, consider each persona as a skill, e.g., the title of a skill worker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*iJjO8BuoRQ8rjOOvfcSY2g.png" /><figcaption>Hybrid data creation approach via persona-driven synthesis along with data mixing &amp; selection methods</figcaption></figure><p>Let’s dig a little bit deeper. By combining the existing general problems datasets (generated through data mixing and selection method) with task-specific problems datasets (synthesized through Personas-driven Synthesis) as proxies (e.g., proxy dataset for reasoning), we aim this way to enable targeting specific skills (e.g., math, code, precise instruction following), ensure high diversity, as well as enable scaling. To do so, when creating instruction for a specific task (via curation &amp; mixing), the model also generates a task-specific question for it, containing a persona (specific-skill). This means, depending on each task’s context and in proper with its required skill (to solve the task), the model should augment a persona to the task to form the instruction generated as a specific skill question. The persona can be such as an engineer, a chemist, a 6-year-old child, and so on. As an example, in the following from the paper titled “Scaling Synthetic Data Creation with 1,000,000,000 Personas”, [Ge et al], depicts creating an instruction with a persona augmented to elucidate more:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*Q5Qic_4LYBo8v13u-2QmsQ.png" /><figcaption>Persona-driven Data generation for Scalability and Improved Diversity,[Photo from Ge et al. 2024]</figcaption></figure><p>This way, we can generate as many as persona-based, specific task instructions as needed at scale in order for our tuned model to be addressed, targeting specific skills (e.g., math, code, precise instruction following) and ensuring high diversity at scale as well. Refer to the paper for their work on a hybrid approach via Persona-driven Synthesis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Tw8iPHAaii0MCPkE1bemg.png" /><figcaption>Persona-driven Data generation for Scalability and Improved Diversity</figcaption></figure><p>After generating lots of such task-specific instructions in this way, the generated instructions are then given to another LM to solve them and, more importantly, generate a CoT for each, explaining step-by-step reasoning solution. And eventually, general-task datasets are mixed with these newly created specific-task datasets, in different proportions with each other. E.g., 20% for general datasets + 80% for specific problems, or maybe in some situations 50–50, and so on so forth as needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*u_aG9bK_IDIQa3EkazDMOw.png" /><figcaption>Hybrid data creation via mixing general purpose problems with persona-driven synthetic problems</figcaption></figure><p>From this step forward, it is our base LM turn. We give each synthetic category (a general and specific problem dataset pair) to the base LM to learn CoT reasoning and solve the problems. Performance-wise, the impact of applying a persona-driven approach shows performance scaling such that, for example, adding more persona-driven math data consistently improves MATH performance. And in fact, adding more persona-driven skill-specific-data, consistently improves the skill performance of the model. And for general reasoning tasks, using GSM8k likewise improves the performance, but less than the math dataset, but even so, adding grade-school math (hybrid synthetic data) helps it scale performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cx5s2KwRmZXx0U6JSLLPPw.png" /><figcaption>Example of Impact of Synthesizing Persona-Driven Math Data</figcaption></figure><h4><strong>1–1–4) Data Ablation Optimization</strong></h4><p>The goal here is to further performance improving of the hybrid approach by improving data quality through removing instances with no majority vote. This optimization uses the <strong>Self-consistency techniques</strong>. For more study on self-consistency, you can refer to my past article on “search and selection inference time techniques”. To do with the way that self-consistency works, the LM should after generating reasoning solutions (CoTs) via hybrid step filter the ones whose answer has higher majority votes, such that, for each sample problem given to the LM, it generates multiple reasoning paths (Solutions or say CoTs), then it applies the <strong>self-consistency-based selection</strong> on answers to filter only <strong>Most-Common-Answer reasonings</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CafeettE8RHW_gtuTAeP8A.png" /><figcaption>Improving data quality via majority voting seelction or self-consistency, rigth after hybrid mixing</figcaption></figure><p>And what it means is that those instances with no majority votes are removed from the mixed dataset (of combined problems). With that, the volume of original data (mixed combined data) reduced, yet this time, with less data, we are getting the same or better Performance on all the same datasets and tasks. For example, in Ai2’s experiment, using only 60% of the data, the Tulu model is still able to maintain the performance in Math and improve in GSM8K.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9dVh68X44X54CowYrcOIaQ.png" /><figcaption>Applying self-consistency to filter by majority-selection results in less data, but same or better performance</figcaption></figure><h4><strong>1–1–5) Capability-Driven Data Approach</strong></h4><p>Taking the Capability-Driven Data Mixing approach, Tulu SFT, as an example, is the Ai2 post-trained LLM which is built (instruction-tuned via supervised-fine-tuning) based on such <strong>chained optimizations: data creation, data mixing, hybrid persona-driven, and data ablation</strong>, combining human and synthetic data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wfCGStUlBh5CjocEk4jhDQ.png" /><figcaption>Capability-driven approach for SFT via data mixing, selection, persona-driven, and ablation</figcaption></figure><p>All models of Tulu SFTs were trained on either Llama3.0 or 3.1. e.g., Tulu3 SFT 70B parameters. For further study, reading on the Tulu SFT and their <strong>Open Instruction Tuning Recipe</strong>, please refer to their papers, e.g., “<em>Tult3 [Lambert, …, Wang, Dasigi, Hajishirzi]”</em>, <em>“Tulu 3 [Ivison, Wang et al., 2024]”</em>, and <em>“Tülu: Fully-open post-training recipe [Groeneveld et al]”</em>, and other papers during the evolution of their SFT model (reference section). Performance-wise, the impact of data mixing for the Tulu SFT model, its version 3 model, exhibits strong performance, achieving a higher average score than other comparable mixes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*31S6IhTTAr4Y_idwmn9RJw.png" /><figcaption>Performance of Tulu 3 compared to other mix-based models across skills</figcaption></figure><p>It can be inferred from the results that training on real user interactions with strong models is helpful almost across the board. Also, safety training is largely orthogonal to the other skills. and in addition, persona-based data synthesis is very useful for targeting new skills.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kiV6WStlNwjtLntvFJas0w.png" /><figcaption>Accuracy of Tulu3 model in data mixing for SFT</figcaption></figure><h4><strong>1–2)</strong> <strong>Instruction Following Training (or Preference Tuning)</strong></h4><p>Preference Tuning methodology fundamentally builds upon a supervised fine-tuning intrinsically inspired by RLHF (reinforcement learning through incorporating human feedback) to better align model outputs with human preferences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*wJBcU1dXVqBG-tHkzze3tg.png" /><figcaption>Reinforcement learning through environmet reward based on an action policy [photo credit from Ai2 papers]</figcaption></figure><p>The promising goal of RLHF has been aligning with human preferences in the sense that human preferences give a very strong training signal to have a better style of chat. i.e., these preferences have a strong influence on improving the chat-based evaluation. Learning through human preferences also continues building capabilities of skills from SFT, but lower absolute magnitude of improvements (e.g., for math capabilities). It can likewise keep improving such an LM’s capabilities targeted on SFT. Though the improvements in core task capabilities may be less pronounced.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*y411tX5Yt8DUMouPeRjtHA.png" /><figcaption>Self-Instruction Creation to Seed IFT &amp; EFT Data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*mI3vvETlZSigo0P6yvyO5A.png" /><figcaption>Preference judgments via RLHF</figcaption></figure><p>However, in some cases of RLHF, it is hard to come up with just some absolute numbers identifying that, e.g., oh, ok, this response is good (4 out of 5). Whereas it is much easier to deal with a comparison to say this response is generally better than the other one. This way, the task of annotation has become easier. As an example of this situation, given a prompt like “Explain the moon landing to a 6-year-old in a few sentences.”. We want our model to generate two responses, and then the preference instance tells us one response is better than the other one (comparing pairs of responses). and then it can be annotated by a human saying that “this response to me seems much more suitable for a 6-year-old”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*ZQcfv0yQr5yoHxyX6hBkJQ.png" /><figcaption>Learning from human feedbacks, comparing pairs of responses</figcaption></figure><blockquote><strong>It is a human preference actually!</strong></blockquote><p>The nature of data plays an important role in post-training stages, which is due to the fact that we are dealing with open-ended generations. And again, as we know, despite manual human containing high-quality reasoning traces annotation (e.g., GSM8K dataset: Annotators write step-by-step solutions), rewarding in the RLHF algorithm has challenges as well. As it is time and cost-intensive, it often requires expert annotations. e.g., in more challenging math problems, there needs to have expert annotators. Human labelers have to be very accurate in their work(rewarding) and, of course, without mistakes. In fact, response labeling is even becoming hard and harder for humans, particularly for tasks that need domain expert knowledge. Therefore, manual annotation is time-consuming and expensive. Next to these, it is difficult to scale and not diverse enough, and actually is still lacking in diversity in reasoning styles, in the sense that it is very hard to boost diversity of skills (Limited scale, only 7K).</p><p>Idea: Hence, it is better to help LMs to help themselves on their own. What if we have the model reward its responses by itself? But here, we cannot use the same type of algorithms as SFT to deal with this type of preference data. In fact, we need RLHF algorithms to cope with such a situation, even though, as mentioned before, we replace traditional reinforcement learning (RLHF) with an RLAIF that implicitly models human preferences, i.e., AI in the loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*DF0KgXR8xxQFMMxatGaqLg.png" /><figcaption>Learning from AI feedbacks, comparing pairs of responses</figcaption></figure><h3><strong>Preference Tuning Optimization via RLAIF</strong></h3><p>With regard to the LLM-as-a-Judge method that we have already applied to score and make ranking of the responses, the idea could be replacing RLHF with LLM-as-a-Judge, replacing human feedback with LLM feedback so that the rewarding functionality is done by the LM itself. To do so, by using the RLAIF algorithm, instead of humans, we can have another AI model (GPT-4o, Claude Sonnet, …) to evaluate which of these responses are better for a 6-year-old. With that, LLM improves itself by assigning rewards to its own outputs and can keep optimizing, whose goal same as RLHF is maximizing the reward, i.e., achieving the maximum reward for a response. This way, we can enable AI in the loop when compared with the base RLHF:</p><ul><li>The <strong>Reward</strong> here is the output of the judge model, which would be both generated responses and scores as preference feedback, meaning preference data that are pairs of a prompt &amp; responses alongside their preferences each.</li><li><strong>Environment</strong> is actually a <strong>Reward Model</strong> is a NN that is trained (fed with preference data and prompts) to tell how good the model tries to model the preferences, meaning for a given prompt, which response is better.</li><li>The<strong> State </strong>of the environment is here the<strong> Task or Prompt</strong>, and includes the instructions and responses (generated in the previous self-instruction step) along with <strong>policy training data, </strong>which is the algorithm for generating the next action for better response. i.e., <strong>next state</strong> is the <strong>next prompt</strong></li><li><strong>Policy Model</strong> here is the <strong>Base LM,</strong> which is an <strong>RL Model</strong> fed with prompts and policy training data, so that it can learn policies in addition to prompts (SFT on policies), so that it is able to generate the next token based on the policy algorithm. Its first action as the first output response is not necessarily optimal; that is why the responses should iteratively be optimized. This base RL model is actually the <strong>State of the World</strong> that is updated each time by receiving rewards. This means that the reward model iteratively gives feedback to the policy model that learns (understands) based on a reward, which action (next token) to generate. And in the same way, it is iteratively optimizing the response (next token) based on the reward</li><li>The <strong>Action</strong> is the <strong>Response (Answers or Next Token)</strong> that is generated by the policy model</li><li><strong>Reward/feedback</strong> is the score given by the reward model to each action (response)</li><li><strong>Loop</strong> is the <strong>Iterations</strong> between the reward and policy models</li><li><strong>(X, Y)</strong> are the <strong>(prompts, responses)</strong> pairs, and <strong>(X, Y’)</strong> are the (prompt-response, reward)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hhcA0HvPZDItv9aawUhtJw.png" /><figcaption>Reinforcement learning through AI reward based on a policy LM and a reward LM, [Christiano et al., 2017] [photo credit from Ai2 papers]</figcaption></figure><p>The aim of training the base LM (policy model) here is that it becomes as close as possible to preference data. Therefore, this <strong>Instruction Following Training</strong> step is going to conduct reinforcement learning through the AI feedback (<strong>RLAIF</strong>) mechanism for us. It leverages the preference dataset (EFT data) yielded in the first step, and seeds them to the model (here as <strong>Reward model</strong>) to <strong>Evaluation-Following-Training</strong>, after which we go through iterative training to enable <strong>Instruction-following-training</strong>. At first, having EFT dataset, given a prompt and k responses along with their scores, the base LM (instruction-tuned) binarizes the response preferences in a <strong><em>[chosen completion, rejected completion]</em></strong> pair way so, it selects the highest scoring response as the winning one (chosen), and lowest scoring response as the losing one (rejected) to form each preference pair (based on answer correct vs. not). This <strong>selection</strong> mechanism is based on whether each response is correct or not, so that this reward model can tell us what the score of this completion is. And as the output here, we have <strong><em>{ XI , ywin , yloss , rwin , rloss }</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*8QkOXbJhaEudnwhmInCAhg.png" /><figcaption>EFT Selection in order for Instruction Following to Do Optimal Preference Training</figcaption></figure><p>Now, with these exemplars scored already, we should seed them into the base LM to learn them too.</p><h3>Further Improvements:</h3><blockquote><strong><em>There are optimization algorithms for RLAIF, particularly aiming at preference tuning optimization; we are going to explore them in my next articles ahead, continuing the progress of this subject “</em>Introspection &amp; Self-Improvement Algorithms: LM’s Self-learning to Self-Reason”.</strong></blockquote><h3>References &amp; Credits:</h3><p><a href="https://arxiv.org/abs/2404.19733">Iterative Reasoning Preference Optimization</a></p><p><a href="https://arxiv.org/abs/2310.03716">A Long Way to Go: Investigating Length Correlations in RLHF</a></p><p><a href="https://rdi.berkeley.edu/">The Berkeley Center for Responsible, Decentralized Intelligence (RDI)</a></p><p><a href="https://rdi.berkeley.edu/adv-llm-agents/sp25">Berkeley RDI, Advanced LLM Agents</a></p><p><a href="https://www.allenai.org/">Allen Institute Ai2</a></p><p><a href="https://arxiv.org/abs/2306.06070">Mind2Web: Towards a Generalist Agent for the Web</a></p><p><a href="https://arxiv.org/abs/1706.03741">Deep reinforcement learning from human preferences</a></p><p><a href="https://arxiv.org/abs/2309.03409">Large Language Models as Optimizers</a></p><p><a href="https://arxiv.org/abs/2310.01798">Large Language Models Cannot Self-Correct Reasoning Yet</a></p><p><a href="https://arxiv.org/abs/2402.03620">Self-Discover: Large Language Models Self-Compose Reasoning Structures</a></p><p><a href="https://arxiv.org/abs/2309.11495">Chain-of-Verification Reduces Hallucination in Large Language Models</a></p><p><a href="https://arxiv.org/abs/2306.05685">Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena</a></p><p><a href="https://aclanthology.org/2025.acl-long.355/">Hybrid Preferences: Learning to Route Instances for Human vs. AI Feedback</a></p><p><a href="https://arxiv.org/abs/2304.05128">Teaching Large Language Models to Self-Debug</a></p><p><a href="https://arxiv.org/abs/2212.10560">Self-Instruct: Aligning Language Models with Self-Generated Instructions</a></p><p><a href="https://arxiv.org/abs/2305.20050">Let’s Verify Step by Step</a></p><p><a href="https://arxiv.org/abs/2306.04751">How Far Can Camels Go? Exploring the State of Instruction Tuning on Open Resources</a></p><p><a href="https://arxiv.org/abs/2311.10702">Camels in a Changing Climate: Enhancing LM Adaptation with Tulu 2</a></p><p><a href="https://arxiv.org/abs/2306.04751">Ai2, Tülu 1 , How Far Can Camels Go? Exploring the State of Instruction Tuning on Open Resources</a></p><p><a href="https://arxiv.org/abs/2311.11829">System 2 Attention (is something you might need too)</a></p><p><a href="https://arxiv.org/abs/2402.08939">Premise Order Matters in Reasoning with Large Language Models</a></p><p><a href="https://arxiv.org/abs/2402.12875">Chain of Thought Empowers Transformers to Solve Inherently Serial Problems</a></p><p><a href="https://arxiv.org/abs/2402.10200">Chain-of-Thought Reasoning Without Prompting</a></p><p><a href="https://openai.com/index/learning-to-reason-with-llms/">OpenAI, Learning to reason with LLMs</a></p><p><a href="https://platform.openai.com/docs/guides/reasoning-best-practices">Reasoning best practices</a></p><p><a href="https://arxiv.org/abs/2304.11477">LLM+P: Empowering Large Language Models with Optimal Planning Proficiency</a></p><p><a href="https://arxiv.org/abs/2310.15123">Branch-Solve-Merge Improves Large Language Model Evaluation and Generation</a></p><p><a href="https://arxiv.org/abs/2307.09288">Llama 2: Open Foundation and Fine-Tuned Chat Models</a></p><p><a href="https://arxiv.org/abs/2205.11916">Large Language Models are Zero-Shot Reasoners</a></p><p><a href="https://agenticai-learning.org/f24">Berkeley RDI Large Language Model Agent</a></p><p><a href="https://arxiv.org/abs/2201.11903">Chain-of-Thought Prompting Elicits Reasoning in Large Language Models</a></p><p><a href="https://arxiv.org/abs/1706.03762">Attention Is All You Need</a></p><p><a href="https://arxiv.org/abs/2206.07682">Emergent Abilities of Large Language Models</a></p><p><a href="https://arxiv.org/abs/2204.05862">Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedback</a></p><p><a href="https://arxiv.org/abs/2203.02155">Training language models to follow instructions with human feedback</a></p><p><a href="https://www.nature.com/articles/nature14236">Human-level control through deep reinforcement learning</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=708454126ad8" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/introspection-algorithms-self-learning-to-self-reason-part-1-708454126ad8">Introspection &amp; Self-Improvement Algorithms: LM&#39;s Self-learning to Self-Reason — Part 1</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Search and Selection Inference-Time Techniques for Language Reasoning Agents]]></title>
            <link>https://medium.com/threadsafe/search-and-selection-inference-time-techniques-for-language-reasoning-agents-0e64d419bef6?source=rss-6acfbf0d8c9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e64d419bef6</guid>
            <category><![CDATA[design-thinking]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Hamid Nafiyan]]></dc:creator>
            <pubDate>Wed, 24 Sep 2025 16:19:57 GMT</pubDate>
            <atom:updated>2025-11-22T13:16:53.824Z</atom:updated>
            <content:encoded><![CDATA[<p>Increasing the Width of Solution Space, the Rationale needed for Performance-Gain on Challenging Tasks</p><h3>Introduction</h3><p>The problem with existing LLMs was that they achieved less than 25% accuracy if no special inference-time techniques were used. In fact, without post-training techniques, the performance of standard prompting (few-shot exemplars) is pretty poor on reasoning. Because standard few-shot prompts only provide information on the final solution “format” but not the “rationale” needed to reach the solution. So obviously the incentive here is to achieve impressive performance across various challenging reasoning tasks in math, coding, STEM, etc. This motivates the other end of the spectrum, which is chain-of-thought. In fact, the “<strong>long CoT</strong>” (more token budget) could provide clues to gaining a better solution to get a more accurate final answer. That is, we want the LLM to think more and longer. Remember, though, thinking time can be calculated as latency (milliseconds) or budget (number of generated tokens). So, we consider scaling the token budget as the core idea to trigger the LLM to generate a long chain-of-thought (CoT), which means generating long hidden thoughts before generating the solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*h1sirbCvcThZkBPjgw8M6g.png" /><figcaption>Hidden thought before generating the solution.PNG</figcaption></figure><p>The further we scale out the inference time cost (more expensive computation cost), the higher accuracy model can achieve, and this way LLM’s performance improves with more inference-time compute. However, the inference-time computation shows an exponential cost-increase in proportion of the higher accuracies, meaning the model can perform in ideal case when the inference-time computation cost would not be cared so much!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*8V1XLaTM3BSPIuVwpGFtNQ.png" /><figcaption>Performance improves with more inference-time compute.PNG</figcaption></figure><p>Following my last article, I am going to explore some other Inference-time techniques on <strong>Search and Selection</strong> to try to apply them to achieve impressive performance across various challenging reasoning tasks. But again, before digging into these techniques and methods, I recommend to refer to my article on “<a href="https://medium.com/@hamid.n.d/on-lms-reasoning-strategies-approaches-f843651b7bf8">LLMs’ Reasoning Strategy Approaches</a>” to give you a flavor of the where and the when of these techniques in order to better leveraging the how to. I personally recommend you consider reasoning strategies just as <strong>Analytical Algorithmic Approaches</strong> for these techniques and methods, such that you distinguish when to delegate these patterns to those techniques. In my previous article on “<a href="https://medium.com/@hamid.n.d/on-llm-reasonings-inference-time-prompting-techniques-bf9d590ca554">Inference-Time Prompting Techniques,</a>” we explored the <strong>Prompting techniques for scaling the token budget</strong>. Their goal is using more-efficiently token budget (reducing token cost) to generate a single solution. <strong>Search and Selection techniques</strong>, on the other hand, aim to search and select from multiple candidates (solutions) through increasing the width of solution space exploration. So this is essentially their main goal.</p><blockquote>Please refer to the references &amp; credits of the material covered in this article as well. Also note that all photos are screenshots taken from papers to which referred in this article.</blockquote><h3><strong>Inference-Time Search and Selection Techniques</strong></h3><p>The problem with the CoT is that LLM generates only one solution for each problem, meaning the model greedy-decodes a single solution. In fact, in case of incorrectness of this single solution, and since the model relies only on that solution, if the model is limited to only one solution to solve a problem, then the model might make a mistake. Therefore, this greedy decoding can most likely be problematic. With that caveat in mind, we should not limit the LLM to generating only one solution per problem! The main idea here is that the model had better sample multiple solution candidates for each problem, and eventually selects a solution which has better performance in order to generate the final response as well as to reduce mistakes from a single prediction.</p><p>So, to address this capability, our goal focuses on increasing the width to explore the solution space, as exploring multiple branches allows the LLM to recover from mistakes in a single generation. And another optimization we can take advantage of is to further scale the inference-time compute by sampling multiple branches in the solution space. To do so in a step-by-step way, we have the model first generate multiple candidate solutions per problem (this is done through sampling previous relevant problems as an analogical reasoner), at each step of which, we get it to generate multiple potential next reasoning steps given the current (partial) thought. That is, our model’s performance has a higher upper bound as there might be some solution by selecting which the performance probably becomes even better.</p><p>However, the challenge is how to select the best response from multiple candidates. Since in most cases, we do not have an oracle scorer at inference time, one way could be giving all sampled solutions to a human user, and then get them to score and select the desired fit solution of their choosing. But even so, the ideal way would be we get the model to score and choose the better solution, and then generate the final answer based on it.</p><p>Before getting into the search and selection techniques, let’s briefly explain LLMs’ internal mechanism for solution selection.</p><p>Generally, LLMs on-premises use three methods to produce responses to reach the final answer for the user problem:</p><h4><strong>1-</strong> <strong>Greedy decoding (single path)</strong></h4><p>applying greedy decoding for all prompt variants of a problem. There is only one solution for each problem.</p><h4><strong>2- Oracle-based Certainty (Multi-paths)</strong></h4><p>This method infers multiple CoT reasoning paths and then generates multiple solutions. The next step is giving a user all solutions and getting it (human) to score all solutions and then select a fit solution of their choosing. This method puts emphasis on selecting the final answer from the solutions based on higher certainty.</p><h4><strong>3-</strong> <strong>Sample-and-Rank (Multi-path)</strong></h4><p>It is actually sampling and reranking responses based on a desired consistency criterion. After generating response paths, the LLM puts a probability log on each reasoning path, and then selects the response with the highest log probability</p><h3><strong>LLMs as Bayes Models (Probability Models)</strong></h3><blockquote>LLMs are, by nature, probabilistic models to generate next tokens. They do this calculation through Bayes&#39; Rule. This way, a response can be generated by the following semi-heuristic search and selection techniques:</blockquote><h4><strong>Technique 1: Most-Frequent Reasoning</strong></h4><p>What LLM does in the decoding process of tokens is by using the Argmax function as:</p><blockquote><strong>argmax_P( reasoning_path, final answer | problem )</strong></blockquote><p>Where the reasoning_path parameter is the response samples that the LLM itself generates through the past relevant problems. Therefore, this formula is telling us that our LLM, in order to reach the final answer of the problem (stated in the user prompt) should first generate multiple sample responses, and then select the most frequent one among them. In other words, the most frequent reasoning generated path is treated as the most probable candidate for solving the task, and then reaching the final answer. But even so, what we want is actually <strong>Most-frequent appeared final answer! meaning the most probable answer is just enough for us</strong>. And this motivates the other end of the spectrum, which is <strong>Consistency-based selection (Majority voting) or the Most-frequent answer approach</strong>. This way, our model not only itself samples multiple relevant reasoning paths but also solves all of them itself, and as such, it is able to select the most frequent final answer among its own responses.</p><blockquote><em>“most-frequent answer” or “most-frequent reasoning”? which one??</em></blockquote><h4><strong>Technique 2:</strong> <strong>Self-Consistency Decoding (Optimization of Consistency-based Majority Voting)</strong></h4><p>Taking the most-frequent answer method by its definition aforementioned, the selection is only based on the final answer; the reasoning paths do not need to be the same across different sampled responses. The aim of self-consistency approach is to select the response with the most consistent final answer. So here, reasoning paths can be the same or different, yet selection is only based on the final answer. With this definition, reasoning path is even though important, self-consistency is more important.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*CskA5MrgFg16lbWSfglrTA.png" /><figcaption>Self-Consistency vs Greedy decoding — select the response with the most consistent final answer</figcaption></figure><blockquote><strong><em>In fact, in the current and anticipated state of AI/AGI, this method is a highly-referred-to approach, aboard which we expect the solutions place emphasis more on a self-consistent model, meaning rely as much as possible on its own reasoning-answering capability rather than others’.</em></strong></blockquote><p>In consequence of self-consistency, the process of step-by-step reasoning would be optimized. Performance-wise, being direct and highly correlated with the accuracy, the more consistent it is, the higher the accuracy we have. In other words, if more sampled responses lead to the same final answer, the LLM is more certain with its predicted conclusion, and besides, the aggregated solution is more likely to be correct. Hence, more consistent results are more likely to be correct.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*roL-8oOOwws9X9wxEaeqrQ.png" /><figcaption>Consistency is highly correlated with the accuracy</figcaption></figure><p>On top of that, self-consistency performance scales with more samples, as its performance scales much better than probability-based ranking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A54FcGkKTJ2h9AvoZHTJQA.png" /><figcaption>Self-Consistency performance scales with more samples, much better than probability-based ranking</figcaption></figure><p>But even so, sampling diverse responses is crucial to self-consistency for the sake of performance. In order that self-consistency maintains its high-performance with sample scaling, the sampling method needs to ensure the response diversity, e.g., using a high temperature, nucleus sampling, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*SytWuS7M0SmpVQvvR6T2kA.png" /><figcaption>Sampling diverse responses is crucial to self-consistency for the sake of performance</figcaption></figure><p>Meanwhile, the sample generation here is of course through generating multiple sample responses by its own relevant problems instead of generating multiple responses through reasoning paths. And the calculation of tokenization is just by the same as the reasoning paths, such that each sample response is individually tokenized, then the probability of each is calculated, and consequently the token with the highest probability is outputted as the final answer selected. That is why this method is also known as <strong>Maximum Marginal Inference</strong> or <strong>Most-common answer </strong>(applying MMI on generated sample paths and selecting an MCA). This is a simple, effective, and general principle for selecting Most-common answer by` marginalizing out different/same reasoning paths The Argmax function is thereby the probability of the final answer given the problem (user prompt):</p><blockquote><strong>argmax_P (final answer | problem )</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*zFHW7HMG9EStBFiQY6NbSg.png" /><figcaption>Self-Consistency boosts the performance across models and benchmarks</figcaption></figure><p>In code generation, for instance, taking an execution consistency approach based on MMI, we can first cluster the codes based on filtering their execution results. This way we have a higher number of sample responses &amp;&amp; more diverse samples for given tasks. After that, according to the problem (current task), LLM candidates retrieve the relevant codes for the user&#39;s problem from those clusters. With that, clustering predicted code based on the consistency of execution results. Finally, the model selects (predicts) a code with higher execution-consistency (without error). As shown in the following figure, clustering provides additional performance gain over filtering only yet still there is a gap from the oracle selection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*GU8z0Vekge1mYJgUJnI3pA.png" /><figcaption>Consistency-based code selection using a 1B encoder-decoder model</figcaption></figure><h4><strong>Technique 3:</strong> <strong>Universal Self-consistency (USC)</strong></h4><p>The limitation of self-consistency decoding is to require an answer extraction process. That is, in the case of open-ended generation like summarization and QA, utilizing self-consistency is inapplicable. This is because it is difficult for the model to select the correct final answer (best next token) among responses. So, the question is that can we enable consistency-based decoding for free-form generation? The idea here is that instead of a process for extraction, we ask LLMs to perform consistency-based selection. Provided we give the model a criterion for measuring based on which it can more easily select the correct final answer, to do so, in the prompt, we simply ask the model to answer the question based on the given consistency criterion. For example, a USC prompt to the model along with the task could be: “<em>select the most consistent response based on majority consensus</em>”. And thus, the model looks at candidate responses and selects the final answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OFd3J0yALXtVZgV4lSbB0w.png" /><figcaption>Universal self-consistency, asking the LLM to perform consistency-based selection</figcaption></figure><p>This way, USC does not require answer extraction and code execution. Other important pros, though, are improving the performance on open-ended generation (summarization, QA), where the original self-consistency is inapplicable. The USC performance in such cases is bounded by the long-context tokenization capability. USC likewise matches self-consistency performance on math reasoning and coding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*NauIL4aA66bwvTIsINlG0g.png" /><figcaption>USC performance on open-ended generations, and math reasoning and coding</figcaption></figure><h3><strong>A potential drawback: Solution-level response selection</strong></h3><p>All of these aforementioned methods so far handle the process of response selection on the solution level. It is when the model generates all reasoning paths and reaches all solutions. After that, the model starts off selecting amongst them, either selecting a consistent reasoning path or choosing most-common answer. This way can waste the throughput to some extent. Because although democracy, there might be some solution(s) weak or incorrect or low majority, some processing power is consumed for (wasting of CPU/GPU consumption). In consequence, the throughput cost for such solutions increases as a whole taken together. So, instead of doing response selection only after the full responses are generated, it would be better to leverage some method on the step-level so that we can select responses on the step-level (<strong>Step-wise Response Selection</strong>).</p><h4><strong>Technique 4:</strong> <strong>LLM-based Verifiers (Reward/Ranker models)</strong></h4><p>These models are an improvement over the consistency-based selection method by training LLM rankers. The mechanism here is to train an LLM to rank responses such that it can judge the answer quality and say which responses are more likely to be accurate. There are two types of LLM-based verifiers/reward models.</p><ul><li><strong>Outcome-supervised Reward Models (ORM):</strong> Verify at the solution level (solution space), meaning, the model tells whether a solution is correct or not, and gives a score to each solution.</li><li><strong>Process-supervised Reward Models (PRM):</strong> Verify at the step level for each solution, meaning the model tells whether each solution’s step is accurate or not, and finally give a score to each step.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*nm4MWjnqmZNXg1b8-o5_UA.png" /><figcaption>Outcome-supervised Reward Model (ORM) to verify and score at the solution level</figcaption></figure><p>And from performance respect, LLM-based verifiers outperform consistency-based selection (Majority voting). As an aside, the process-supervised reward model (PRM) scales better with more samples. But even so, the performance is highly dependent on the verifier quality, as the same verifier might not generalize across tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*NpAwQ5bcMrNoabgyp_n8wQ.png" /><figcaption>LLM-based verifiers outperform consistency-based selection</figcaption></figure><h4><strong>Technique 5:</strong> <strong>Tree of thought (ToT) or Tree-Search-based Selection:</strong></h4><p>Taking the Step-wise Response Selection approach into account, still not even does reward/ranker model method fully utilize a step-wise scorer, neither does the original consistency-based! The idea of the ToT approach is a more fine-grained way to break down a complex task into subtasks and then optimally process each subtask individually, taking inspiration from both decomposition and tree traversal algorithms. The algorithm leverages a step-wise scorer to score each solution and then applies the response-selection process in a more efficient way, yet still as certain as previous SC methods. Having this step-wise scorer function, we can perform tree search on LLM’s thoughts, in such a way that, instead of waiting for a solution become complete, we can, during such a search process at step-level, prioritize exploration of more promising partial solutions, actually early steps of which are more promising.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*Jb_8IhuA20H23JgDqIEbvw.png" /><figcaption>ToT step-wise selection instead of SC solution-level selection</figcaption></figure><p>Here, the first step of each solution is a root having a tree relationship with all other steps of that solution. The next steps in the solution tree, by this definition, can be its nodes, each of which can contain multiple branches for next-step exploration. That is, the model doesn’t have to pass all the steps to the end. As it in each level(step) picks a subtask with the best score in each level (step), and traverses the tree until the solution is completed. So, this is a more fine-grained way through which those solutions that are not optimal are not selected as their steps in the tree are not traversed, and this results in eliminating non-promising paths. And hence, many inefficient solutions are not processed at all. This, in turn, makes the response-selection process cost-efficient. This method is also called<strong> multiple parallel chains</strong>,<strong> </strong>because many CoTs are simultaneously being evolved, and eventually ending up with a CoT, during its steps (sub-tasks) gain higher scores. As an example, for solving the task in the game of 24, at each step, we prompt the LLM to propose possible next thinking steps (thought generation), and also prompt the LLM to evaluate how promising the current state is (thought evaluation).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*poFdN6PyxPaXOsbqCsXDTg.png" /><figcaption>Tree-of-thought for game of 24</figcaption></figure><h4><strong>Voting-based state evaluation and selection in ToT</strong></h4><p>For ToT to work as efficiently as aforementioned, the algorithm is iteratively processed in two stages: thought generation and thought evaluation. At first, the given prompt asks it to propose some sub-tasks. Thus, LLM on its own generates some sample responses as the next steps (thought generation). The model does this through relevant past problems. in the evaluation stage, another given prompt asks the model to evaluate how promising each of your suggestion reasons is, and then give each of them a score (using the scorer function). Notice also that each proposed step is a candidate, and the model has to pick one to continue on the solving path (state evaluation on candidates and select the best state among candidates). To do so, in the scorer function’s mechanism, LLM votes multiple times, then selects the majority vote as the final choice, such that LLM itself analyzes each choice (step) in detail, and repeats this evaluation multiple times, so as to vote each choice multiple times (e.g., 5 times voting for each step). After that, the model selects the state that gains the majority vote as the final choice. From here on, based on the selected step, it keeps traversing the tree in iterative stages (generation &amp; evaluation) until completing the solution, so that it reaches the final answer (best solution with best answer).</p><p>In the ToT mechanism, we can utilize breadth-first search, depth-first search, and best-first search for tree search. Going further, we can integrate more advanced search algorithms, e.g., Monte-Carlo Tree Search (MCTS).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*D6Y9I83W-pM9nfadu5HHGw.png" /><figcaption>ToT Voting-based state evaluation</figcaption></figure><p>Performance-wise, ToT with breadth-first search (BFS) scales better than standard prompting and CoT, in terms of the number of visited nodes in solution steps and therefore w.r.t. token budget. As with increasing the nodes, the accuracy scales better. Hence, we can further scale the inference-time compute by sampling multiple branches in the solution space</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*O3ZPJwDi7lhCWZqJlJr4nA.png" /><figcaption>Tree-of-thought results, for game of 24</figcaption></figure><p>As an important design consideration, though, in order to utilize the ToT method, we need to use a good LLM besides designing a prompt schema for self-evaluation, as when LLM self-evaluation works well, search in the partial solution space can help. In the following example, again, the game of 24, ToT results are depicted.</p><h3><strong>Conclusion:</strong></h3><blockquote><strong>Comparison, Certainty</strong></blockquote><p>Self-consistency boosts the performance across models and benchmarks. Factors of scaling we can investigate include:</p><ul><li>Number of sample responses (regardless of the number and diversity of reasoning paths)</li><li>Diversity of sample responses (~ Number of reasoning paths)</li><li>Token budget (efficient use of token budget to reduce token cost)</li></ul><p>Notes here are that:</p><ul><li>Greedy decode method (single path), even with an increasing number of sample responses, has almost a steady performance. i.e., however many sample responses are generated, their accuracy in selecting the final answer is still low or on average.</li><li>Sampler-ranker models gain better performance as the number of samples is increased, but they plateau. For example, its performance scales with increasing samples from 10 to more, yet with 20 samples, it doesn’t exhibit high accuracy anymore in selecting the final answer</li><li>But in the case of SC, a higher number of sample responses takes its performance to new heights, and it scales much more than the probability-based models, e.g., up to 40 sample responses. In other words, in the case of generating 40 responses, SC can still pick the more accurate final answer among them. As an aside, although it exhibits weaker performance in some benchmarks (~ 24%, 55% for instance), it is still higher than other inference scaling techniques. As mentioned, for SC to enhance its performance, we can train the model as a verifier. If the SC model generates samples diverse enough, meaning it generates more reasoning paths, then the performance improves. To do so, we can use ways like temperature parameter, nucleus sampling, etc, to ensure the diversity level of samples.</li><li>Use USC for improving performance on open-ended generations. It gains better performance in math reasoning and coding. And the performance is limited by the long-context tokenization capability</li><li>PRM scales better with more samples than the basic consistency model. However, the performance of PRM &amp; ORM models is highly dependent on the verifier quality</li><li>ToT models with breadth-first search (BFS) scale better than standard prompting and CoT, in terms of the number of visited nodes in solution steps and therefore w.r.t. token budget (this does not necessarily apply to increasing the number of sample responses). As with increasing the nodes, their accuracy scales better. Hence, we can further scale the inference-time compute by sampling multiple branches in the solution space</li><li>With respect to certainty, due to the fact that SC, in terms of response samples, has a direct relation with accuracy. This means the more responses that result in a correct answer are (higher consistency of final answer), the higher the accuracy the model has. In other words, an SC model is more certain in its prediction with a highly consistent final answer. And in turn, the model can generate the correct final answer with more certainty. On the other hand, the more consistent the final answer is, the more probable it is that its solution (the answer’s own reasoning path) is correct. And this indicates the model tells us the solution (reasoning path) using which it reaches the final answer is more likely to be a correct way of solving.</li><li>With regard to generalization and certainty, although an SC model (basic, verifier, ranker) is capable of applying to different tasks (domains), special consideration should be made that a verifier/ranker model cannot necessarily generalize well on different tasks. Hence, about these models, we need to qualitatively design not only an appropriate training strategy but also suitable training data, so as to generalize well in different domains.</li></ul><h3><strong>References &amp; Credits:</strong></h3><p><a href="https://arxiv.org/abs/2203.11171">Self-Consistency Improves Chain of Thought Reasoning in Language Models</a></p><p><a href="https://arxiv.org/abs/2203.07814">Competition-level Code Generation with AlphaCode</a></p><p><a href="https://arxiv.org/abs/2311.17311">Universal Self-Consistency for Large Language Model Generation</a></p><p><a href="https://arxiv.org/abs/2110.14168">Training Verifiers to Solve Math Word Problems</a></p><p><a href="https://arxiv.org/abs/2305.20050">Let’s Verify Step by Step</a></p><p><a href="https://arxiv.org/abs/2305.10601">Tree of Thoughts: Deliberate Problem Solving with Large Language Models</a></p><p><a href="https://arxiv.org/abs/2310.01798">Large Language Models Cannot Self-Correct Reasoning Yet</a></p><p><a href="https://arxiv.org/abs/2309.03409">Large Language Models as Optimizers</a></p><p><a href="https://rdi.berkeley.edu/adv-llm-agents/sp25">Berkeley RDI, Advanced LLM Agents</a></p><p><a href="https://agenticai-learning.org/f24">Berkeley RDI, Agentic AI</a></p><p><a href="https://arxiv.org/abs/2402.08939">Premise Order Matters in Reasoning with Large Language Models</a></p><p><a href="https://arxiv.org/html/2402.16837v1">Do Large Language Models Latently Perform Multi-Hop Reasoning?</a></p><p><a href="https://arxiv.org/abs/2402.10200">Chain-of-Thought Reasoning Without Prompting</a></p><p><a href="https://arxiv.org/abs/2309.11495">Chain-of-Verification Reduces Hallucination in Large Language Models</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e64d419bef6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/threadsafe/search-and-selection-inference-time-techniques-for-language-reasoning-agents-0e64d419bef6">Search and Selection Inference-Time Techniques for Language Reasoning Agents</a> was originally published in <a href="https://medium.com/threadsafe">ThreadSafe</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inference-time Prompting Techniques for Language Reasoning Agents]]></title>
            <link>https://levelup.gitconnected.com/on-llm-reasonings-inference-time-prompting-techniques-bf9d590ca554?source=rss-6acfbf0d8c9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf9d590ca554</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Hamid Nafiyan]]></dc:creator>
            <pubDate>Thu, 18 Sep 2025 14:10:35 GMT</pubDate>
            <atom:updated>2025-12-09T13:14:30.647Z</atom:updated>
            <content:encoded><![CDATA[<h3>Inference-Time Prompting Techniques for Language Reasoning Agents</h3><p>In my three articles ahead, I am going to explore some mechanisms called Inference-time techniques to try to apply them to achieve impressive performance across various challenging reasoning tasks. But, before digging into these techniques and methods, I recommend referring to my article on “<a href="https://medium.com/@hamid.n.d/on-lms-reasoning-strategies-approaches-f843651b7bf8">LLMs’ Reasoning Strategies Approaches</a>” to give you a flavor of the where and the when of these techniques in order to better leverage the how to. I personally recommend you consider reasoning strategies just as <strong>Analytical Algorithmic Approaches</strong> for these techniques and methods, such that you distinguish when to delegate these patterns to those techniques.</p><p>Going through the following definitions section, we don’t want to reexplain concepts, but we want to just make sure that we agree on them, and we then in a later part of the article, come back and move on to our main subject, this article’s purpose; Prompting Techniques.</p><blockquote>Please refer to the references &amp; credits of the material covered in this article as well. Also note that all photos are screenshots taken from papers to which referred in this article.</blockquote><h3><strong>Definitions</strong></h3><p><strong>1–1. Language agent vs Neural agent: </strong>Language agents have high expressiveness, encoding almost anything, especially verbalizable parts of the world</p><ul><li>Implicit reasoning: language-based inferences are semi-implicit reasoning, fuzzy, semi-explicit, and flexible. over NN’s implicit reasoning, which is due to parametric inferences that are stochastic, implicit, and rigid</li><li>High adaptability: the strong prior is from LLMs and language use, over medium adaptability of NNs that are data-driven but sample-inefficient.</li><li>These are just for distinguishing, not as pros &amp; cons. As each choice has had its own capabilities in relevant scenarios, particularly when it comes to sparsity, distillation, teacher-student, and single network.</li></ul><p><strong>1–2. Reasoning Agent: </strong>Reasoning agent, due to the ability of Thinking, differs from LLM, and besides LLM’s properties, it involves the following:</p><ul><li>Memory (storing new experience over previous experience)</li><li>Learning (Fine-tuning: storing new knowledge and skills over previous knowledge)</li><li>Planning</li><li>Multi-agent setting</li><li>New applications, tools, tasks, and benchmarks: Web browsing, computer use, personal assistance, code generation, software engineering, workflow automation, robotics, scientific discovery, deep research (E.g., PerplexityPro, Google deep research, OpenAI deep research), RAG, API call, domain database, tool-use, and etc.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*BwvO7kroD0Rl_ovW9d8ADA.png" /><figcaption>Language agent vs Reasonig Agent</figcaption></figure><p>We integrate LLMs into AI agents to build reasoning agents so they can use language for reasoning and communication:</p><ul><li>Communication is Instruction following, in-context learning(*-shot), and output customization</li><li>Acting without reasoning (Act-only) cannot explore systematically or incorporate feedback</li></ul><p><strong>1–2–1. Agentic AI and LLMs Agents</strong></p><p>The core idea that is the basis for the Agentic Approach for LLMs is:</p><blockquote>“<strong>Empowering LLMs with the agent framework, which enables LLMs to interact with the environment<em>”</em></strong>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*eVTBJPUHiuNgjtddSco71w.png" /><figcaption>AI Agent — Empowering LLMs with the agent framework, enabling LLMs to interact with the environment.</figcaption></figure><p>But why agentic? This is mainly stemming from the reasons that can include, but are not limited to:</p><ul><li><strong>Solving real-world tasks needs a trial-and-error process:</strong> LLMs in real-world tasks have weaknesses because LLMs need to interact with the new environment to understand the successes &amp; failures of different actions. That is why an agent can interact with the environment and get feedback from it. The agent has its own internal memory and revises it when giving LLM FBs received from the environment. By memory revision &amp; using tool-use alongside RAG, the agent’s capability is improved/expanded concerning making more informed decisions.</li><li><strong>Leveraging external tools and retrieving from external knowledge expands LLM’s capabilities</strong></li><li><strong>Agent workflow facilitates complex tasks:</strong> when it comes to complex tasks (like desomposition, allocation, division, …) or workflows, designing workflows using agents facilitates the accomplishment of such complex tasks (including task decomposition, allocation of subtasks to specialized modules, division of labor for project collaboration between different specialized modules, and multi-agent settings to get better responses).</li></ul><blockquote><strong>In all tasks, the LLM is the brain of the agent, such that the agent leverages its LLM for reasoning and planning</strong></blockquote><p><strong>1–3. ReAct </strong>is a paradigm of agents that reason and act. it is actually a Synergy of reasoning and acting, a simple and intuitive trajectory of agent thoughts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0wDfLE8N6ln3sCniIJGv8A.png" /><figcaption>ReActing, a Synergy of reasoning and acting</figcaption></figure><ul><li>The purpose of reasoning is actually for better replanning and better ReActing</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cgwuj584dWx6pg9yFsYttg.png" /><figcaption>Synergy, acting support reasoning, reasoning guides acting</figcaption></figure><ul><li>ReAcing supports One-shot prompting, Few-shot prompting, and Fine-tuning</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qYGZfm4XMGJ2BALHcvFOvQ.png" /><figcaption>ReAct prompting</figcaption></figure><ul><li>ReAct also Enables Systematic Exploration. it is general and effective across domains, and involves either new applications/tasks/benchmarks (such as Web browsing, Software engineering, Scientific discovery, etc) or new methods of memory, learning, planning, multi-agent, etc.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*6JbN2aTCrkWHTz3miAS32w.png" /><figcaption>ReAct is general and effective across domains</figcaption></figure><ul><li><strong>FireAct</strong> <strong>or Fine-tuning ReAct</strong> is a training principle for language agent fine-tuning. It establishes a model-agent synergy that improves “agent capabilities” like planning, self-evaluation, calibration, and so on. It is also an Open-source agent backbone model. The aim can also be the next trillion tokens for model training.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*3e0R8MjZXPZy5aTd6-VrAQ.png" /><figcaption>ReAct finetuning vs ReAct prompting</figcaption></figure><ul><li>In contrast to the traditional agents in which the Action space is defined by the environment, in the reasoning agents, the Action space is furthermore augmented by reasoning</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xYDLAjYL5IYpODRScgSlJw.png" /><figcaption>Action Space in traditional agents vs reasoning agents</figcaption></figure><ul><li>Reasoning is used for all kinds of tasks, such as Inferring environmental state, Retrospection, Self-reflection, Dynamic replanning, Synthetic data, and internalized search</li></ul><p><strong>1–4. Cognitive Functions: </strong>Human cognitive functions, including perception, intuitive inferences, and symbolic reasoning, are through Thought (the implicit reasoning). They are effortless, taking a single forward pass, meaning without needing many iterations, human very quickly detects the relations between observations, perceiving naturally fast what relations there are. Machine cognitive functions, on the other hand, are thought through explicit reasoning, or say token generation. Cognitive architectures for language agents (CoALA) involve Memory, Action space, and Decision making.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*qb8cPVo8R8vriMzZhVyTRw.png" /><figcaption>Cognitive architectures for language</figcaption></figure><p><strong>1–5. Language Agent cognitive components: </strong>A language agent mapping for human cognitive functions comprises the following layers:</p><ul><li>Upper layer: multi-agent, theory of mind, continual learning</li><li>Utilities &amp; Cross-cutting layer: Grounding, tool-use, world models</li><li>Context layer: planning</li><li>Core context layer: reasoning</li><li>Underlying layer: multimodal perception, memory, embodiment</li></ul><p><strong>1–6. From the Perspective of Russel’s &amp; Norvig’s Fundamental Agent Model:</strong></p><ul><li>New type of action of actuator: Reasoning here is in fact an internal action of the agent: (for better replanning and better ReActing)</li><li>Internal Environment (brain’s reasoning): where reasoning takes place in an inner monologue fashion</li><li>Self-reflection is a ‘meta’ reasoning action (i.e., reasoning over the reasoning process), akin to metacognitive functions</li><li>Percept and external action spaces are substantially expanded, thanks to using language for communication and multimodal perception</li></ul><p><strong>1–7. Chain-of-thought (CoT): </strong>It simply is a hidden thought before generating a response as <strong><em>Think about what you need to do next?</em></strong> It is also referred to as the Intermediate steps for the multi-step reasoning or the reasoning key stages. These stages are:</p><ul><li>Initial planning</li><li>Evaluating the initial plan based on the model’s internal belief</li><li>Revise the plan according to the few-shot constraints</li><li>Improve the optimality</li></ul><p><strong>1–8. Common Approaches to Trigger CoT Generation:</strong></p><p><strong>1–8–1- 0-shot learning (no exemplars): </strong>asking the model to label the user input (by inferring or extracting) without giving the model any examples as a dataset</p><p><strong>1–8–2- few-shot prompting (few exemplars): </strong>manual prompting by providing human-generated exemplars as CoT or intermediate steps. For instance, just providing the model with one, two, or three examples and then asking it to predict the fourth one (by inferring/extracting). Here, instead of training the LLM on a large number of samples, it is trained on just a few examples.</p><p><strong>1–8–3- *-shot prompting (many exemplars):</strong> providing a large number of exemplars (E.g., 1000) as an instruction to train.</p><p><strong>1–8–4- Instruction prompting (0-shot cot): </strong>the problem with 0-shot no exemplars, and few-shot prompting methods is that the model is likely to make a mistake, predicting an incorrect answer based on just the exemplars given. A handy way to solve is to synthesize the prompt with a reason in order for the model to understand the reasoning process and thus to infer with this reasoning. Hinting the model by whispering “<em>let’s think about it step by step</em>” in the prompt can give rise to its intermediate steps as self-generated cot.</p><p><strong>1–8–5- 0-shot analogical cot as an Optimized Zero-shot:</strong></p><p>That the zero-shot learning is significantly worse than few-shot, and also zero-shot CoT performance is still worse than few-shot CoT, raises the question of what mechanism the agent should have if it wants the LLM to predict the correct answer without getting any exemplars. This also points to the problem of the second role of Transformers. The analogical inference is where the idea here got from, which is based on comparing with a method or a result experience in the past, which is called a related problem. To do so, this approach has the LLM find the solution without prompting “<em>lets think about it step by step</em>” yet by getting the model to find relevant problems, methods, results, and experience as the self-generated exemplars and intermediate steps, that are all the self-generated, by leveraging of which the model can compare the discovered solutions reach to the suitable reasoning and then inferring the final answer.</p><p><strong>1–8–6- Instruction tuning:</strong> putting CoT data into our supervised finetuning mixture. It takes up several techniques, such as analogical reasoning, logical reasoning, and inference, self-consistent, maximum marginal inference, or most-common answer, to name a few, that will be covered in this article’s “inference-time techniques section” to come.</p><h4><strong>1–9- Post-training:</strong></h4><blockquote>ways of modification of LLMs’ weights. They can be done in a parametric or non-parametric way.</blockquote><p><strong>1–9–1. Supervised fine-tuning, </strong>or SFT for short, is one of the parametric tuning methods, which include:</p><p><strong>1–9–1–1. In-context autoregressive learning: </strong>through the 0/few-shot learning, and has zero cost of training. An LLM is given a prompt including a few training examples and a test instance as input. By leveraging its “autoregressive power”, LLMs understand and learn from the in-context examples to generate the output for the test instance directly, without any update to their parameters. Performs in a zero-shot/few-shot manner. Context learning is one of the most common ways to use giant LLMs. The advantages include:</p><ul><li>No training, only inference</li><li>Enables real-time interaction (e.g., ChatGPT)</li><li>Lowered requirements on train dataset size or label cost: only a few examples (&lt;10) are enough</li><li>Better generalization and less likely to overfit on the training data</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*qWdEYbrIIPuvg85H2er6sw.png" /><figcaption>In-context autoregressive learning</figcaption></figure><p><strong>1–9–1–2. Full fine-tuning: </strong>Given a pretrained model checkpoint (e.g., BERT), then having a new dataset/task, doing supervised learning on the new dataset and updating the weights of the new model. This approach requires a modest amount of compute (e.g., xxx chips for a few days for a 340B model) as well as in-depth knowledge of the model architecture. It results in<strong> </strong>updating the weight of all nodes in LLM’s transformers. This is an expensive way (in terms of cost of training time), and it might also need a large number of datasets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*Kemaycuj0pB6uTFlZjBUcw.png" /><figcaption>Conventional Fine-tuning</figcaption></figure><p><strong>1–9–1–3. Prompt tuning:</strong> What it does is just provide a large number of exemplars as an instruction to train. For instance, providing 1000 examples. To do so, it freezes the backbone model and then prepends a soft prompt (e.g., learnable) to the input. It actually only optimizes the prompt to adapt to downstream tasks. It has an average cost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*tzvVDv_rbvkgGV8oxJt6GQ.png" /><figcaption>Conventional Prompt Tuning</figcaption></figure><p><strong>1–9–1–4. Parameter-efficient fine-tuning</strong>: it has lower adaptation, meaning lower tuning on the model’s parameters, so a partial updating will happen, such that not all of the Transformer’s parameters are updated. Two matrices as adaptors are added to the LLM such that, after training, only these matrices need to be stored. This method is more commonly used and has advantages for security, privacy, and performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*UIp_sAA-0k0zEq6SNb_2hw.png" /><figcaption>Parameter-efficient fine tuning</figcaption></figure><p>In comparison with full fine-tuning, the pros and cons of PEFT can be considered as follows, to know why we need PEFT:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*94X-XZFrWDexqAXhIyNSOA.png" /><figcaption>Pros and Cons of PEFT vs conventional finetuning</figcaption></figure><p>LoRA is an example model of PEFT method. The key idea is decomposing updated parameters into a product of lower rank matrices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H0FB7LH2vEGKtmd9_6B6dQ.png" /><figcaption>LoRA vs fine-tuning</figcaption></figure><p>LoRA can apply to any dense layers in the foundation models, but applying to all dense layers may not be optimal. Only applying adaptation to attention weights (not on MLPs).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*byo3pzGB3s1jcLliAyQiNA.png" /><figcaption>LoRA Transformer, applying adaptation on attention weights not all dense layers on MLP</figcaption></figure><p>Performance-wise, it has no additional inference latency. In some cases, it shows better performance even in comparison to full fine-tuning.</p><p><strong>1–9–1–5. Distillation:</strong> Over and above using efficient prompt-tuning, on the other hand, there are going to be situations, though, that we want to have our own language model, but small yet fine-tuned. We want to customize our model based on specific data and use case, specifically for cost/latency purposes, imagine prompt-tuning for 100k examples! Here, instead of 100k shots treated as labeled exemplars, which is very expensive (regarding the token budget and training time), there needs to extract a small pre-parameterized model fine-tuned on a given custom dataset. So, the goal here is model-size reduction and performance improvement. This gives us a hint of generating a very small model still by supervised tuning methods. A process called distillation from generalization to specification, and creating a smaller model. Therefore, addressing the criteria of “Memory- &amp; Compute-Efficient LLM”, distillation reduces the cost and latency of huge models. For that, there is an algorithm called “Teacher-Student” in which the teacher is an LLM, and the student is a small model supposed to learn from the teacher model. To do with the way that the algorithm works, we do not train a model by hard-labeling the dataset in a classic classification way; instead, we first give the teacher model (our LLM) our domain dataset to label the data. This process is called soft-labeling, and in this process, it can also be a little helped by humans to soft-label the dataset as well. At the same time, we give the dataset to our student model, not to label it but to make predictions on samples. The results of both models are then compared based on a loss function called distillation loss, by which, in fact, the student is being evaluated, and given a good accuracy, a trained model is built, our student. This gives us a glimpse of how the student learns from the teacher. One thing, though, that should be noted is that during this process, the “Temperature” parameter of the models is larger than 1 (T &gt; 1). The Softmax function with a larger temperature smooths the output probability distribution, resulting in the likelihood of predicting each sample is not so variant from one another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*JBlpPiSooECQ8OKdqvhIoA.png" /><figcaption>Softmax function in Distillation</figcaption></figure><p>From here on, for doing prediction, instead of using the teacher model (LLM), which is very huge, we make use of the student model to do prediction, called “Hard prediction” now. This hard prediction is actually when the regular softmax (T=1) is used in the student model, and is finally evaluated by the student loss function, resulting in generating “Hard labels” which are the ground truth labels in one-hot encoding. However, one thing one should be aware of is that the mechanism of NNs’ softmax functions is based on similarity error, and might not necessarily work the same in logistic regression, which predicts the probability of a label much higher than the others. That is why, to come up with a smoother probability on predictions, we here apply the temperature parameter after the softmax function to smooth the prediction’s probability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*itMtei44rIRXGQibxmsKig.png" /><figcaption>Softmax function with temperature to smooth the output</figcaption></figure><p><strong>1–9–1–6. Incremental Distillation: </strong>Given a new input(s), we can again leverage the teacher model to soft-label and then train the student model to be tuned with the new samples. This leads us to the setup to iteratively do this process of distillation, meaning that as new inputs have come in, the algorithm has been conducted, and the soft-labels and hard-labels are generated by teacher and student models, consequently, in an iterative manner. Over time, the student model is tuned and its weights are updated through backpropagation of the loss function onto its parameters.</p><p><strong>1–9–1–7. Evaluation between LLMs: </strong>Using a larger LLM to evaluate the prediction results of several other LLMs. As with distillation, human labels can also be applied here as well.</p><p>The following comparison could produce helpful insights about which approach can be a candidate for model adaptation and research goals:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cFzyBnnQbG-jb1gnGXdqfw.png" /><figcaption>Model adaptation approaches comparison</figcaption></figure><p><strong>1–9–2. Reinforcement Learning: </strong>RL includes parametric tuning methods in which the transformer can get feedback of its actions and learn from it to modify and update the weights of its NNs, by involving human in the loop<strong> </strong>as RLHF (Reinforcement learning through human feedback), in which humans are used (in the loop) first to create (X, Y) data, and then to collect judgments on (X, Y’) data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bTnGx-zwwqLcrSig0jbP1A.png" /><figcaption>Model adaptation approaches, tuning and customizing with data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*uDzTit-mKVfZP7UQ_qqfIQ.png" /><figcaption>Post Training for Alignment with Human Preferences- [Photo by <a href="http://twitter.com/FanaHOVA">@FanaHOVA</a> on X]</figcaption></figure><p>However, it is obvious that humans need to read the responses carefully in order to make decisions. Since, as LLMs write better and better responses, it becomes harder and harder for humans to process them, especially those that are lengthy and require domain expertise! This is where <strong>Reward Engineering</strong> and its methods like <strong>RLAIF</strong>, <strong>PPO</strong>, and <strong>Self-Rewarding</strong> come into play.</p><p>One method is by involving another LLM in the loop, known as RLAIF (Reinforcement learning through AI feedback), to provide feedback and feed it into the original LLM. Self-improvement via self-rewarding is also another way, which consists of optimization methods in which the LLM is able to self-learn from observations and feedback. We will see these methods as we progress through my next articles on “<strong><em>Self-Improvement and Self-Reasoning Methods</em></strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*S03k0DqaLrAA5d837tTl4A.png" /><figcaption>Three Types of Rewarding Mechanisms, RLHF, RLAIF, and PPO</figcaption></figure><p><strong>1–9–3. Direct Preference Optimization (DPO): </strong>In order for an LLM to be fine-tuned based on rewards (external observations), RL is not just a given. We don’t have to leverage only RL for reward function gains. Briefly, DPO is a non-parametric optimization method for achieving reward-based functionalities in policy optimization when fine-tuning an implicit reward model. DPO actually replaces traditional reinforcement learning (reward model) with a closed-form classification objective that implicitly models human preferences, directly optimizing the policy without requiring an explicit reward function. Its implementation is based on using gradient ascent. In this article, we will not get into DPO and PPO, but in my next articles on “<strong><em>Self-Improvement and Self-Reasoning Methods</em></strong>”, we will see these methods in detail, and explain their application in self-improvement via self-rewarding methods as well.</p><p><strong>1–9–4. Long-term Memory: </strong>The token budget of each session (or context window size) is considered as the LLM’s context-memory, and is the limitation factor for the short-term memory of the LLM. The problem with STM is that the self-improvement mechanism can not perform well with such a limited window size. This is because in each session, the LLM is likely to learn new actual experience and skills (from observations and feedback), but even so, there is no clue for the LLM to access such past experience with each user in subsequent sessions. That said, Long-term memory comes into play, meaning the LLM more likely can self-improve by using the LTM. To do so, two general methods have been investigated. The straightforward way is to use coding and text log to accumulate and maintain continuous STMs throughout frequent session windows. This method obviously needs extra storage and therefore has the potential to experience a performance drop over time. Another way gets the idea from RL and back propagation mechanisms, but has no same implementation as RL’s. This way aims at updating the transformer’s NNs parameters through the synergy between the agent and its LLM, in which the agent, in addition to feeding the observations into the model, as it updates the model’s NNs’ parameters, it also leverages the ever-gathered LTM into each session, and adds it to the current session’s STM. By doing so, the agent makes the LLM a specialized model, and more importantly, as the LLM is becoming more generalized, it becomes specific as well, hence ending up to a model that is both generalized and specialized, generalizing in the real world while able to make specific inferences.</p><p><strong>1–9–5- Augmented Actions and Augmentation Methods (Non-parametric): </strong>A performance tuning method of the agents to build a customizable model powered by augmented actions as new reasons to replan its CoT, thus better ReActing. The agent is able to use tools such as a search engine, a calculator, an API, a programming language, etc. Language models can also teach themselves to use tools. There are two ways for augmentation methods: RAG and Graounding.</p><p><strong>1–9–5–1- Extensions/APIs</strong>: by <strong>Retrieval-augmented generation (RAG)</strong> is for the retrieval of knowledge and computation. It, like the definition suggests, happens when many tasks (on calculative, referential, domain-specific knowledge) turn out not to have a simple answer, so LLM is unable to generate a response for such tasks, exhibiting poor performance for these specific tasks. For instance, when asking it for a flight booking. That said, an external environment appears to be needed for retrieving the required knowledge or relevant computation so as to handle the task, and augmenting it to complete its knowledge and then form the final inference. In order for that to happen:</p><ul><li>To solve the question by LLM, besides symbolic reasoning, various reasoning capabilities are needed to form its CoTs, including but not limited to mathematical reasoning, commonsense reasoning, knowledge-intensive reasoning, and can be done through API usage.</li><li>Taking it into account, for LLM to be able to do such reasoning and solve specific tasks, a higher abstraction level of reasoning and acting is needed, under which the “Agent” in an iterative manner, the agent sends the prompt to LLM, and handles any required round-trips (RAG as its actions) the model needs to generate CoTs, providing the model with augmented-knowledge (as observations from external environment) gained from the external tool.</li><li>Here’s a continuous cycle of synergy in which both acting and reasoning are continuously informing each other, such that acting is supporting reasoning, and reasoning is also guiding the acting as well, shaping the” CoT-RAG-ReAct”, the agent’s internal mechanism to accomplish the given task. This can lead to an increase in the accuracy of the answer. So the model can generate a more accurate response by leveraging RAG capabilities.</li></ul><p><strong>1–9–5–2- Grounding (factuality) and Dynamic Retrieval</strong>: Relying on RAG-Powered parametric ways alone can still be problematic. Since in many cases the model needs to be factual rather than creative, this method combines the LLM’s results with search engine’s results (or external enterprise results akin to RAG) to make it factual. The main goals here are minimizing the model’s hallucinations, as well as leveraging physics-inspired empirical outside-world truth for LLM inference. Having said that, there are some considerations as follows to comply:</p><ul><li><strong>Right context</strong>: the source from which the agent is supposed to search should be relevant, reliable, and trustworthy.</li><li><strong>Better models</strong>: Due to the fact that, when the LLMs have hallucination in their reasoning, they don’t even know if they are lying or not, and concerning critical usages (e.g. in healthcare, finance, stock, and etc), it is essential to not only combine the model’s results with that of search engines, but also detect the correct result. Moreover, hallucination and the fact that they don’t know if they are lying are two of the reasons why causality is absent in LLMs’ reasoning. Given that, for the model to have less hallucination, using some reinforcement learning mechanism here can be beneficial to provide feedback based on which underground responses can be punished. By doing so, we can do some trade-off, and emphasize more on the factual side rather than the creative (reasoning) side of the model. As recalled, LLM’s own reasoning is in fact the creativity side of the transformer that can be controlled by its temperature hyperparameter.</li><li><strong>User experience: </strong>It is of importance for users to know where the sources of LLM’s results are from, meaning citations</li><li><strong>Dynamic Retrieval: </strong>Although<strong> </strong>language models can also teach themselves to use tools, with regard to what the prompt is and how to solve such a task, the LLM basically doesn’t know how to react in terms of API/tool-use. The challenge here refers to function calling flexibility, and is when the LLM should call the APIs, and even more important than that is which APIs the LLM should call. Over time, the larger number of extensions is provided, emerging all the time, the harder this challenge becomes, so the smarter the model should be. With that caveat in mind, the LLM should intelligently understand where and when it should and should not combine its results with grounding.</li></ul><p>Even so, there are some cons for grounding:</p><ul><li><strong>Possible Late binding</strong>: Since LLMs released have been trained often recently but not so close in time (they are trained on usually past data, and are not updated with the latest changes of data) they are prone to produce inaccurate results, or might not produce as good and accurate results as search engines, which output quite recently the latest results.</li><li><strong>Cost</strong>: for huge models that have the potential for high cost and latency, distillation is considered a good solution to come up with.</li><li><strong>Inconsistency</strong>: Again, due to the hallucination, the LLMs are likely to give an inconsistent response compared to the existing downstream information.</li></ul><h3><strong><em>Notice that:</em></strong></h3><ul><li><em>For all parametric methods, in case of incorrectness in LLM’s prediction (Error), the back propagation is still treated as an adjusting mechanism for parameter tuning.</em></li><li><em>The LLMs embed the user’s query into a vector, and then compare this vector with their own encoder’s vector space based on cosine similarity and eventually decode the most similar vector amongst vectors.</em></li><li><em>When fine-tuning, the LLM embeds the given exemplar to put it into its encoder’s vector space as its new knowledge.</em></li><li><em>For RAG capability, the LLM at first embeds entire external information as vectors into its own encoder’s z-space, and then compares the given query with each new-embedded vector to find the most similar one. Although this is not an efficient way in terms of time complexity, it is actually time-consuming.</em></li><li><em>Some insights have been investigated that sometimes, for achieving intelligence, it is not necessary to make the agent smart, but rather it can be done by optimizing the environment. What that means is the environment in which human engages is not necessarily given to the agent in the same shape. Instead, we can give the agent more options and means but fewer limitations in the environment, such that the agent has fewer restrictions to solve the task and can solve it better. </em>By this definition, the examples could be <em>richer coding IDEs or more scalable simulations, to name a few</em><strong><em>.</em></strong></li></ul><h4><strong>1–10- Types of Self-Reasoning</strong></h4><p>There have been two types of reasoning, evolving to improve language models’ inference :</p><h4><strong>1–10–1- Reactive Reasoning, also known as “System 1”:</strong></h4><p>It relies on associations (correlations). E.g., attention models are considered as System 1, and so also LLM can be viewed as System 1. In fact, in language modeling, the basis has been calculation through Bayes&#39; Rule (Bayesian models). In coarse ranking scope, they do word embedding by vectorization (embedding keywords as vectors), and so train by predicting the next token only on “positive examples” of language (pre-training).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*EnXLHCIf8oEtXmdfOT_21g.png" /><figcaption>Language Models do Vectorization as Word Embedding</figcaption></figure><p>Most of the 2000s’ research and attempts on language modeling focused on finding ways to increase capacity without increasing training time too much (to deal with corpora with hundreds of millions of words). They used methods from support vector machines, Neural Nets, which was the path going through shallow word manipulating to deep manipulation in a sense that unlike SVMs, Neural nets can manipulate words as end-to-end, resulting in word embedding architectures via CNNs and attention networks able to multi-task learning and predicting middle word in a window, it was there where the transformers emerged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eMV5vSU7frYm8QQG0MjmxQ.png" /><figcaption>NLP Architectures via Deep Learning Networks</figcaption></figure><p>LLM attention mechanism was born in 2014. The NN models, trying to generate a target word given a sequence of words, where sequence-to-sequence learning stated the “Scaling Hypothesis”, investigating given a large dataset, and training a very big neural network, then the prediction shows successful results. in 2015, end-to-end memory networks came out, upon which the transformers are evolved and improved. Some key ingredients at this point included the stacked layers of attention over the input, query &amp; key embeddings, position embedding, normalization, feed forward, multi-head attention, NN layers between attention layers, and a final softmax layer for prediction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*BcqFeLgyuWyB6Ul90cUKfw.png" /><figcaption>A Single Layer of the Model (a Transformer Network)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*KQxLc2RIxl8f1M3Ybbm3qQ.png" /><figcaption>Three Layers of embedding in the Model (a Transformer Architecture)</figcaption></figure><p>This network architecture, enabling self-attention, was shown to work well on language modeling, where the repeated attention was actually key for reasoning, such that models learnt to focus on the correct supporting sentences during a multi-hop inference, each of which has a prediction used for the next hop&#39;s prediction sequentially.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*Vb9ue9n3o49dl3F_dwN_2g.png" /><figcaption>An end to end memory network with transformer encoder and embedding layers</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*IXUMR5B0jzhyC9G9P5uSdw.png" /><figcaption>Architecture of self-attention transformer models</figcaption></figure><p>As of 2020 onwards, large language models (LLMs) started emerging from use cases like chatbots to instruction following. This evolution of reasoning as System 1 was shown by the research and attempts that just language modeling is not enough.</p><blockquote><em>Although, these kind of reasoning have fixed compute per token, and directly outputs answer which are actually their limitations. Other cons? They might have failures due to the fact that they can learn spurious/unwanted correlations including hallucination, sycophancy, and jailbreaking.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5_VB1Q_xTdTrbw931RzmWw.png" /><figcaption>System 1 failures — Factuality &amp; hallucination</figcaption></figure><p>For more information on chain of thought, prompting methods, and their challenges out there, you can refer to this article’s earlier sections on which provide these definitions.</p><p>So, as can be inferred and on demand, the aim lies obviously in improving System 1 in terms of architecture, which can be a better attention model or a world model and etc. However, the challenge here is scalability. Such a challenge leads researchers to enable the latter type of reasoning, which is <strong>System 2</strong>.</p><h4><strong>1–10–2- More Deliberate Reasoning and Effortful Thinking, also known as System 2:</strong></h4><p>This type of reasoning should, as such, be able to call reactive models (system 1s) multiple times. And in the literature of LLMs, it means having multiple calls to system 1 LLM(s). Such reasoning aims to spend more time thinking so that it could give us better results. The pros here enable planning, search, verifying, reasoning, and so on, while having dynamic token computation (chain-of-thought, ToT, …).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GfJQYRdi6QjDv4rYVY9vYA.png" /><figcaption>System 2 Reasoning, Multiple Calls to System 1 LLM</figcaption></figure><p>On top of that, it gives us the potential added benefit of resolving issues on hallucination, sycophancy, bias, or when dealing with complex, large tasks, etc. For more information on reasoning strategies, exploring resolving such failures of System 1 reasoning, you can refer to my past article on “<a href="https://medium.com/@hamid.n.d/on-lms-reasoning-strategies-approaches-f843651b7bf8">On LLMs’ Reasoning Strategy Approaches</a>”. For example, explicit reasoning such as “<strong>chain-of-verification</strong>” that gets into reducing Hallucination in LLMs, or “<strong>Effortful Thinking</strong>” dealing with Sycophancy or Bias issues, or <strong>Branch-Solve-Merge (LLM-as-a-Judge)</strong>, for when the task is complex, the instruction is hard, and LLM fails.</p><h3><strong>Inference-Time Prompting Techniques</strong></h3><p>The problem with existing LLMs was that they achieved less than 25% accuracy if no special inference-time techniques were used. In fact, without post-training techniques, the performance of standard prompting (few-shot exemplars) is pretty poor on reasoning. Because standard few-shot prompts only provide information on the final solution “format” but not the “rationale” needed to reach the solution. So obviously, the incentive here is to achieve impressive performance across various challenging reasoning tasks in math, coding, STEM, etc. This motivates the other end of the spectrum, which is chain-of-thought. In fact, the “<strong>long CoT</strong>” (more token budget) could provide clues to gaining a better solution to get a more accurate final answer. That is, we want the LLM to think more and longer. Remember, though, thinking time can be calculated as latency (milliseconds) or budget (number of generated tokens). So, we consider scaling the token budget as the core idea to trigger the LLM to generate a long chain-of-thought (CoT), which means generating long hidden thoughts before generating the solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*h1sirbCvcThZkBPjgw8M6g.png" /><figcaption>Hidden thought before generating the solution</figcaption></figure><p>The further we scale out the inference time cost (more expensive computation cost), the higher the accuracy model can achieve, and this way LLM’s performance improves with more inference-time compute. However, the inference-time computation shows an exponential cost increase in proportion to the higher accuracies, meaning the model can perform in an ideal case when the inference-time computation cost would not be a concern!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*8V1XLaTM3BSPIuVwpGFtNQ.png" /><figcaption>Performance improves with more inference-time compute</figcaption></figure><p>There are three main categories of inference techniques as follows:</p><ol><li><strong>Prompting techniques for scaling token budget</strong>: their goal is to use more-efficiently token budget (reducing token cost) to generate a single solution</li><li><strong>Search and Selection techniques:</strong> they aim to search and select from multiple candidates (solutions) through increasing the width of the solution space exploration</li><li><strong>Iterative Self-improvement techniques:</strong> using the model increases its “depth” to reach the final solution and derive the final answer</li></ol><p>In this article, we explore the first category, and for the other categories, you can refer to my next articles on them.</p><h3><strong>Prompting techniques:</strong></h3><p>A.k.a instruction tuning methods is one of the supervised fine-tuning techniques, putting CoT data into our supervised fine-tuning mixture. These techniques fine-tune the pretrained LMs with “prompts and completions” to be able to follow user instructions. Their main goal is for <strong>scaling token budget</strong>, meaning using more-efficiently toekn budget (reducing token cost) to generate a single solution. They take up several techniques such as analogical reasoning, logical reasoning, inference, self-consistent, maximum marginal inference, or the most common answer.</p><h4><strong>Technique 1: Zero/few-shot reasoners with no deep thought (Standard prompting or IO prompt)</strong></h4><p>Providing manual labeling via exemplars as a question &amp; only the final answer. This way, then the transformers just generated a direct answer (usually incorrect), meaning LLM generates an incorrect answer. LLMs are often trained offline, then deployed zero-shot as agents, and that is why, without post-training techniques, the performance of standard prompting (few-shot exemplars) is pretty poor on reasoning. Because standard few-shot prompts only provide information on the final solution “format” but not the “rationale” needed to reach the solution. This type of zero-shot learning is significantly worse than few-shot! The other downside is the static budget, meaning it uses the same amount of inference time (same number of tokens) for every question of different difficulty levels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*cT795wR58e_TlI5H6oPdCg.png" /><figcaption>Standard prompting, Zero shot reasoning with no deep thought</figcaption></figure><h4><strong>Technique 2: Few-shot reasoners with some deep thought (Chain-of-Though prompting)</strong></h4><p>It tries to enable a deep thought mechanism for LLM as Chain-of-Though by providing thoughts in the exemplars (manual labeling), which in turn improves the CoT performance at inference time by labeling of thoughts. Mentioned as a drawback for standard prompting, without post-training techniques, the performance of standard prompting (few-shot exemplars) is pretty poor on reasoning. Because standard few-shot prompts only provide information on the final solution “format” but not the “rationale” needed to reach the solution (method of solving). The intuition of this looks like a teacher solving some questions by just giving only the final answers and without presenting any solutions or contexts for them! So, in order for LLMs to learn the required context knowledge, we should provide them with the method for solving the question, i.e., the solution explained within the shots. The solution consists of the step-by-step calculations to derive the final answer. This guidance plays the role of our chain-of-thought here, helping the model to <strong><em>try to think</em></strong> <strong><em>deeply</em></strong>. It is more than just a simple final answer to respond to reasoning queries, and therefore, “Chain-of-thought data” is crucially important for reasoning tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sv33NWXl6zGeXzFRFPWDBA.png" /><figcaption>Chain-of-thought prompting, providing thoughts in the exemplars</figcaption></figure><p>Therefore, up to here we can say thought-provided-prompt matters because:</p><ul><li>Helps models handle complex, multi-step problems more easily</li><li>Reveals the model’s reasoning process</li><li>Makes it easier to spot errors in logic, thus more trustworthy</li><li>Resembles human thought process</li></ul><h4><strong>Ways for CoT generation</strong></h4><p>Along with the common approaches to trigger CoT generation, as mentioned in the definition section, Few-shot exemplars can be provided to the model in 2 types:</p><ol><li><strong>Few-shot-fixed CoT (Manual Human Annotation):</strong> Exemplars are provided by a human (human-written exemplars). The annotators write step-by-step solutions. This way has high-quality reasoning traces, although its challenges are:</li></ol><ul><li>Time and cost-intensive</li><li>Often requires expert annotations, e.g., more challenging math problems need expert annotators (time-consuming &amp; expensive)</li><li>Limited scale or difficult to scale: Lacking diversity in reasoning styles, it is very hard to boost diversity (of skills)</li></ul><p><strong>2- Few-shot-retrieved CoT:</strong> the exemplars are provided externally. This is done via RAG mechanisms, or by a self-generated model, or etc. Usually, models with this type have better performance compared to the fixed CoTs, and are able to generate their own CoTs. This type can be provided in the following ways:</p><ul><li><strong>RAG-based:</strong> retrieving the required CoT relevant to the task, and augmenting it to the task</li><li><strong>Program-Aided Language Models (PAL):</strong> Convert math problems into Python code execution traces. The pro is to guarantee correctness through execution. And the cons are Less natural language reasoning, less intuitive, as well as Limited to problems that can be coded.</li><li><strong>Self-generated CoT (self-ask):</strong> using LLMs to generate their reasoning paths. This way is scalable to many problems, but its quality is highly dependent on the base model.</li></ul><h4><strong>CoT Performance scaling</strong></h4><ul><li>CoT also gives us the advantage of <strong>variable computation</strong> of thought process, adapting to tasks of different difficulty levels:<strong> </strong>it uses budget (token space) in proportion to the complexity of each task, such thata more complex question leads to more reasoning steps in the CoT (variable computation), which results in better solving the tasks</li><li>The same CoT can generalize from simple exemplars to difficult exemplars that require many more reasoning steps.</li><li>In recent experiments on both pretrained &amp; post-trained models, better models benefit more with CoT generation, having different scaling curves, both models still hold the performance improvement.</li><li>CoT performance improves more significantly with the increase in the model size. A drastic improvement in reasoning performance, though, appears to be when the model reaches a certain scale. So, the bigger models have exhibited higher accuracy.</li><li>Amongst the same-size models, those making use of CoT have better performance.</li><li>The comparison remains true for the light LLMs (lower parameters), which are even post-trained with fine-tuning more capabilities, meaning those of post-training making use of CoT show better performance compared to those of them lacking CoT.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*ESqQncQxJgTNjaC87ROaKg.png" /><figcaption>CoT performance scales with the model size</figcaption></figure><p>Going further forward, we investigate how to improve the CoT performance at inference time. and further improvements than variable computation include</p><ul><li>Few-shot prompting with labeling of thoughts</li><li>Instruction prompting to trigger CoT generation</li><li>Instruct the LLM to automate the prompt design</li></ul><h4><strong>Technique 3: Zero-shot reasoners with a hint (Instruction prompting w/o CoT)</strong></h4><p>Generating CoT without having to provide exemplars (manual labeling). Here, we just provide a prompt with the instruction: “Let’s think step by step”. In fact, the goal here is to provide the pre-trained LLM NOT with any exemplars (0-shot) but with the instruction “let’s think step by step”. This way, LLM self-generates its internal CoT and then derives its final answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*ETlrPeBMtJiMBmrERW7seg.png" /><figcaption>Zero-shot CoT generation with an instruction</figcaption></figure><p>It ends up with improving the CoT performance at inference time by Instruction prompting to trigger CoT generation, as it significantly outperforms zero-shot performance, but even so, this zero-shot CoT performance is still worse than the few-shot CoT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*7ocLIeKi6WkWXJuD36-SRA.png" /><figcaption>Zero-shot CoT performance vs zero-shot vs few-shot</figcaption></figure><blockquote>So again, how to improve CoT performance without manually labeling exemplars?</blockquote><h4><strong>Technique 4: Zero-shot instruction-based analogical reasoners (Analogical prompting)</strong></h4><p>So, obviously, our goal is already to eliminate the weakness of 0-shot types, yet still improve their performance, without needing to do any manual labeling. This approach aims to instruct the LLM to generate exemplars, and it is motivated by human analogical reasoning, which states, “Humans are not explicitly given demonstrations every time for a new task, but instead, humans intrinsically recall from past relevant experience”. This actually comes from a Mathematical Method:</p><p><em>“HOW TO SOLVE NEW RELATED PROBLEM? AND DO YOU KNOW A RELATED PROBLEM?</em></p><blockquote><em>IN FACT, WHEN SOLVING A PROBLEM, WE ALWAYS PROFIT(LEARN) FROM PEVIOUSLY SOLVED PROBLEMS, USING THEIR RESULTS, OR THEIR METHODS, OR THE EXPERIENCE WE ACQUIRED SOLVING THEM. WE ACTUALLY LOOK FOR A FORMERLY SOLVED PROBLEM WHICH IS LINKED TO OUR PRESENT ONE BY GENERALIZATION, SPECIALIZATION, OR ANALOGY. SO THAT IT CAN HELP US SOLVE NEW PROBLEMS BETTER.”</em></blockquote><blockquote><em>How to solve it, George Pólya, 1945-</em></blockquote><p>So, to do with the way analogical instruction prompting works, we prompt the LLM to first recall relevant exemplars, before solving the test problem. The LLM then itself produces an internal CoT. So, we should provide our pre-trained LLM NOT with any exemplars (0-shot) but with instruction “Recall relevant exemplars” &amp;&amp; “Solve the initial problem”. And LLM self-generates both its exemplars &amp;&amp; its internal CoT, then derives its final answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*ETlrPeBMtJiMBmrERW7seg.png" /><figcaption>Analogical prompting -instruct the LLM to generate exemplars</figcaption></figure><p>This gives us the following benefits:</p><ul><li>Self-generated exemplars (no need for manual labeling)</li><li>Self-generated CoT</li><li>Tailored samples to individual problems</li><li>Self-generated high-level knowledge that complements the problems with broader insights. Besides exemplars, the LLM can also self-generate high-level knowledge. For instance, the LLM can generate a helpful tutorial that is useful for both the current task and also provides insight for other problems, along with a solved example. With that, there might be no need to chat for similar problems/topics if we get the required knowledge. E.g. In coding, algorithms, science, and math.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c0it44Sabw65T1Op8OTR-Q.png" /><figcaption>Codeforces example- prompt, self-generated-knowledge, exemplars, and final answer</figcaption></figure><p>The downsides, however, can be where there might be some exemplars being irrelevant, or containing errors, or having noisy demonstrations that have higher error than human-generated exemplars.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HDCt5yfoWXHVvbuFFuvdpQ.png" /><figcaption>Performance of analogical prompting</figcaption></figure><h4><strong>Instructive performance comparison in self-generated CoT models</strong></h4><p>Performance-wise, analogical prompting not only outperforms 0-shot-cot but it outperforms manual few-shot-cot as well. In general, stronger LLMs are better analogical reasoners, such that</p><ul><li>With stronger LLMs, analogical prompting outperforms CoT with manually-designed or retrieved exemplars</li><li>Whereas weaker LLMs benefit less from analogical prompting, though it does not hurt the zero-shot performance. The generated CoT is more tailored to the underlying LLM</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*g_rxiXPB10r46Vk8wf5-lQ.png" /><figcaption>Stronger LLMs are better analogical reasoners</figcaption></figure><p>Given the results that elicit the few-shot-retrieved-cot models exhibit better performance than few-shot-fixed-cot, as well as taking into account that self-generated analogical reasoners have gained higher performance than all the few-shots, thus, the better models are those that are able to discover the best reasoning strategy via self-generation capability (zero-shot-retrieved analogical models).</p><p>But now the question is, which instructions work for CoT generation to reach higher performance amongst zero-shot self-generated models? And we know that there are some challenges here left:</p><ul><li>Current LLMs are sensitive to prompt design</li><li>There is no clear principle of how to write optimal prompts</li><li>How to reduce the manual work for writing prompts?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*Y5Y-ClDaxPalM6hcFsgbYw.png" /><figcaption>Which instructions work for CoT generation</figcaption></figure><blockquote>These issues lead us to another approach, leveraging the Prompt Engineering!</blockquote><h4><strong>Technique 5: Zero-shot prompt-engineer reasoner (LLM as human-level prompt engineer)</strong></h4><p>The core idea here is to instruct the LLM to automate the prompt design so that we leverage the LLM to generate initial instructions in such a way that we have LLMs to propose/generate initial prompts that might perform even better than human-written prompts (proposal generation). The method is similar to supervised learning, but with generating much fewer samples (10–100 samples as initial instructions), then scoring each instruction based on the prediction correctness on a small set of problems. Eventuall,y the highest scores will be selected as our improved instructions. This method uses a set of LLMs coming into play for three roles: Resampling models, Scoring models, and Inference models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*JauLHaydLd39YjKEEO2_lw.png" /><figcaption>Large language models for prompt engineering</figcaption></figure><h4><strong>Technique 6: Improvement: Zero-shot Prompt-Optimizer Reasoner</strong></h4><p>Here, we want to improve our prompt-engineer reasoner so as to consider an LLM as the optimizer to iteratively improve the prompt. The core idea is to instruct the LLM to leverage the past optimization trajectory, represented as sorted (solution, score) pairs. And in fact, we have two LLMs playing the roles:</p><ul><li><strong>Optimizer:</strong> the LLM to propose a new instruction given old ones and task exemplars</li><li><strong>Evaluator:</strong> the LLM to evaluate the accuracy of an instruction</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*qWHhfCR2u9jZDxj03X9-JQ.png" /><figcaption>LLM as the optimizer to iteratively improve the prompt</figcaption></figure><p>That way, both LLMs continuously work on the meta-prompt consisting of solution-score pairs, in order for the meta-prompt to be iteratively optimized until it reaches a state including the top past instructions and accuracies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*LlNQiHXJSeTie2FrUi6eEw.png" /><figcaption>Meta-prompt for prompt optimization</figcaption></figure><p>The table below, from Berkeley RDI&#39;s recent experiments, shows, for example, the top instruction with the highest GSM8K zero-shot test accuracies from prompt optimization with different optimizer LLMs. All results use the pre-trained PaLM 2-L as the scorer.</p><ul><li>Initial instruction is for prompt optimization: “Let’s solve the problem.” with acc = 60.8%</li><li>The best LLM-generated prompt outperforms “Let’s think step by step” by ~8%, matching the few-shot CoT accuracy (80.7%) in PaLM-2 technical report.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*i3ulGG-LxWYKwkvViItm8w.png" /><figcaption>Results of optimized prompt engineer reasoner on GSM8K</figcaption></figure><p>And performance-wise, for example, in the two setups below, optimization graphs show the accuracy increases with more optimization steps, then plateaus.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*lGEmlCdO3j4Thvi4Egqy6A.png" /><figcaption>Setting 1- scorer is PaLM 2-L and optimizer is PaLM 2-L-IT</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*kyZ-uneFLZWp6hVQRVL_MQ.png" /><figcaption>Setting 2 — scorer is text-bison and optimizer is PaLM 2-L-IT</figcaption></figure><h4><strong>Technique 7: Logical Inference</strong></h4><p>In some cases, in which there are some rules and facts about the context of the task(s), LLM receives a query, also receives those logics (rules &amp; facts) as meta-prompt, and then generates the results based on the rules given. The order of applying the rules is also based on inferring them from facts. That is, it does not necessarily mean all the rules are going to be applied in user query processing. Sometimes, changes in the order of rules result in a performance drop.</p><h4><strong>Technique 8: Explicit Reasoning Strategies</strong></h4><p>These strategies are enabled by CoT, such that we can explicitly instruct the LLM with the desired reasoning strategies for problem-solving. They include strategies such as decomposition, planning, dynamic least-to-most prompting, self-discover structures, branch-Solve-Merge Approach, and LLM-as-a-Judge. To explore these strategies, please refer to my previous article titled “<a href="https://medium.com/@hamid.n.d/on-lms-reasoning-strategies-approaches-f843651b7bf8">On LLMs’ Reasoning Strategies Approaches</a>”.</p><p><strong>What CoT?! The Best Practices?</strong></p><p>What CoT brings into LLM reasoning eventually depends specifically on the where and when of our needs and requirements in our application and domain. Hence, considering the pros and cons of any technique and method that we have discussed, into account will lead us to opting for a better method to apply for the given task. For instance, regarding variable computation of thought process, adapting to tasks of different difficulty levels, more complex questions, and coming up with more reasoning steps in the chain-of-thought. All in all, the best practice to interact with LLMs evolves over time we can rely on include:</p><ul><li>The principles of how to discover good prompting strategies for reasoning hold true</li><li>Encourage longer CoT for complex tasks</li><li>Support reasoning strategies required for the task</li></ul><h3>References &amp; Credits:</h3><p><a href="https://arxiv.org/abs/2309.03409">Large Language Models as Optimizers</a></p><p><a href="https://arxiv.org/abs/2201.11903">Chain-of-Thought Prompting Elicits Reasoning in Large Language Models</a></p><p><a href="https://arxiv.org/abs/2310.01798">Large Language Models Cannot Self-Correct Reasoning Yet</a></p><p><a href="https://arxiv.org/abs/2402.10200">Chain-of-Thought Reasoning Without Prompting</a></p><p><a href="https://arxiv.org/abs/2206.07682">Emergent Abilities of Large Language Models</a></p><p><a href="https://arxiv.org/abs/2205.11916">Large Language Models are Zero-Shot Reasoners</a></p><p><a href="https://arxiv.org/abs/2310.01714">Large Language Models as Analogical Reasoners</a></p><p><a href="https://arxiv.org/abs/2210.03629">ReAct: Synergizing Reasoning and Acting in Language Models</a></p><p><a href="https://arxiv.org/abs/2402.08939">Premise Order Matters in Reasoning with Large Language Models</a></p><p><a href="https://agenticai-learning.org/f24">Berkeley RDI, Agentic AI</a></p><p><a href="https://rdi.berkeley.edu/adv-llm-agents/sp25">Berkeley RDI, Advanced LLM Agents</a></p><p><a href="https://arxiv.org/abs/2211.01910">Large Language Models are Human-Level Prompt Engineers</a></p><p><a href="https://arxiv.org/abs/2205.10625">Least-to-Most Prompting Enables Complex Reasoning in Large Language Models</a></p><p><a href="https://arxiv.org/abs/2209.15003">Compositional Semantic Parsing with Large Language Models</a></p><p><a href="https://arxiv.org/abs/1912.09713">Measuring Compositional Generalization: A Comprehensive Method on Realistic Data</a></p><p><a href="https://arxiv.org/abs/2402.03620">SELF-DISCOVER: Large Language Models Self-Compose Reasoning Structures</a></p><p><a href="https://aclanthology.org/P17-1015.pdf">Program Induction by Rationale Generation: Learning to Solve and Explain Algebraic Word Problems</a></p><p><a href="https://arxiv.org/pdf/2104.08691.pdf">github.com/google-research/bert/blob/master/tokenization.py</a></p><p><a href="https://arxiv.org/abs/2110.14168">Training Verifiers to Solve Math Word Problems</a></p><p><a href="https://arxiv.org/abs/2112.00114">Scratchpads for Intermediate Computation with Language Models</a></p><p><a href="https://platform.openai.com/docs/guides/reasoning-best-practices">https://platform.openai.com/docs/guides/reasoning-best-practices</a></p><p><a href="https://openreview.net/forum?id=3EWTEy9MTM">Chain of Thought Empowers Transformers to Solve Inherently Serial Problems</a></p><p><a href="https://blog.google/technology/ai/google-gemini-ai">https://blog.google/technology/ai/google-gemini-ai</a></p><p><a href="https://openai.com/index/learning-to-reason-with-llms/">https://openai.com/index/learning-to-reason-with-llms/</a></p><p><a href="https://arxiv.org/abs/2312.11805">Gemini: A Family of Highly Capable Multimodal Models</a></p><p><a href="https://arxiv.org/abs/2403.05530">Unlocking multimodal understanding across millions of tokens of context</a></p><p><a href="https://arcprize.org/blog/oai-o3-pub-breakthrough">https://arcprize.org/blog/oai-o3-pub-breakthrough</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf9d590ca554" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/on-llm-reasonings-inference-time-prompting-techniques-bf9d590ca554">Inference-time Prompting Techniques for Language Reasoning Agents</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[On LLMs’ Reasoning Strategy Approaches]]></title>
            <link>https://www.cantorsparadise.com/on-lms-reasoning-strategies-approaches-f843651b7bf8?source=rss-6acfbf0d8c9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f843651b7bf8</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[math]]></category>
            <category><![CDATA[writing-prompts]]></category>
            <dc:creator><![CDATA[Hamid Nafiyan]]></dc:creator>
            <pubDate>Sat, 31 May 2025 17:21:03 GMT</pubDate>
            <atom:updated>2025-12-08T09:13:51.016Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>In the literature of Agentic AI, solving real-world tasks requires a trial-and-error process. The fact is that LLMs in real-world tasks have weaknesses because LLMs need to interact with new environments to understand the successes and failures of different actions. That is why an agent can interact with the environment and get feedback from it. This agent has its own internal memory and revises it when receiving feedback from the environment. By memory revision &amp; leveraging tool-use alongside RAG, the agent’s capability is improved and expanded concerning making more informed decisions. When it comes to complex tasks (including tasks like decomposition, allocation, division, subtasks to specialized modules, labor for project collaboration between different specialized modules, and multi-agent settings workflows), designing the needed workflows using agents facilitates the accomplishment of such complex tasks to get better responses. The key is in all tasks; the LLM is the brain of the agent, such that the agent leverages its LLM for reasoning, inferencing, and planning. Enabling LLMs to generate intermediate steps, or a chain of thought (CoT), before outputting the final answer is considered one of the clues that unlock the advanced capabilities in complex reasoning tasks lies in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*eVTBJPUHiuNgjtddSco71w.png" /><figcaption>AI Agent— Empowering LLMs with the agent framework, enabling LLMs to interact with the environment</figcaption></figure><p>Instructing the model to generate a sequence of intermediate steps, <em>a.k.a.</em> a chain of thought (CoT), is a highly effective method to improve the accuracy of language models (LLMs) on arithmetics and symbolic reasoning tasks. This can be achieved through various strategies and techniques. A natural explanation is that the intermediate steps provide extra information about the tasks and efficient approaches to solving, so that a model can imitate or better estimate. In fact, LLMs’ intrinsic reasoning abilities (as CoT reasoning paths) can be elicited from pre-trained LLMs.</p><blockquote>However, sometimes we want LLMs to solve reasoning tasks with and without CoT in order to achieve high-performance rigorous reasoning either as expert models or generally adopted across various domains.</blockquote><p>This article aims to explore under the hood and details on how the “strategies, techniques and methodologies” (investigated and introduced through Berkeley’s RDI Center) improve the rigorous reasoning capability of LLMs along with its robustness of inferencing as well as its well-supported planning to reasons, all of which to address various issues such as search algorithms and search space scaling up, effective test-time scaling, self-correction capability, optimization problems, oracle feedbacks, varied-level mathematical problem-solving (grade-school to IMO), robust-code generation, NIAH, distracting rules, imitated-reasoning of fundamental human cognitive functions, transformers core problems, local knowledge distillation just to name a few. Here, the assumption is that such methods of reasoning-inferencing-planning allow for performing more serial or parallel computations that even a sub-optimal LLM might struggle with, and a vanilla transformer most likely cannot do without leveraging these methods.</p><blockquote>Please refer to the references &amp; credits of the material covered in this article as well. Also note that all photos are screenshots taken from papers to which referred in this article.</blockquote><h3><strong>Reasoning Strategies</strong></h3><p>Here, discovering good prompting strategies for reasoning is our challenge. It stems from the fact that there is no clear principle of how to write optimal prompts. So, therefore, the Goal here is “Rigorous Reasoning”, gaining robustness of reasoning to enhance reasoning performance. The key idea is that there have long been Inherent Strategies for problem-solving, given from mathematical numerical analysis theories(G. Poyla), saying “<em>If you go into details, you may lose yourself in details”</em>.</p><p>What has been previously seen from Transformers:</p><ul><li><strong>Taking the transformer’s role, deep thought, into account;</strong> if the transformer generates intermediate steps by itself then the LLM can solve any inherently Serial problem as long as its depth (problem’s depth) exceeds a constant threshold which is that “losing in details threshold” (this is of course the zero-shot method).</li><li><strong>Hinting the LLM by whispering “Let’s think about it step by step”?</strong> This time, LLM generates intermediate steps and tries to reach to accurate answer (not given any shot).</li><li><strong>No deep thought; </strong>asking it the question, wanting it to direct immediate answer! Here, if transformers generated direct answers, then LLM either more probably needed much deeper thought to solve the question, or (e.g., as many-shot or few-shot) or more likely made a mistake, even outputting an incorrect answer (in case getting no depth like zero-shot)</li><li><strong>Needle in a haystack (NIAH):</strong> putting a piece of sentence/image/audio/video as one key fact (called a “needle”) into a long text of irrelevant information in the prompt and asking LLM to retrieve its context to find and use this fact to answer a question. The twist is the question, and the key fact uses different but related words. Often, transformers find answers by matching words that appear in both the question and text. Often, LLMs even struggle as texts get longer, but good retrieval starts off when smaller contexts are searched. Although we want LLMs can use real knowledge to bridge gaps, not just match similar words, but actual reasoning in long contexts, meaning models need to get better at reasoning, not just matching in long contexts. One skill might be breaking text into smaller chunks that still helps. It is going to be mentioned in this article later on.</li><li><strong>Risk of memorization or say overfitting: </strong>despite interacting and encountering new context in the same environment, the LLM still tends to refer to its memorized datasets, taking actions not suitable for new context and user applications, but based on pre-trained overfitted ones.</li><li><strong>Hallucination</strong>: due to the hallucination, the LLMs are likely to give an inconsistent response compared to the existing downstream information. Hallucination is one of the reasons why causality is absent in LLMs’ reasoning. Minimizing the model’s hallucinations, as well as leveraging physics-inspired empirical outside-world truth for LLM inference, has been a desirable goal in the LLM’s reasoning.</li><li><strong>Sycophancy, Bias, and Semantic Leakage</strong>: These issues are proven to have affected LLMs&#39; output. The problem is that the whole context affects LLM output, even irrelevant parts! LLMs inherited this problem from transformer architecture, still going on as one of the current-day problems. It stems from the fact that we, for now, consider it as a <strong><em>Hypothesis</em></strong><em> </em>that “<em>Soft-attention inherently spreads attention thin over everything. Also, the LM objective favors correlations</em>.” This may give rise to the <strong><em>Semantic Leakage</em></strong><em> </em>or that LLMs learn <strong><em>Spurious Correlations</em></strong>, or even yield <strong><em>Sycophancy </em>or <em>Bias</em></strong>.</li></ul><h3><strong>Reasoning Strategy Approaches:</strong></h3><p>In order for the LLMs to avoid losing in detail, getting stuck in long contexts, overfitting, as well as not being instructive-only, and to achieve higher performance, leveraging some strategy approaches can be beneficial, which we refer to as Implicit strategies and Explicit strategies.</p><h4><strong>1-</strong> <strong>Compositional Implicit Reasoning</strong></h4><p><strong>Idea</strong>: <strong>Reviewing a potential hidden way, Implicit Relations in Transformers</strong></p><p>During pre-training, an LLM memorizes facts as its knowledge. From the relevant fact vectorized, it then infers the other related fact, which is also vectorized as its prediction (answer). I.e., given a fact, the model embeds all of each token as a vector representing the relationship among them. Then, given another fact (correlated to the former), the model again does so for the latter’s tokens. The association between two vectorized facts forms through the model’s parameters’ weighting. When a query comes in, the model finds the most similar vector based on cross-entropy loss to infer the next token (included in each of the two facts).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*BTvempBuWHKQw2X69cuwIw.png" /><figcaption>Example of relations in data for compositional reasoning</figcaption></figure><p>As can be seen, the LLM here, via a single forward pass, can infer the next token amongst its vectors just through its parameters’ weight without needing to verbalize any CoT that occurred. So the potential gain is that just the intrinsic Implicit relations in transformers make LLM capable of generalization, as directly predicting the answer.</p><blockquote>So why does the intrinsic implicit reasoning matter for us to leverage it for strategies?</blockquote><blockquote>Implicit reasoning fundamentally determines how well LLMs acquire structured representations of facts and rules, and reasoning strategies from data and during pre-training. In fact, implicit reasoning is the model’s internal belief or hidden thought (hidden CoT) before generating the response. It is the default mode of large-scale (pre-)training with no CoT at training time.</blockquote><p><strong>Issues:</strong></p><p>LLMs, however, have struggled with some issues with implicit reasoning, which have been solved at the time:</p><ul><li>Compositionality gap on related facts at scale: as related facts were scaled, the model with more reasoning steps no longer responded as correct, meaning the model could not do multi-hop reasoning well, and only showed substantial evidence in the first hop reasoning.</li><li>Also, some issues have been seen in comparative reasoning when comparing properties of the fact together in spite of knowing those facts themselves. E.g. task of comparing the age of two people while knowing their ages.</li></ul><h4><strong>1–1-</strong> <strong>Compositional RL-based Implicit Reasoning for long CoTs</strong></h4><p>The key idea is that by leveraging a base model, we can make it capable of explicit reasoning techniques by training it on explicit strategy techniques, and then use the model to reason implicitly, but this time based on its internal explicit knowledge.</p><p>To do so, a capable base model is chosen to learn some explicit strategies (such as analogical, self-refine, self-reflection, instructive, …). and after training, the model learns by using a reinforcement learning mechanism to make and use compositions of those strategies so that it gets to a suitable combined-strategy which is also high-performant. That is, RL has the model continuously try various explicit strategies, and therefore makes it not lazy, which might cause it to even learn very new strategies. This mechanism can result in an LLM that is still able to reason implicitly while generating long CoTs. Note that if the base model is not capable enough, then RL can not do much.</p><h4><strong>1–2-</strong> <strong>Optimization on Compositional &amp; Comparative Implicit Reasoning</strong></h4><h3><strong>Inductive Learning of Deduction Rules:</strong></h3><p>The fundamental question here is whether transformers can even learn reasoning as a skill. And if so, what factors are important in gaining such skills? This leads us to a form of optimized implicit reasoning, so-called Inductive Learning of deduction latent rules. In this method, latent rules are elicited and captured through the following setup:</p><ul><li><strong>KG of Atomic Facts:</strong> The first step is to constitute a knowledge graph through the knowledge required for LLM, consisting of entities (as nodes) and their relations (as edges) as examples of atomic facts.</li><li><strong>ID &amp; OOD facts: </strong>Randomly splitting atomic facts into ID (in-distribution) &amp; OOD (out-of-distribution) atomic facts. For: ID facts: Anderson&#39;s wife Luisa</li><li>OOD includes facts, none of which were seen during training, and therefore have no composition with ID_train and ID_test facts.</li><li><strong>Learning latent rules through multi-hop relation</strong>: In this step, a standard decoder-only transformer is trained separately on ID and OOD sets to extract latent rules from premises:</li></ul><p><strong>(head, relation1, bridge) ^ (bridge, relation2, tail) -&gt; (h, r1, r2, t)</strong></p><blockquote><em>The latent rules are relation1, relation2, and bridge. Here is an example:</em></blockquote><blockquote>fact1: Anderson’s wife is Luisa &gt;&gt; (Anderson, wife, Luisa)</blockquote><blockquote>fact2: Luisa born in 1971 &gt;&gt; (Luisa born, 1971)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*RGnXSHiWoBPAYHQBRJ2NGw.png" /><figcaption>Setup- inductive learning of deduction rules</figcaption></figure><blockquote><em>The transformer’s first layer learns bridges, then the next layers learn to extract relations, and in the last layer, the tail is elicited as a prediction. Finally, the transformer memorizes these latent rules as new inferred facts. This way, it is able to generalize primary atomic facts as (h, r1, r2, t).</em></blockquote><blockquote><em>The model is then trained on the datasets of the inferred facts (latent rules), similar to cross-validation splitting: ID_Train, ID_Test, and OOD_Test.</em></blockquote><blockquote><em>That is, all samples in both test sets are unseen (holdout sets) for the training set, such that the ID_Train set comprises the compositions of relations of atomic facts as 2-hop compositions. E.g.:</em></blockquote><blockquote>(relation1: Anderson’s wife Luisa) -&gt; (relation2: Luisa born in 1971)</blockquote><blockquote><em>And ID_test set consists of the exact inferred facts: “Anderson’s wife was born in 1971”</em></blockquote><blockquote><em>Hence, in this stage, the deduced rules must be inferred for our generalization purposes. Then the generalized results (predictions) must be compared with the exact inferred facts in ID_test, to calculate the prediction Error/Loss.</em></blockquote><ul><li><strong>Systematic Generalization</strong>: Due to the fact that OOD_test set 1- does, on one hand, include just atomic facts and does not include any relations, and 2- on the other hand its atomic facts are not present neither in ID_train nor in ID_test, and therefore have no relation with their facts, this dataset (OOD_test) is stronger than ID_test in terms of generalization making it completely suitable for comparing next token (ID_Train_Predicted) with real-world facts (OOD_Test_Real) to evaluate the final answer to user.</li></ul><p><strong>Our goal: </strong>if evaluation via the OOD_Test set performs well, then this implies the model can learn deduction rules with high accuracy, being able to apply to any arbitrary facts</p><h4><strong>1–3- Grokked Transformers:</strong></h4><p><strong>Debugging, Interpreting, and Performance Measurement through Grokking:</strong></p><p>Transformers can learn to reason implicitly, but only through a process called ‘grokking’. A Model reaches the well-generalization during grokking in which it has the highest accuracy. By investigating various conditions, we can discover under what circumstances the model can generalize well with its own highest accuracy. So, by realizing these conditions, the model can faster reach its grokking level. These conditions can comprise hyperparameter variances, data distribution, and etc. Hence, we can analyze the changes during the grokking process by interpreting this behavior inside a grokked transformer, meaning debugging the model and improving it. However, the questions still remain are: Why does grokking happen? What happens during grokking? And why does the level of systematicity in generalization vary? Answering these requires a deeper look inside the model. So, for making a napkin for this mechanistic interpretation technique:</p><h4><strong>1–3–1- Analyzing the changes during grokking to Detect Generalizing Circuits</strong>:</h4><p>Using this technique, by intervention in the internal mechanism of the transformer, we then investigate the impact of this intervention on the output, such that, we can compare this perturbed run’s result with that of a normal run. The intervention here means injecting a change inside the transformer, then following it throughout the model’s layers all the way to the output, such that we can measure how much it impacts the final output. That is, by monitoring various places, we can figure out which has the most impact on the output variance. By doing so, we detect affected circuits during grokking. Given this idea of analyzing by intervention, we at first make a change into the internal state of a neuron (activation) of one of the hidden layers __for example by multiplying its activation result by an embedding matrix­­__ in order to get its distribution to check its internal representation. For this purpose, we can use a tool called “Logit Lens” to make the change, and use another tool called “Causal Tracing” to measure the effect of that change or i.e. effect of the perturbed activation’s internal state. This measurement is between 0 and 1, if rated near to 1, meaning that the affected internal state has a larger impact on the final NN’s decision.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*XwrlGN26lSsC8y0pGY3P0Q.png" /><figcaption>Analyzing the changes during grokking</figcaption></figure><p><strong><em>The important takeaways for this stage are that it is the critical data distribution (not the size of the data) that matters for grokking to happen.</em></strong></p><h4><strong>1–3–2- Analyzing Generalization Behavior: Generalizing Circuits for Facts &amp; Rules</strong></h4><p>In this step, we want to discover what circuits are formed for different reasoning types (comparative/compositional);</p><p>· For compositional reasoning, the circuit is formed as:</p><blockquote>o In early layers (lower layer 0 to 5), the bridge facts are learned. E.g.: bridge (head, relation): Anderson Luisa</blockquote><blockquote>o In the next layers, the transformer learns relation facts. E.g., relation (bridge, relation2): Anderson Luisa born in</blockquote><blockquote>o In the last layer, the prediction (tail) must be added to the rules (deduced in previous layers). Then memorizing this prediction to form a generalization: (h,r1,r2,t)</blockquote><p>· for comparison reasoning: it has a different circuit called a parallel circuit:</p><blockquote>o In early layers (lower layer 0 to 5), the transformer in a parallel way learns attributes: Cristopher is 67, Teddy is 73</blockquote><blockquote>o Upper layers (7,8), use the facts (recently learnt) to do comparison &amp; predict the final answer (smaller/larger).</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*pSuLBP6iTpuuvIW7Zl4Ygw.png" /><figcaption>Generalizing circuit configuration determines systematicity of generalization</figcaption></figure><p><strong><em>The important takeaway of this step is that the difference in the circuits’ configurations determines the reasoning type (generalizing circuits’ configuration).</em></strong></p><h4><strong>1–3–3- Debugging and Fixing; Cross-Layer Parameter Sharing</strong></h4><p><strong>Captured bug:</strong><em> OOD generalization on composition never happened? Why?</em></p><p>In the ID_set, the bridge compositions (h,r) are stored in lower layers after being learned. And also the relation compositions (h,r1,r2,t) are stored in the upper layers as well after being learned. That is, the transformer memorizes all of the facts &amp; deduced rules, and that is why at test time, it knows them so well and has generalized them.</p><p>Whereas, in OOD_set, due to the fact that none of these atomic facts have been seen during training to be composed with others, the model does not store any composition of them in the upper layer. In fact, the model, despite learning such rules, has no incentive to store the second half of atomic facts, which are relations! And that is why OOD generalization never happens. So our transformer seems to need extra effort!</p><p>However, OOD does not have this problem for comparison tasks. Because there is no second relation between atomic facts (learned in lower layers) to be stored as deduced rules in the upper layers. Therefore, just retrieving their attributes is enough to be compared in the upper layers’ activations, and finally making the prediction (smaller/larger).</p><p><strong>Fixing the bug:</strong></p><p>To fix the problem of compositional reasoning in OOD, we make use of a technique called “cross-layer parameter sharing” in which we tie weights of the lower layers with the weights of the upper layers, i.e., “parameter sharing”. By doing so, if the lower layers memorize atomic facts, then the upper layers also will get “a copy of them” from the previous layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWaxig3QkF2Ezalo24vipg.png" /><figcaption>Cross layer parameter sharing and improving systematic generalization performance</figcaption></figure><h3><strong>1–3–4- ‘Aha moment’:</strong></h3><h4><strong><em>Emergence of Self-reflection Behaviors, from Memorization to Well-Generalization</em></strong></h4><blockquote><em>Taking the Budget-forcing approach, we can let the model think more. But how?</em></blockquote><p>There is an underlying method to do so, that leverages system instruction as an internal hint token in order to tell the model “Wait! you are not sure if your answer incorrect/incomplete/uncertain” and with that we force the model to generate more tokens which in turn leads it to think longer and longer ending up with a more accurate answer, i.e., scaling performance without adding any extra prompt templates (meaning without explicit instruction-tuning via SFT). In DeepSeek, this internal mechanism is called “Aha moment,” by which the model itself has learnt to understand its mistakes and therefore rethink them and then fix them, by saying like “Wait, wait! …” which is an aha moment it can flag here. Following this flag, the model starts to generate new CoT to reach a verifiable answer, meaning quality performance. In fact, during the “Aha moment”, the model learns emergent skills such as self-reflection.<br>On the other end of this spectrum, Grokking is also an underlying phase transition from rote learning(overfitting) to generalization. It starts from overfitting(memorization) and gradually goes toward generalization, meaning just having zero loss doesn’t mean the model is able to capture generalizable circuits, but it just memorizes the facts, not in a generalizable way. Hence, well-generalization takes place when the generalizing circuits are formed</p><p>To further validate our hypothesis: using an intervention technique for parameter sharing (tracing causal strength throughout all layers), we can still see the well-generalization happening on compositional reasoning, resulting in proving our hypothesis that tying the layers’ memories together works well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*MCO-1YQ92gP9RtbMQIiJ8Q.png" /><figcaption>Grokking is when the generalizing circuit forms and outcompetes the memorizing circuit</figcaption></figure><blockquote><strong>The important takeaway of this step is that the generalizing circuit is much more efficient than the memorizing circuit (for rote learning).</strong></blockquote><h4><strong>1–3–5- Circuit Efficiency and Regularization: Regularization for Dangerous-Circuit Honing</strong></h4><p>Keeping training even after overfitting, where regularization is applied to the model gradually builds more efficient circuits, ending up with the desired generalizing circuit. That’s why it is beneficial to train way beyond overfitting, and that’s when the regularization starts to kick in and gets us a more efficient circuit. Hence, the grokking mechanism covers both memorization and regularization, which can end up in generalization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*8ra5W-fWKTrIQFUrY0fxkQ.png" /><figcaption>Implicit regularization even after overfitting or memorization resulting in generalization and circuit ffficiency</figcaption></figure><p><strong><em>The important takeaway of this step is that grokking enables memorization during early training phases, which later, due to the “implicit regularization effect”, transits into generalization.</em></strong></p><h3><strong>2-</strong> <strong>Explicit Strategies:</strong></h3><p>These methods explicitly instruct the LLM with the desired reasoning strategies for problem-solving. From a software engineering perspective, the good practices, instead of user-given general shots (manual CoT) are to give a clear guideline to the model such that it contains the instructions of what exactly we want. And the model then just follows out instructions as an interactive discussion or as a long-detailed instruction at once. By doing so, we aim for:</p><ul><li>Instructing LLM to automate the prompt design, allowing it to generate self-optimized reasoning pathways without explicit human intervention.</li><li>Utilizing instruction prompting to explicitly guide the model toward generating a structured CoT, improving interpretability, and stepwise reasoning.</li><li>Applying few-shot prompting where examples are provided with labeled intermediate reasoning steps, reinforcing the model’s ability to generate CoT responses in a guided manner</li><li>Encourage longer CoT for complex tasks.</li><li>Support reasoning strategies required for the task.</li><li>The best use of the token space budget(decreasing token cost). Instead of giving a bunch of all CoTs and a few shots to the LM, we can break exemplars into smaller parts and then provide every subproblem with the CoT &amp; exemplars in proportion to each subproblem’s need.</li></ul><h4><strong>2–1- Chain-of-Verification (CoVe):</strong></h4><p>Language models sometimes fail at inferring factuality, tending to hallucinate about the context (user prompt), which is due to the fact that transformers during self-attention inherently tend to thin-attention rather than sharp-attention.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DEM380BVelr3dK5EXHh6iA.png" /><figcaption>Factuality and hallucination, where LLMs fail</figcaption></figure><p>Using a mechanism called Chain-of-Verification (CoVe), they can verify if their early outputs are factual, and therefore avoid such hallucinations. To do so, CoVe is a structured approach where an LLM generates reasoning steps and explicitly verifies intermediate conclusions to reduce hallucination, errors, and improve robustness. One example of this would be like the following prompt, where the LLM tries to apply some verification on its early responses so that it can generate the verified answer as factual.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*YIUdjgFtkYtmdSDWuYmbvQ.png" /><figcaption>Chain-of-Verification (CoVe) steps</figcaption></figure><p>Here, the variants of verifications that happened include:</p><ul><li><strong>Joint:</strong> left-to-right generation of all four steps</li><li><strong>Factored</strong>: step (3) attends to (2) but not to step (1)</li><li><strong>Factor with Revise</strong>: Extra “cross-check” step where LLM explicitly checks if 2 answers seem to match.</li></ul><h4>2–2- Effortful Thinking by Instructing rewriting of the input</h4><p>Sycophancy and Bias are proven to have affected LLMs&#39; output. The problem is that the whole context affects LLM output, even irrelevant parts! LLMs inherited this problem from transformer architecture, still going on as one of the current-day problems. It stems from the fact that we, for now, consider it as a <strong>Hypothesis</strong> that “<em>Soft-attention inherently spreads attention thin over everything. Also, the LM objective favors correlations</em>.” This may give rise to the <strong>Semantic Leakage</strong> or that LLMs learn <strong>Spurious Correlations</strong>, or even yield <strong>Sycophancy or Bias</strong>.</p><p>In its internal mechanism, the model tends to attend to the input (context) and therefore becomes correlated to it. Then the model relies on correlations and, in its inference, favors correlations. This transformer’s internal feature becomes problematic for LLMs! In the sense that it brings about over-attention to the context (user prompt), and therefore makes the model biased, meaning the model is biased not to Factuality but to Hypothesis. i.e., Soft(thin)-attention happens rather than Sharp-attention. In consequence, models in any context either hallucinate or produce irrelevant answers, or bias or sycophancy (tend to agree with the user’s opinion). In math tasks, the irrelevant parts in prompts even try to fool the model!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*EVvpZ11oze476v-MrqSpOA.png" /><figcaption>Example of Semantic Leakage</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*COZo1VkZNimJaTrfp-R2hg.png" /><figcaption>LLMs learn spurious correlations</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*TpnDeCVFE8xBAUtBJLezqQ.png" /><figcaption>Sycophancy — LLMsagrees with user’s opinion</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*2x9gMu2CFvFmdSbVIBhb5Q.png" /><figcaption>More Explicit and effortful Attention, Ignoring irrelevant parts for less biased answer</figcaption></figure><p>To resolve such situations, one explicit way is to make attention more <strong>Explicit &amp;</strong> <strong>Effortful</strong> by prompting LLM to extract relevant context, meaning deciding what to attend explicitly by rewriting the input. By doing so, in fact, we have the LLM itself remove the irrelevant parts of the user prompt. Because without time to think, even humans make mistakes and are biased too. Therefore, we need a more explicit way that uses effortful thinking! So that it results in the LLM ignoring irrelevant parts and generating a less biased answer. Here are the examples of rewritten inputs for the previous ones:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*zE-w67gNlBASLrU3ICmY1g.png" /><figcaption>Decide what to attend explicitly by rewriting the input</figcaption></figure><p>The steps are just simply as follows:</p><ul><li>Give the original instruction to LLM,</li><li>And then ask the LLM to rewrite the instruction, ignore the irrelevant parts, and remove the bias</li><li>And then get a new instruction</li><li>And then get the LLM to answer the rewritten instruction</li></ul><p>As shown below, it yields better results, and hence the model is not biased as much.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*oOFkxrWlojn3T53oL--AaA.png" /><figcaption>Branch-Solve-Merge for Evaluating and Improving Respose, Given a Complex and Large Task</figcaption></figure><h4><strong>2–3- Analogical Reasoning</strong></h4><p>This method draws inspiration from mathematical analogy, Inferring Step-by-step reasoning based on related previously solved problems’ methods or results, or experience. Here, without hinting “let’s think about it step-by-step”, the transformer learns to be able to generate reasoning step by step by itself as it generates intermediate steps to decompose the problem and finally recombines intermediate steps to infer the solution. This way, instead of chains-of-though prompting (through 0-shot or few-shot manual examples as intermediate steps), we have this analogical reasoner generate relevant problems itself according to every problem to infer the solutions and reach the final answer in an analogical way.</p><h4><strong>2–4- Decomposition (Compositional Generalization)</strong></h4><p>This method also gets ideas from mathematical strategies in which we decompose the whole into its parts, and then recombine the parts into a more/less different whole. Here, the goal is to decompose complex tasks into simpler tasks. The core approach is called “Least-to-most prompting” or “least complex to most complex problem” in order to achieve easy-to-hard generalization via decomposition. Here, we explicitly tell to model what the best practice is to decompose the original problem. I.e., instead of the classical method of using exemplars &amp; CoTs, we give an instructive guide as CoT to the LLM, stating “how to break the given complex task into subtasks”. Through this problem-reduction process, the model:</p><ul><li>Reduces the problem to subproblems such that each is easier to solve (needs fewer calculation steps). e.g, CoT: to solve X, we need to solve Y first</li><li>Solves subproblems sequentially, and then combines the solutions to solve the whole problem. First, it calculates the solution for Y, then, by knowing the solution to Y, calculates the solution for X. Then solves the original task.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*_ejkOELdDMf1sTAChgahFA.png" /><figcaption>Example of Least-to-most prompting — easy-to-hard generalization via decomposition</figcaption></figure><p>There are some optimizations for the decomposition method, such as SCAN, dynamic least-to-most complex prompting, self-discover reasoning structures, etc. For example, in an experiment called SCAN for translating synthetic natural language commands into action sequences, where for the “length split” action sequences in the test set are longer than training samples, to solve the SCAN compositional generalization benchmark, least-to-most prompting can achieve nearly perfect test accuracy with 0.1% training samples as exemplars.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*65RNpIvxYXlRbba-k25MSA.png" /><figcaption>Least-To-Most Complex Prompting, solving the SCAN compositional generalization benchmark</figcaption></figure><p>In another example, in the CFQ (Compositional Freebase Questions) benchmark, to solve text-to-code compositional generalization benchmarks, the challenge was a more complicated grammar with a larger vocabulary, when a single prompt might not be enough to cover all grammar rules. Here, decomposition enables a customized prompt for each subproblem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*t3OF88HH9aJFShU47fO3Fw.png" /><figcaption>text-to-code compositional generalization benchmarks in CFQ</figcaption></figure><h4><strong>2–4–1- Dynamic Least-To-Most Complex Prompting</strong></h4><p>DL2M mechanism not only reduces, but it also does:</p><ul><li>Selects the most relevant context for each subproblem, meaning it dynamically chooses exemplars in proportion to each subproblem.</li><li>Generates a customized prompt for each subproblem (e.g, in text-to-code generation)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*HBiHAEMGnEHhFMAFbfOzJA.png" /><figcaption>An example of dynamic least-to-most prompting</figcaption></figure><p>And again, the evaluation on CFQ is shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HVFAlFVlys4uBQx82U2lLQ.png" /><figcaption>Dynamic least-to-most prompting, evaluation on CFQ</figcaption></figure><h4><strong>2–4–2- Self-Discover Reasoning Structures</strong></h4><p>This approach instructs the LLM to compose reasoning structures for each task. It says different reasoning tasks require different reasoning structures, such that it composes task-specific reasoning structures without manually written demonstrations. This way, the required data is provided for each subtask in the form of a dictionary structure. E.g.:</p><p>subtask1:{instruction:””, exemplar1:””, exemplar2:””, reasoning structure: { “item1”:value1, “item2”:value2, …}}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*i1LHN5gjxju44oQUrv5EjQ.png" /><figcaption>Self-Discover- instruct the LLM to compose reasoning structures for each task</figcaption></figure><p>For example, the accuracies gained using this approach over direct answer compared with the chain-of-thought are shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*vfJ1eY7yqtlroMCUmnIJFg.png" /><figcaption>Self-discover over direct answer vs over chain-of-thought</figcaption></figure><h4><strong>2–5-Branch-Solve-Merge Approach (LLM-as-a-Judge)</strong></h4><p>The key idea here is to give extra time to the LLM in order to think more. To do so, the model breaks down response evaluation into subproblems, each of which is evaluated based on some (additive) criteria (relevance, clarity, accuracy, coverage, usefulness, originality, and expertise) such that the model comes up with those criteria specific to the task. In this method, the original task is not broken into smaller subtasks. The model does not solve the problem in a divide-and-conquer way, but evaluates the original task based on various criteria, performing judgments on many responses via several criteria.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*Kf4ocSgSALedLTGw8Gm1eg.png" /><figcaption>Instructs the LLM to evaluate the response using five additive criteria (relevance, coverage, usefulness, clarity and expertise)</figcaption></figure><p>The instructive approach to do by model includes the following steps:</p><ul><li>Given a task, generate a plan to break it into subproblems</li><li>Solve subproblems, one for each branch</li><li>Given partial solutions, merge solutions</li></ul><p>Example Experiment: Assume we have a pool of prompts that represent user requirements. The model in the t-th iteration (Mt) generates k (we choose k=4) candidate responses for each new prompt, Mt, which also predicts reward for each response via LLM-as-a-Judge prompting. Given a prompt and k responses, we select the highest-scoring response as the winning one and the lowest-scoring response as the losing one to form a preference pair. Then we conduct DPO training on those pairs to get Mt+1 starting from Mt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*yTWhp3TVEhQV2zy6EI8CUg.png" /><figcaption>LLM-as-a-Judge process- includes pool of bootstrap instructions and iterative self-instruction and instruction following training</figcaption></figure><h3><strong>References &amp; Credits:</strong></h3><p><a href="https://language-agent-tutorial.github.io/">Language Agents: Foundations, Prospects, and Risks</a></p><p><a href="https://arxiv.org/abs/2405.15071">Grokked Transformers are Implicit Reasoners: A Mechanistic Journey to the Edge of Generalization</a></p><blockquote>· <a href="https://language-agent-tutorial.github.io/">Language Agents: Foundations, Prospects, and Risks</a></blockquote><blockquote>· <a href="https://openreview.net/forum?id=D4QgSWxiOb&amp;nesting=2&amp;sort=date-desc">Grokking of Implicit Reasoning in Transformers: A Mechanistic Journey to the Edge of Generalization</a></blockquote><blockquote>· <a href="https://arxiv.org/abs/2309.14402">Physics of Language Models: Part 3.2, Knowledge Manipulation</a></blockquote><blockquote>· <a href="https://arxiv.org/abs/2210.03350">Measuring and Narrowing the Compositionality Gap in Language Models</a></blockquote><blockquote>· <a href="https://arxiv.org/abs/2006.10413">Are Pretrained Language Models Symbolic Reasoners Over Knowledge?</a></blockquote><blockquote>· <a href="https://aclanthology.org/2020.tacl-1.48/">oLMpics-On What Language Model Pre-training Captures</a></blockquote><blockquote>· <a href="https://arxiv.org/abs/1706.03762">Attention Is All You Need</a></blockquote><p>RDI Advanced Large Language RDI Model Agents, MOOC, Spring 2025</p><p><a href="https://arxiv.org/abs/2309.11495">Chain-of-Verification Reduces Hallucination in Large Language Models</a></p><p><a href="https://arxiv.org/abs/2309.03409">Large Language Models as Optimizers</a></p><p><a href="https://arxiv.org/abs/2205.10625">Least-to-Most Prompting Enables Complex Reasoning in Large Language Models</a></p><p><a href="https://arxiv.org/abs/2310.01714">Large Language Models as Analogical Reasoners</a></p><p><a href="https://arxiv.org/abs/2310.01798">Large Language Models Cannot Self-Correct Reasoning Yet</a></p><p><a href="https://arxiv.org/abs/2407.19594">Meta-Rewarding Language Models: Self-Improving Alignment with LLM-as-a-Meta-Judge</a></p><p><a href="https://arxiv.org/abs/2211.01910">Large Language Models Are Human-Level Prompt Engineers</a></p><p><a href="https://arxiv.org/abs/2205.11916">Large Language Models are Zero-Shot Reasoners</a></p><p><a href="https://arxiv.org/abs/2201.11903">Chain-of-Thought Prompting Elicits Reasoning in Large Language Models</a></p><p><a href="https://arxiv.org/abs/2402.12875">Chain of Thought Empowers Transformers to Solve Inherently Serial Problems</a></p><p><a href="https://arxiv.org/abs/2402.08939">Premise Order Matters in Reasoning with Large Language Models</a></p><p><a href="https://arxiv.org/abs/2302.00093">Large Language Models Can Be Easily Distracted by Irrelevant Context</a></p><p><a href="https://github.com/gkamradt/LLMTest_NeedleInAHaystack">Needle In A Haystack — Pressure Testing LLMs</a></p><p><a href="https://blakesnotes.io/2025/03/01/Needle-in-a-Haystack-What-it-Does-and-Does-Not-Imply.html">Needle in a Haystack: What It Does and Does Not Imply</a></p><p><a href="https://arxiv.org/abs/2402.10200">Chain-of-Thought Reasoning Without Prompting</a></p><p><a href="https://arxiv.org/html/2402.16837v1">Do Large Language Models Latently Perform Multi-Hop Reasoning?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f843651b7bf8" width="1" height="1" alt=""><hr><p><a href="https://www.cantorsparadise.com/on-lms-reasoning-strategies-approaches-f843651b7bf8">On LLMs’ Reasoning Strategy Approaches</a> was originally published in <a href="https://www.cantorsparadise.com/">Cantor’s Paradise</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agentic LLMs, Compound AI Systems]]></title>
            <link>https://medium.com/@hamid.n.d/agentic-llms-compound-ai-systems-5156962dc9fe?source=rss-6acfbf0d8c9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5156962dc9fe</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[compound-ai-system]]></category>
            <category><![CDATA[llm-agent]]></category>
            <dc:creator><![CDATA[Hamid Nafiyan]]></dc:creator>
            <pubDate>Thu, 12 Dec 2024 17:42:24 GMT</pubDate>
            <atom:updated>2025-10-30T10:52:01.031Z</atom:updated>
            <content:encoded><![CDATA[<p>In the space of Large Language Models, there are various methods and mechanisms for building an LLM-based application. However, every AI system will make mistakes! Sometimes the LLM’s mistakes or (low accuracy) affect the companies’ services, resulting in unreliable ones that make their customers at least unsatisfied or even damaged. Some of such behaviors or limitations are inspected to have stemmed from the uncontrollability and sensitivity of chains of thought generated during the reasoning and inference time of LLMs.</p><p>In this article, I want to give an overview of a mechanism called “Compound AI” (introduced by <a href="http://llmagents-learning.org/f24">Berkeley’s MOOC </a>) by which an agent can leverage an LLM through compound modules as Task-agnostic (instead of a totally monolithic module) regarding CoTs from pretraining and finetuning to grounding and inference. Nevertheless, ever since LLMs started to blow up, turning monolithic LMs into reliable AI systems remains challenging.</p><p>Check also the references &amp; credits at the end.</p><h4><strong>Modular Monolithic AI Systems</strong></h4><p>That the monolithic nature of LLMs makes them hard to control, debug, and improve, has been an incentive for AI research to tackle this challenge so that modular programs use LMs as specialized components. We can design and build an LLM-based application as a pipeline each step of which is given to the LLM, reflecting and producing each of their responses, while each component iteratively continues to have a conversation with the LLM as task-agnostic. Given that, all hand-written prompts transformed into a set of Signatures in such a way all agents’ behaviors, reactions, reflections, limitations, metrics, optimizers, etc, are particularly declared in big JSON files as Task-agnostic prompting strategies as single-responsible CoTs and cohesive PoTs(Programs-of-though).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*soi1lbHo8T0WbNWIU2eVNQ.png" /></figure><p>There are some pros to leveraging the composition of modules handling the Agent’s tasks:<br> ⦁ Transparency: can debug trajectories &amp; offer user-facing attribution<br> ⦁ Efficiency: can use smaller LMs, offloading knowledge &amp; control flow<br> ⦁ Control: can iteratively improve the system &amp; ground it via tools<br> ⦁ Quality: can more reliable composition of better-scoped LM capabilities<br> ⦁ Inference-time Scaling: can systematically search for better outputs</p><p>Note that Inference-time Scaling can be achieved as more iterations are done on the LLM, meaning more space explorations on its NNs, all resulting in a sort of brainstorming for better outputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*Guxs0T4mPH0DAKQ-vcn-Fg.png" /></figure><p>There are also some cons:<br> ⦁ LMs are highly sensitive to how they are instructed to solve tasks, and also highly sensitive to how to ask them to play modules’ roles. This may cause a degree of limitation on each module’s performance.<br> ⦁ However, the Compound AI Systems are modular in principle, they are too “stringly-typed” meaning they couple the fundamental system architecture with incidental choices not portable to new LMs, objectives, or pipelines. They may be limited to a super-specific pipeline (strongly coupled) or even a specific LLM. Due to the fact that the components are always changing, any new changes may end up needing many changes throughout the other components.</p><p>These limitations can avoid the adaptability and portability of the compound agent. With these caveats in mind, some Architectural concerns are required to address:<br> ⦁ Controllability<br> ⦁ Iterative development<br> ⦁ Modularly-improvable</p><p>Therefore, knowing how to build controllable systems &amp; improve them modularly, we can make use of “Declarative Programming” &amp; “Language Compiler” concepts so that we can abstract Compound AI Systems as programs with fuzzy natural-language-typed modules that learn their behavior. Let’s say, considering LLM as the infrastructure, and the Optimizer as the Compiler. This way, the agent (compound modules) has the portability to be used with other LLMs or contexts. This architecture aims to resolve the problem of stringlty-typed components, and too-long prompts.</p><h4><strong>Declaratively self-improving</strong></h4><p>Considering a layer of abstraction(as delegation) and its implementation into account, we can demonstrate CoTs/PoTs as multi-hop abstractions including inputs (question, context), iterations or hops (degree of reasoning for iterative reasoning), and output (the answer). All of this together makes the multi-hop function we need in the declaration phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*I2N8cGV7eCsfWiBBcpFxow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*5Pd8YwAyfBz6SS_pHicCcA.png" /></figure><p>We don’t have gradients or intermediate labels to optimize each module! How should we go about this?</p><p>In the iteration part, there is a loop getting query to get the context as many steps as needed to think reasonably, as well as asking the question with the retrieved context. The body of the multi-hop function can handle a variety of requirements out of iterations, such as validations, extra matrics, extra RAG, extra API grounding, and even more iterations on all of these.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*RKXysrTT4nHvInzD4-GB6w.png" /></figure><p><strong>DSPy (Declaratively self-improving Python):</strong></p><p>DSPy is a framework built for this purpose aforementioned. It is for programming rather than prompting. It allows it to iterate fast on building modular AI systems and offers “algorithms for optimizing their prompts and weighs”, whether while building simple classifiers, sophisticated RAG pipelines, or even Agent loops.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jUaTYfuoJjKaXCGJ4bv_mw.png" /></figure><p>The example of a multi-hop function using DSPy can be as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*FLhZHexi57U6q8Jyg1k_Jw.png" /></figure><p><strong>Under the hood</strong></p><p>Dspy has three main modules: Adapter, Predictor, and Optimizer. First, modules are translated into basic prompts using Adapters and Predictors. The adapter parses CoTs and translates to the structured prompt the output of which this time can be parsable as the next query for the next reasoning. A predictor is kind of similar to an Adapter but takes extra parameters regarding reasoning whether to think logically or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VHOuJ1gI_bb5ZI4aTqLygQ.png" /></figure><p>Optimizers can then tune this prompt:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Yew925S7leCyyCCivHyhg.png" /></figure><p>The optimizer acts as a prompt tuner to maximize metrics. So, the optimizer is actually the metrics maximizer meaning it optimizes two parts:<br> ⦁ Instructions or the description of the task<br> ⦁ Demonstration or few-shot: that says that these examples with these inputs and these behaviors (as outputs) seem to work well in the past.</p><p>Hence, taking the above instructions, and CoT’s samples as well as other metrics, It turns the prompt into an optimized one in such a way does the following:<br> ⦁ Deep thought: Interfering optimization using metrics to increase the correctness of the response via iteratively improving the few-shot examples by testing other examples rather than only the input ones, while scoring and evaluating them<br> ⦁ If labels are not provided in the instructions and samples, it uses retrieved-context (RAG) &amp; grounded answer (APIs grounding) to enhance the accuracy<br> ⦁ The reinforcement learning in order to weight-updating and model tuning, resulting eventually in enhancing accuracy and quality of response</p><p>Optimizer plugins all the above steps in newly generated prompts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cj3sw2Wf8c7Chu_VVThVKQ.png" /></figure><p><strong>Constraints and Challenges:</strong></p><p>⦁ No access to log-probs or model weights: Developers may want to optimize LM programs for use on API-only models.<br>⦁ No intermediate metrics/labels: We assume no access to manual ground-truth labels for intermediate stages.<br>⦁ Budget-Conscious: We want to limit the number of input examples we require and the number of program calls we make.<br>⦁ Lowering quality due to the variety of possibilities of strings that come from interactions of multiple modules<br>⦁ Credit assignments: lowering performance due to the variety of modules’ prompts</p><p>To avoid such problems, and lessen the constraints, three methods can be used:<br>⦁ Bootstrapping few-shot<br>⦁ Prompt Optimization individually<br>⦁ Co-optimization</p><p><strong>Bootstrapping few-shot(self-generating few-shot examples):</strong></p><p>Optimizer builds examples itself and searches over them. It can do so in various ways, such as by asking developers to provide examples for the relevant modules or by requesting another LLM to generate examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XQHgSF2hDbXMe29v-PIaXA.png" /></figure><p><strong>Prompt Optimization individually (or OPRO: Optimization through Prompting):</strong></p><p>In this method optimizer combines previous learning and grounding such that first generates instructions (similar to the first method), and then iteratively gives the LLM previous instructions (history) to evaluate the result and improve their score. This way, the optimizer gets the LLM to explore other spaces in its NNs. This method actually indicates the importance of iterative optimizations with regard to “Model Creativity”.</p><p>OPRO can perform based on three following approaches:</p><p>⦁ Greedy Approach or Coordinate-Ascent: it works as sequential and module by module, meaning trying iteratively various instructions per module until reaching the best score of the current module then going to the next module to continue iteration. This method is expensive to run: O(NxD²xM)<br> ⦁ Parallel Approach (multi-module): It simultaneously generates instructions for multiple modules in parallel until can converge all modules’ performance.<br> ⦁ Multi-stage Bootstrapping and Synthesizing Sequential Joint-instructions: in brief, it generates every single module’s instructions optimized, and then synthesizes a big instruction (for all modules) which is iteratively optimized. This method is hard &amp; confusing for LM.</p><p><strong>Co-optimization (MIPRO):</strong></p><p>This method uses a s</p><p>Surrogate Model powered by a Bayesian-learning-based multi-prompt instruction optimizer. It enhances the previous methods via the concept of Bayesian probabilistic hyperparameter tuning rather than using random-based methods. It optimizes both few-shot examples and instruction while dealing with credit assignments using a Bayesian Surrogate Model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WcL-Q5dMDyCKJVqLUgYodA.png" /></figure><p>This method is essentially seeking an improved combination of instructions &amp; modules while looking for a suitable list of examples of every module. It performs “Every N trials, evaluates on our full val set! It continues to reach the highest quality and performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*vUxBzItadDMpqzH3tXjDYA.png" /></figure><p>So now what is the right combination of module instructions and module examples to achieve the highest performance? For this purpose, in each iteration of a pair of modules, the surrogate model calculates the probabilities to find the right combination of the instructions between those two modules. It then sends the combination to LM to check the accuracy and finally backpropagates the results onto the surrogate model so that it updates its weights in order to produce the next right combinations of instructions. It continues iteratively this process until reaching the highest score regarding those two modules’ instruction combined. It then sets the best result and goes to the next pair of modules to perform the same process on them iteratively. Eventually, It finds the best combinations amongst modules two-by-two. Hence, this method is obviously different from what is executed in the Greedy approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gh741zIF3_Xx2ECroAb7kg.png" /></figure><p>In the end, however, it is worth taking into account a controversial but well-discussed point that has been worked on as emergent concerning what LLMs cannot do well yet:</p><blockquote>“In existing LLMs, good reasoning is actually because of good training data on which LLM learned. So, therefore, LLMs are probably good at high-approximated-retrieval (accurate) rather than real reasoning and particularly causal inference ”</blockquote><p><strong>Summary:</strong><br>With regard to LLM Agents, building large-scale modular LLM-based applications comprising many different contexts/domains using the composition of modules (instead of a large monolith application) to achieve single-responsibility &amp; cohesion amongst modules, is the optimized way to architect the AI System. That way, using natural language programming, programs can often be more accurate, controllable, transparent, and efficient than models. You just need declarative programs, not implementation details. High-level optimizers can bootstrap prompts or weights, or whatever the next paradigm deals with. DSPy is a framework to do so and is being widely used in production &amp; OSS. In isolation, on many tasks, nothing beats bootstrapping good demonstrations. Generating good instructions on top of these is possible, and is especially important for tasks with conditional rules. You will still need effective grounding and explicit forms of credit assignment. The DSPy framework lies in modularity. It aims at well-scoped programs, better inference-time strategies, and new ways to optimize how LMs are used to solve tasks.</p><p><strong>References and credits:</strong><br>1- <a href="http://llmagents-learning.org/f24">http://llmagents-learning.org/f24</a><br>2- <a href="https://dspy.ai/">https://dspy.ai</a><br>3- <a href="https://www.youtube.com/live/JEMYuzrKLUw">https://www.youtube.com/live/JEMYuzrKLUw</a><br>4- <a href="https://arxiv.org/abs/2406.11695">https://arxiv.org/abs/2406.11695</a><br>5- <a href="https://arxiv.org/abs/2407.10930">https://arxiv.org/abs/2407.10930</a><br>6- <a href="https://www.youtube.com/live/QL-FS_Zcmyo">https://www.youtube.com/live/QL-FS_Zcmyo</a><br>7- <a href="https://arxiv.org/abs/2402.10200">https://arxiv.org/abs/2402.10200</a><br>8- <a href="https://arxiv.org/abs/2310.01798">https://arxiv.org/abs/2310.01798</a><br>9- <a href="https://arxiv.org/abs/2402.12875">https://arxiv.org/abs/2402.12875</a><br>10- <a href="https://www.youtube.com/watch?v=RM6ZArd2nVc">https://www.youtube.com/watch?v=RM6ZArd2nVc</a><br>11- <a href="https://arxiv.org/abs/2207.01206">https://arxiv.org/abs/2207.01206</a><br>12- <a href="https://arxiv.org/abs/2210.03629">https://arxiv.org/abs/2210.03629</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5156962dc9fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>