<?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"><channel><title><![CDATA[Engineering Journal]]></title><description><![CDATA[Engineering Journal]]></description><link>https://rajanotes.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1593680282896/kNC7E8IR4.png</url><title>Engineering Journal</title><link>https://rajanotes.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 15:04:53 GMT</lastBuildDate><atom:link href="https://rajanotes.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Understanding what happens behind the scenes when you chat with AI.]]></title><description><![CDATA[1. What is an LLM?
Think of an LLM as the brain behind AI assistants like ChatGPT, Gemini, Claude, and Copilot.
Just like our brain learns by reading books, listening to conversations, watching the wo]]></description><link>https://rajanotes.hashnode.dev/understanding-what-happens-behind-the-scenes-when-you-chat-with-ai</link><guid isPermaLink="true">https://rajanotes.hashnode.dev/understanding-what-happens-behind-the-scenes-when-you-chat-with-ai</guid><category><![CDATA[generative ai]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[transformer]]></category><category><![CDATA[Tokenization]]></category><dc:creator><![CDATA[Raja Gupta]]></dc:creator><pubDate>Fri, 03 Jul 2026 10:43:18 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a44ef1798d96795eeabe0b6/e97b50ec-0c4d-496b-9de1-f938a0181f7f.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1>1. What is an LLM?</h1>
<p>Think of an LLM as the <strong>brain</strong> behind AI assistants like ChatGPT, Gemini, Claude, and Copilot.</p>
<p>Just like our brain learns by reading books, listening to conversations, watching the world, and connecting ideas, an LLM learns patterns from an enormous amount of text.</p>
<p>But here's an important difference.</p>
<p>It doesn't memorize every sentence it has seen.</p>
<p>Instead, it learns <strong>how words, ideas, and sentences usually fit together.</strong></p>
<p>That's why it can answer questions it has never seen before.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a44ef1798d96795eeabe0b6/9eda79a8-70e7-400d-988e-a7fe3d0d2820.png" alt="" style="display:block;margin:0 auto" />

