<?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 Adit Whorra on Medium]]></title>
        <description><![CDATA[Stories by Adit Whorra on Medium]]></description>
        <link>https://medium.com/@aditwhorra?source=rss-db88bfae004e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jAr-T9GRGN2Moch9BfFMhw.jpeg</url>
            <title>Stories by Adit Whorra on Medium</title>
            <link>https://medium.com/@aditwhorra?source=rss-db88bfae004e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 19:34:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aditwhorra/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[An Intuitive Introduction to solving Scalable Oversight using Iterated Amplification]]></title>
            <link>https://aditwhorra.medium.com/an-intuitive-introduction-to-solving-scalable-oversight-using-iterated-amplification-403bf14b4061?source=rss-db88bfae004e------2</link>
            <guid isPermaLink="false">https://medium.com/p/403bf14b4061</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai-risk]]></category>
            <category><![CDATA[ai-safety]]></category>
            <dc:creator><![CDATA[Adit Whorra]]></dc:creator>
            <pubDate>Tue, 27 Feb 2024 12:59:13 GMT</pubDate>
            <atom:updated>2024-02-27T12:59:13.403Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine you have a genius child prodigy in your neighborhood, someone who is exceptionally gifted in physics — let’s call them Alex. Alex is so brilliant that they could revolutionize the world with their inventions, potentially solving energy crises or even discovering new forms of travel. However, there’s a catch: Alex is young and, like many geniuses, somewhat naive about the broader implications of their work. Without guidance, Alex might inadvertently create something dangerous, like a new energy source that’s incredibly efficient but could also be used as a powerful weapon.</p><p>In this analogy, Alex represents an advanced AI system. Just like Alex, AI can perform tasks or solve problems with efficiency far beyond what we can imagine. However, without proper guidance, it might pursue goals that are harmful or misaligned with human values.</p><p>The other physicists in the neighborhood (representing humanity) would like to guide and monitor Alex’s research and development process to ensure it’s beneficial and doesn’t lead to negative outcomes. This process of aligning and supervising AI systems that outperform humans at the task at hand is known as scalable oversight.</p><p>The physicists could try the following things to guide Alex -</p><ol><li>Alex could start inventing things and the other physicists could come together and give some feedback to Alex about their invention. However, like all inventions, it is hard to tell if they will be beneficial and safe in the long run so the physicists can’t “label” the invention as good or bad (providing a training signal for complex problems behaviors exhibited by advanced AI systems is supervised learning is not possible).</li><li>The physicists could start inventing things by themselves and try to “demonstrate” the desired behavior to Alex. However, since the physicists are not as smart as Alex, the kind of inventions they want Alex to come up with are too hard for them to demonstrate in the first place. How do the physicists then guide Alex when they can’t match their intellect? (providing a training signal to advanced AI systems via reward mechanisms or imitation is not possible)</li></ol><p>So what can the physicists do? They soon realize something. Even though they cannot supervise Alex in his task of inventing something beyond their capabilities, they can help Alex break down the process of invention into smaller subtasks for which they can guide Alex. By aligning Alex’s goals for these smaller subtasks, they arguably ensure that Alex’s invention will also be aligned towards the greater good. This describes the process of iterated amplification that allows us to supervise advanced AI systems in learning complex behaviors and goals by demonstrating small fundamental subtasks and then iteratively composing more complex tasks with these subtasks while making sure their behavior remains aligned with our objectives.</p><p>The following process breaks down the physicists’ approach -</p><p><strong>Starting Small: </strong>Initially, they ask Alex to work on very small, fundamental problems in science, something like “Explain why objects fall to the ground” or “What happens when you mix these two chemicals together?”. Since they are all established physicists, they are capable enough to provide feedback to Alex about what he learns or demonstrate their approach to these problems so that Alex can learn from their demonstrations. Additionally, the physicists also introduce Alex to basic ethical principles in science and innovation, focusing on the importance of safety, transparency, and the well-being of society. These guidelines serve as the moral compass for all of Alex’s projects. Moreover, since the physicists provide close supervision for these fundamental tasks, they can provide positive reinforcement when Alex completes a task with the desired ethical outcomes, encouraging Alex to internalize these values as core to the problem-solving process.</p><p><strong>Learning by Decomposition:</strong> As Alex successfully navigates these small tasks, the physicists introduce slightly larger challenges, such as “Design a simple machine that could help reduce household energy consumption.” The physicists guide Alex in decomposing this challenge and they make sure that the challenge they propose can be broken down into the smaller subtasks that Alex has already learned previously. Now, since Alex already knows how to solve the smaller subtasks, Alex can learn the more complex challenges without any help from the physicists apart from task decomposition. The physicists still oversee Alex’s behavior and can correct misalignments as and when they occur.</p><p><strong>Amplification:</strong> With each success, the tasks that the physicists propose become more complex. At each step, Alex ‘amplifies’ the knowledge and skills acquired from the previously learned subtasks to iteratively learn more complex tasks without direct feedback from the physicists. Eventually, Alex will be able to learn how to invent things beyond the capabilities of the physicists, and the inventions remain aligned with the objectives of the neighboring physicists.</p><p>Thus, the physicists have been able to successfully guide Alex into learning tasks beyond their capabilities and make sure Alex’s behavior and intentions remain aligned with the greater good.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=403bf14b4061" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Everything you need to know about Adversarial Training in NLP]]></title>
            <link>https://medium.com/analytics-vidhya/everything-you-need-to-know-about-adversarial-training-in-nlp-b249301b6229?source=rss-db88bfae004e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b249301b6229</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[adversarial-training]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <dc:creator><![CDATA[Adit Whorra]]></dc:creator>
            <pubDate>Mon, 04 Jan 2021 08:15:00 GMT</pubDate>
            <atom:updated>2021-01-07T15:51:23.199Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Adversarial training is a fairly recent but very exciting field in Machine Learning. Since Adversarial Examples were first introduced by Christian Szegedy[1] back in 2013, they have brought to light fundamental limitations of deep neural networks in their ability to correctly classify adversarially perturbed inputs. These perturbations are enforced to be infinitesimally small, most often imperceivable by humans, and yet they are able to fool modern state-of-the-art neural models. Adversarial training is a technique developed to overcome these limitations and improve the generalization as well as the robustness of DNNs towards adversarial attacks. This blog post will cover everything you need to know about Adversarial Training in NLP — the concept, the motivation, and the challenges.</p><h3><strong>Backdrop — Adversarial Examples and Adversarial Training</strong></h3><p>The blog post will cover the concept of adversarial examples (originally in Computer Vision), the application of these concepts in NLP as well as the recent developments and setbacks in adversarial training and robust optimizations.</p><h4><strong>Adversarial Examples</strong></h4><p>Christian Szegedy[1] introduced the idea of adversarial examples in his paper Intriguing Properties of Neural Networks. He conducted his experiments on the MNIST dataset using the QuocNet and AlexNet models.</p><p>An <em>Adversarial Example</em> x’, for x ε X and y, y’ ε Y can be formulated as the following -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*3fQjTGmv0TsRxo5h" /><figcaption>The second line shows a <strong>targetted</strong> <strong>adversarial example</strong> where we are forcing the output of the perturbed input to be a specific label that is not the input label. The third line shows an <strong>untargeted adversarial example</strong> where the output of the perturbed label is anything but the input label</figcaption></figure><p>Here, η is some perturbation added to the original input example x.</p><p>Crafting adversarial examples using large perturbations would be trivial since the output of the model would in most scenarios change if the inputs are very different from each other.</p><blockquote>Therefore, an important criteria for an adversarial example is that the perturbation is very small (imperceivable by a human observer). If the inputs are in a continuous space (like pixels or word/character embeddings), the norm (magnitude) of the perturbation vector is often restricted to a small value.</blockquote><p>Another thing to note is that adversarial examples can be of two types — given a model that one is trying to fool, a <strong>blackbox</strong> adversarial example is one that is created without having access to the model gradients or model parameters. On the other hand, a <strong>whitebox </strong>adversarial example is one which is created with access to the model gradients (which can be used to determine the sensitivity of the model towards certain perturbations as we will see later)</p><p>The following are examples of adversarial examples shown by Christian Szegedy in the paper —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*izLL9bFmiGGE8mDJq_sPEA.png" /><figcaption>The first column is the input image. The second column is a small perturbation that is added to the image. The third column is the resultant image. As can be seen, the resultant image is very similar to the input image. Adding the small noise caused the model to predict “ostrich” for all these images!</figcaption></figure><h4><strong>Adversarial Examples in Computer Vision VS in NLP</strong></h4><p>The idea of perturbing the input space (given that the perturbation is imperceivable) fits perfectly in the field of Computer Vision. This is because of the following reasons -</p><ul><li>The input space is continuous (pixels).</li><li>A small change in the pixel values will not change the resulting image (resistant to small perturbations).</li></ul><p>However, it is not so straightforward to apply the same ideas to create adversarial examples in NLP. This is due to the following reasons -</p><ul><li>Image data (pixel values) is continuous but textual data (tokens) is discrete so the idea of input perturbations is meaningless if we consider tokens as our input space.</li><li>A solution to this is to consider the embedding space (continuous space) as the input space. However, how do we translate the perturbed embedding back into a token? Will it even be a valid token after perturbation?</li><li>Another more important issue here is that unlike image pixels, text embeddings might actually be really sensitive to small perturbations. In fact, a small perturbation might result in a sentence with an incorrect syntactic structure or completely different semantic meaning.</li></ul><p>Therefore, instead of focussing on the embedding space, algorithms to generate adversarial examples in NLP have mostly dealt with character/word/sentence level perturbations. To give a few examples -</p><ul><li>Jia and Liang[2] fooled Reading Comprehension models by inserting sentences to SQuAD without altering the answer of the question. (Blackbox)</li><li>Liang et al.[3] used gradients to determine the sensitivity of model towards certain words/characters and manually replacing them with common misspellings (Whitebox)</li><li>Samanta et al.[4] a removal-addition strategy that constrained replacements such that grammar is preserved. (Whitebox)</li><li>Jin et al.[5] ranked words by their importance and replaced them with synonyms while maintaining grammatical sense and sentence meaning. (Blackbox)</li><li>Other paraphrase and edit based text perturbations (Blackbox)</li></ul><p>Now that we have some basic knowledge about adversarial examples (and how they differ between computer vision and NLP), let us look at adversarial training which is a method introduced by Ian Goodfellow to address this vulnerability in deep learning models.</p><h4><strong>Adversarial Training and Robust Optimizations</strong></h4><p><em>Adversarial training </em>is a method used to improve the robustness and the generalisation of neural networks by incorporating adversarial examples in the model training process.</p><p>There are two ways of doing so -</p><ol><li>The simple but less effective way is to re-train a model using some adversarial examples that have successfully fooled the model. Intuitively, one is adding the examples that were fooling a model to the training data itself resulting in the model becoming robust to these perturbations and correctly classifying these adversarial examples.</li><li>The second and more effective way is to incorporate input perturbations as part of the model training process.</li></ol><p>It is important to note that the first method only exposes certain types of adversarial examples in the model training process. For example, if the algorithm to generate adversarial examples replaces the input words with their synonyms to create adversarial examples, the model has only become more robust when it comes to this particular type of perturbation. It still remains vulnerable to other kinds of adversarial examples. In contrast, the second method incorporates perturbations as part of the model training process often done by adding small perturbations to the continuous input space as we will see below. Therefore, it assures a more general and effective robustness to adversarial examples.</p><blockquote>Since our objective here is to adversarially optimise the loss function and not to create adversarial examples, it is possible to adversarially perturb the embedding space when we are dealing with Natural Language. Therefore, the algorithms discussed below can be applied to NLP by perturbing the continous embedding space of input examples.</blockquote><p><strong>One-step Adversarial Training as a Regulariser</strong></p><p>Adversarial Training was first introduced by Goodfellow et al.[6] in a follow-up paper to Christian Sxegedy’s paper. He proposed adding perturbations to the input example as a regulariser in the loss function. The loss function in ERM was modified as follows -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wEsj8sDFEapEiHMy" /><figcaption>𝛂 is the regularisation parameter and ε is the perturbation (Very small value). The sign refers to the sign of the value.</figcaption></figure><p>Therefore, a very small perturbation is added to the original input example in the direction of the gradient of the parameters with respect to the loss function. Intuitively, by going in the direction of the gradient, as opposed to the direction away from the gradient (as done while performing weight updates in SGD), one is maximising loss for that example instead of minimising it. Therefore, the model would be sensitive towards noise in this direction and a small perturbation in this direction might cause the model to change its prediction. This gave a quick and effective way of generating adversarial examples and also introduced the idea of adversarial training.</p><p><strong>Note</strong> — This is a one-step perturbation (we are perturbing the input only once) where the adversarial term is added as a regulariser in the loss function.</p><p><strong>K-step perturbation (min/max)</strong></p><p>Following the idea of adversarial training introduced by Goodfellow, Madry et al.[7] further modified the ERM objective as a min/max saddle point optimisation problem as follows -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/0*5OHFfiUtBrA70Bsd" /></figure><p>The proposed min-max style optimisation is the composition of an <strong>inner non-concave maximization</strong> (solved using <a href="http://niaohe.ise.illinois.edu/IE598_2016/pdf/IE598-lecture10-projected%20gradient%20descent.pdf">Projected Gradient Descent</a>) problem and an <strong>outer non-convex minimization</strong> problem (solved using Stochastic Gradient Descent). Here, the outer minimization is optimised to find parameters that minimise the loss function (as before) and at the same time, the inner maximisation is optimised to find a perturbation vector that maximises the loss for that particular example/mini-batch.</p><p>This method is different from the original proposition in the following ways -</p><ul><li>Instead of perturbing the input once (in the direction of the gradient), this method makes the perturbation a parameter that is learnt as part of the training process. This requires an inner loop where for each mini-batch, the perturbation vector is updated K-times in order to maximise the loss. Therefore, this is known as a K-PGD adversary.</li><li>Since this is designed to maximise δ, it <strong>guarantees </strong>that the resulting model is robust <strong>against perturbation within the </strong>ϵ <strong>norm-ball.</strong> This is something the previous approach did not provide. Therefore, adversarial training under the K-PGD provides greater confidence in model robustness.</li><li>Instead of adding perturbations as part of a regularisation term, this approach directly modifies the loss function to incorporate perturbations.</li></ul><p>K-PGD adversarial training has the following algorithm -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hv71rCF-xs7VosGz" /></figure><p>It is obvious by looking at the algorithm that for each weight update, K-PGD requires K forward-backward passes through the network, while the standard SGD update requires only one. That is, the model weight updations happen only once after K-ascent steps. Therefore, K-PGD adversarial training is computationally much more expensive requiring roughly K+1 times more computation. There are many proposed solutions to this problem — FreeAT[8], YOPO[9], FreeLB[10] that implement a K-PGD adversary with little or no computational overhead. These implementations also apply these algorithms to NLP by adversarially perturbing the embedding space.</p><h3>Challenges and Drawbacks of Adversarial Training</h3><p>Even though adversarial training improves the robustness of models and makes them less vulnerable towards adversarial attacks, recent papers show that there exists a trade-off between the generalization of a model (i.e. the standard test accuracy) and its robustness (accuracy on an adversarial dataset). That is, models trained with an adversarial objective often show an increase in the robust accuracy but a decrease in the standard accuracy.</p><p>According to Tsipras et al.[11] the goals of standard performance and adversarial robustness might be fundamentally at odds. They conclude this by showing that the trade-off<em> </em>exists even in a fairly simple and natural setting and the root of this trade-off is the fact that features learned by the standard and robust classifiers can be fundamentally different and this phenomenon persists even in the infinite data setting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mP_GBUpLrBh-4n2S" /></figure><p>As can be seen in the figure above, Raghunathan et.[12] show that a model trained with an adversarial objective has better robust (adversarial) test accuracy but worse standard test accuracy. Since the training accuracy for both datasets is 100%, the conclusion that can be made is that training with an adversarial objective hurts the generalisation of the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LaTXs9m2dRoJOoVo" /></figure><p>In fact, Min et al.[13] show that this trade-off between generalisation and robustness exists even in the infinite data limit. As can be seen in the figure, in the case of a strong adversary (where ϵ is a larger value implying that perturbations can be larger), the standard loss in monotonically increasing even in the infinite data setting. This observation corroborates Tsipras’s proposition that the features learnt while optimising an adversarial objective are fundamentally different than those learnt while optimising a standard objective. Hence, the stronger the adversary, the more likely it is for the features learnt to be different than those that are learnt in standard optimisation, resulting in the monotonically increasing loss for strong adversaries.</p><h3><strong>Conclusion</strong></h3><p>In this blog post, we covered the idea of adversarial examples and how they differ in Computer Vision and NLP. We also covered the concept of adversarial training and robust optimisations and discussed the various algorithms for adversarial training. More importantly, we understood that since the goal of adversarial training is to adversarially optimise the loss function and not to create adversarial examples, the adversarial training algorithms developed in Computer Vision can be applied to NLP. Finally, we understood the recent drawbacks that have come to light in the field of Adversarial Training. In a future blog post, I will be covering a recent paper called <a href="https://arxiv.org/pdf/2004.08994.pdf">Adversarial Training for Large Natural Language Models</a>, which addresses these limitations and claims an improvement in both robustness and generalisation in an adversarial training setting in NLP.</p><h3><strong>References</strong></h3><ol><li>Szegedy, Christian, et al. ‘Intriguing Properties of Neural Networks’. <em>ArXiv:1312.6199 [Cs]</em>, Feb. 2014. <em>arXiv.org</em>, <a href="http://arxiv.org/abs/1312.6199">http://arxiv.org/abs/1312.6199</a>.</li><li>Jia, Robin, and Percy Liang. ‘Adversarial Examples for Evaluating Reading Comprehension Systems’. <em>ArXiv:1707.07328 [Cs]</em>, July 2017. <em>arXiv.org</em>, <a href="http://arxiv.org/abs/1707.07328">http://arxiv.org/abs/1707.07328</a>.</li><li>Liang, Bin, et al. ‘Deep Text Classification Can Be Fooled’. <em>Proceedings of the Twenty-Seventh International Joint Conference on Artificial Intelligence</em>, International Joint Conferences on Artificial Intelligence Organization, 2018, pp. 4208–15. <em>DOI.org (Crossref)</em>, doi:10.24963/ijcai.2018/585.</li><li>Samanta, Suranjana, and Sameep Mehta. ‘Towards Crafting Text Adversarial Samples’. <em>ArXiv:1707.02812 [Cs]</em>, July 2017. <em>arXiv.org</em>, <a href="http://arxiv.org/abs/1707.02812">http://arxiv.org/abs/1707.02812</a>.</li><li>Jin, Di, et al. ‘Is BERT Really Robust? A Strong Baseline for Natural Language Attack on Text Classification and Entailment’. <em>ArXiv:1907.11932 [Cs]</em>, Apr. 2020. <em>arXiv.org</em>, <a href="http://arxiv.org/abs/1907.11932">http://arxiv.org/abs/1907.11932</a>.</li><li>Goodfellow, Ian J., et al. ‘Explaining and Harnessing Adversarial Examples’. <em>ArXiv:1412.6572 [Cs, Stat]</em>, Mar. 2015. <em>arXiv.org</em>, <a href="http://arxiv.org/abs/1412.6572">http://arxiv.org/abs/1412.6572</a>.</li><li>Madry, Aleksander, et al. ‘Towards Deep Learning Models Resistant to Adversarial Attacks’. <em>ArXiv:1706.06083 [Cs, Stat]</em>, Sept. 2019. <em>arXiv.org</em>, <a href="http://arxiv.org/abs/1706.06083.">http://arxiv.org/abs/1706.06083.</a></li><li>Shafahi, Ali, et al. ‘Adversarial Training for Free!’ <em>ArXiv:1904.12843 [Cs, Stat]</em>, Nov. 2019. <em>arXiv.org</em>, <a href="http://arxiv.org/abs/1904.12843">http://arxiv.org/abs/1904.12843</a>.</li><li>Zhang, Dinghuai, et al. ‘You Only Propagate Once: Accelerating Adversarial Training via Maximal Principle’. <em>ArXiv:1905.00877 [Cs, Math, Stat]</em>, Nov. 2019. <em>arXiv.org</em>, <a href="http://arxiv.org/abs/1905.00877">http://arxiv.org/abs/1905.00877</a>.</li><li>Zhu, Chen, et al. ‘FreeLB: Enhanced Adversarial Training for Natural Language Understanding’. <em>ArXiv:1909.11764 [Cs]</em>, Apr. 2020. <em>arXiv.org</em>, <a href="http://arxiv.org/abs/1909.11764">http://arxiv.org/abs/1909.11764</a>.</li><li>Tsipras, Dimitris, et al. ‘Robustness May Be at Odds with Accuracy’. <em>ArXiv:1805.12152 [Cs, Stat]</em>, Sept. 2019. <em>arXiv.org</em>, <a href="http://arxiv.org/abs/1805.12152.">http://arxiv.org/abs/1805.12152.</a></li><li>Raghunathan, Aditi, et al. ‘Adversarial Training Can Hurt Generalization’. <em>ArXiv:1906.06032 [Cs, Stat]</em>, Aug. 2019. <em>arXiv.org</em>, <a href="http://arxiv.org/abs/1906.06032">http://arxiv.org/abs/1906.06032</a>.</li><li>Min, Yifei, et al. ‘The Curious Case of Adversarially Robust Models: More Data Can Help, Double Descend, or Hurt Generalization’. <em>ArXiv:2002.11080 [Cs, Stat]</em>, June 2020. <em>arXiv.org</em>, <a href="http://arxiv.org/abs/2002.11080.">http://arxiv.org/abs/2002.11080.</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b249301b6229" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/everything-you-need-to-know-about-adversarial-training-in-nlp-b249301b6229">Everything you need to know about Adversarial Training in NLP</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>