<?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 Jasmine Padhye on Medium]]></title>
        <description><![CDATA[Stories by Jasmine Padhye on Medium]]></description>
        <link>https://medium.com/@jasmine.padhye.0805?source=rss-989968b30a7a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3FT3_83wJT9XTAuuCADNKw@2x.jpeg</url>
            <title>Stories by Jasmine Padhye on Medium</title>
            <link>https://medium.com/@jasmine.padhye.0805?source=rss-989968b30a7a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:58:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jasmine.padhye.0805/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[Language Models and their Evolution]]></title>
            <link>https://medium.com/machine-learning-reply-dach/language-model-and-its-evolution-6c01cf26caf8?source=rss-989968b30a7a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c01cf26caf8</guid>
            <category><![CDATA[transformer-model]]></category>
            <category><![CDATA[language-model]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <dc:creator><![CDATA[Jasmine Padhye]]></dc:creator>
            <pubDate>Tue, 06 Dec 2022 09:16:24 GMT</pubDate>
            <atom:updated>2022-12-06T09:17:38.133Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9eyPcITvvx9RcWL2" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_source=medium&amp;utm_medium=referral">Brett Jordan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Natural Language Processing is one of the hot research topics that deals with extracting and understanding text data. The field has undergone significant growth in recent years, and one of the major contributing factors to this growth is the emergence of language models. This blog post gives an overview of what a language model is and how it has evolved over the years to become more powerful.</p><p>In simple words, a <em>Language Model (LM)</em> assigns a probability to a sentence, i.e a sequence of words. It determines how likely a sequence of words will occur. For example, the sentence <em>It is going to rain today</em> is more likely to occur than the sentence <em>Today is rain</em>. This example can be mathematically represented as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*r4BlyMlLclgqAdsOCCPdEQ@2x.jpeg" /></figure><p>But why do we need such probabilities? Getting these probabilities can be useful in different use cases such as <em>text summarisation</em> in which the input sentence is shortened without losing meaning, <em>question-answering</em> in which answers for a given question are extracted from the web/input text, <em>chatbots</em> in which computer communicates with humans and provides assistance, <em>text recognition</em> which converts text from image to textual data, and many more. The following examples show how these probability distributions can be useful.</p><h4>1. Machine translation: Translate input sentence from one language to another</h4><p>When a sentence from one language is translated into another, the order of words in the output sentence might need rearrangement, or some words might need replacement with more plausible words to make sense of the output. In the given example, <em>heavy rain</em> is more plausible than <em>large rain</em>. This probability helps in choosing the correct synonym during translation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*4JisH2HzAdGWki0sitWLlg@2x.jpeg" /></figure><h4>2. Autocorrect: Suggest a correction for misspelled words or incorrect grammar</h4><p>When a word is misspelled, the probability of the given sequence drops. When this happens, the likelihood of a word that fits best with the given sequence can be suggested as the correct replacement. For example, the occurrence of <em>15 minutes</em> is much more probable than <em>15 minuets</em>. Autocorrect also considers which words from the most probable words need the least character replacement with the misspelled word.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*-FrX01LrOV47D6Jd5K2mHw@2x.jpeg" /></figure><h4>3. Speech recognition: Convert input voice signal to text</h4><p>In speech recognition, many similar sounding words can be confused with each other. The likelihood of combinations of words is required to recognize which word was spoken correctly. For example, the probability of someone saying <em>I saw a cow</em> is much higher than saying <em>Eyes of a bow</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*auWiPzQXwznR_bBOde2w8g@2x.jpeg" /></figure><h4>4. Sentence completion: Suggest next words in the input sentence</h4><p>For sentence completion, the model needs to suggest the most likely word to occur given the current sequence of words. For example, a cheese pizza is much more likely to be ordered with <em>olives</em> than <em>rice</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*yt_AhnmCok20yno89XJjiw@2x.jpeg" /></figure><p>The methods of finding these probability distributions have improved tremendously in the last few years.</p><p>Our intuition tells us to find this probability distribution by applying the chain rule to the joint probability of a sentence. For example, to find the probability distribution of the sentence <em>I will not be able to attend the meeting</em>, we do the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*gFjYNug5WpxoJPkf-VTl7Q@2x.jpeg" /></figure><p>And we get these individual conditional probabilities as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*xisrdYnL-TJXHvWkfT9EDQ@2x.jpeg" /></figure><p>However, the issue with this approach is that we cannot have enough data for estimating these conditional probabilities for long sentences. These long term dependencies can be handled by simply limiting the number of words on which the next word depends. In other words, instead of computing <em>P(meeting|I will not be able to attend the)</em>, the dependency can be reduced to 2 words to compute <em>P(meeting|attend the)</em>. In NLP, this kind of prediction which is based on short history is called the <em>Markov assumption.</em></p><p>This assumption implies that the probability of the <em>n-th</em> word depends only on <em>n-1</em> words, and the words prior to that do not affect this probability. The <strong><em>N-gram</em></strong> language model is based on this assumption.</p><ul><li>Unigram model: probability of n-th word depends on 1–1=0 prior words</li><li>Bi-gram model: probability of n-th word depends on 2–1 = 1 prior words</li><li>N-gram model: probability of n-th word depends on n-1 prior words</li></ul><p>With the increase in <em>n</em>, looking back becomes more and more expensive. In addition, setting this hard limit on how far back to look results in completely forgetting the beginning of a sentence. To combat this limitation, <em>RNN-based</em> language models were developed allowing information to persist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*O87POQRWB7k9x87e5neQHg@2x.jpeg" /><figcaption>Unrolled Recurrent Neural Network</figcaption></figure><p>In a RNN model, one word is processed after another in a loop by the same neural network, which introduces the recurrent nature of the model as shown in the image above. At every step, the network processes the new input along with the information obtained from the previous step and passes it to the next step. This helps the network connect previous information with current information, which can help with tasks such as sentence completion. For example, if we want to predict the next word in <em>The cat drank ___</em>, the RNN based language model can easily connect <em>cat</em> and <em>drank</em> to <em>milk</em> as the prediction. However, this model also comes with its own limitations. When a sentence gets long, only the most recent information is not enough, and some context from earlier steps of the sentence is required for the prediction. For example, in the sentence, <em>I went to India to visit my parents and I ate ___</em>, the model can use the recent information <em>ate</em> to predict the next word to be a food item. However, the model needs to look even further back to <em>India</em> to predict a food item from Indian cuisine. When this gap between current steps and relevant information increases, the performance of RNN drops.</p><p>Similar to the training process on a simple NN, during the training of RNN, the weights are updated in the backward pass. The gradients during backpropagation flow backward across time steps. And with an increase in sentence length, the risk of facing exploding or vanishing gradients increases. These two issues of RNN-based language models were solved by using <em>LSTM networks</em>.</p><p>LSTMs are a special kind of RNNs that consists of so called long term memory. Unlike RNNs in which each cell consists of a single NN layer, a LSTM cell consists of 4 layers that decide which information to keep, which to forget and how much information to pass through. Using LSTMs can give a better performance than simple RNN as the network can hold relevant information for longer. However, training a LSTM network can be time expensive. Researchers developed another breakthrough approach, much simpler and faster than LSTM, called <em>Attention</em> which was proposed in a paper titled <em>Attention is all you need</em>.</p><p>LSTMs consist of gates for forgetting information. Unlike LSTMs, instead of actively deciding which information is not important, an Attention mechanism concentrates only a few things at every step while ignoring others. For example, if we want to predict a pronoun after <em>Jane is writing ___</em>, we only need to focus on <em>Jane</em> to predict the pronoun to be <em>her</em> and other information <em>is writing</em> can be ignored. Similarly, to predict the next word of <em>Jane is writing her ___</em>, the attention mechanism only focuses on <em>is writing</em> and gives <em>essay</em> as output, and it ignores other non-relevant information <em>Jane</em> and <em>her</em>.</p><p>The working of the attention mechanism idea can be visualized quite nicely during image captioning, as shown below. The different colors show the correspondence between underlined words and the attended region in the attention map.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*Jc9dhX_AiY2dOwaGWunjeQ@2x.jpeg" /><figcaption>Source: arXiv:1612.01887</figcaption></figure><p>This attention mechanism was then adopted in a deep learning model with an encoder-decoder structure called <em>Transformers</em>. The encoder encodes the input sentence like in any encoder-decoder architecture. However, the attention mechanism helps the encoder to look also at other parts of the input sentence while it encodes a word. Similarly, it also helps the decoder to look at other relevant information while decoding.</p><p>A Transformer architecture does not contain any recurrence component and takes the entire input sequence simultaneously, which enables parallelizing the computation. This can help in faster training of a model with a huge number of parameters on a large corpus. Because of these advantages, Transformers created a massive impact in NLP and Computer Vision domain. BERT by Google, GPT by OpenAI, and their variants are some examples in NLP of such Transformer models with billions of parameters trained on large corpora using parallel computation power. Nowadays, when we talk about language models, we always refer to these powerful Transformer-based language models.</p><h3>References:</h3><ul><li>https://www.youtube.com/watch?v=rURRYI66E54</li><li>https://www.analyticsvidhya.com/blog/2019/11/comprehensive-guide-attention-mechanism-deep-learning/</li><li>http://jalammar.github.io/illustrated-transformer/</li><li>https://huggingface.co/docs/transformers/main/en/index</li><li>http://colah.github.io/posts/2015-08-Understanding-LSTMs/</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c01cf26caf8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/machine-learning-reply-dach/language-model-and-its-evolution-6c01cf26caf8">Language Models and their Evolution</a> was originally published in <a href="https://medium.com/machine-learning-reply-dach">Machine Learning Reply DACH</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>