<p>Notice something interesting in the illustration above.</p>
<p>The brain is surrounded by books, conversations, websites, code, and articles.</p>
<p>Those don't represent things the model <em>remembers</em> word-for-word.</p>
<p>They represent the different kinds of information it learned patterns from during training.</p>
<p>When you ask,</p>
<blockquote>
<p>"Write a leave application."</p>
</blockquote>
<p>the model isn't searching for an old leave application.</p>
<p>It's using those learned language patterns to generate a completely new one.</p>
<h3>💡 Think of it like this</h3>
<p>Imagine a chef.</p>
<p>A chef may have cooked thousands of dishes throughout their career.</p>
<p>When you ask them to prepare something new, they don't search for the exact recipe they cooked five years ago.</p>
<p>Instead, they use everything they've learned about ingredients, flavors, and cooking techniques to create a fresh dish.</p>
<p>An LLM works in a very similar way.</p>
<p>It creates responses using learned patterns—not by copying text from memory.</p>
<h2>What Problems Do LLMs Solve?</h2>
<p>Before Large Language Models became popular, interacting with computers often required specific commands or predefined inputs. If the command wasn't written in the expected format, the system simply wouldn't understand it.</p>
<p>LLMs changed that by making communication with computers feel more natural. Instead of learning the computer's language, we can now use our own.</p>
<p>For example, instead of searching through multiple web pages to understand a concept, you can simply ask:</p>
<blockquote>
<p><em>"Explain recursion like I'm a beginner."</em></p>
</blockquote>
<p>Or instead of manually drafting an email, you can write:</p>
<blockquote>
<p><em>"Write a professional leave application for two days."</em></p>
</blockquote>
<p>An LLM understands the intent behind your request and generates a response accordingly.</p>
<p>Some of the major problems LLMs help solve include:</p>
<ul>
<li><p><strong>Understanding natural language</strong> – You can ask questions the way you normally speak instead of using rigid commands.</p>
</li>
<li><p><strong>Explaining complex topics</strong> – Difficult concepts can be simplified based on your level of understanding.</p>
</li>
<li><p><strong>Generating content</strong> – From emails and reports to blog posts and code, LLMs can create new content in seconds.</p>
</li>
<li><p><strong>Summarizing information</strong> – Long articles, documents, or meeting notes can be condensed into concise summaries.</p>
</li>
<li><p><strong>Translation and language assistance</strong> – They can translate text, improve grammar, or rewrite content in different tones.</p>
</li>
<li><p><strong>Programming assistance</strong> – Developers use LLMs to generate code, debug errors, and understand unfamiliar technologies.</p>
</li>
</ul>
<p>Rather than replacing traditional software, LLMs act as an intelligent layer that makes interacting with technology faster and more intuitive.</p>
<h2>Popular Examples of LLMs</h2>
<p>Today, several organizations have developed their own Large Language Models. Although they are created by different companies, they are all designed to understand and generate human language.</p>
<p>Some of the most well-known LLMs include:</p>
<ul>
<li><p><strong>GPT</strong> by OpenAI</p>
</li>
<li><p><strong>Gemini</strong> by Google</p>
</li>
<li><p><strong>Claude</strong> by Anthropic</p>
</li>
<li><p><strong>Llama</strong> by Meta</p>
</li>
<li><p><strong>Mistral</strong> by Mistral AI</p>
</li>
</ul>
<p>Each of these models is trained differently and may vary in size, capabilities, and training data, but they all work on the same fundamental principle—predicting the next token based on the context they receive.</p>
<blockquote>
<p><strong>Note:</strong> ChatGPT is the application we interact with, while GPT is the Large Language Model that powers it. Similarly, Gemini, Claude, and Meta AI are applications built around their respective language models.</p>
</blockquote>
<h2>Common Applications of LLMs in Daily Life</h2>
<p>Whether you're a student trying to understand a difficult concept, a developer debugging code, or a professional writing an email, chances are you've already used an LLM without giving it much thought.</p>
<p>What makes LLMs special is that the same model can assist with a wide variety of tasks. It simply adapts its response based on what you ask.</p>
<p>Here are some of the most common ways people use LLMs today:</p>
<h3>Learning &amp; Education</h3>
<p>Students and professionals use LLMs to understand complex topics, simplify technical concepts, summarize study material, and prepare for interviews.</p>
<h3>💻 Programming</h3>
<p>Developers use LLMs to explain code, debug errors, generate code snippets, learn new technologies, and understand documentation more quickly.</p>
<h3>Content Creation</h3>
<p>From writing blogs and reports to generating social media captions or brainstorming ideas, LLMs help speed up the writing process.</p>
<h3>Language Assistance</h3>
<p>LLMs can translate text between languages, improve grammar, rewrite sentences, and adjust the tone of writing to suit different audiences.</p>
<h3>📄 Document Summarization</h3>
<p>Instead of reading lengthy articles or reports from start to finish, users can ask LLMs to extract the key points in just a few seconds.</p>
<h3>Everyday Productivity</h3>
<p>People also rely on LLMs for planning trips, creating study schedules, organizing daily tasks, generating recipes, and even preparing shopping lists.</p>
<blockquote>
<p>💡 <strong>The interesting part?</strong><br />Whether you're writing an email, learning JavaScript, or planning a vacation, you're interacting with the same underlying technology. The task changes, but the LLM remains the same.</p>
</blockquote>
<h1>2. What Happens When You Send a Message to ChatGPT?</h1>
<p>Every conversation with ChatGPT begins with a simple action—you type something into the chat box and press <strong>Enter</strong>.</p>
<p>From your perspective, it feels almost instantaneous. Within a few seconds, the response starts appearing on your screen.</p>
<p>But in reality, your prompt goes through several stages before the first word of the answer is generated.</p>
<p>ChatGPT doesn't read your sentence the way we do. It first transforms your text into a format it can understand, analyzes the relationships between the words, predicts the most appropriate next token, and finally converts those predictions back into readable text.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a44ef1798d96795eeabe0b6/c7e86547-2126-4408-a966-f584448aa6c8.png" alt="" style="display:block;margin:0 auto" />

