<?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 Anand Majmudar on Medium]]></title>
        <description><![CDATA[Stories by Anand Majmudar on Medium]]></description>
        <link>https://medium.com/@almond.maj?source=rss-25b9623d574e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Anand Majmudar on Medium</title>
            <link>https://medium.com/@almond.maj?source=rss-25b9623d574e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 18:22:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@almond.maj/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[The Tournament of Reinforcement Learning: DDPG, SAC, PPO, I2A, Decision Transformer]]></title>
            <link>https://medium.com/data-science/the-tournament-of-reinforcement-learning-ddpg-sac-ppo-i2a-decision-transformer-6c1e42f394f0?source=rss-25b9623d574e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c1e42f394f0</guid>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[humanoid-robot]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Anand Majmudar]]></dc:creator>
            <pubDate>Fri, 23 Aug 2024 16:59:33 GMT</pubDate>
            <atom:updated>2024-08-23T16:59:33.467Z</atom:updated>
            <content:encoded><![CDATA[<h4>Training simulated humanoid robots to fight using five new Reinforcement Learning papers</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z_SSOavFcQcYrYkX" /><figcaption>Generated with GPT-4</figcaption></figure><p>I remembered the old TV show Battlebots recently and wanted to put my own spin on it. So I trained simulated humanoid robots to fight using five new Reinforcement Learning papers.</p><p>By reading below, you’ll learn the theory and math of how these five Reinforcement Learning algorithms work, see me implement them, and see them go head to head to determine the champion!</p><ol><li>Deep Deterministic Policy Gradient (DDPG)</li><li>Decision Transformer</li><li>Soft Actor-Critic (SAC)</li><li>Imagination-Augmented Agents (I2A) with Proximal Policy Optimization (PPO)</li></ol><p><strong>Setting up the Simulation Environment:</strong></p><p>I used the Unity machine learning agents simulator and built each robotic body with 21 actuators on 9 joints, 10 by 10 RGB vision through a virtual camera in their head, and a sword and shield. I then wrote the C# code defining their rewards and physics interactions. Agents can earn rewards in three main ways:</p><ol><li>Touching the sword to the opponent (‘Defeating’ their opponent)</li><li>Keeping the y-position of their head above their body (to incentivize them to stand up)</li><li>Going closer to their opponent than they were previously (to encourage agents to converge and fight)</li></ol><p>Agents get reset after 1000 timesteps, and I parallelized the environment massively for training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/0*Y3jYfPZ0cOs7hoKF" /><figcaption>Massively parallelized training environment, my screenshot</figcaption></figure><p>Then it was time to write the algorithms. To understand the algorithms I used, it’s critical to understand what Q-Learning is, so let’s find out!</p><p><strong>Q Learning </strong><em>(skip ahead if you’re familiar)</em></p><p>In Reinforcement Learning, we let an agent take actions to explore its environment, and reward it positively or negatively based on how close it is to the goal. How does the agent adjust its decision-making criteria to account for receiving better rewards?</p><p>Q Learning offers a solution. In Q Learning, we track Q-function Q(s,a), which tracks the expected return after action a_t from state s_t.</p><p>Q(s, a) = R(s, a) + γ * E[Q(s_t + 1, a_t + 1)] + γ² * E[Q(s_t + 2, a_t + 2) + …]</p><p>Where R(s,a) is the reward for the current state and action, y is the discount factor (a hyperparameter), and E[] is expected value.</p><p>If we properly learn this Q function, we can simply choose the action which returns the highest Q-value.</p><p>How do we learn this Q function?</p><p>Starting from the end of the episode, where we know the true Q value for certain (just our current reward), we can use recursion to fill in the previous Q values using the following update equation:</p><p>Q(s,a) ← (1 — α) Q(s,a) + α * [r + γ * max_a’ Q(s’,a’)]</p><p>Where α is the learning rate, r is the immediate reward, γ is the discount factor (weight parameter), s’ is the next state, and max_a’ Q(s’,a’) is the maximum Q-value for the next state over all possible actions</p><p>Essentially, our new Q value becomes old Q value plus small percentage of the difference between the current reward + the next largest Q value and the old Q value. Now, when our agent wants to choose an action, they can select the action which yields the greatest Q value (expected reward)</p><p>You might notice a potential issue though: we are evaluating the Q function on every possible action at every timestep. This is fine if we have a limited number of possible actions in a discrete space, but this paradigm breaks down in continuous actions spaces, where it is no longer possible to efficiently evaluate the Q function over the infinite number of possible actions. This brings us to our first competing algorithm: (DDPG)</p><p><strong>Deep Deterministic Policy Gradient (DDPG)</strong></p><p>DDPG tries to use Q Networks in continuous action spaces in a novel way.</p><p><em>Innovation 1: Actor and Critic</em></p><p>We can’t use the Q network to make our decisions directly, but we can use it to train another separate decision-making function. This is the actor-critic setup: the Actor is the policy decides actions, and the Critic determines future expected rewards based on these actions</p><p>Target Critic: Q_target(s,a) = r + γ * Q’(s’, μ’(s’))</p><p>Where r is the immediate reward, γ is the discount factor, s’ is the next state, μ’(s’) is the target policy network’s action for the next state, Q’ is the target critic network, Target Actor: Gradient of expected return wrt policy ≈ 1/N * Σ ∇a Q(s, a)|a=μ(s) * ∇θ_μ μ(s)</p><p>Essentially, over N samples, how does Q value of action chosen by policy (wrt policy changes, which change wrt policy params</p><p>To update both, we use a Stochastic Gradient Ascent update with lr * gradient on MSE loss of current Q and target Q. Note that both actor and critic are implemented as neural networks.</p><p><em>Innovation 2: Deterministic Action Policy</em></p><p>Our policy can either be deterministic (guaranteed action for each state) or stochastic (sample action for each state according to a probability distribution). The deterministic action policy for efficient evaluation of Q function (singular recursive evaluations since only one action for each state).</p><p>How do we explore with a deterministic policy, though? Won’t we be stuck running the same actions over and over again? This would be the case, however, we can increase the agent’s exploration by adding randomly generated noise to encourage exploration (a bit like how mutation benefits evolution by allowing it to explore unique genetic possibilities)</p><p><em>Innovation 3: Batch Learning in interactive environments</em></p><p>We also want to get more bang for our buck with each timestep observed (which consists of state action reward next state): so we can store previous tuples of timestep data and use it for training in the future</p><p>This allows us to use batch learning offline (which means using previously collected data instead of interaction through an environment), plus lets us parallelize to increase training speed with a GPU. We also now have independent identically distributed data as opposed to the biased sequential data we get regularly (where the value of a datapoint depends on previous datapoints)</p><p><em>Innovation 4: Target Networks</em></p><p>Usually Q Learning with NNs is too unstable and doesn’t converge to an optimal solution as easily because updates are too sensitive/powerful</p><p>Thus, we use target actor and critic networks, which interact with the environment and change to be partially but not fully closer to the real actor and critic during training ((large factor)target + (small factor)new)</p><p><em>Algorithm Runthrough and Code</em></p><ol><li>Initialize critic, actor, target critic and actor, replay buffer</li><li>For the vision I use a CNN before any other layers (so the most important features of the vision are used by the algorithm)</li><li>For each episode</li><li>Observe state, select and execute action mu + noise</li><li>Get reward, next state</li><li>Store (s_t,a_t,r_t, s_(t+1)) in replay buffer</li><li>sample rendom minibatch from buffer</li><li>Update y_i = reward_i + gamma Q(s given theta)</li><li>Evaluate recursively</li><li>Update critic to minimize L = y_i — Q(s,a|theta)</li><li>Update actor using policy gradient J expected recursive Q given policy</li><li>Update targets to be large factor * targets + (1 — large factor) * actual</li></ol><p><a href="https://github.com/AlmondGod/Knights-of-Papers/blob/main/src/DDPG/DDPG.py">Knights-of-Papers/src/DDPG/DDPG.py at main · AlmondGod/Knights-of-Papers</a></p><p><strong>Soft Actor-Critic (SAC)</strong></p><p>DDPG does have a few issues. Namely, Critic updates include bellman equation: Q(s,a) = r + max Q(s’a’), but NN as Q network approximators yield lot of noise, and max of noise means we overestimate, thus we become too optimistic about our policy and reward mediocre actions. Notoriously, DPPG also requires extensive hyperparameter tuning (including noise added) and doesn’t guarantee convergence to an optimal solution unless its hyperparameters are within a narrow range.</p><p><em>Innovation 1: Maximum Entropy Reinforcement Learning</em></p><p>Instead of the actor trying to purely maximize reward, the actor now maximizes reward + entropy:</p><p>Why use entropy?</p><p>Entropy is essentially how uncertain are we of a certain outcome (ex coin max entropy biased coined less entropy coin always heads has 0 entropy: show formula).</p><p>By including entropy as a maximization factor, we incentivize wide exploration and thus improves sensitivity to local optima, by allowing for more consistent and stable exploration of high dimensional spaces (why is this better than random noise). Alpha: param that weights how much to prioritize entropy, automatically tuned (how?)</p><p><em>Innovation 2: Two Q functions</em></p><p>This change aims to solve the Bellman overestimation bias of the Q function by training two Q networks independently and using the minimum of the two in policy improvement step,</p><p><em>Algorithm Runthrough and Code</em></p><ol><li>Initialize actor, 2 Q functions, 2 target Q functions, replay buffer, alpha</li><li>Repeat until convergence:</li><li>For each environment step:</li><li>Sample action from policy, observe next state and reward</li><li>Store (s_t, a_t, r_t, s_t+1) in replay buffer</li><li>For each update step:</li><li>Sample batch</li><li>Update Qs:</li><li>Compute target y = reward plus minimum Q of policy + alpha entropy</li><li>Minimize Q prediction — y</li><li>Update policy to maximize Q of policy + alpha reward</li><li>Update alpha to meet target entropy</li><li>Update target Q networks (soft update targets to be large factor * targets + (1 — large factor) * actual)</li></ol><p><a href="https://github.com/AlmondGod/Knights-of-Papers/blob/main/src/SAC/SAC.py">Knights-of-Papers/src/SAC/SAC.py at main · AlmondGod/Knights-of-Papers</a></p><p><strong>I2A with PPO</strong></p><p>Two algorithms here (bonus alg layer works on top of any algorithm)</p><p><strong>Proximal Policy Optimization (PPO)</strong></p><p>Using a different approach to that of DDPG and SAC, our goal is a scalable, data-efficient, robust convergence algorithm (not sensitive to definition of hyperparameters.</p><p><em>Innovation 1: Surrogate Objective Function</em></p><p>The surrogate objective allows off-policy training so we can use a much wider variety of data (especially advantageous to real-world scenarios where vast pre-existing datasets exist).</p><p>Before we discuss surrogate objective, the concept of Advantage is critical to understand. Advantage is the:difference between expected reward at s after taking s and expected reward at s. Essentially, it quantifies to what degree an action a better or worse than the ‘average’ action.</p><p>We estimate it as A = Q(a,s) — V(a) where Q is action-value (expected return after action a) and V is state-value (expected return from current state), and both are learned</p><p>Now, the surrogate objective:</p><p>J(θ) = Ê_t [ r_t(θ) Â_t ]</p><p>Where:</p><ul><li>J(θ) is the surrogate objective</li><li>Ê_t […] denotes the empirical average over a finite batch of samples</li><li>r_t(θ) = π_θ(a_t|s_t) / π_θ_old(a_t|s_t) is likelihood of action in new policy / likelihood in old policy</li><li>Â_t is the estimated advantage at timestep t</li></ul><p>This is equivalent to quantifying how well the new policy improves the likelihood of higher return actions and decreases likelihood of lower return actions.</p><p><em>Innovation 2: Clipped Objective Function</em></p><p>This is another way to solve the oversized policy update issue towards more stable learning.</p><p>L_CLIP(θ) = E[ min( r(θ) * A, clip(r(θ), 1-ε, 1+ε) * A ) ]</p><p>The clipped objective is minimum of the real surrogate and the surrogate where the ratio is clipped between 1 — epsilon and 1 + epsilon (basically trust region of unmodified ratio). Epsilon is usually ~0.1/0.2</p><p>It essentially chooses more conservative of clipped and normal ratio.</p><p>The actual PPO objective:</p><p>L^{PPO}(θ) = Ê_t [ L^{CLIP}(θ) — c_1 * L^{VF}(θ) + c_2 * Sπ_θ ]</p><p>Where:</p><ol><li>L^{VF}(θ) = (V_θ(s_t) — V^{target}_t)²</li><li>Sπ_θ is the entropy of the policy π_θ for state s_t</li></ol><p>Essentially we’re prioritizing higher entropy, lower value function, and higher clipped Advantage</p><p>PPO also uses minibatching and alternates data training.</p><p><em>Algorithm Runthrough and Code</em></p><ol><li>For each iteration</li><li>For each of N actors</li><li>Run policy for T timesteps</li><li>Compute advantages</li><li>Optimize surrogate function with respect to policy for K epochs and minibatch size M &lt; NT</li><li>Update policy</li></ol><p><a href="https://github.com/AlmondGod/Knights-of-Papers/blob/main/src/I2A-PPO/gpuI2APPO.py">Knights-of-Papers/src/I2A-PPO/gpuI2APPO.py at main · AlmondGod/Knights-of-Papers</a></p><p><strong>Imagination-Augmented Agents</strong></p><p>Our goal here is to create an extra embedding vector input to any other algorithm to give key valuable information and act as a ‘mental model’ of the environment</p><p><em>Innovation: Imagination Vector</em></p><p>The Imagination vector allows us to add an extra embedding vector to our agent’s observations to encode multiple ‘imagined future runs’ of actions and evaluations of their rewards (goal is to “see the future” and “think before acting”).</p><p>How do we calculate it? We use a learned environment approximation function, which tries to simulate the environment (this is called model-based learning because were attempting to learn a model of the environment). We pair this with a rollout policy, which is very simple and fast-executing policy (usually random) to decide on actions by which to “explore the future”. By running the environment approximator on the rollout policy, we can explore future actions and their rewars, then find a way to represent all these imagined future actions and rewards in one vector. A notable drawback to note: as you’d expect, it adds a lot of training and makes large amounts of data more necessary.</p><p><em>Combined I2A-PPO Algorithm Runthrough and Code</em></p><ol><li>Every time we collect observations for PPO:</li><li>Initialize environment model and rollout pollicy</li><li>For multiple ‘imagined runs’:</li><li>run environment model starting from current state and deciding with rollout policy until a horizon to yield an imagination trajectory (s, a, r sequence)</li><li>Imagination encoder: turns multiple of these imagined trajectories into a single input embedding for the actual decision making network</li></ol><p><strong>Decision Transformer</strong></p><p>Our goal here is to use the advantage of transformer architecture for reinforcement learning. With Decision Transformer, we can identify important rewards among sparse/distracting rewards, enjoy a wider distribution modeling for greater generalization and knowledge transfer, and learn from pre-obtained suboptimal limited data (called offline learning).</p><p>For Decision Transformers, we essentially cast Reinforcement Learning as sequence modeling problem.</p><p><em>Innovation 1: Transformers</em></p><p>If you want to truly understand transformers, I recommend the karpathy building GP2 from scratch video. Here’s a quick Transformers review as it applies to DT:</p><p>We have sequences of tokens representing states, actions, returns to go (the sum of future rewards expected to be received), and timesteps. Our goal is now to take in a sequence of tokens and predict the next action: this will act as our policy.</p><p>These tokens all have keys, values, and queries that we combine using intricate networks to express relationships between each element. We then combine these relationships into an ‘embedding’ vector which encodes the relationships between the inputs. This process is known as Attention.</p><p>Note that a ‘causal self-attention mask’ ensures embeddings can only relate to embeddings that came before them in the sequence, so we can’t use the future to predict the future, use the past information to predict the future (since our goal is to predict next action).</p><p>Once we have this embedding vector, we pass it through neural network layers (the analogy Karpathy uses is that here, we ‘reason about relationships’ between the tokens).</p><p>These two combined (find relationships between tokens with Attention, reason about relationships with our NN layers) are one head of Transformers, which we stack on itself many times. At the end of these heads, we use a learned neural network layer to convert the output to our action space size and requirements.</p><p><em>By the way, at inference time, we predefine returns to go as our desired total reward at the end.</em></p><p><em>Algorithm Runthrough and Code</em></p><ol><li>For (R,s,a,t) in dataloader</li><li>Predict action</li><li>Model converts obs, vision (with convnet layer), rtg, and timestep to unique embeddings and adds timestep embedding to the others</li><li>All three used as input to the transformer layers, at the end use action embedding</li><li>compute MSEloss (a_pred-a)**2</li><li>Perform SGD on the decision transformer model with the gradient of params wrt this loss</li></ol><p><a href="https://github.com/AlmondGod/Knights-of-Papers/blob/main/src/Decision-Transformer/DecisionTransformer.py">Knights-of-Papers/src/Decision-Transformer/DecisionTransformer.py at main · AlmondGod/Knights-of-Papers</a></p><p><strong>Results</strong></p><p>To train these models, I ran the algorithms on an NVIDIA RTX 4090 to take advantage of these algorithms GPU acceleration innovations. Thank you <a href="http://vast.ai/">vast.ai</a>! Here are the loss curves:</p><p><em>DDPG Loss (2000 Episodes)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p720jO23qqjPJ7U0" /><figcaption>Matplotlib Loss Chart, me</figcaption></figure><p><em>I2APPO Loss (3500 Episodes)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pJk73qtdlnNCxM0i" /><figcaption>Matplotlib Loss Chart, me</figcaption></figure><p><em>SAC Loss (5000 Episodes)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fe6u0nPhqTy9TxHg" /><figcaption>Matplotlib Loss Chart, me</figcaption></figure><p><em>Decision Transformer Loss (1600 Episodes, loss recorded every 40)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rEz_BA1vLCjGBjMo" /><figcaption>Matplotlib Loss Chart, me</figcaption></figure><p>By comparing the algorithms’ results (subjectively and weighted by time taken to train), I found Decision Transformer to perform the best! This makes sense considering DT is built specifically to take advantage of GPUs. Watch the <a href="https://www.youtube.com/watch?v=kpDfXqX7h1U">video</a> I made to see the algorithms’ actual performance. The models learned to crawl and stop falling over but still had a ways to go before they would be expert fighters.</p><p><strong>Areas of Improvement:</strong></p><p>I learned just how hard training a humanoid is. We’re operating in both a high-dimensional input space (both visual RGB and actuator positions/velocities) combined with an incredibly high-dimensional output space (27-dimensional continuous space).</p><p>From the beginning, the best I was hoping for was that they crawl to each other and touch swords, though even this was a challenge. Most of the training runs didn’t even get to experience the high reward of touching ones sword to the opponent, since walking alone was too hard.</p><p>The main dimension for improvement is simply increasing the time to train and amount of compute used. As we’ve seen in the modern AI revolution, these increased compute and data trends seem to have no upper limit!</p><p>Most importantly, I learned a lot! For next time, I would use NVIDIA’s skill embeddings or Lifelong Learning to allow the robots to learn to walk before they learn to fight!</p><p>To see the video I made walking through the process of creating this project, and see the robots fight, see this video below:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FkpDfXqX7h1U%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DkpDfXqX7h1U&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FkpDfXqX7h1U%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/f7a3d11359a22b7883420be2308a5534/href">https://medium.com/media/f7a3d11359a22b7883420be2308a5534/href</a></iframe><p>Thanks for making it to the end! Find me on Twitter <a href="https://x.com/Almondgodd">@AlmondGodd</a> if you’re interested in more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c1e42f394f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/the-tournament-of-reinforcement-learning-ddpg-sac-ppo-i2a-decision-transformer-6c1e42f394f0">The Tournament of Reinforcement Learning: DDPG, SAC, PPO, I2A, Decision Transformer</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Examining Lifelong Machine Learning through ELLA and Voyager: Part 2 of Why LLML is Next in AI]]></title>
            <link>https://medium.com/data-science/examining-lifelong-machine-learning-through-ella-and-voyager-part-2-of-why-llml-is-next-in-ai-bea36a01f529?source=rss-25b9623d574e------2</link>
            <guid isPermaLink="false">https://medium.com/p/bea36a01f529</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[voyager]]></category>
            <category><![CDATA[lifelong-learning]]></category>
            <category><![CDATA[multitask-learning]]></category>
            <dc:creator><![CDATA[Anand Majmudar]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 09:27:38 GMT</pubDate>
            <atom:updated>2024-08-20T05:23:44.602Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Examining Longterm Machine Learning through ELLA and Voyager: Part 2 of Why LLML is the Next Game-changer of AI</strong></h3><h4>Understanding the power of Lifelong Learning through the Efficient Lifelong Learning Algorithm (ELLA) and VOYAGER</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*mTmnFlaHfH46qyRktTDp7g.jpeg" /><figcaption>AI Robot Piloting Space Vessel, Generated with GPT-4</figcaption></figure><p>I encourage you to read <a href="https://medium.com/@almond.maj/the-origins-of-lifelong-ml-part-1-of-why-llml-is-the-next-game-changer-of-ai-8dacf9897143">Part 1: The Origins of LLML</a> if you haven’t already, where we saw the use of LLML in reinforcement learning. Now that we’ve covered where LLML came from, we can apply it to other areas, specifically supervised multi-task learning, to see some of LLML’s true power.</p><p><strong>Supervised LLML: The Efficient Lifelong Learning Algorithm</strong></p><p>The Efficient Lifelong Learning Algorithm aims to train a model that will excel at multiple tasks at once. ELLA operates in the multi-task supervised learning setting, with multiple tasks T_1..T_n, with features X_1..X_n and y_1…y_n corresponding to each task(the dimensions of which likely vary between tasks). Our goal is to learn functions f_1,.., f_n where f_1: X_1 -&gt; y_1. Essentially, each task has a function that takes as input the task’s corresponding features and outputs its y values.</p><p>On a high level, ELLA maintains a shared basis of ‘knowledge’ vectors for all tasks, and as new tasks are encountered, ELLA uses knowledge from the basis refined with the data from the new task. Moreover, in learning this new task, more information is added to the basis, improving learning for all future tasks!</p><p>Ruvolo and Eaton used ELLA in three settings: landmine detection, facial expression recognition, and exam score predictions! As a little taste to get you excited about ELLA’s power, it achieved up to a 1,000x more time-efficient algorithm on these datasets, sacrificing next to no performance capabilities!</p><p>Now, let’s dive into the technical details of ELLA! The first question that might arise when trying to derive such an algorithm is</p><p><em>How exactly do we find what information in our knowledge base is relevant to each task?</em></p><p>ELLA does so by modifying our f functions for each t. Instead of being a function f(x) = y, we now have f(x, θ_t) = y where θ_t is unique to task t, and can be represented by a linear combination of the knowledge base vectors. With this system, we now have all tasks mapped out in the <em>same</em> basis dimension, and can measure similarity using simple linear distance!</p><p><em>Now, how do we derive θ_t for each task?</em></p><p>This question is the core insight of the ELLA algorithm, so let’s take a detailed look at it. We represent knowledge basis vectors as matrix L. Given weight vectors s_t, we represent each θ_t as Ls_t, the linear combination of basis vectors.</p><p>Our goal is to minimize the loss for each task while maximizing the shared information used between tasks. We do so with the objective function e_T we are trying to minimize:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*9-MTu178cLR8b6A5AyM9-w.jpeg" /></figure><p>Where ℓ is our chosen loss function.</p><p>Essentially, the first clause accounts for our task-specific loss, the second tries to minimize our weight vectors and make them sparse, and our last clause tries to minimize our basis vectors.</p><p>**This equation carries two inefficiencies (see if you can figure out what)! Our first is that our equation depends on all previous training data, (specifically the inner sum), which we can imagine is incredibly cumbersome. We alleviate this first inefficiency using a Taylor sum of approximation of the equation. Our second inefficiency is that we need to recompute every s_t to evaluate one instance of L. We eliminate this inefficiency by removing our minimization over z and instead computing s when t is last interacted with. I encourage you to read the original paper for a more detailed explanation!**</p><p>Now that we have our objective function, we want to create a method to optimize it!</p><p>In training, we’re going to treat each iteration as a unit where we receive a batch of training data from a single task, then compute s_t, and finally update L. At the start of our algorithm, we set T (our number-of-tasks counter), A, b, and L to zeros. Now, for each batch of data, we case based on the data is from a seen or unseen task.</p><p>If we encounter data from a new task, we will add 1 to T, and initialize X_t and y_t for this new task, setting them equal to our current batch of X and y..</p><p>If we encounter data we’ve already seen, our process gets more complex. We again add our new X and y to add our new X and y to our current memory of X_t and y_t (by running through all data, we will have a complete set of X and y for each task!). We also incrementally update our A and b values negatively (I’ll explain this later, just remember this for now!).</p><p>Now we check if we want to end our training loop. We set our (θ_t, D_t) equal to the output of our regular learner for our batch data.</p><p>We then check to end the loop (if we have seen all training data). If we haven’t ended, we move on to computing s and updating L.</p><p>To compute s, we first compute optimal model \theta_t using only the batched data, which will depend on our specific task and loss function.</p><p>We then compute D_t, and either randomly or to one of the θ_ts initialize any all-zero columns of L (which occurs if a certain basis vector is unused). In linear regression,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/106/1*4YP7Mi9zeyCdFhoLtSpGnw.jpeg" /></figure><p>and in logistic regression</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/204/1*bp7dyZruNP1fHK7BLEU-8g.jpeg" /></figure><p>Then, we compute s_t using L by solving an L1-regularized regression problem:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/229/1*gepNAvmFZbr7iYJI-QiQFA.jpeg" /></figure><p>For our final step of updating L, we take</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*XQ4O9L7EDDq6wBeL5Jia7w.jpeg" /></figure><p>, find where the gradient is 0, then solve for L. By doing so, we increase the sparsity of L! We then output the updated columnwise-vectorization of L as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*6jP_j4ZYrYrQJ8-Hz9Un1A.jpeg" /></figure><p>so as not to sum over all tasks to compute A and b, we construct them incrementally as each task arrives.</p><p>Once we’ve iterated through all batch data, we’ve learned all tasks properly and have finished!</p><p>The power of ELLA lies in many of its efficiency optimizations, primarily of which is its method of using θ functions to understand exactly what basis knowledge is useful! If you care about a more in-depth understanding of ELLA, I highly encourage you to check out the pseudocode and explanation in the <a href="https://proceedings.mlr.press/v28/ruvolo13.pdf">original paper</a>.</p><p>Using ELLA as a base, we can imagine creating a generalizable AI, which can learn any task it’s presented with. We again have the property that the more our knowledge basis grows, the more ‘relevant information’ it contains, which will even further increase the speed of learning new tasks! It seems as if ELLA could be the core of one of the super-intelligent artificial learners of the future!</p><p><strong>Voyager</strong></p><p>What happens when we integrate the newest leap in AI, LLMs, with Lifelong ML? We get something that can beat Minecraft (This is the setting of the actual paper)!</p><p>Guanzhi Wang, Yuqi Xie, and others saw the new opportunity offered by the power of GPT-4, and decided to combine it with ideas from lifelong learning you’ve learned so far to create Voyager.</p><p>When it comes to learning games, typical algorithms are given predefined final goals and checkpoints for which they exist solely to pursue. In open-world games like Minecraft, however, there are many possible goals to pursue and an infinite amount of space to explore. What if our goal is to approximate human-like self-motivation combined with increased time efficiency in traditional Minecraft benchmarks, such as getting a diamond? Specifically, let’s say we want our agent to be able to decide on feasible, interesting tasks, learn and remember skills, and continue to explore and seek new goals in a ‘self-motivated’ way.</p><p>Towards these goals, Wang, Xie, and others created<a href="https://arxiv.org/pdf/2305.16291.pdf"> Voyager</a>, which they called the first LLM-powered embodied lifelong learning agent!</p><p><em>How does Voyager work?</em></p><p>On a large-scale, Voyager uses GPT-4 as its main ‘intelligence function’ and the model itself can be separated into three parts:</p><ol><li><strong>Automatic curriculum: </strong>This decides which goals to pursue, and can be thought of as the model’s “motivator”. Implemented with GPT-4, they instructed it to optimize for difficult yet feasible goals and to “discover as many diverse things as possible” (read the original paper to see their exact prompts). If we pass four rounds of our iterative prompting mechanism loop without the agent’s environment changing, we simply choose a new task!</li><li><strong>Skill library:</strong> a collection of executable actions such as craftStoneSword() or getWool() which increase in difficulty as the learner explores. This skill library is represented as a vector database, where keys are embedding vectors of GPT-3.5-generated skill descriptions, and executable skills in code form. GPT-4 generated the code for the skills, optimized for generalizability and refined by feedback from the use of the skill in the agent’s environment!</li><li><strong>Iterative prompting mechanism: </strong>This is the element that interacts with the Minecraft environment. It first executes its’ interface of Minecraft to gain information about its current environment, for example, the items in its inventory and the surrounding creatures it can observe. It then prompts GPT-4 and performs the actions specified in the output, also offering feedback about whether the actions specified are impossible. This repeats until the current task (as decided by the automatic curriculum) is completed. At completion, we add the learned skill to the skill library. For example, if our task was create a stone sword, we now put the skill craftStoneSword() into our skill library. Finally, we ask the automatic curriculum for a new goal.</li></ol><p><em>Now, where does Lifelong Learning fit into all this?</em></p><p>When we encounter a new task, we query our skill database to find the top 5 most relevant skills to the task at hand (for example, relevant skills for the task getDiamonds() would be craftIronPickaxe() and findCave().</p><p>Thus, we’ve used previous tasks to learn our new task more efficiently: the essence of lifelong learning! Through this method, Voyager continuously explores and grows, learning new skills that increase its frontier of possibilities, increasing the scale of ambition of its goals, thus increasing the powers of its newly learned skills, continuously!</p><p>Compared with other models like AutoGPT, ReAct, and Reflexion, Voyager discovered 3.3x as many new items as these others, navigated distances 2.3x longer, unlocked wooden level 15.3x faster per prompt iteration, and was the only one to unlock the diamond level of the tech tree! Moreover, after training, when dropped in a completely new environment with no items, Voyager consistently solved prior-unseen tasks, while others could not solve any within 50 prompts.</p><p>As a display of the importance of Lifelong Learning, without the skill library, the model’s progress in learning new tasks plateaued after 125 iterations, whereas with the skill library, it kept rising at the same high rate!</p><p>Now imagine this agent applied to the real world! Imagine a learner with infinite time and infinite motivation that could keep increasing its possibility frontier, learning faster and faster the more prior knowledge it has! I hope by now I’ve properly illustrated the power of Lifelong Machine Learning and its capability to prompt the next transformation of AI!</p><p>If you’re interested further in LLML, I encourage you to read Zhiyuan Chen and Bing Liu’s <a href="https://www.cs.uic.edu/~liub/lifelong-machine-learning-draft.pdf">book</a> which lays out the potential future paths LLML might take!</p><p>Thank you for making it all the way here! If you’re interested, check out my website anandmaj.com which has my other writing, projects, and art, and follow me on Twitter @almondgodd.</p><p><strong>Original Papers and other Sources:</strong></p><p>Eaton and Ruvolo: <a href="https://www.seas.upenn.edu/~eeaton/papers/Ruvolo2013ELLA.pdf">Efficient Lifelong Learning Algorithm</a></p><p>Wang, Xie, et al: <a href="https://arxiv.org/pdf/2305.16291.pdf">Voyager</a></p><p>Chen and Liu, Lifelong Machine Learning (Inspired me to write this!): <a href="https://www.cs.uic.edu/~liub/lifelong-machine-learning-draft.pdf">https://www.cs.uic.edu/~liub/lifelong-machine-learning-draft.pdf</a></p><p>Unsupervised LL with Curricula: <a href="https://par.nsf.gov/servlets/purl/10310051">https://par.nsf.gov/servlets/purl/10310051</a></p><p>Deep LL: <a href="https://towardsdatascience.com/deep-lifelong-learning-drawing-inspiration-from-the-human-brain-c4518a2f4fb9">https://towardsdatascience.com/deep-lifelong-learning-drawing-inspiration-from-the-human-brain-c4518a2f4fb9</a></p><p>Neuro-inspired AI: <a href="https://www.cell.com/neuron/pdf/S0896-6273(17)30509-3.pdf">https://www.cell.com/neuron/pdf/S0896-6273(17)30509-3.pdf</a></p><p>Embodied LL: <a href="https://lis.csail.mit.edu/embodied-lifelong-learning-for-decision-making/">https://lis.csail.mit.edu/embodied-lifelong-learning-for-decision-making/</a></p><p>LL for sentiment classification: <a href="https://arxiv.org/abs/1801.02808">https://arxiv.org/abs/1801.02808</a></p><p>Lifelong Robot Learning: <a href="https://www.sciencedirect.com/science/article/abs/pii/092188909500004Y">https://www.sciencedirect.com/science/article/abs/pii/092188909500004Y</a></p><p>Knowledge Basis Idea: <a href="https://arxiv.org/ftp/arxiv/papers/1206/1206.6417.pdf">https://arxiv.org/ftp/arxiv/papers/1206/1206.6417.pdf</a></p><p>Q-Learning: <a href="https://link.springer.com/article/10.1007/BF00992698">https://link.springer.com/article/10.1007/BF00992698</a></p><p>AGI LLLM LLMs: <a href="https://towardsdatascience.com/towards-agi-llms-and-foundational-models-roles-in-the-lifelong-learning-revolution-f8e56c17fa66">https://towardsdatascience.com/towards-agi-llms-and-foundational-models-roles-in-the-lifelong-learning-revolution-f8e56c17fa66</a></p><p>DEPS: <a href="https://arxiv.org/pdf/2302.01560.pdf">https://arxiv.org/pdf/2302.01560.pdf</a></p><p>Voyager: <a href="https://arxiv.org/pdf/2305.16291.pdf">https://arxiv.org/pdf/2305.16291.pdf</a></p><p>Meta-Learning: <a href="https://machine-learning-made-simple.medium.com/meta-learning-why-its-a-big-deal-it-s-future-for-foundation-models-and-how-to-improve-it-c70b8be2931b">https://machine-learning-made-simple.medium.com/meta-learning-why-its-a-big-deal-it-s-future-for-foundation-models-and-how-to-improve-it-c70b8be2931b</a></p><p>Meta Reinforcement Learning Survey: <a href="https://arxiv.org/abs/2301.08028">https://arxiv.org/abs/2301.08028</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bea36a01f529" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/examining-lifelong-machine-learning-through-ella-and-voyager-part-2-of-why-llml-is-next-in-ai-bea36a01f529">Examining Lifelong Machine Learning through ELLA and Voyager: Part 2 of Why LLML is Next in AI</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Origins of Lifelong ML: Part 1 of Why LLML is the Next Game-changer of AI]]></title>
            <link>https://medium.com/data-science/the-origins-of-lifelong-ml-part-1-of-why-llml-is-the-next-game-changer-of-ai-8dacf9897143?source=rss-25b9623d574e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8dacf9897143</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[lifelong-learning]]></category>
            <category><![CDATA[multitask-learning]]></category>
            <category><![CDATA[q-learning]]></category>
            <dc:creator><![CDATA[Anand Majmudar]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 09:24:21 GMT</pubDate>
            <atom:updated>2024-04-16T17:25:48.454Z</atom:updated>
            <content:encoded><![CDATA[<h4>Understanding the power of Lifelong Machine Learning through Q-Learning and Explanation-Based Neural Networks</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aJkjeCWobnGzj2ALOKCuWQ.png" /><figcaption>AI Robot in Space, Generated with GPT-4</figcaption></figure><p>How does Machine Learning progress from here? Many, if not most, of the greatest innovations in ML have been inspired by Neuroscience. The invention of neural networks and attention-based models serve as <a href="https://www.cell.com/neuron/pdf/S0896-6273(17)30509-3.pdf">prime examples</a>. Similarly, the next revolution in ML will take inspiration from the brain: Lifelong Machine Learning.</p><p>Modern ML still lacks humans’ ability to use past information when learning new domains. A reinforcement learning agent who has learned to walk, for example, will learn how to climb from ground zero. Yet, the agent can instead use <em>continual learning</em>: it can apply the knowledge gained from walking to its process of learning to climb, just like how a human would.</p><p>Inspired by this property, Lifelong Machine Learning (LLML) uses past knowledge to learn new tasks more efficiently. By approximating continual learning in ML, we can greatly increase the time efficiency of our learners.</p><p>To understand the incredible power of LLML, we can start from its origins and build up to modern LLML. In Part 1, we examine Q-Learning and Explanation-Based Neural Networks. In Part 2, we explore the Efficient Lifelong Learning Algorithm and Voyager! I encourage you to read Part 1 before Part 2, though feel free to skip to Part 2 if you prefer!</p><p><strong>The Origins of Lifelong Machine Learning</strong></p><p>Sebastian Thrun and Tom Mitchell, the fathers of LLML, began their LLML journey by examining reinforcement learning as applied to robots. If the reader has ever seen a visualized reinforcement learner (like this agent <a href="https://www.youtube.com/watch?v=DcYLT37ImBY&amp;t=17s">learning to play Pokemon</a>), they’ll realize that to achieve any training results in a reasonable human timescale, the agent must be able to iterate through millions of actions (if not much more) over their training period. Robots, though, take multiple seconds to perform each action. As a result, moving typical online reinforcement learning methods to robots results in a significant loss of both the efficiency and capability of the final robot model.</p><p><em>What makes humans so good at real-world learning, where ML in robots is currently failing?</em></p><p>Thrun and Mitchell identified potentially the largest gap in the capabilities of modern ML: its inability to apply past information to new tasks. To solve this issue, they created the first Explanation-Based Neural Network (EBNN), which was the first use of LLML!</p><p>To understand how it works, we first can understand how typical reinforcement learning (RL) operates. In RL, our ML model decides the actions of our agent, which we can think of as the ‘body’ that interacts with whatever environment we chose. Our agent exists in environment W with state Z, and when agent takes action A, it receives sensation S (feedback from its environment, for example the position of objects or the temperature). Our environment is a mapping Z x A -&gt; Z (for every action, the environment changes in a specified way). We want to maximize the reward function R: S -&gt; R in our model F: S -&gt; A (in other words we want to choose the action that reaches the best outcome, and our model takes sensation as input and outputs an action). If the agent has multiple tasks to learn, each task has its own reward function, and we want to maximize each function.</p><p>We could train each individual task independently. However, Thrun and Michael realized that each task occurs in the same environment with the same possible actions and sensations for our agent (just with different reward functions per task). Thus, they created EBNN to use information from previous problems to solve the current task (LLML)! For example, a robot can use what it’s learned from a cup-flipping task to perform a cup-moving task, since in cup-flipping it has learned how to grab the cup.</p><p>To see how EBNN works, we now need to understand the concept of the Q function.</p><p><strong>Q* and Q-Learning</strong></p><p>Q: S x A -&gt; r is an evaluation function where r represents the expected future total reward after action A in state S. If our model learns an accurate Q, it can simply select the action at any given point that maximizes Q.</p><p>Now, our problem reduces to learning an accurate Q, which we call Q*. One such scheme is called <a href="https://link.springer.com/article/10.1007/BF00992698">Q-Learning</a>, which some think is the inspiration behind OpenAI’s Q* (though the naming might be a complete coincidence).</p><p>In Q-learning, we define our action policy as function π which outputs an action for each state, and the value of state X as function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*URWsW5ZR6Kcrc_V_9A7tqw.jpeg" /></figure><p>Which we can think of as the immediate reward for action π(x) plus the sum of the probabilities of all possible future actions multiplied by their values (which we compute recursively). We want to find the optimal policy (set of actions) π* such that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*LFq37Bydbh9CwcLkvE45AQ.jpeg" /></figure><p>(at every state, the policy chooses the action that maximizes V*). As the process repeats Q will become more accurate, improving the agent’s selected actions. Now, we define Q* values as the true expected reward for performing action a:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*bF4hJHm_Vq5GvqtxnEDM_w.jpeg" /></figure><p>In Q-learning, we reduce the problem of learning π* to the problem of learning the Q*-values of π*. Clearly, we want to choose the actions with the greatest Q-values.</p><p>We divide training into episodes. In the nth episode, we get state x_n, select and perform action a_n, observe y_n, receive reward r_n, and adjust Q values using constant α according to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*zpSunFA19Ibd0JaSo6k1Dg.jpeg" /></figure><p>Where</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/181/1*Eo1EFj3VS4LeIN54c7VeyA.jpeg" /></figure><p>Essentially, we leave all previous Q values the same except for the Q value corresponding to the previous state x and the selected action a. For that Q value, we update it by weighing the previous episode’s Q value by (1 — α) and adding to it our payoff plus the max of the previous episode’s value for the current state y, both weighted by α.</p><p>Remember that this algorithm is trying to approximate an accurate Q for each possible action in each possible state. So when we update Q, we update the value for Q corresponding to the old state and the action we took on that episode, since we</p><p>The smaller α is, the less we change Q each episode (1 - α will be very large). The larger α is, the less we care about the old value of Q (at α = 1 it is completely irrelevant) and the more we care about what we’ve discovered to be the expected value of our new state.</p><p>Let’s consider two cases to gain an intuition for this algorithm and how it updates Q(x, a) after we take action a from state x to reach state y:</p><ol><li>We go from state x through action a to state y, and are at an ‘end path’ where no more actions are possible. Then, Q(x, a), the expected value for this action and the state before it, should simply be the immediate reward for a (think about why!). Moreover, the higher the reward for a, the more likely we are to choose it in our next episode. Our largest Q value in the previous episode at this state is 0 since no actions are possible, so we are only adding the reward for this action to Q, as intended!</li><li>Now, our correct Q*s recurse backward from the end! Let’s consider the action b that led from state w to state x, and let’s say we’re now 1 episode later. Now, when we update Q*(w, b), we will add the reward for b to the value for Q*(x, a), since it must be the highest Q value if we chose it before. Thus, our Q(w, b) is now correct as well (think about why)!</li></ol><p>Great! Now that you have intuition for Q-learning, we can return to our original goal of understanding:</p><p><strong>The Explanation Based Neural Network (EBNN)</strong></p><p>We can see that with simple Q-learning, we have no LL property: that previous knowledge is used to learn new tasks. Thrun and Mitchell originated the Explanation Based Neural Network Learning Algorithm, which applies LL to Q-learning! We divide the algorithm into 3 steps.</p><p>(1) After performing a sequence of actions, the agent predicts the states that will follow up to a final state s_n, at which no other actions are possible. These predictions will differ from the true observed states since our predictor is currently imperfect (otherwise we’d have finished already)!</p><p>(2) The algorithm extracts partial derivatives of the Q function with respect to the observed states. By initially computing the partial derivative of the final reward with respect to the final state s_n, (by the way, we assume the agent is given the reward function R(s)), and we compute slopes backward from the final state using the already computer derivatives using chain rule:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*7NgtbR-wk4pbC4ow2LMK8A.jpeg" /></figure><p>Where M: S x A -&gt; S is our model and R is our final reward.</p><p>(3) Now, we’ve estimated the slopes of our Q*s, and we use these in backpropagation to update our Q-values! For those that don’t know, backpropagation is the method through which neural networks learn, where they calculate how the final output of the network changes when each node in the network is changed using this same backward-calculated slope method, and then they adjust the weights and biases of these nodes in the direction that makes the network’s output more desirable (however this is defined by the cost function of the network, which serves the same purpose as our reward function)!</p><p>We can think of (1) as the<em> Explaining</em> step (hence the name!), where we look at past actions and try to predict what actions would arise. With (2), we then <em>Analyze</em> these predictions to try to understand how our reward changes with different actions. In (3), we apply this understanding to <em>Learn</em> how to improve our action selection through changing our Qs.</p><p>This algorithm increases our efficiency by using the difference between past actions and estimations of past actions as a boost to estimate the efficiency of a certain action path. The next question you might ask is:</p><p><em>How does EBNN help one task’s learning transfer to another?</em></p><p>When we use EBNN applied to multiple tasks, we represent information common between tasks as NN action models, which gives us a boost in learning (a productive bias) through the explanation and analysis process. It uses previously learned,<em> task-independent</em> knowledge when learning new tasks. Our key insight is that we have generalizable knowledge because every task shares the same agent, environment, possible actions, and possible states. The only dependent on each task is our reward function! So by starting from the explanation step with our task-specific reward function, we can use previously discovered states from old tasks as training examples and simply replace the reward function with our current task’s reward function, accelerating the learning process by many fold! The LML fathers discovered a 3 to 4-fold increase in time efficiency for a robot cup-grasping task, and this was only the beginning!</p><p>If we repeat this explanation and analysis process, we can replace some of the need for real-world exploration of the agent’s environment required by naive Q-learning! And the more we use it, the more productive it becomes, since (abstractly) there is more knowledge for it to pull from, increasing the likelihood that the knowledge is relevant to the task at hand.</p><p>Ever since the fathers of LLML sparked the idea of using task-independent information to learn new tasks, LLML has expanded past not only reinforcement learning in robots but also to the more general ML setting we know today: supervised learning. Paul Ruvolo and Eric Eatons’ Efficient Lifelong Learning Algorithm (ELLA) will get us much closer to understanding the power of LLML!</p><p>Please read <a href="https://medium.com/@almond.maj/examining-lifelong-machine-learning-through-ella-and-voyager-part-2-of-why-llml-is-next-in-ai-bea36a01f529">Part 2: Examining LLML through ELLA</a> and Voyager to see how it works!</p><p>Thank you for reading Part 1! Feel free to check out my website <a href="https://anandmaj.com/">anandmaj.com</a> which has my other writing, projects, and art, and follow me on <a href="https://twitter.com/Almondgodd">Twitter</a>.</p><p><strong>Original Papers and other Sources:</strong></p><p>Thrun and Mitchel: <a href="https://www.sciencedirect.com/science/article/abs/pii/092188909500004Y">Lifelong Robot Learning</a></p><p>Watkins: <a href="https://link.springer.com/article/10.1007/BF00992698">Q-Learning</a></p><p>Chen and Liu, Lifelong Machine Learning (Inspired me to write this!): <a href="https://www.cs.uic.edu/~liub/lifelong-machine-learning-draft.pdf">https://www.cs.uic.edu/~liub/lifelong-machine-learning-draft.pdf</a></p><p>Unsupervised LL with Curricula: <a href="https://par.nsf.gov/servlets/purl/10310051">https://par.nsf.gov/servlets/purl/10310051</a></p><p>Deep LL: <a href="https://towardsdatascience.com/deep-lifelong-learning-drawing-inspiration-from-the-human-brain-c4518a2f4fb9">https://towardsdatascience.com/deep-lifelong-learning-drawing-inspiration-from-the-human-brain-c4518a2f4fb9</a></p><p>Neuro-inspired AI: <a href="https://www.cell.com/neuron/pdf/S0896-6273(17)30509-3.pdf">https://www.cell.com/neuron/pdf/S0896-6273(17)30509-3.pdf</a></p><p>Embodied LL: <a href="https://lis.csail.mit.edu/embodied-lifelong-learning-for-decision-making/">https://lis.csail.mit.edu/embodied-lifelong-learning-for-decision-making/</a></p><p>EfficientLLA (ELLA): <a href="https://www.seas.upenn.edu/~eeaton/papers/Ruvolo2013ELLA.pdf">https://www.seas.upenn.edu/~eeaton/papers/Ruvolo2013ELLA.pdf</a></p><p>LL for sentiment classification: <a href="https://arxiv.org/abs/1801.02808">https://arxiv.org/abs/1801.02808</a></p><p>Knowledge Basis Idea: <a href="https://arxiv.org/ftp/arxiv/papers/1206/1206.6417.pdf">https://arxiv.org/ftp/arxiv/papers/1206/1206.6417.pdf</a></p><p>AGI LLLM LLMs: <a href="https://towardsdatascience.com/towards-agi-llms-and-foundational-models-roles-in-the-lifelong-learning-revolution-f8e56c17fa66">https://towardsdatascience.com/towards-agi-llms-and-foundational-models-roles-in-the-lifelong-learning-revolution-f8e56c17fa66</a></p><p>DEPS: <a href="https://arxiv.org/pdf/2302.01560.pdf">https://arxiv.org/pdf/2302.01560.pdf</a></p><p>Voyager: <a href="https://arxiv.org/pdf/2305.16291.pdf">https://arxiv.org/pdf/2305.16291.pdf</a></p><p>Meta-Learning: <a href="https://machine-learning-made-simple.medium.com/meta-learning-why-its-a-big-deal-it-s-future-for-foundation-models-and-how-to-improve-it-c70b8be2931b">https://machine-learning-made-simple.medium.com/meta-learning-why-its-a-big-deal-it-s-future-for-foundation-models-and-how-to-improve-it-c70b8be2931b</a></p><p>Meta Reinforcement Learning Survey: <a href="https://arxiv.org/abs/2301.08028">https://arxiv.org/abs/2301.08028</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8dacf9897143" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/the-origins-of-lifelong-ml-part-1-of-why-llml-is-the-next-game-changer-of-ai-8dacf9897143">The Origins of Lifelong ML: Part 1 of Why LLML is the Next Game-changer of AI</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Thousands of Needles in Your Skull? MEAs and the Future of Invasive BCIs]]></title>
            <link>https://medium.com/@almond.maj/thousands-of-needles-in-your-skull-meas-and-the-future-of-invasive-bcis-5a82cbf9258c?source=rss-25b9623d574e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a82cbf9258c</guid>
            <category><![CDATA[neurotechnology]]></category>
            <category><![CDATA[neuroscience]]></category>
            <category><![CDATA[brain-computer-interface]]></category>
            <category><![CDATA[multi-electrode-array]]></category>
            <category><![CDATA[neurotech]]></category>
            <dc:creator><![CDATA[Anand Majmudar]]></dc:creator>
            <pubDate>Tue, 07 Dec 2021 03:27:39 GMT</pubDate>
            <atom:updated>2023-09-02T18:56:36.615Z</atom:updated>
            <content:encoded><![CDATA[<p>You’re lying on an operating table. Your eyes flash open, the light hits quickly. As your eyes adjust, you find a mirror.</p><p>Where are you? What happened? Your feel a sharp pain all over your head like you’ve never felt before.</p><p>As your eyes adjust, you turn to look in the mirror, and slowly you realize: there are 10,000 needles piercing the deepest depths of your brain! How did this happen? Did you get abducted by aliens?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*zZcwEixnCp8EU3daMyMaSw.png" /><figcaption>YIKES!</figcaption></figure><p>Turns out, this is your fault! The year is 2050, and you wanted to undergo the brain-needling procedure yourself, because you didn’t want to be left behind. Left behind from what? Let me clarify: These needles are the leading method of creating a <strong>brain-computer interface, an electronic structure of highly various kinds that receives and/or inputs electrical signals from/to the brain.</strong> I want to try to give you a window into this incredible piece of technology, so come along!</p><p><strong>Quick Anatomy of a Neuron</strong></p><p>To understand this, you’ll need to know some basic neuroscience (if you already do, feel free to skip ahead). Essentially, when neurons are ‘activated’, positive ions move into the cell body and negative ions exit. <strong>This is called an action potential: every thought you’ve ever had has just been an incredibly complex combination of action potentials across an even more complex network of neurons.</strong> Action potentials are ‘all or nothing”, meaning that either an action potential occurs or it doesn’t, there are no levels of strength for an action potential.</p><p><strong>Methods of Brain Interaction</strong></p><p>Some methods stay outside the brain (called noninvasive), like Electroencephalogram (EEG), which uses electrodes on the surface of the scalp to measure many many action potentials of nearby neurons: Because they’re on the surface, though, they can’t nearly reach the mysterious depths of our brain!</p><p>What about Electrocorticograms (ECG) that are surgically inserted between the skull and the brain. Trust me, you do <em>not</em> want to see a picture! These electrodes have more capabilities due to their immediate proximity to the brain, but remember, they’re still only on its surface. So although they can pierce a little deeper than EEGs, they’re still not reaching our full brain-probing potential.</p><p>So what if we actually gather data from and input data to each individual cell? Patch clamps connect directly to singular cells and are able to pierce deeply into the brain. They too are not without issues, though: they’re bulky and highly imprecise!</p><p>It seems like with each method, we have some major problem which severely limits our data-gathering ability. Can we create a technology that solves all these problems simultaneously? Yes, and their name is:</p><p><strong>Multi-Electrode Arrays (MEAs)!</strong></p><p>With MEAs, we get multiple simultaneous neuron measurements wherever, easy installation and setup, <em>and </em>selective stimulation of neurons (input instructions to neurons)! So, yeah, these guys are super useful! Now the question becomes how they work: to understand how the array works, as with most problems, it’s easiest to reduce the scale and eliminate everything but the core functionalities.</p><p><strong>Basic In Vitro Microelectrode Array</strong></p><p>Let’s start with an in vitro (not in a multicellular organism) array of 4 by 4 electrodes. On these electrodes, we’ll randomly place 8 pre-connected neurons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K_EfQAO4OtYfbOug.jpg" /></figure><p>When a neuron activates, an electrode converts the change in electrical charge from the movement of ions to an electronic current (ions vs. electrons). For a single neuron,</p><p>The voltage output of the electrode depends directly on the total change of ion charge in the overlapping area between electrode and neuron and the ratio of the overlapping region to the entire electrode.</p><p>Wow, that’s a lot! So basically, the voltage value that a given electrode outputs at a given time depends on the change in ion voltage it detects and how much it overlaps with the neuron. The more it overlaps and the larger change from negative to positive ions that the electrode detects, the higher the voltage output! So now we can get the instantaneous ion composition of each neuron in the form of voltage, which corresponds directly to whether the electrode is undergoing an action potential or not. But:</p><p><strong>How do we determine exactly when it experiences an action potential?</strong></p><p>We can set a floor for how many volts the signal of the electrode has to be to count as an action potential for its corresponding neuron. This floor is typically calculated as x times the standard deviation from the mean or median of the value of ion composition of neurons in time periods of inactivity, which still have electrical activity due to noise (x is often 4 or 5).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*azwN8Neu33jp4QPVe2UfCg.png" /></figure><p><strong>How do we actually read the data?</strong></p><p>Each of the 8 electrodes has its own horizontal line which spikes when an action potential occurs. Scientists can then observe the patterns and structure of bursts of spikes, and make inferences based on these patterns. We’ll get into data processing later when we talk about actually used MEAs, which are more complicated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*rplxH0PERe6GZp7YzdjR5Q.png" /></figure><p><strong>So what if you wanted to use this technology to look at actual neurons still in living organisms?</strong></p><p>Well, you can, in two ways. The more basic way is using an electrode for each neuron, just as in the in vitro array. Although this limits your ability to measure to less than about 500 neurons, the method yields more precise measurements which may be desired depending on the nature of the experiment.</p><p>Single-neuron measurement uses microwire arrays, advantageous because they can be bent and positioned precisely so as to reach a singular neuron and not be constricted by extraneous structures such as glial cells, who are more or less the caretakers of neurons. The data is received and analyzed the same way as in vitro arrays.</p><p><strong>Now to in vivo!</strong></p><p>Once we get to the neural networks of living structures on a macro scale, though, it becomes unrealistic to get data from each neuron among the billions in your brain (at least 100 billion, and potentially 50 times more glial cells!). How do we solve this problem? The solution that comes to mind most quickly would be to somehow measure multiple neurons with each electrode. That method happens to be the one we went with!</p><p>Let’s again start with the most basic form of this in vitro array, called the Utah Array (cause it was created in Utah, maybe the only thing Utah ever did!). A is what it looks like: a regular array of electrodes, except the electrodes are at the ends of incredibly intimidating needles so they can reach inside the brain. The only setback of Utah array electrodes is that they only receive electrical stimulation from the tip. To solve this, we use Michigan array electrodes, which allow for obtaining signals along the length of the electrode as well. Each electrode ends in an intercellular space (not in a cell).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*EisKD0WBWFUrpp434KkQuA.png" /></figure><p>So what exactly does each electrode measure? An easy way to gauge the aggregate of an area’s action potentials at any given time is to simply do the same thing as before: convert the change in electric charge from ion movement into electronic voltage, except this time, each electrode is further apart and measures charge in extracellular space. Therefore, the more negative the ions in the extracellular space, the more action potentials currently are occurring (since positive ions would have left the extracellular space to go into the cells).</p><p>The impact of currents traveling between neurons on the electrode’s final voltage output depends on the same factors mentioned above: magnitude of ion change, distance from electrode, noise, etc. In this way, each electrode can potentially get a reasonable assessment of action potentials for all the neurons within 100 micrometers of the origin of the action potential.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*timbI1GvJPhJ52EAH0WkyQ.png" /></figure><p>For each neuron, the voltage of the electrode is directly related to the point current value and inversely related to the conductivity of the medium and the distance from the point source of action potential to the electrode.</p><p>It’s important to not, however, that the change that the electrode detects is rarely the true change in ions. Numerous factors influence what the electrode detects, which are super important to know for the operation of an MEA. Let’s start with the most simple:</p><ol><li><strong>The Medium of the Cell</strong></li></ol><p><strong>Essentially, how well does the medium conduct the change in ions from the neuron to the electrode? </strong>This is determined most directly to the medium’s innate electrical conductivity: how easily a medium allows current to flow through. The quality of the medium is also measured by its Capacitance, the ability of the medium to store electric charge. Lastly, we have Homogeneity, which is a universal word meaning how similar things are to each other, here, specifically how all physical properties of molecules in the medium are the same. For our purposes, in the ideal cell, we would have high electrical conductivity, high capacitance, and high homogeneity.</p><p><strong>2. The Electrode</strong></p><p>The electrode itself, of course, influences the total voltage absorbed as well. The shape of the electrode is the most apparent. Then comes electrical impedance, an infamously difficult concept that boils down to a circuit’s resistance to alternating current (current that reverses direction periodically).</p><p>The electrode also needs to transfer the signal it receives to the reception location (central receiver). So, how well does it do that? Specifically, the factors here are data transmission, how well it transfers the data, and signal amplification, how large the signal is amplified.</p><p>Next comes the infamous factor of signal detection:</p><p><strong>3. Noise</strong></p><p><strong>Basically, think of noise as any sort of interference that can influence the total change in ions detected. </strong>Noise can be biological, such as neural activity from the heart, or external, such as radio waves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*uJEvfi6yyt0YVUZXxmWOVA.jpeg" /></figure><p>Some of the more prominent biological noises interfering with our neuron action potential detection are the action potentials of distant cells. Naturally, distant cells negatively affect the ionic composition of the intracellular environment, but when we aren’t trying to measure their impact, this can be less than useful. The heart is also a large interferer.</p><p>And, of course, the electrode itself generates noise as well, in the form of voltage and heat. There’s also the noise from the device that amplifies and digitizes the signal.</p><p>Power lines are also a famous factor. So, yeah, there’s a lot of noise! How do we counter all this interference? Well, to use the example of power lines, which emit waves at 50–60 Hz, we can just exclude that frequency in the data processing phase for this reason. Or, for the excess neuron noise, scientists use complex mathematics to isolate the signals of the neurons from which they want to get data.</p><p><strong>What’s the purpose of all this?</strong></p><p>The electrode can record the instantaneous ion constitution of the extracellular space, which accounts for the overall pattern of action potentials of the neurons in an area. This can be used to measure ‘brainwaves’, which are patterns of action potentials that reveal generalities about the subject’s state of consciousness, feelings, and intents shown as changing lines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*-F608UGav_-2xyirRyeLqA.png" /><figcaption>Brainwaves!</figcaption></figure><p>So what actually happens to change the raw voltage to usable data?</p><p><strong>How to transfer the data</strong></p><p>First, we want to separate the fast action potentials from all the noise we mentioned before, which we can do by applying a filter of typically 300–3000 Hz, a narrow band that significantly increases the accuracy of readings. After the signal is filtered, spikes are detected the same as before: an amplitude threshold.</p><p>Next comes spike sorting, which most often uses (buzzword incoming) machine learning algorithms! to group the spikes in activity according to their shape.<strong> </strong>In the ideal scenario, each neuron fits into one and only one cluster based on their spikes. We won’t go deep into this sorting stage due to its potential to be complex and variable, but if you want to know more about this aspect of MEA&lt; there’s definitely research on there about different sorting methods.</p><p><strong>How do we analyze all this?</strong></p><p>So you have the data of spike grouping, now what do you do with it? Ideally, <strong>you can find out something useful about the subject based on the behavior they exhibit or state they are in, and vice versa. </strong>We can do this by focusing on bursts, when a neuron exhibits multiple action potentials in a short amount of time followed by a period of relative rest. Most especially useful is the focus on multi-neuron bursts.</p><p>Say you have a given simple action, like moving one’s left pinky. We can ask the subject to try to move only their left pinky multiple times (this works even if the subject&#39;s pinky is not there anymore). Every time they do so, we can now observe the sequence of action potentials in their motor cortex, which are slightly different each time, and use Machine Learning Algorithms! to create a trend of action potentials when the pinky fires. Then, every time the MEA detects that action potential pattern, you can activate, say, a robotic pinky to contract!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*dr38CigJzNamR_1x.jpg" /><figcaption>This idea taken to the future? Cyborg Genos (One Punch Man)</figcaption></figure><p>Here’s another one: an experiment with cats! 8 sets of electrodes were implanted in a cat’s parietal cortex during wakefulness and sleep state. During wakefulness, intracellular space was dominated by low-amplitude fast-frequency waves of charge. Transitioning to sleep, though, fast waves gave way to high amplitude slow waves dominated, but then in REM sleep gave way to the same low amplitude fast-frequency brainwaves exhibited during wakefulness! Interesting…. Perhaps because the parietal lobe is sensory and we dream during REM sleep?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Gv6C-Ss1timAENG7.jpg" /></figure><p>MEAs are also capable of stimulating electrical signals, which I won’t talk about here. So yeah, they’re pretty amazing. I encourage you to explore the Brain-computer interface area further since it has a lot more to offer!</p><p>Please help me by sharing this article with anyone interested in neuroscience and/or emerging technologies. If you enjoyed the article, follow me on <a href="https://www.linkedin.com/in/anand-majmudar-962406221/">Linkedin</a>. If you like this sort of thing, I think you’ll also enjoy my book, <a href="https://www.amazon.com/Monkes-Guide-Consciousness-Anand-Majmudar-ebook/dp/B09FFVRGDS/ref=cm_cr_arp_d_product_top?ie=UTF8">An Illustrated Exploration of Consciousness</a>, about the mysteries of our mind.</p><p>Thanks for reading, I appreciate you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a82cbf9258c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>