{"id":86,"date":"2025-07-30T10:16:59","date_gmt":"2025-07-30T02:16:59","guid":{"rendered":"https:\/\/firooz.us\/blog\/?p=86"},"modified":"2025-07-30T10:17:01","modified_gmt":"2025-07-30T02:17:01","slug":"some-resources-for-reinforcement-learning-basic","status":"publish","type":"post","link":"https:\/\/firooz.us\/blog\/index.php\/2025\/07\/30\/some-resources-for-reinforcement-learning-basic\/","title":{"rendered":"Some Resources for Reinforcement Learning Basic"},"content":{"rendered":"\n<p>Reinforcement learning (RL) has surged in popularity over the past few months, largely thanks to Large\u202fReasoning\u202fModels\u202f(LRMs) and test\u2011time scaling techniques. A solid understanding of RL fundamentals often makes the difference between a model that merely trains and one that converges stably and efficiently when applied to LLMs.<\/p>\n\n\n\n<p>To refresh my own knowledge, I\u2019ve been revisiting the basics and prototyping a few canonical algorithms. One of my resources is Prof.\u202fErnest\u202fRyu\u2019s UCLA <a href=\"https:\/\/www.youtube.com\/watch?v=q9972BRoXzQ\">YouTube course<\/a>\u2014it leans theoretical, but does a great job unpacking core ideas such as value functions, advantage estimates, policy gradients, Generalized Advantage Estimation (GAE), Trust Region Policy Optimization (TRPO), Proximal Policy Optimization (PPO), and more.<\/p>\n\n\n\n<p>To ground the theory, I implemented several algorithms in Google\u202fColab using Gym environments. The code is in my this github <a href=\"https:\/\/github.com\/mamhamed\/Reinforcement_Learning\">repo<\/a>, codes are kept deliberately pure\u2011Python and PyTorch for clarity. Below is a quick look at what each notebook covers:<\/p>\n\n\n\n<p><strong><code>RL_Basics_CartPole_REINFORCE.ipynb<\/code><\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>gym: <code>CartPole\u2011v1<\/code><\/li>\n\n\n\n<li>Algorithms implemented:\n<ul class=\"wp-block-list\">\n<li>Vanilla <strong>REINFORCE<\/strong><\/li>\n\n\n\n<li><strong>REINFORCE\u202f+\u202fValue Network<\/strong> (one\u2011step Actor\u2013Critic)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Main Points:\n<ul class=\"wp-block-list\">\n<li>Monte-Carlo policy gradient<\/li>\n\n\n\n<li>Benefit of subtract a <strong>baseline <\/strong>for reducing variance<\/li>\n\n\n\n<li>Walks through the full policy\u2011gradient pipeline\u2014from collecting rollouts to computing returns\/advantages.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong><code>RL_Sparse_reward_Actor_Critic_and_PPO.ipynb<\/code><\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>gym: <code>FrozenLake\u2011v1<\/code> (sparse\u2011reward setting)<\/li>\n\n\n\n<li>Algorithms implemented:\n<ul class=\"wp-block-list\">\n<li>REINFORCE\u202f+\u202fValue Network<\/li>\n\n\n\n<li><strong>PPO<\/strong> with Generalized Advantage Estimation (GAE)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Main Points:\n<ul class=\"wp-block-list\">\n<li>Illustrates how sparse rewards derail vanilla policy gradient.<\/li>\n\n\n\n<li>Demonstrates PPO\u2019s clipped objective and GAE fixing instability.<\/li>\n\n\n\n<li>Includes side\u2011by\u2011side reward curves comparing REINFORCE vs. PPO.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong><code>RL_DQN.ipynb<\/code><\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>gym: <code>LunarLander\u2011v2<\/code><\/li>\n\n\n\n<li>Algorithms implemented:\n<ul class=\"wp-block-list\">\n<li><strong>Deep\u202fQ\u2011Network (DQN)<\/strong> with experience replay<\/li>\n\n\n\n<li>Target\u2011network updates (with notes on Double\u2011DQN)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Main Points:\n<ul class=\"wp-block-list\">\n<li>Provides a value\u2011based contrast to policy\u2011gradient methods.<\/li>\n\n\n\n<li>Covers \u03b5\u2011greedy exploration, replay\u2011buffer tuning, and target\u2011network syncing.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>Please note that LRMs primarily rely on PPO and its variants (e.g.,\u202fGRPO). PPO can leverage a strong pre\u2011trained policy\u2014in the LRM setting, the language model\u2019s next\u2011token predictor. By contrast, DQN does not learn a separate policy network; instead, its policy is the simple rule at=arg\u2061max_at\u2061 Q(st,at). Consequently, DQN cannot benefit from a pre\u2011trained policy in the same way.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Reinforcement learning (RL) has surged in popularity over the past few months, largely thanks to Large\u202fReasoning\u202fModels\u202f(LRMs) and test\u2011time scaling techniques. A solid understanding of RL fundamentals often makes the difference between a model that merely trains and one that converges stably and efficiently when applied to LLMs. To refresh my own knowledge, I\u2019ve been revisiting &#8230; <a title=\"Some Resources for Reinforcement Learning Basic\" class=\"read-more\" href=\"https:\/\/firooz.us\/blog\/index.php\/2025\/07\/30\/some-resources-for-reinforcement-learning-basic\/\" aria-label=\"More on Some Resources for Reinforcement Learning Basic\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[17,16],"class_list":["post-86","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-reinforcement-learning","tag-technical-notes"],"_links":{"self":[{"href":"https:\/\/firooz.us\/blog\/index.php\/wp-json\/wp\/v2\/posts\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/firooz.us\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/firooz.us\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/firooz.us\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/firooz.us\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=86"}],"version-history":[{"count":1,"href":"https:\/\/firooz.us\/blog\/index.php\/wp-json\/wp\/v2\/posts\/86\/revisions"}],"predecessor-version":[{"id":89,"href":"https:\/\/firooz.us\/blog\/index.php\/wp-json\/wp\/v2\/posts\/86\/revisions\/89"}],"wp:attachment":[{"href":"https:\/\/firooz.us\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/firooz.us\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/firooz.us\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}