<h2>Typing a Prompt</h2>
<p>Everything starts with a <strong>prompt</strong>.</p>
<p>A prompt is simply the input you provide to the model. It could be a question, an instruction, or even a request to generate something.</p>
<p>For example,</p>
<blockquote>
<p><strong>Explain recursion with a simple JavaScript example.</strong></p>
</blockquote>
<p>This single sentence tells the model <strong>what you're asking</strong> and <strong>how you'd like the answer to be presented</strong>.</p>
<p>A prompt doesn't need to be long. What matters is that it clearly communicates your intent.</p>
<h2>Processing Your Message</h2>
<p>The moment you press <strong>Enter</strong>, ChatGPT begins processing your prompt.</p>
<p>Although it looks like the model instantly understands your question, that's not what actually happens.</p>
<p>Before any response is generated, your message passes through several internal stages.</p>
<p>It is first broken into smaller pieces, converted into numerical representations, enriched with positional information so the model knows the order of the words, and finally passed through the Transformer, where the relationships between all the tokens are analyzed.</p>
<p>These steps happen in milliseconds, but together they allow the model to understand <strong>both the meaning of individual words and how they relate to one another in the sentence</strong>.</p>
<p>Don't worry if terms like <em>tokens</em>, <em>embeddings</em>, or <em>Transformer</em> sound unfamiliar right now—we'll explore each of them in the next sections.</p>
<h2>Generating the Response</h2>
<p>Once the model understands your prompt, it begins generating the answer.</p>
<p>One interesting thing about ChatGPT is that it <strong>doesn't generate the entire paragraph at once</strong>.</p>
<p>Instead, it predicts the response <strong>one token at a time</strong>.</p>
<p>After selecting the first token, it immediately uses that new token as additional context to predict the next one. This cycle continues until the complete response is formed.</p>
<p>That's why you'll often notice the answer appearing gradually on the screen instead of showing up all at once.</p>
<h2>Why Isn't the Response Copied from the Internet?</h2>
<p>A common misconception is that ChatGPT searches the internet every time you ask a question and copies information from websites.</p>
<p>In reality, that's not how an LLM works.</p>
<p>During training, the model learned <strong>patterns in language</strong>—how words are connected, how explanations are structured, and how ideas flow together. When you ask a question, it uses those learned patterns to generate a brand-new response that fits your prompt.</p>
<p>This is also why the same question can produce answers with different wording while still conveying the same idea.</p>
<blockquote>
<p><strong>Think of it this way:</strong> If three teachers explain the same topic, each explanation will be different because every teacher has their own way of presenting the concept. The knowledge is the same, but the explanation is original. ChatGPT works in a similar way—it generates responses from what it has learned rather than copying a paragraph from a website.</p>
</blockquote>
<h1>3. Why Computers Don't Understand Human Language</h1>
<p>Humans and computers process information in completely different ways.</p>
<p>Imagine someone sends you this message:</p>
<blockquote>
<p><strong>"The movie was surprisingly good."</strong></p>
</blockquote>
<p>You instantly understand that it's expressing an opinion about a movie.</p>
<p>A computer doesn't see opinions, emotions, or meaning.</p>
<p>It only sees a sequence of characters.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a44ef1798d96795eeabe0b6/9e43fe37-bbd1-4dff-bfd9-e91f9fc90a61.png" alt="" style="display:block;margin:0 auto" />

<p>To us, these letters form a meaningful sentence.</p>
<p>To a computer, they're simply symbols until they're converted into something mathematical.</p>
<h2>Why Computers Need Everything Converted into Numbers</h2>
<p>Modern AI models are built using neural networks.</p>
<p>A neural network performs millions (sometimes billions) of mathematical calculations every time you ask a question.</p>
<p>But mathematical operations can only be performed on <strong>numbers</strong>, not words.</p>
<p>For example, the model cannot calculate with something like:</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a44ef1798d96795eeabe0b6/db689c6c-4b7a-4667-9356-267df0efc266.png" alt="" style="display:block;margin:0 auto" />

<p>because these are pieces of text.</p>
<p>Instead, every part of your sentence must first be represented numerically before the neural network can process it.</p>
<p>That's why <strong>every prompt you type eventually becomes numbers inside the model.</strong></p>
<blockquote>
<p><strong>Interesting fact:</strong> Even though you only see words on your screen, the model never actually "reads" words the way you do. During computation, it only works with numerical values.</p>
</blockquote>
<h2>Where Do Tokens Come In?</h2>
<p>Converting an entire paragraph directly into numbers would be extremely difficult.</p>
<p>Instead, the model first divides your text into <strong>smaller units called tokens</strong>.</p>
<p>Think of tokens as building blocks.</p>
<p>Just as a large LEGO model is easier to build by connecting many small pieces, a language model understands a sentence by first breaking it into smaller parts.</p>
<p>For example,</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a44ef1798d96795eeabe0b6/86ec6407-67aa-4999-98aa-cc8172d27fbb.png" alt="" style="display:block;margin:0 auto" />

