<?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 Dipendra Misra on Medium]]></title>
        <description><![CDATA[Stories by Dipendra Misra on Medium]]></description>
        <link>https://medium.com/@dipendrakumarmisra?source=rss-a360cf732141------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*csisBsQYWxJo3CqeUPcu1w.jpeg</url>
            <title>Stories by Dipendra Misra on Medium</title>
            <link>https://medium.com/@dipendrakumarmisra?source=rss-a360cf732141------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 08:40:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dipendrakumarmisra/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[Learning to Generate Better than your LLM]]></title>
            <link>https://medium.com/@dipendrakumarmisra/learning-to-generate-better-than-your-llm-41b9f0511ece?source=rss-a360cf732141------2</link>
            <guid isPermaLink="false">https://medium.com/p/41b9f0511ece</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Dipendra Misra]]></dc:creator>
            <pubDate>Wed, 12 Jul 2023 00:05:15 GMT</pubDate>
            <atom:updated>2023-07-12T00:05:15.590Z</atom:updated>
            <content:encoded><![CDATA[<p>We recently put out a paper proposing a new way of fine-tuning a Large Language Model (LLM) using a hybrid imitation learning-reinforcement learning algorithm on arXiv (link is <a href="https://arxiv.org/abs/2306.11816">here</a>). Co-authors are <a href="https://jdchang1.github.io/">Jonathan D. Chang</a>, <a href="http://www.cs.umd.edu/~kdbrant/">Kiante Brantley</a>, <a href="https://scholar.google.de/citations?user=vVzcztcAAAAJ&amp;hl=en">Rajkumar Ramamurthy</a>, and <a href="https://wensun.github.io/">Wen Sun</a>. The algorithm is quite simple and effective and can be used as a drop-in replacement for PPO or supervised learning approaches. This post describes the core idea of this approach and its background.</p><h3><strong>2-Methods for Training/Fine-tuning LLM</strong></h3><p>There are two popular ways of training an LLM. The first is supervised learning which was used for training GPT-3. In this approach, you train the parameters by maximizing the log-probabilities of the tokens in a large training data. Intuitively, the model is being trained to imitate the training data and be able to generate it (or, something like it). This approach is also called behavior cloning, especially in control settings. There are a few well-known issues with this approach:</p><ul><li><strong>Metric Mismatch issue:</strong> We often don’t want to imitate data but solve a task. In this case, simply imitating the data will be undesirable. Instead, we may want to train the LLM to get high rewards using a reward model task that captures generic human preferences (such as in RLHF). Or, we may have a very well-defined downstream task such as writing a summary of a movie or generating a CV out of a few lines of description. Supervised learning is agnostic to reward/task specification and, therefore, doesn’t optimize what it is being evaluated for.</li><li><strong>Distributional Mismatch issue:</strong> The LLM is trained on training data which is human-written but when it is evaluated the text is generated by the model. This mismatch means that the model is more likely to make mistakes. In very simple terms, the model hasn’t learned to “stand on its own feet”. Further, every mistake it makes can push the model increasingly away from the <em>correct</em> human-written text on which is trained, further, increasing the chance of failure.</li></ul><p>Reinforcement learning (RL) approaches address both these two issues. Firstly, in reinforcement learning, the model is trained to maximize the reward. Secondly, in popular RL approaches such as PPO, the model tries to generate data on its own during training to maximize the reward which removes the distributional mismatch. The figures below visualize the two settings. RL was used to train ChatGPT on top of GPT3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*01gCuer9RpeNvLAxXoA-cw.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kduSk9mFSXlUo-Beok8M5A.gif" /></figure><p>Unfortunately, RL can be expensive meaning it will use lots of samples to give good results. This is where imitation learning approaches enter into the picture.</p><h4><strong>Imitation Learning for LLM</strong></h4><p>In imitation learning approaches such as <a href="https://arxiv.org/pdf/1406.5979.pdf">AggreVate</a>, <a href="https://arxiv.org/pdf/1703.01030.pdf">AggreVateD</a> and <a href="http://proceedings.mlr.press/v37/changb15.pdf">LOLS</a> (those are actual algorithm names!), one still maximizes the reward and trains the LLM to generate data on its own during training. However, one uses the help of a “reference LLM” to guide the LLM during training.</p><p>We will consider two separate settings here. In the first setting, called the <em>improvement setting</em>, this reference LLM is good but not perfect and so we want to improve upon it. In a typical setting, this reference LLM will be the LLM trained using supervised learning. In the second setting, called the<em> imitation setting</em>, this reference LLM is very good but is expensive to use and so we want to distill it down into a cheaper LLM that we will train. In both cases, the algorithm behaves the same way.</p><p>Let’s understand this more with the help of an example and a simple IL algorithm called AggreVate. The algorithm runs updates in a loop. In a single update, you sample a prompt from the dataset and first generate part of the text using our trainable LLM (to make the model stand on its own feet). This is called the <strong>“roll-in”</strong> phase. We then use the reference LLM to complete it, in effect, showing how to adequately recover from a given generation. This is called the <strong>“roll-out”</strong> phase. At the end of the generation, the model gets a reward that is used to optimize the LLM, not the reference LLM. We won&#39;t get into the details of how the model is optimized but it suffices to say that it is done very similarly to policy gradient.</p><p>In summary, the model relies on the reference LLM to show where to explore but still cares about the final reward metric. This way we retain the advantage of RL while using a reference LLM to make the learning faster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x3hYqzpmRIQ9fv_KrziT8w.gif" /></figure><p>However, despite their theoretical advantages, imitation learning approaches aren’t well applied in practice. One reason has been the lack of popular implementations, unlike the case for RL. Secondly, in the general case, implementing a reference policy would require human interference, however, modern LLMs are good enough that they can be used as references. This is why it makes sense to revisit the IL paradigm in LLMs.</p><h3><strong>A New Framework and a New Algorithm</strong></h3><p>In our paper, we apply the imitation learning framework to LLM and generalize it in the process. We propose a new framework where one can select various ways of doing<em> “roll-in”</em> and <em>“roll-out”</em>. In addition, to capturing the aforementioned IL algorithms, we also propose and study a new algorithm called D2LOLS. This algorithm trains the model by first performing AggreVate style roll-in/roll-outs and then finetunes it by using the reference LLM to do the entire generation. As we show in our paper, this algorithm typically achieves the best performance in two tasks from the <a href="https://rl4lms.apps.allenai.org/">RL4NLP benchmark</a>.</p><p>As mentioned earlier, our framework can be used to improve upon a given LLM say by learning a reward model using human preferences, as in RLHF, and then optimizing this reward using our framework. However, it can be also used in an imitation setting for more task-specific purposes. E.g., if you do not want to use the full power of a big and expensive LLM, and only care about a specific task (such as writing a summary or CV), then you can train a cheaper open-source LLM using the more expensive LLM as the reference alongside a reward model that better captures your task.</p><p><strong>Coming Soon: </strong>We plan to release the code in the next 2–3 months.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41b9f0511ece" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HOMER: Provable Exploration in Reinforcement Learning]]></title>
            <link>https://medium.com/@dipendrakumarmisra/homer-provable-exploration-in-reinforcement-learning-6a18378fddb8?source=rss-a360cf732141------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a18378fddb8</guid>
            <category><![CDATA[icml-2020]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <dc:creator><![CDATA[Dipendra Misra]]></dc:creator>
            <pubDate>Wed, 15 Jul 2020 01:51:05 GMT</pubDate>
            <atom:updated>2021-04-20T23:12:29.097Z</atom:updated>
            <content:encoded><![CDATA[<p>This week at ICML 2020, <a href="http://www.mikaelhenaff.com/">Mikael Henaff</a>, <a href="https://people.cs.umass.edu/~akshay/">Akshay Krishnamurthy</a>, <a href="https://hunch.net/~jl/">John Langford</a> and I have a paper presenting a new reinforcement learning (RL) algorithm called HOMER that addresses three main problems in real-world RL problem: (i) exploration, (ii) decoding latent dynamics, and (iii) optimizing a given reward function. <a href="https://arxiv.org/pdf/1911.05815.pdf">ArXiv version of the paper can be found here</a>, and the ICML version would be released soon.</p><p>The paper is a bit mathematically heavy in nature and this post is an attempt to distil the key findings. We will also be following up soon with a new codebase release (more on it later).</p><h3><strong>Rich-observation RL landscape</strong></h3><p>Consider the combination lock problem shown below. The agent starts in the state s1a or s1b with equal probability. After taking h-1 actions, the agent will be in either state sha, shb, or shc. There is a big treasure chest that one can get after taking 100 actions. We view the states with subscript “a” or “b” as “<em>good states</em>” and one with subscript “c” as “<em>bad states</em>”. The agent can reach the treasure chest at the end only if it remains in good states. If it reaches any bad state, then it can never make it to the treasure chest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p-B5UlnoRKsRA4gs2MG__Q.png" /></figure><p>The environment makes it difficult to reach the big treasure chest in three ways. Firstly, the environmental dynamics are such that if you are in good states, then only 1 out of 10 possible actions will let you reach the two good states at the next time step with equal probability (the good action changes from state to state). Every other action in good states and all actions in bad states will put you into bad states at the next time step, from which it is impossible to recover. Secondly, it will try to mislead you by giving you a small myopic bonus for transitioning from a good state to a bad state (small treasure chest). This means that a locally optimal policy is to transition to one of the bad states as quickly as possible. Third, the agent never directly observes which state it is in. Instead, it receives a high-dimensional, noisy observation from which it must decode the true underlying state.</p><p>It is easy to see that if we take actions uniformly at random, then the probability of reaching the big treasure chest at the end is 1/10^{100}. The number 10^{100} is called <a href="https://en.wikipedia.org/wiki/Googol">Googol</a> and is larger than the current estimate of the number of elementary particles in the universe. Furthermore, since transitions are stochastic one can show that no fixed sequence of actions would perform well either.</p><p>A key aspect of the rich-observation setting is that the agent receives observation instead of the latent state. The observations are stochastically sampled from an <em>infinitely</em> large space conditioned on the state. However, observations are rich-enough to <em>enable decoding</em> the latent state which generates them.</p><h3><strong>What does provable RL mean?</strong></h3><p>A provable RL algorithm means that for any given numbers <strong>e</strong>, <strong>d</strong> in (0, 1); we can learn an <strong><em>e</em></strong><em>-optimal policy</em> with probability at least <strong>1-d</strong> using a number of episodes which are polynomial in relevant quantities (state size, horizon, action space, 1/e, 1/d, etc.). By <strong>e</strong>-optimal policy, we mean a policy whose value (expected total return) is at most <strong>e</strong> less than the optimal return.</p><p>Thus, a provable RL algorithm is capable of learning a close to an optimal policy with high probability (where the word high and close can be made arbitrarily more refined), provided the assumptions it makes are satisfied. There are other ways to define a provable RL algorithm and other considerations but we won’t cover them here.</p><h3>Why should I care if my algorithm is provable?</h3><p>There are two main advantages of being able to show your algorithm is provable:</p><ol><li>We can only test an algorithm on a finite number of environments (in practice somewhere between 1 and 20). Without guarantees, we don’t know how they will behave in a new environment. This matters especially if failure in a new environment can result in high real-world costs (e.g., in health or financial domains).</li><li>If a provable algorithm fails to give the desired result, this can be attributed with high probability to failure of at least one of its assumptions. A developer can then look at the assumptions and try to determine which ones are violated, and either intervene to fix them or determine that the algorithm is not appropriate for the problem.</li></ol><h3><strong>HOMER</strong></h3><p>Our algorithm addresses what is known as the <a href="https://arxiv.org/pdf/1901.09018.pdf">Block MDP</a> setting. In this setting, a small number of discrete states generates a potentially infinite number of high dimensional observations.</p><p>For each time step, HOMER learns a state decoder function and a set of exploration policies. The state decoder maps high-dimensional observations to a small set of possible latent states, while the exploration policies map observations to actions which will lead the agent to each of the latent states. We describe HOMER below.</p><ul><li>For a given time step, we first learn a decoder for mapping observations to a small set of values using contrastive learning. This procedure works as follows. Firstly, collect a transition by following a randomly sampled exploration policy from the previous time step until that time step, and then taking a single random action. We collect two transitions this way as shown below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mWMGmHX9R-gBH4RuPkuAZQ.gif" /></figure><ul><li>We then flip a coin; if we get heads then we store the transition <strong>(x1, a1, x’1)</strong>, and otherwise, we store the <em>imposter</em> transition <strong>(x1, a1, x’2)</strong>. We train a supervised classifier to predict if a given transition <strong>(x, a, x’)</strong> is real or not. This classifier has a special structure which allows us to recover a decoder for time step h.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*_0irtizbezKiGq_XkOGmMw.png" /></figure><ul><li>Once we have learned the state decoder, we will learn an exploration policy for every possible value of the decoder (which we call <em>abstract state</em> as they are related to the latent state space). This step is standard can be done using many different approaches such as model-based planning, model-free methods, etc. In the paper, we use an existing model-free algorithm called <a href="https://www.cs.cmu.edu/~schneide/bagnellPSDP.pdf">policy search by dynamic programming (PSDP)</a> by Bagnell et al. 2004.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TKdAjp42Uprz0ca4koTdyg.png" /></figure><ul><li>We have now recovered a decoder and a set of exploration policies for this time step. We repeat this procedure for each of the following time steps and learn a decoder and a set of exploration policies for the whole latent state space. Finally, we can easily optimize any given reward function using any provable planner like PSDP or a model-based algorithm. (The algorithm actually recovers the latent state space up to an inherent ambiguity by combining two different decoders, but I’ll leave that to avoid overloading this post).</li></ul><h3><strong>Key findings</strong></h3><p>HOMER achieves the following three properties:</p><ol><li>The contrastive learning procedure gives us the right state decoding (we recover up to some inherent ambiguity but I won’t cover it here).</li><li>HOMER can learn a set of exploration policies to reach every latent state</li><li>HOMER can learn a nearly-optimal policy for <em>any</em> given reward function with high probability. Further, this can be done after the exploration part has been performed.</li></ol><h3>Failure cases of prior RL algorithms</h3><p>There are many RL algorithms in the literature and many new are proposed every month. It is difficult to do justice to this vast literature in a blog post. It is equally difficult to situate HOMER in this vast literature. However, we show that several very commonly used RL algorithms fail to solve the above problem whereas HOMER succeeds. One of these is the <a href="https://arxiv.org/abs/1707.06347">PPO</a> algorithm, a widely used policy gradient algorithm. In spite of its popular use, PPO is not designed for challenging exploration problems and easily fails. Researchers have made efforts to alleviate this with ad-hoc proposals such as using prediction errors, counts based on auto-encoders, etc. One such approach is called <a href="https://arxiv.org/abs/1810.12894">Random Network Distillation</a>(RND) which measures novelty of a state based on prediction errors for a fixed randomly initialized network.</p><p>Below we show how PPO+RND fails to solve the above problem while HOMER succeeds. We simplify the problem by using a grid pattern where rows represent the state (the top two represents “good” states and the bottom row represents “bad” states), and column represents timestep.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Ftjxl4kpd7Uw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dtjxl4kpd7Uw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Ftjxl4kpd7Uw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba402d2215e88b03ec39e93ac58e021e/href">https://medium.com/media/ba402d2215e88b03ec39e93ac58e021e/href</a></iframe><p>We present counter-examples for other algorithms in the paper (see Section 6 <a href="https://arxiv.org/pdf/1911.05815.pdf">here</a>). These counterexamples allow us to find limits of prior work without expensive empirical computation on many domains.</p><h3><strong>How can I use with HOMER?</strong></h3><p>We will be providing the code super soon as part of a new package release called cereb-rl. You can find it here: <a href="https://github.com/cereb-rl">https://github.com/cereb-rl</a> and join the discussion here: <a href="https://gitter.im/cereb-rl">https://gitter.im/cereb-rl</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a18378fddb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>