<?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 Pshrishti on Medium]]></title>
        <description><![CDATA[Stories by Pshrishti on Medium]]></description>
        <link>https://medium.com/@pshrishti325?source=rss-180e2b67f7a0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VBsTi6tiCGGor8y2</url>
            <title>Stories by Pshrishti on Medium</title>
            <link>https://medium.com/@pshrishti325?source=rss-180e2b67f7a0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 16:21:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pshrishti325/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[How Encoder decoder works to resolve Machine Translation.]]></title>
            <link>https://medium.com/@pshrishti325/how-encoder-decoder-works-to-resolve-machine-translation-5c680ead8ec1?source=rss-180e2b67f7a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c680ead8ec1</guid>
            <dc:creator><![CDATA[Pshrishti]]></dc:creator>
            <pubDate>Tue, 18 Aug 2026 06:43:12 GMT</pubDate>
            <atom:updated>2026-08-18T06:43:12.405Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k_7SBLX5_zigse5OqbVj2g.png" /></figure><p>As many of us know, machine translation is a very common use case of NLP. But before we jump directly into machine translation and what a encoder-decoder model is? I think it is important that we first understand the problem we are actually trying to solve.</p><p>In this article, we will discuss about all these things in detail. We will first understand <strong>what the core problem is</strong> and <strong>what challenges come with it</strong>. From there, we will go deep in things <strong>what machine translation is</strong>, <strong>why it came into the picture</strong>, and<strong> how it actually helps in resolving that core problem</strong>.</p><p>Once we understand that, we will move towards the interesting part — <strong>how encoder-decoder came into the picture</strong> when we talk about machine translation. <strong>We will understand what an encoder-decoder model actually is</strong>, look at its architecture, and finally see how the encoder-decoder works when we use it for machine translation.</p><p>By the end of this article, I hope you get a clear understanding of <strong>what machine translation is, why it came into the picture, what an encoder-decoder model is, and how it helps solve the core problem.</strong></p><p>Let’s dig in!!!</p><h3><strong>Let’s look at the problem.</strong></h3><p>We live in a world where different people speak different languages. When people who speak different languages need to communicate, they face a real problem: neither understands the other.</p><p>For example:<br>1. Suppose a tourist in Japan tries to order food without knowing a single Japanese word.<br>2. Or lets say a business negotiating a contract with partners from another country.</p><p>Traditionally, <strong>solving this problem required a human translator — a third person standing between two people, converting words and meaning from one language to another.</strong> This approach works, but it’s slow, expensive, and doesn’t scale. What if you’re in a remote area? What if you need a translator at 2 AM? What if translation costs more than the entire transaction?</p><p>This is where <strong>machine translation</strong> enters the scene. So rather than just depending on humans, let’s just ask a machine to translate one language to another. Now let’s understand in detail <strong>what machine translation is</strong> and <strong>why it matters</strong>.</p><h3><strong>Machine Translation: Why It’s Harder Than It Looks</strong></h3><p><strong>Machine Translation</strong> is the task of automatically translating text from one language (source) to another language (target). It may sound simple in theory, but it’s surprisingly more complex in practice.</p><p>Let’s look at a few examples:</p><pre>English → Hindi <br>Input: &quot;The cat is sleeping on the mat&quot;<br>Output: &quot;बिल्ली चटाई पर सो रही है&quot;</pre><p><strong>Why Is Direct Word-to-Word Translation Not Enough?</strong></p><p>A naive approach might seem obvious: just look up each word in a dictionary and replace it. But this fails spectacularly. Here’s why:</p><p><strong>1. Word Order Differs Across Languages</strong></p><p>Consider this English to Hindi example:</p><ul><li>English (word-by-word): “I <strong>like </strong>mangoes” → “मैं पसंद आम”</li><li>Correct Hindi: “मुझे आम <strong>पसंद </strong>हैं”</li></ul><p>In English, the verb “like” comes early, and the object “mangoes” comes last. In Hindi, this order is completely reversed, which implies Simply rearranging English words won’t work — the entire sentence structure must change.</p><p><strong>2. Context and Meaning Matter More Than Individual Words</strong></p><p>The word “bank” could mean:</p><ul><li>A financial institution: “I went to the bank to deposit money”</li><li>The side of a river: “We sat by the bank of the river”</li></ul><p>Without understanding the surrounding context, a machine can’t understand which translation is correct.</p><p><strong>3. Idioms and Cultural Context Don’t Translate Literally</strong></p><ul><li>English: “It’s raining cats and dogs” (means heavy rain, not actual animals)</li><li>Hindi: “बारिश हो रही है” (simply “it’s raining”)</li></ul><p>No dictionary can capture these cultural nuances.</p><p><strong>4. Grammar Structures Are Fundamentally Different</strong></p><p>Languages have different:</p><ul><li>Verb tenses and aspects</li><li>Gender and number agreement</li><li>Sentence constructions</li></ul><p><strong>Hindi is a perfect example:</strong></p><ul><li><strong>Hindi uses Subject-Object-Verb (SOV) order</strong>, while English uses Subject-Verb-Object (SVO):</li><li>English: “I eat rice” (S-V-O)</li><li>Hindi: “मैं चावल खाता हूं” (main chawal khata hoon) — literally “I rice eat” (S-O-V)</li><li>A word-for-word translation would produce nonsense in English.</li></ul><p><strong>By now, it should be clear:</strong> Machine Translation isn’t just about swapping words. A proper translation system must understand <strong>meaning</strong>, respect <strong>structural differences</strong> between languages, and handle <strong>ambiguity and cultural context</strong>. This is why we need intelligent machine learning models — and this is where the encoder-decoder architecture comes in.</p><p>Now you might be wondering: if direct translation is impossible, how can we ever teach a machine to translate correctly? The answer is surprisingly elegant. Instead of translating <strong>word-by-word</strong>, we need a model that reads the <strong>entire input sentence all at once</strong>, understands its meaning, and then generates the output in a completely different language and structure. <strong>This is exactly what the encoder-decoder model does.</strong></p><h3>Encoder-Decoder what is it, how does it works in our problem which is Machine Translation and Why Does This Solve Our Problem?</h3><p>An encoder-decoder model is a architecture made of two parts: an <strong>encoder</strong> that reads and compresses an input sequence into a context vector, and a <strong>decoder</strong> that takes that vector to generate a new output sequence step by step.</p><p>Core Components</p><ul><li><strong>Encoder</strong>: Reads the input data piece by piece and turns it into a compact numerical summary.</li><li><strong>Context Vector (Latent Space)</strong>: The middle state holding the core meaning of the input data.</li><li><strong>Decoder</strong>: Uses the summary vector to build the final output one token at a time.</li></ul><p>This answers our question What is an encoder-decoder model?</p><p>Now lets try to answer our next question which is How does it works in Machine Translation Problem?<br>The encoder-decoder model solves machine translation by splitting the problem into two simple stages:</p><ol><li><strong>Encoder</strong>: Read and understand the entire input sentence</li><li><strong>Decoder</strong>: Generate the output, one word at a time, based on that understanding</li></ol><p>Instead of trying to map words directly (which we know fails), the model creates an intermediate “meaning” representation called a <strong>context vector</strong>. This context vector is like a compressed summary of what was said, in a language-neutral form.</p><p>Think of it like this:</p><pre>English Sentence<br>    ↓<br>ENCODER (Understanding)<br>    ↓<br>Context Vector (What was meant)<br>    ↓<br>DECODER (Generating output)<br>    ↓<br>Hindi Sentence</pre><p><strong>How Does It Work?</strong></p><p><strong>Stage 1: The Encoder</strong></p><p>The encoder reads the entire input sentence and converts it into a context vector.</p><p>Process:</p><ol><li>Convert each word into a numerical representation (embedding)</li><li>Process these through layers that learn relationships between words.</li><li>Create a single context vector that summarizes the entire meaning</li></ol><p>Example: “I like mangoes”</p><ul><li>The encoder reads all three words together</li><li>It understands: “A person (I) + feeling (like) + object (mangoes)”</li><li>It outputs a context vector: [0.3, -0.2, 0.8, 0.1, …, 512 dimensions]</li></ul><p><strong>Stage 2: The Decoder</strong></p><p>The decoder takes that context vector and generates the output word-by-word.</p><p>Process:</p><ol><li>Start with a &lt;START&gt; token and the context vector</li><li>Generate the first word of the target language</li><li>Use that word + context vector to generate the second word</li><li>Repeat until the model outputs &lt;END&gt; token</li></ol><p>Example: “I like mangoes” → Hindi “मुझे आम पसंद हैं”</p><pre>Step 1: &lt;START&gt; + context_vector → Output: &quot;मुझे&quot; (to me)<br>Step 2: &quot;मुझे&quot; + context_vector → Output: &quot;आम&quot; (mangoes)<br>Step 3: &quot;आम&quot; + context_vector → Output: &quot;पसंद&quot; (preferred)<br>Step 4: &quot;पसंद&quot; + context_vector → Output: &quot;हैं&quot; (are)<br>Step 5: &quot;हैं&quot; + context_vector → Output: &lt;END&gt; (Stop)</pre><p>The key insight: The context vector tells the decoder what was said, so it can generate grammatically correct Hindi words in the right order — not English order.</p><p><strong>How Does It Solve Each Problem?</strong></p><p><strong>Problem 1: Word Order Differs Across Languages</strong></p><p>Naive approach: Try to map “I like mangoes” position-by-position to Hindi<br>Encoder-Decoder solution:</p><ul><li>Encoder reads: “I like mangoes” (understands the complete meaning)</li><li>Creates context vector: “First person + positive feeling + object: mangoes”</li><li>Decoder generates in Hindi order: “मुझे आम पसंद हैं” (literally: “to me mangoes preferred are”)</li><li>The decoder generates Hindi word order naturally, not by rearranging English</li></ul><p><strong>Problem 2: Context and Meaning Matter More Than Individual Words</strong></p><p>Naive approach: Look up “bank” in dictionary, get both meanings, pick randomly<br> Encoder-Decoder solution:</p><ul><li>Encoder reads the ENTIRE sentence: “The bank is by the river. The bank is closed.”</li><li>It understands from context:</li><li>First “bank” = river bank (because “by the river” is the context) → Hindi: “नदी का किनारा”</li><li>Second “bank” = financial institution (because “closed” implies business hours) → Hindi: “बैंक”</li><li>Creates TWO different context vectors for the two sentences</li><li>Decoder generates the correct Hindi word for each</li></ul><p><strong>Problem 3: Idioms and Cultural Context Don’t Translate Literally</strong></p><p>Naive approach: Translate “It’s raining cats and dogs” word-by-word, get nonsense<br>Encoder-Decoder solution:</p><ul><li>Encoder reads the full phrase and learns (from training data) that this is an idiom</li><li>Context vector encodes: “This is an idiom meaning heavy rainfall”</li><li>Decoder learns to generate appropriate phrase in target language:</li><li>Hindi: “बारिश हो रही है” (simply: it’s raining)</li><li>Model generates culturally appropriate translation, not literal translation</li></ul><p><strong>Problem 4: Grammar Structures Are Fundamentally Different</strong></p><p>Naive approach: Try to apply English grammar rules to Hindi<br>Encoder-Decoder solution:</p><ul><li>Encoder reads: “I eat rice” and understands the complete meaning</li><li>Creates context vector with: subject person/gender, verb type, object info</li><li>Decoder generates in Hindi grammatical structure:</li><li>Step 1: Generate “मैं” (I — nominative)</li><li>Step 2: Generate “चावल” (rice — accusative with postposition)</li><li>Step 3: Generate “खाता” (eat — agrees with masculine subject)</li><li>Step 4: Generate “हूं” (am — auxiliary with proper tense)</li></ul><p>The decoder naturally outputs Hindi grammar because it’s generating word-by-word in the target language, using the context vector to guide grammatically correct choices.</p><p><strong>The Core Insight</strong></p><p>The key difference:</p><ul><li><strong>Naive approach</strong>: “Map positions” → Fails because languages have different structures</li><li><strong>Encoder-Decoder</strong>: “Understand meaning → Generate in target language” → Works because it respects the target language’s rules</li></ul><p>The encoder extracts meaning (language-independent), and the decoder generates it in the target language (language-specific).</p><h3>Where Does the Encoder-Decoder Start Struggling?</h3><p>So far, the Encoder-Decoder looks like a pretty good solution to our Machine Translation problem.</p><p>The encoder reads the input sentence, understands the information in it, and converts everything into a single context vector. The decoder then uses this context vector to generate the translated sentence.</p><p>But there is one problem here.</p><p>Everything the encoder understands about the input has to be passed to the decoder through this single context vector.</p><p>For a short sentence like: Input : I like mangoes this might work reasonably well. There isn’t too much information that the encoder needs to compress into that single representation.</p><p>But what happens when the sentence becomes much longer?</p><p>Imagine a sentence containing 30 or 40 words, with multiple ideas, relationships, and important details. The encoder still has to represent all of that information in a single fixed-size context vector.</p><p>As the input becomes longer and more complex, this becomes harder. Important information can get lost or become difficult for the decoder to recover accurately.</p><p>This is known as the information bottleneck of the basic Encoder-Decoder architecture.</p><p>Scenario 1: Short Sentence Input: “I like mangoes” The sentence is short, and the encoder can capture the important information in a single representation. Output: “मुझे आम पसंद हैं”</p><p>Scenario 2: Long Sentence Now imagine a much longer sentence containing multiple pieces of information, such as: Input : The European Union has established many programs to support sustainable development in Africa, including infrastructure investment, education initiatives, and technology transfer agreements that aim to reduce poverty and promote economic growth.</p><p>Now the encoder has a much harder job. It needs to compress all of these details into one context vector. The longer and more complex the sentence becomes, the more difficult it gets to preserve every important detail.</p><p>This is where the basic Encoder-Decoder architecture starts to struggle.</p><p>And this leads us to the next question: can we somehow allow the decoder to look back at the important parts of the input, instead of depending entirely on one context vector?</p><h3>Conclusion</h3><p>That question is really the turning point of this whole story. We set out to solve a simple-sounding problem — get a machine to translate one language into another — and found that it’s anything but simple. Word order, grammar, ambiguity, and cultural nuance all stand in the way of anything as naive as word-for-word substitution.</p><p>The Encoder-Decoder architecture gave us a real way forward: understand the meaning first, then generate the translation in the target language’s own structure. But as we just saw, squeezing an entire sentence’s meaning into one fixed-size context vector only holds up so well — and it starts to break down as sentences grow longer and more complex.</p><p>That single limitation is what Attention was built to fix. In the next part, we’ll see exactly how it works, and how it lets the decoder look back at the input directly instead of relying on one overworked vector.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c680ead8ec1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>