<p>may become something similar to:</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a44ef1798d96795eeabe0b6/5cb7f80f-398a-4044-9fa2-38ceda4cbc0d.png" alt="" style="display:block;margin:0 auto" />

<p>Notice that punctuation is treated separately as well.</p>
<p><strong>In some cases, even a single word can be split into multiple tokens depending on the tokenizer being used.</strong></p>
<h1><strong>4. Tokenization</strong></h1>
<img src="https://cdn.hashnode.com/uploads/covers/6a44ef1798d96795eeabe0b6/2065b790-07c0-4e0f-bc80-f1358643db75.png" alt="" style="display:block;margin:0 auto" />

<h2>What Are Tokens?</h2>
<p>A <strong>token</strong> is simply the smallest unit of text that a language model processes.</p>
<p>Depending on the tokenizer, a token can be:</p>
<ul>
<li><p>a complete word</p>
</li>
<li><p>part of a word</p>
</li>
<li><p>a punctuation mark</p>
</li>
<li><p>a number</p>
</li>
<li><p>or even a special symbol</p>
</li>
</ul>
<p>Unlike humans, who naturally think in words and sentences, an LLM processes one token at a time.</p>
<p>That's why tokenization is always the <strong>first step</strong> before the model can understand your prompt.</p>
<h2>Why Is Tokenization Needed?</h2>
<p>Imagine someone gives you a 500-page novel and asks you to memorize it in one glance.</p>
<p>Impossible.</p>
<p>Instead, you'd probably read it one sentence at a time.</p>
<p>Then one paragraph.</p>
<p>Then one chapter.</p>
<p>Only after understanding the smaller pieces would you understand the entire story.</p>
<p>Language models work in a very similar way.</p>
<p>Breaking text into tokens makes it much easier to analyze relationships between words, understand context, and eventually predict the next token.</p>
<p>Without tokenization, the model wouldn't know where one idea ends and another begins.</p>
<h2>Words vs Tokens</h2>
<p>One thing that often surprises beginners is this:</p>
<p><strong>A word and a token are not always the same thing.</strong></p>
<img src="https://cdn.hashnode.com/uploads/covers/6a44ef1798d96795eeabe0b6/255a18dd-281f-490a-9c30-aaecffc6e4f9.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6a44ef1798d96795eeabe0b6/c80226b9-c9a0-4e67-85cc-af5ee4b01348.png" alt="" style="display:block;margin:0 auto" />

<p>But longer or less common words may be split into multiple tokens.</p>
<p>For example,</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a44ef1798d96795eeabe0b6/d5f77b97-47e2-4bf7-99e5-88faa5e3393f.png" alt="" style="display:block;margin:0 auto" />

<p>Similarly,</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a44ef1798d96795eeabe0b6/ebfd4319-c138-418b-afb8-d81cce7900a3.png" alt="" style="display:block;margin:0 auto" />

<p>This doesn't happen because the model is bad at English.</p>
<p>It happens because breaking rare or long words into reusable pieces helps the model understand many more words using a smaller vocabulary.</p>
<p>Different models may even split the <strong>same sentence</strong> differently because each model has its own tokenizer and vocabulary.</p>
<h1>5. Transformers</h1>
<p>By now, our sentence has been:</p>
<ul>
<li><p>Broken into tokens.</p>
</li>
<li><p>Converted into embeddings (numerical representations).</p>
</li>
<li><p>Given positional information so the model knows the order of the words.</p>
</li>
</ul>
<p>But one big challenge still remains:</p>
<p><strong>How does the model understand the meaning of the entire sentence instead of just individual words?</strong></p>
<p>The answer is Transformers.</p>
<h3>What is a Transformer?</h3>
<p>A Transformer is the core architecture behind modern Large Language Models.</p>
<p>Its job is to understand relationships between all the words in a sentence before predicting what should come next.</p>
<p>Instead of reading text one word at a time and forgetting earlier words, a Transformer looks at the entire context and learns how different words are connected.</p>
<img src="https://images.openai.com/static-rsc-4/-mwuFpmzKnLkoFSvld0E0Ox7cCCL4Mtgpktrqb9RbugvZa7h8s4SiPnOcbhN0VFOVcqmOgQYeDErGnLZJt_g42eg96NFepUob-2K3LUmeekBrk0_ZBl1efwA7iNf4xasaDA4rK_O2-HPcnbyt9cxfHH0YTLH6KCx-pQH7bUN7PDa8AEF79mLQnFwvsSNB5co?purpose=fullsize" alt="The Impact of the ‘Attention is All You Need’ Paper on NLP | by John Vastola | Medium" style="display:block;margin:0 auto" />

