<?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 Abhishek Mohandas on Medium]]></title>
        <description><![CDATA[Stories by Abhishek Mohandas on Medium]]></description>
        <link>https://medium.com/@mabhishek2817?source=rss-1b6e453df7ae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*47w42wiC2RY09XDZeX7aew.jpeg</url>
            <title>Stories by Abhishek Mohandas on Medium</title>
            <link>https://medium.com/@mabhishek2817?source=rss-1b6e453df7ae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:39:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mabhishek2817/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[Evolution of Sequence models]]></title>
            <link>https://medium.com/@mabhishek2817/evolution-of-sequence-models-4cce225fb002?source=rss-1b6e453df7ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cce225fb002</guid>
            <category><![CDATA[lstm]]></category>
            <category><![CDATA[rnn]]></category>
            <category><![CDATA[gated-recurrent-unit]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[sequence-modeling]]></category>
            <dc:creator><![CDATA[Abhishek Mohandas]]></dc:creator>
            <pubDate>Mon, 21 Jul 2025 07:25:19 GMT</pubDate>
            <atom:updated>2025-07-21T07:25:19.252Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we will discuss about what a sequence model is and how sequence models have evolved from RNNs to Transformers. In upcoming blogs, I will dive deeper into Transformers specifically. Before jumping into NLP, I would recommend learning about RNNs, LSTMs, GRUs, and the attention mechanism, as they form the foundation for understanding more advanced models. I’m new to blogging, and this is my first shot at writing a blog here on Medium :)</p><h3>Sequence models</h3><p>In simplest form, a sequence model is designed to handle data where the order of elements matters. In this model, the data is processed in a step-by-step, ordered manner, often with each step building upon the previous; it is most popular in use cases such as time series data, text, and audio.</p><h3>Recurrent Neural Networks (RNNs)</h3><p>RNNs are built specifically to handle sequential data, while processing a sentence, each word can be treated as an individual input at time t.</p><p>The hidden state in RNNs acts like a memory that stores information about the previous input. When the RNN receives the input at time t, it combines this with the new input with its previous hidden state from time t-1. This allows the network to remember important information from earlier inputs while processing new ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*p4EKmpmy0xJxai4s0nhKIA.png" /><figcaption>Figure 1: Architecture of Recurrent Neural Networks(Credits: <a href="https://d2l.ai/chapter_recurrent-neural-networks/index.html">https://d2l.ai/chapter_recurrent-neural-networks/index.html</a>)</figcaption></figure><p>After updating the hidden state, the RNN generates the output based on its current hidden state and back propagates its gradient of the loss through each of the individual networks ( adjusting each time step), which is way tricky as it involves multiplication of weight matrices over and over again.</p><p>If the weight metrics are very big, it results in an exploding gradient problem, making it infeasible and not possible to train the network stably.</p><p>If the weight metrics are very, very small, it results in a vanishing gradient problem.</p><p>In short, RNNs perform well on short sequences but struggle to capture long-range dependencies due to their limited memory, and as the sequence grows longer, they struggle to retain earlier feed information.</p><h3>Long Short Term Memory (LSTM)</h3><p>LSTM is a type of Recurrent Neural Network that is designed to overcome the exploding and vanishing gradient problem. LSTM has a chain-like structure comprising of four feed-forward neural network layers, which regulate memory management operations such as the deletion of the information( Forget Gate), adding new information (Input Gate), and using present information(Output Gate).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*kK3SEbL14rUfkZIbK1m_Lw.png" /><figcaption>Figure 2: Architecture of a LSTM Unit (Credits: <a href="https://d2l.ai/chapter_recurrent-modern/lstm.html">https://d2l.ai/chapter_recurrent-modern/lstm.html</a>)</figcaption></figure><p>In LSTM receives three input vectors (C, H, X), in which two are from previous LSTM itself, namely cell state(C) and hidden state(H), and the third comes from outside, which is a vector X inputted to an LSTM at instant t.</p><p>In practice, the LSTM unit uses short-term memory(H) and the input vector(X) to update the long-term memory called the cell state(C), and finally, it uses the cell state(<em>C</em>) to update the hidden state(H).</p><p>To regulate the information flow, the LSTM uses three gates.</p><ol><li>Forget Gate:<br>Forget gate in LSTM decides what information is discarded from the cell state, for which it looks at previous hidden state(ht−1) and the input(x), and outputs a number between 0 and 1 for each element in the cell state Ct−1. In a forget gate, a 1 represents “completely keeping information,” while a 0 represents “deleting the information.”</li><li>Input Gate:<br>The input gate determines what new information will be stored in the cell state. This gate has two parts. First, a sigmoid layer called the “input gate layer” decides which values we are going to update. Next, a tanh layer creates a vector of new candidate values, Ct, that could be added to the state. Later, we update the old cell state, Ct−1, into the new cell state Ct.</li><li>Output Gate:<br>In the Output gate first, we run a sigmoid layer, which decides what parts of the cell state we are going to output. Then, we put the cell state through tanh (to push the values to be between −1 and 1) and multiply it by the output of the sigmoid gate, so that we only output information we need to pass on.</li></ol><p>Despite their advancements, LSTMs face challenges such as computational complexity due to memory cells, gates, and longer training time, and are also prone to overfitting, especially when they have too many parameters.</p><h3>Gated Recurrent Units(GRU)</h3><p>Evolution to GRU started with the idea of maintaining the same benefits of LSTM and but reducing the computation time. While it has the same architecture as LSTM, GRU and LSTM differ in the way they handle the memory cell state. In LSTM, the memory cell state is maintained separately from the hidden state and is updated using three gates such as input gate, output gate, and forget gate. In GRU, the memory cell state is replaced with a “candidate activation vector,” which is updated using the reset gate and update gate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*ltlTiJDpy2TCSZ_PhHn7pQ.png" /><figcaption>Figure 3: Architecture of a GRU (Credits:<a href="https://d2l.ai/chapter_recurrent-modern/gru.html">https://d2l.ai/chapter_recurrent-modern/gru.html</a>)</figcaption></figure><p>Like other recurrent neural network architectures, GRU processes sequential data one element at a time, updating its hidden state based on the current input and the previous hidden state. At each time step, the GRU computes a “candidate activation vector” that combines information from the input and the previous hidden state. This candidate vector is then used to update the hidden state for the next time step.</p><p>The candidate activation vector is computed using two gates: the reset gate and the update gate. The reset gate determines how much of the previous hidden state to forget, while the update gate determines how much of the candidate activation vector to incorporate into the new hidden state.</p><p>Overall, GRU networks performed well for short to medium-length sequences, they still struggled with long-term dependencies and parallelization. As tasks such as machine translation, summarization, and speech recognition demanded deeper understanding and generation of sequences, a more structured approach was needed. This led to the rise of encoder-decoder architectures, where the encoder compresses the input sequence into a fixed context vector, and the decoder uses this vector to generate output tokens step by step. This framework introduced modularity and flexibility, laying the foundation for more advanced models.</p><h3><strong>Rise of the Encoder–Decoder model to Transformers</strong></h3><p>In the encoder-decoder model, the encoder takes in an input sequence (a sentence in English), processes it token by token using GRU or LSTM cells, and encodes the sequence into a single context vector, this vector is passed to the decoder, which begins generating output tokens (corresponding to French sentence), one step at a time. At each decoding step, the decoder uses the context vector and its previous hidden state to predict the next word.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O6jCx_9Hqg6EuSFpD_rynw.png" /><figcaption>Figure4 : LSTM based Encoder and Decoder(Credits :<a href="https://medium.com/@vipra_singh/llm-architectures-explained-encoder-decoder-architecture-part-4-b96ace71394c">https://medium.com/@vipra_singh/llm-architectures-explained-encoder-decoder-architecture-part-4-b96ace71394c</a>)</figcaption></figure><p>Though its proven effective, this approach relies on single context vector, which is often too restrictive, especially for longer sequences and limited the model ability to dynamically focus and losing detailed information from distant parts of the input. This led to the introduction of the attention mechanism, which allowed the decoder to access all encoder hidden states and weigh them differently for each output token. This made models significantly better at handling long-range dependencies. Eventually, the Transformer architecture was proposed, which removed recurrence altogether and used self-attention and positional encodings to model sequence relationships, resulting in better performance and faster training.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cce225fb002" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>