<h3>Why Did Transformers Change AI?</h3>
<p>Before Transformers, many language models processed text sequentially. They often struggled with long sentences because earlier information could gradually be forgotten.</p>
<p>Transformers introduced a much better idea:</p>
<p>Every token can look at every other relevant token.</p>
<p>This dramatically improved:</p>
<ul>
<li><p>Language understanding</p>
</li>
<li><p>Translation</p>
</li>
<li><p>Question answering</p>
</li>
<li><p>Summarization</p>
</li>
<li><p>Code generation</p>
</li>
<li><p>Long conversations</p>
</li>
</ul>
<h3>How Does a Transformer Understand Language?</h3>
<p>Consider this sentence:</p>
<p>The trophy doesn’t fit in the suitcase because it is too big.</p>
<p>When the model reaches the word “it”, how does it know what “it” refers to?</p>
<p>Is it the trophy or the suitcase?</p>
<p>A Transformer solves this using Self-Attention.</p>
<h3>👀 Self-Attention</h3>
<p>Self-Attention allows each token to look at other tokens and decide which ones are most important.</p>
<p>For the sentence above, the model gives much more attention to “trophy” while interpreting “it”.</p>
<img src="https://images.openai.com/static-rsc-4/ugwvY_rqGVZ-7HPs-Em8JcMt2RS4dku4erhMkRR9Br3NETj5tVSKN6inNLeqm_DufaZSQJTu5RhQK2BkBCxoRSrAlYnPVs140vVC_0GmE8sCktvlDnnO3BxRlMBE0FldqxOzK45s8-dFvMsTYe1dE9q2h-l6nakEpXrlTDvSqGc_OpZcbUELUUFM3uapED_Q?purpose=fullsize" alt="Understanding Multi-Head Attention in Transformers | DataCamp" style="display:block;margin:0 auto" />

<h3>Positional Encoding</h3>
<p>Transformers process tokens in parallel, so they also need to know word order.</p>
<p>Dog bites man.</p>
<p>Man bites dog.</p>
<p>Same words.</p>
<p>Completely different meaning.</p>
<p>Positional Encoding adds information about where each token appears in the sentence, allowing the model to understand word order.</p>
<h3>Feed Forward Network</h3>
<p>After attention, each token passes through a Feed Forward Network.</p>
<p>Think of it as a small neural network that refines the information learned from attention before sending it to the next Transformer layer.</p>
<h3>Softmax — Choosing the Next Token</h3>
<p>After processing the sentence, the model calculates a score for every possible next token.</p>
<p>For example:</p>
<p>The capital of France is</p>
<table>
<thead>
<tr>
<th>Token</th>
<th>Probability</th>
</tr>
</thead>
<tbody><tr>
<td>Paris</td>
<td>96%</td>
</tr>
<tr>
<td>London</td>
<td>2%</td>
</tr>
<tr>
<td>Berlin</td>
<td>1%</td>
</tr>
<tr>
<td>Tokyo</td>
<td>1%</td>
</tr>
</tbody></table>
<p>Softmax converts the model’s scores into probabilities that add up to 100%.</p>
<h3>One Token at a Time</h3>
<p>ChatGPT does not generate an entire paragraph at once.</p>
<p>It repeatedly performs this cycle:</p>
<p>Read the current context</p>
<p>Apply self-attention</p>
<p>Refine with feed-forward layers</p>
<p>Use Softmax to calculate probabilities</p>
<p>Predict the next token</p>
<p>Repeat until the response is complete</p>
<h3>Why Almost Every Modern LLM Uses Transformers</h3>
<p>Models such as GPT, Gemini, Claude, Llama, and Mistral are all built on Transformer-based architectures.</p>
<p>They differ in size, training data, and capabilities, but they share the same fundamental idea:</p>
<p>Understand the context first, then predict the next token.</p>
<h2>Thanks for reading! ❤️</h2>
<p>If you found this article helpful, consider leaving a ❤️ or sharing it with someone who's just getting started with LLMs and Generative AI.</p>
]]></content:encoded></item></channel></rss>