<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MANGESH MANDLIK</title>
    <description>The latest articles on DEV Community by MANGESH MANDLIK (@mangeshmandlik).</description>
    <link>https://dev.to/mangeshmandlik</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4131208%2Fa9ac2096-0793-425e-8cf2-63f73f694fe7.jpg</url>
      <title>DEV Community: MANGESH MANDLIK</title>
      <link>https://dev.to/mangeshmandlik</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mangeshmandlik"/>
    <language>en</language>
    <item>
      <title>You Probably Don't Need an LLM: ML vs Deep Learning vs Generative AI</title>
      <dc:creator>MANGESH MANDLIK</dc:creator>
      <pubDate>Sat, 19 Sep 2026 12:21:06 +0000</pubDate>
      <link>https://dev.to/mangeshmandlik/you-probably-dont-need-an-llm-ml-vs-deep-learning-vs-generative-ai-mi9</link>
      <guid>https://dev.to/mangeshmandlik/you-probably-dont-need-an-llm-ml-vs-deep-learning-vs-generative-ai-mi9</guid>
      <description>&lt;p&gt;Picture a planning meeting where someone says, "We should use AI to catch fraudulent transactions." Everyone nods.&lt;/p&gt;

&lt;p&gt;But one engineer is thinking about a gradient-boosted model trained on last year's transaction table. Another is imagining a neural network. A third has already opened the docs for a hosted LLM API. Same sentence, three completely different systems, with different costs, latencies and failure modes. Nobody in the room noticed, because "AI" has become a word that stretches from a 1990s chess engine to whatever is writing your pull request descriptions this week.&lt;/p&gt;

&lt;p&gt;The words AI, machine learning, deep learning and generative AI are not synonyms. They aren't competitors either. They're nested, and once you have that picture in your head, a surprising number of architecture decisions get easier.&lt;/p&gt;

&lt;p&gt;I also built an animated walkthrough of this hierarchy, &lt;a href="https://seeitflow.com/ai/ai-foundations/ml-vs-dl-vs-genai" rel="noopener noreferrer"&gt;ML vs Deep Learning vs Generative AI on SeeItFlow&lt;/a&gt;, if you'd rather watch it move. What follows is the written version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four circles, one inside the other
&lt;/h2&gt;

&lt;p&gt;Think of four circles, each sitting inside the previous one.&lt;/p&gt;

&lt;p&gt;The biggest is &lt;strong&gt;AI&lt;/strong&gt;: any system that mimics intelligent behaviour. That includes hand-written rules, statistical methods and neural networks. A chess engine from 1997 counts.&lt;/p&gt;

&lt;p&gt;Inside it sits &lt;strong&gt;machine learning&lt;/strong&gt;, where the system learns patterns from data instead of following rules a human wrote down. Inside that is &lt;strong&gt;deep learning&lt;/strong&gt;, which is machine learning done with neural networks that have many layers. And in the middle is &lt;strong&gt;generative AI&lt;/strong&gt;, which is deep learning that creates new content (text, code, images, audio) rather than just labelling what you give it.&lt;/p&gt;

&lt;p&gt;That nesting gives you a one-way rule. Every generative AI system is a deep learning system, and every deep learning system is a machine learning system. The reverse is not true. Your spam filter is machine learning but not deep learning. An image classifier that sorts photos into a thousand categories is deep learning but not generative. When someone says "AI" and means "a chatbot," they've skipped three circles and landed on the innermost one, and that's where a lot of bad project decisions start.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the layers exist at all
&lt;/h2&gt;

&lt;p&gt;These categories didn't appear together. Each one showed up when the previous approach ran into a wall.&lt;/p&gt;

&lt;p&gt;For decades, roughly the 1960s through the 90s, building intelligent software meant writing rules. Expert systems and chess engines ran on explicit if/else logic that people typed in by hand. This works until the world gets messier than your rulebook. A spam filter with 500 hardcoded rules is out of date the week a new spam pattern shows up, and someone has to notice and write rule 501. Manual rules don't scale.&lt;/p&gt;

&lt;p&gt;Machine learning flipped the workflow. Instead of writing the rules, you show the system a pile of labelled examples and let it find the rules itself. Spam filters, credit scoring and recommendation systems all moved this way.&lt;/p&gt;

&lt;p&gt;But classic ML has a catch that's easy to miss: a human still decides what the model gets to look at. That step is called feature engineering. On a table of transactions, a domain expert knows to compute something like "this amount compared to the customer's usual spending." On a photograph, though, nobody knows which combination of pixel values means "cat." Experts spent years hand-designing image features, and the results plateaued.&lt;/p&gt;

&lt;p&gt;Then came 2012. AlexNet, a deep convolutional network, cut the error rate on the ImageNet benchmark from about 26% to about 15% in a single year. That was a gap large enough to change where the whole field put its money. Deep learning had been possible for a long time. What made it practical was a combination of things arriving together: GPUs, which are very good at the thousands of parallel matrix multiplications that training a neural network consists of, big datasets like ImageNet and Common Crawl, and training improvements like ReLU activations, dropout and batch normalisation. By the middle of the decade it was the dominant approach for images, audio and language.&lt;/p&gt;

&lt;p&gt;Generative AI is the newest layer, from about 2020 onward. It didn't replace what came before it. It asked a different question, which we'll get to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Classic ML: the workhorse nobody tweets about
&lt;/h2&gt;

&lt;p&gt;Here's the whole idea of machine learning in a few lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.feature_extraction.text&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;TfidfVectorizer&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.linear_model&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LogisticRegression&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.pipeline&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;make_pipeline&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;make_pipeline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;TfidfVectorizer&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;train_emails&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;train_labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c1"&gt;# labelled examples go in
&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Congratulations, you won a free cruise&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;   &lt;span class="c1"&gt;# a label comes out
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You give it labelled data, it learns a mapping from inputs to outputs, and then it predicts on data it hasn't seen. Spam detection, fraud detection, demand forecasting and ranking items in a recommendation feed all follow this pattern.&lt;/p&gt;

&lt;p&gt;The practical profile of classic ML is what makes it so useful. It typically needs thousands to millions of rows, not billions. It usually trains and runs fine on a CPU. Many of the models, like linear regression and decision trees, are interpretable, so when the model flags a transaction you can often say why. And on structured, tabular data, gradient boosting libraries like XGBoost and LightGBM have a long track record of beating fancier approaches, including in Kaggle competitions on tabular problems.&lt;/p&gt;

&lt;p&gt;That last point is the one I'd tattoo on the inside of every AI roadmap. A large share of the AI running in production at real companies is still this: boring, cheap, debuggable classic ML. It's not glamorous, and it works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deep learning: for when you can't describe the features
&lt;/h2&gt;

&lt;p&gt;Deep learning is machine learning with multi-layer neural networks, and the "deep" just means many layers. Each layer learns a more abstract representation of the input than the one before it. In an image model, early layers pick up edges, middle layers pick up textures and shapes, and later layers pick up things like "wheel" or "face."&lt;/p&gt;

&lt;p&gt;The important shift is that the network discovers the features itself. You don't hand-craft them. That's exactly why deep learning took over problems where nobody could write down what to look for: image classification, object detection with models like YOLO, speech recognition, machine translation.&lt;/p&gt;

&lt;p&gt;The trade-offs are the flip side of that power. You need much more data. You usually need GPUs. Training is expensive, and the resulting model is often a black box, so explaining an individual prediction gets much harder. If your data is a spreadsheet, you're probably paying all those costs for no gain. If your data is pixels or audio waveforms or raw text, you're paying them because you have no better option.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generative AI asks a different question
&lt;/h2&gt;

&lt;p&gt;This is the layer people mean when they say "AI" in 2026, and it's worth being precise about what's different.&lt;/p&gt;

&lt;p&gt;A classic ML model, and most deep learning models, answer the question: &lt;em&gt;which category does this input belong to?&lt;/em&gt; They output a label or a number. A generative model answers a different question: &lt;em&gt;what should come next, given everything so far?&lt;/em&gt; It outputs new content.&lt;/p&gt;

&lt;p&gt;For text and code, the mechanism is autoregressive generation. The model predicts the next token, appends it to the context, and repeats until it's done. Every response, however long, is built that way, one token at a time. (Image and video generators like Midjourney and Sora use other techniques, diffusion models being the common one, but the spirit is the same: a deep network trained to produce new content that resembles what it learned from.)&lt;/p&gt;

&lt;p&gt;That difference is fundamental, not cosmetic. A fraud model gives you a probability between 0 and 1. A language model gives you a paragraph, and the paragraph might be brilliant, or plausible and wrong. You've moved from a system with a narrow, checkable output to a system with an open-ended one, and everything about how you test, monitor and budget for it changes.&lt;/p&gt;

&lt;p&gt;It's also worth being honest about what these models are. They're extremely good at predicting statistically likely continuations of text. Whether that amounts to "understanding" is a real debate, and some behaviour at scale looks a lot like reasoning. But as an engineer you should design as though the model is a powerful pattern-matcher over token sequences, not as though it has a reliable model of the world. That assumption will save you from a lot of confidently wrong outputs in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  So which one do you reach for?
&lt;/h2&gt;

&lt;p&gt;The fastest way I know to sort a problem is to look at the input and the output.&lt;/p&gt;

&lt;p&gt;Take "is this email spam?" The input is structured features plus text statistics, the output is a label, and you have labelled data. That's classic ML. "Predict tomorrow's sales" is a structured time series with a number as the output, and gradient boosting will often beat a neural network there. "Detect credit card fraud" is tabular data with numeric features, and an XGBoost-class model is the standard answer.&lt;/p&gt;

&lt;p&gt;Now change the input. "Recognise objects in photos" has raw pixels as the input, and no one can handcraft pixel features at scale, so that's deep learning. "Transcribe spoken audio" is raw waveforms turned into text, which needs learned acoustic representations, so also deep learning.&lt;/p&gt;

&lt;p&gt;Change the output and you get the third case. "Write a Python function," "generate marketing copy," "summarise a 50-page document": the output is new content, and only generative models can produce it.&lt;/p&gt;

&lt;p&gt;If you want it as a rule of thumb:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Is the output a label or a number?         -&amp;gt; start with classic ML
Is the input raw images, audio or text?    -&amp;gt; deep learning
Is the output new content?                 -&amp;gt; generative AI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read it top to bottom and stop at the first one that fits. The ordering is deliberate. It pushes you toward the simplest tool that could work.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this changes about how you build
&lt;/h2&gt;

&lt;p&gt;Once you see these as layers with different cost profiles, a few practical things follow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An LLM is not a free upgrade.&lt;/strong&gt; It adds latency, since generation is sequential and each response takes as many forward passes as it has tokens. It adds cost, since you're billed per token. And it adds unpredictability, because the same prompt can produce different outputs and there's no simple accuracy number to watch. For a spam filter, an inventory forecast or a click-through prediction, a small ML model is faster, cheaper, more predictable and frequently more accurate. Reaching for an LLM there is like hiring a novelist to fill in a spreadsheet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Build the dumb baseline first.&lt;/strong&gt; Before you design anything with GPUs in it, train a logistic regression or a gradient-boosted model on the data you have. It takes an afternoon. If it hits your target, you're done, and you've saved months. If it doesn't, you now have a number that any fancier approach has to beat, which keeps the conversation honest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Debuggability is a feature.&lt;/strong&gt; When a decision tree misclassifies something you can walk the tree and see why. When a deep network does, you get a shrug and some saliency maps. When an LLM does, you get a fluent explanation that may or may not reflect what actually happened. In regulated or high-stakes systems, that difference can decide the architecture on its own.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mixing layers is normal.&lt;/strong&gt; The strongest systems I see described tend to combine them: a deep model turns messy input like text or images into something structured, and a classic model makes the final scored decision on top. Nothing says a project has to live in one circle.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where I'd land
&lt;/h2&gt;

&lt;p&gt;None of these layers is better than the others. Each one is a response to a specific limit in the one before it: rules didn't scale, so we learned from data; hand-built features stalled, so we let networks learn them; classification wasn't enough, so we taught models to generate.&lt;/p&gt;

&lt;p&gt;The mistake isn't using generative AI. The mistake is using it because it's the most visible circle, when the problem in front of you lives in an outer one. The next time someone in a meeting says "let's use AI," it's worth asking the boring questions first: what goes in, what comes out, and what's the simplest thing that could possibly work? That five-minute conversation is usually worth more than the model choice itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Explore It Visually
&lt;/h2&gt;

&lt;p&gt;If you learn better by seeing the pieces move, I turned this whole hierarchy into an 8-scene animated walkthrough, from the confusion at the start to a complete side-by-side comparison. You can watch it straight through or jump between scenes: &lt;a href="https://seeitflow.com/ai/ai-foundations/ml-vs-dl-vs-genai" rel="noopener noreferrer"&gt;ML vs Deep Learning vs Generative AI on SeeItFlow&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'm curious how it goes on your side. Have you ever seen a project reach for an LLM when a simple model would have done the job, or the reverse? Tell me in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>genai</category>
    </item>
    <item>
      <title>Attention Mechanism Explained Visually: The Innovation That Made Modern AI Possible</title>
      <dc:creator>MANGESH MANDLIK</dc:creator>
      <pubDate>Sat, 19 Sep 2026 12:07:42 +0000</pubDate>
      <link>https://dev.to/mangeshmandlik/attention-mechanism-explained-visually-the-innovation-that-made-modern-ai-possible-25cg</link>
      <guid>https://dev.to/mangeshmandlik/attention-mechanism-explained-visually-the-innovation-that-made-modern-ai-possible-25cg</guid>
      <description>&lt;p&gt;Imagine reading a book where you forget everything you've read after every sentence.&lt;/p&gt;

&lt;p&gt;You might still understand individual words, but following a story would be almost impossible.&lt;/p&gt;

&lt;p&gt;Characters would appear and disappear. References wouldn't make sense. Important context would constantly be lost.&lt;/p&gt;

&lt;p&gt;For a long time, AI models faced a similar problem.&lt;/p&gt;

&lt;p&gt;They could process text, but maintaining context across long sequences was difficult. As sentences became longer, important information gradually faded away.&lt;/p&gt;

&lt;p&gt;Then came a simple idea that changed the trajectory of AI:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attention.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Today, attention sits at the heart of ChatGPT, Claude, Gemini, Copilot, and most modern AI systems. Without it, the current wave of generative AI probably wouldn't exist.&lt;/p&gt;

&lt;p&gt;Let's see why attention became such a big deal.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem Before Attention
&lt;/h2&gt;

&lt;p&gt;To understand why attention matters, it's worth looking at what came before it.&lt;/p&gt;

&lt;p&gt;Before Transformers, language models primarily relied on architectures such as RNNs and LSTMs.&lt;/p&gt;

&lt;p&gt;These models processed text one token at a time.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Token 1 → Token 2 → Token 3 → Token 4 → Token 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each token passed information to the next token in the sequence.&lt;/p&gt;

&lt;p&gt;That sounds reasonable until the sequence becomes long.&lt;/p&gt;

&lt;p&gt;Consider this sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The database server crashed because it ran out of memory.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When you read the word &lt;strong&gt;it&lt;/strong&gt;, you instantly know it refers to the database server.&lt;/p&gt;

&lt;p&gt;An older sequence model has a harder job.&lt;/p&gt;

&lt;p&gt;It has to carry information about "database server" through every intermediate step before reaching "it". As sequences grow longer, that information becomes harder to preserve.&lt;/p&gt;

&lt;p&gt;This became known as the &lt;strong&gt;long-range dependency problem&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The further apart two related words were, the harder it became for the model to connect them.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Question Every Token Wants Answered
&lt;/h2&gt;

&lt;p&gt;When humans read, we don't give equal importance to every word.&lt;/p&gt;

&lt;p&gt;Consider this sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The customer could not log in because the authentication service was unavailable.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When trying to understand why the login failed, your brain naturally focuses on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;authentication service&lt;/li&gt;
&lt;li&gt;unavailable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and largely ignores less relevant words.&lt;/p&gt;

&lt;p&gt;We instinctively pay attention to the parts that matter.&lt;/p&gt;

&lt;p&gt;The breakthrough idea behind attention was surprisingly simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What if every token could decide which other tokens are most important?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead of forcing information through a long chain, let each token directly look at the rest of the sequence and determine what matters.&lt;/p&gt;

&lt;p&gt;That's attention.&lt;/p&gt;




&lt;h2&gt;
  
  
  Attention Is Basically Smart Context Lookup
&lt;/h2&gt;

&lt;p&gt;A useful way to think about attention is as a search system running inside the model.&lt;/p&gt;

&lt;p&gt;Every token asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Which other tokens should I pay attention to?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The database server crashed because it ran out of memory.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When processing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the model might assign high importance to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;database
server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and lower importance to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;because
out
of
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is that the word "it" receives information from the most relevant parts of the sentence.&lt;/p&gt;

&lt;p&gt;Instead of treating every word equally, the model learns where to focus.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Library Analogy
&lt;/h2&gt;

&lt;p&gt;The terminology used in attention can sound intimidating at first:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Query&lt;/li&gt;
&lt;li&gt;Key&lt;/li&gt;
&lt;li&gt;Value&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The names become easier to understand if you think of a library.&lt;/p&gt;

&lt;p&gt;Imagine you're looking for information about PostgreSQL replication.&lt;/p&gt;

&lt;p&gt;Your search request is the:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every book contains metadata describing what it covers.&lt;/p&gt;

&lt;p&gt;Those descriptions act as:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keys&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once a matching book is found, the actual content inside the book becomes the:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Value&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The same idea exists inside attention.&lt;/p&gt;

&lt;p&gt;Each token creates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a Query (what am I looking for?)&lt;/li&gt;
&lt;li&gt;a Key (what information do I contain?)&lt;/li&gt;
&lt;li&gt;a Value (what information can I provide?)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The model compares Queries and Keys.&lt;/p&gt;

&lt;p&gt;Strong matches receive more attention.&lt;/p&gt;

&lt;p&gt;The corresponding Values contribute more information.&lt;/p&gt;

&lt;p&gt;That's the core mechanism.&lt;/p&gt;




&lt;h2&gt;
  
  
  Watching Attention Happen
&lt;/h2&gt;

&lt;p&gt;Let's revisit the earlier sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The database server crashed because it ran out of memory.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When processing the word:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the model computes relevance scores against every other token.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;database      → high relevance
server        → high relevance
crashed       → medium relevance
because       → low relevance
out           → low relevance
memory        → medium relevance
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These scores are converted into weights.&lt;/p&gt;

&lt;p&gt;The final representation of "it" becomes a weighted combination of information from the most relevant tokens.&lt;/p&gt;

&lt;p&gt;This allows the model to understand that "it" refers to the database server rather than some other word in the sentence.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Was Revolutionary
&lt;/h2&gt;

&lt;p&gt;The real breakthrough wasn't just better context.&lt;/p&gt;

&lt;p&gt;It was that attention removed the sequential bottleneck.&lt;/p&gt;

&lt;p&gt;Older models worked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Token 1 → Token 2 → Token 3 → Token 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Transformers work more like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Token 1
Token 2
Token 3
Token 4
Token 5

↓
All Tokens Attend To Each Other
↓
Processed In Parallel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every token can interact with every other token at the same time.&lt;/p&gt;

&lt;p&gt;This unlocked two enormous advantages:&lt;/p&gt;

&lt;h3&gt;
  
  
  Better Context Understanding
&lt;/h3&gt;

&lt;p&gt;A token can directly access information from anywhere in the sequence.&lt;/p&gt;

&lt;p&gt;Not just nearby words.&lt;/p&gt;

&lt;h3&gt;
  
  
  Massive Parallelism
&lt;/h3&gt;

&lt;p&gt;Modern GPUs can process large numbers of tokens simultaneously.&lt;/p&gt;

&lt;p&gt;Training becomes dramatically faster and more scalable.&lt;/p&gt;

&lt;p&gt;This was one of the key reasons Transformers rapidly replaced older architectures.&lt;/p&gt;




&lt;h2&gt;
  
  
  Multi-Head Attention: Multiple Specialists Looking At The Same Sentence
&lt;/h2&gt;

&lt;p&gt;One type of attention isn't always enough.&lt;/p&gt;

&lt;p&gt;Language contains many different relationships.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The senior engineer fixed the production issue after reviewing the logs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One attention pattern might focus on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;engineer ↔ fixed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another might focus on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;issue ↔ logs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another might focus on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;production ↔ issue&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of using a single attention mechanism, Transformers use multiple attention heads running in parallel.&lt;/p&gt;

&lt;p&gt;Each head learns to focus on different relationships.&lt;/p&gt;

&lt;p&gt;You can think of it as several specialists examining the same sentence from different perspectives.&lt;/p&gt;

&lt;p&gt;The outputs are then combined to create a richer understanding of the sequence.&lt;/p&gt;

&lt;p&gt;This is known as &lt;strong&gt;Multi-Head Attention&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Attention Scales So Well
&lt;/h2&gt;

&lt;p&gt;One of the most important discoveries in modern AI is that larger Transformer models often become more capable when given:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;More data&lt;/li&gt;
&lt;li&gt;More parameters&lt;/li&gt;
&lt;li&gt;More compute&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Attention made that scaling possible.&lt;/p&gt;

&lt;p&gt;Without attention, training massive language models would have been significantly more difficult.&lt;/p&gt;

&lt;p&gt;The architecture was flexible enough to scale from millions of parameters to hundreds of billions of parameters.&lt;/p&gt;

&lt;p&gt;That's one reason why the 2017 paper &lt;em&gt;Attention Is All You Need&lt;/em&gt; is considered one of the most influential papers in AI history.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where You Use Attention Every Day
&lt;/h2&gt;

&lt;p&gt;Even if you've never heard the term before, you're already benefiting from attention.&lt;/p&gt;

&lt;h3&gt;
  
  
  ChatGPT
&lt;/h3&gt;

&lt;p&gt;Attention helps connect your current prompt with relevant parts of the conversation history.&lt;/p&gt;

&lt;h3&gt;
  
  
  GitHub Copilot
&lt;/h3&gt;

&lt;p&gt;Attention helps relate the code you're writing to functions, classes, and files elsewhere in the project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Translation Systems
&lt;/h3&gt;

&lt;p&gt;Attention links words in one language to their most relevant counterparts in another.&lt;/p&gt;

&lt;h3&gt;
  
  
  Semantic Search
&lt;/h3&gt;

&lt;p&gt;Attention-powered models create embeddings that capture contextual meaning.&lt;/p&gt;

&lt;h3&gt;
  
  
  AI Agents
&lt;/h3&gt;

&lt;p&gt;Attention helps combine user goals, retrieved information, previous actions, and tool outputs into a coherent response.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Engineers Should Care
&lt;/h2&gt;

&lt;p&gt;You don't need to train foundation models to benefit from understanding attention.&lt;/p&gt;

&lt;p&gt;Many practical AI engineering decisions become easier once you understand how models focus on information.&lt;/p&gt;

&lt;p&gt;It helps explain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why context placement matters&lt;/li&gt;
&lt;li&gt;Why retrieval quality affects RAG performance&lt;/li&gt;
&lt;li&gt;Why some prompts work better than others&lt;/li&gt;
&lt;li&gt;Why important information can sometimes be overlooked in long contexts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A surprising number of AI engineering problems ultimately come down to guiding attention toward the right information.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;The idea behind attention is remarkably simple.&lt;/p&gt;

&lt;p&gt;Instead of forcing information through a long chain of intermediate steps, let every token decide which other tokens matter most.&lt;/p&gt;

&lt;p&gt;That one change transformed natural language processing.&lt;/p&gt;

&lt;p&gt;It enabled Transformers.&lt;/p&gt;

&lt;p&gt;Transformers enabled modern LLMs.&lt;/p&gt;

&lt;p&gt;And modern LLMs gave us systems like ChatGPT, Claude, Gemini, and Copilot.&lt;/p&gt;

&lt;p&gt;Not bad for a concept that started with a simple question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Which parts of the input should I pay attention to?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Explore It Visually
&lt;/h2&gt;

&lt;p&gt;Reading about attention helps.&lt;/p&gt;

&lt;p&gt;Watching information flow between tokens makes it click much faster.&lt;/p&gt;

&lt;p&gt;If you'd like to see self-attention, multi-head attention, token interactions, and Transformer internals animated step-by-step, check out the interactive walkthrough:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://seeitflow.com/ai/ai-foundations/attention-mechanism" rel="noopener noreferrer"&gt;https://seeitflow.com/ai/ai-foundations/attention-mechanism&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because some engineering concepts are easier to understand when you can actually see them work.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>machinelearning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Transformer Basics: The Architecture Behind ChatGPT, Claude and Gemini</title>
      <dc:creator>MANGESH MANDLIK</dc:creator>
      <pubDate>Sat, 19 Sep 2026 11:48:15 +0000</pubDate>
      <link>https://dev.to/mangeshmandlik/transformer-basics-the-architecture-behind-chatgpt-claude-and-gemini-1ljg</link>
      <guid>https://dev.to/mangeshmandlik/transformer-basics-the-architecture-behind-chatgpt-claude-and-gemini-1ljg</guid>
      <description>&lt;p&gt;Before 2017, most language AI systems relied on Recurrent Neural Networks (RNNs) and LSTMs.&lt;/p&gt;

&lt;p&gt;They worked, but they had a fundamental limitation: they processed information sequentially.&lt;/p&gt;

&lt;p&gt;Every token depended on the previous token's hidden state, making training slow, difficult to parallelize, and increasingly ineffective for long contexts.&lt;/p&gt;

&lt;p&gt;Then came a research paper from Google:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Attention Is All You Need (Vaswani et al., 2017)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The paper introduced the &lt;strong&gt;Transformer&lt;/strong&gt;, an architecture that would eventually power GPT, ChatGPT, Claude, Gemini, Copilot, and most modern AI systems.&lt;/p&gt;

&lt;p&gt;Within a few years, Transformers replaced RNNs as the dominant architecture for natural language processing.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem With RNNs
&lt;/h2&gt;

&lt;p&gt;Consider this sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The database server crashed because it ran out of memory.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To understand what &lt;strong&gt;"it"&lt;/strong&gt; refers to, a model must connect the word &lt;em&gt;it&lt;/em&gt; with &lt;em&gt;database server&lt;/em&gt; several tokens earlier.&lt;/p&gt;

&lt;p&gt;RNNs attempt to carry this information through every intermediate step.&lt;/p&gt;

&lt;p&gt;As sequences grow longer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Information gradually degrades&lt;/li&gt;
&lt;li&gt;Training becomes slower&lt;/li&gt;
&lt;li&gt;Long-range relationships become harder to preserve&lt;/li&gt;
&lt;li&gt;GPU parallelism becomes difficult&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This sequential bottleneck limited how large and capable language models could become.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Core Idea Behind Transformers
&lt;/h2&gt;

&lt;p&gt;The Transformer introduced a radically different approach.&lt;/p&gt;

&lt;p&gt;Instead of processing one token at a time, it processes &lt;strong&gt;all tokens simultaneously&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Every token can directly interact with every other token.&lt;/p&gt;

&lt;p&gt;Rather than passing information through a chain of hidden states, tokens communicate through a mechanism called &lt;strong&gt;self-attention&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Token A  ←→ Token B
   ↑         ↓
Token C  ←→ Token D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every token can examine the entire sequence and decide which other tokens matter most for understanding its meaning.&lt;/p&gt;

&lt;p&gt;This creates a global view of context.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Changed Everything
&lt;/h2&gt;

&lt;p&gt;Processing tokens simultaneously unlocked massive parallelism.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Token1 → Token2 → Token3 → Token4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Transformers perform:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Token1
Token2
Token3
Token4
   ↓
Processed Together
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This made it possible to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fully utilize modern GPUs&lt;/li&gt;
&lt;li&gt;Train on internet-scale datasets&lt;/li&gt;
&lt;li&gt;Build models with billions of parameters&lt;/li&gt;
&lt;li&gt;Learn richer contextual relationships&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The result was a dramatic increase in model capability.&lt;/p&gt;




&lt;h2&gt;
  
  
  RNNs vs Transformers
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;RNN / LSTM&lt;/th&gt;
&lt;th&gt;Transformer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Processing&lt;/td&gt;
&lt;td&gt;Sequential&lt;/td&gt;
&lt;td&gt;Parallel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Long-context handling&lt;/td&gt;
&lt;td&gt;Weakens over distance&lt;/td&gt;
&lt;td&gt;Global context&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPU utilization&lt;/td&gt;
&lt;td&gt;Limited&lt;/td&gt;
&lt;td&gt;Excellent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Training speed&lt;/td&gt;
&lt;td&gt;Slow&lt;/td&gt;
&lt;td&gt;Fast&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scalability&lt;/td&gt;
&lt;td&gt;Limited&lt;/td&gt;
&lt;td&gt;Scales with compute&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Context awareness&lt;/td&gt;
&lt;td&gt;Local&lt;/td&gt;
&lt;td&gt;Global&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Transformers are computationally expensive because attention grows roughly with sequence length squared, but the gains in capability far outweigh the cost.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Scaling Law Discovery
&lt;/h2&gt;

&lt;p&gt;One of the most important discoveries after Transformers emerged was that performance improves predictably with scale.&lt;/p&gt;

&lt;p&gt;Increasing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Training data&lt;/li&gt;
&lt;li&gt;Compute&lt;/li&gt;
&lt;li&gt;Model parameters&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;consistently produced stronger models.&lt;/p&gt;

&lt;p&gt;This observation became known as &lt;strong&gt;Scaling Laws&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead of relying solely on architectural breakthroughs, researchers discovered that simply scaling Transformer models generated substantial improvements.&lt;/p&gt;

&lt;p&gt;This insight fueled the modern AI race.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Short Timeline
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Year&lt;/th&gt;
&lt;th&gt;Milestone&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;2017&lt;/td&gt;
&lt;td&gt;Transformer introduced in &lt;em&gt;Attention Is All You Need&lt;/em&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2018&lt;/td&gt;
&lt;td&gt;BERT popularizes Transformer-based NLP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2019&lt;/td&gt;
&lt;td&gt;GPT-2 demonstrates large-scale text generation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2020&lt;/td&gt;
&lt;td&gt;GPT-3 introduces powerful few-shot learning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2022&lt;/td&gt;
&lt;td&gt;ChatGPT brings LLMs to mainstream users&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2023&lt;/td&gt;
&lt;td&gt;GPT-4, Claude and Gemini expand multimodal capabilities&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2024+&lt;/td&gt;
&lt;td&gt;Open-source models continue closing the gap&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Where You Encounter Transformers Today
&lt;/h2&gt;

&lt;p&gt;Most modern AI products rely on Transformer architectures.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ChatGPT&lt;/li&gt;
&lt;li&gt;Claude&lt;/li&gt;
&lt;li&gt;Gemini&lt;/li&gt;
&lt;li&gt;GitHub Copilot&lt;/li&gt;
&lt;li&gt;Translation systems&lt;/li&gt;
&lt;li&gt;Semantic search engines&lt;/li&gt;
&lt;li&gt;Retrieval-Augmented Generation (RAG) systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even when the product looks different, the underlying architecture is often still a Transformer.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Transformers Matter
&lt;/h2&gt;

&lt;p&gt;Transformers solved the sequential bottleneck that limited previous language models.&lt;/p&gt;

&lt;p&gt;By allowing every token to interact with every other token while processing entire sequences in parallel, they unlocked the scaling behavior that made modern AI possible.&lt;/p&gt;

&lt;p&gt;Whether you're using ChatGPT, Claude, Gemini, semantic search, RAG pipelines, or AI coding assistants, you're almost certainly benefiting from the Transformer architecture introduced in 2017.&lt;/p&gt;




&lt;h2&gt;
  
  
  See It In Action
&lt;/h2&gt;

&lt;p&gt;Want to explore Transformer architecture visually?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://seeitflow.com/ai/ai-foundations/transformer-basics" rel="noopener noreferrer"&gt;https://seeitflow.com/ai/ai-foundations/transformer-basics&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>machinelearning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Vectors &amp; Similarity Search: How AI Finds Meaning Instead of Keywords</title>
      <dc:creator>MANGESH MANDLIK</dc:creator>
      <pubDate>Sat, 19 Sep 2026 11:37:37 +0000</pubDate>
      <link>https://dev.to/mangeshmandlik/vectors-similarity-search-how-ai-finds-meaning-instead-of-keywords-5g23</link>
      <guid>https://dev.to/mangeshmandlik/vectors-similarity-search-how-ai-finds-meaning-instead-of-keywords-5g23</guid>
      <description>&lt;p&gt;Imagine searching for:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How do I scale PostgreSQL?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now imagine the best document in your knowledge base is titled:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Horizontal Scaling of Relational Databases&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A traditional search engine might completely miss it.&lt;/p&gt;

&lt;p&gt;The document is clearly relevant. A human would immediately make the connection.&lt;/p&gt;

&lt;p&gt;But keyword search doesn't think like a human.&lt;/p&gt;

&lt;p&gt;It doesn't understand that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PostgreSQL is a relational database&lt;/li&gt;
&lt;li&gt;Scaling and horizontal scaling are related concepts&lt;/li&gt;
&lt;li&gt;Sharding, replication, and scaling often appear in the same discussions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It only sees words.&lt;/p&gt;

&lt;p&gt;Modern AI systems work differently.&lt;/p&gt;

&lt;p&gt;Instead of searching for words, they search for meaning.&lt;/p&gt;

&lt;p&gt;That's where vectors and similarity search come in.&lt;/p&gt;

&lt;p&gt;They're the reason ChatGPT can retrieve relevant documents, GitHub Copilot can find related code, and AI-powered search feels dramatically smarter than traditional keyword search.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Missing Piece After Embeddings
&lt;/h2&gt;

&lt;p&gt;In the previous article, we looked at embeddings.&lt;/p&gt;

&lt;p&gt;Embeddings convert text into vectors — long lists of numbers that capture meaning.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"PostgreSQL Replication"
→ [0.23, -0.81, 0.44, 0.67, ...]

"Database Sharding"
→ [0.19, -0.77, 0.51, 0.61, ...]

"Pizza Recipes"
→ [0.71, 0.33, -0.28, -0.52, ...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The actual numbers aren't important.&lt;/p&gt;

&lt;p&gt;What matters is where those vectors end up.&lt;/p&gt;

&lt;p&gt;Concepts with similar meanings tend to be positioned close together.&lt;/p&gt;

&lt;p&gt;Unrelated concepts end up further apart.&lt;/p&gt;

&lt;p&gt;That raises an interesting question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If meaning becomes a location, can we search by location instead of words?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's exactly what similarity search does.&lt;/p&gt;




&lt;h2&gt;
  
  
  Think of It Like Google Maps
&lt;/h2&gt;

&lt;p&gt;Imagine opening Google Maps and searching for a coffee shop nearby.&lt;/p&gt;

&lt;p&gt;Google doesn't search for every coffee shop in the world.&lt;/p&gt;

&lt;p&gt;Instead, it looks for locations that are close to your current coordinates.&lt;/p&gt;

&lt;p&gt;Similarity search works the same way.&lt;/p&gt;

&lt;p&gt;Except instead of cities and roads, we're dealing with ideas.&lt;/p&gt;

&lt;p&gt;In this semantic map:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PostgreSQL is near replication&lt;/li&gt;
&lt;li&gt;Replication is near scaling&lt;/li&gt;
&lt;li&gt;Scaling is near sharding&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Meanwhile:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pizza recipes&lt;/li&gt;
&lt;li&gt;Football scores&lt;/li&gt;
&lt;li&gt;Travel itineraries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;end up somewhere completely different.&lt;/p&gt;

&lt;p&gt;The closer two vectors are, the more related their meanings tend to be.&lt;/p&gt;




&lt;h2&gt;
  
  
  Searching for Meaning Instead of Words
&lt;/h2&gt;

&lt;p&gt;Let's revisit our query:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How do I scale PostgreSQL?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The search system first converts that query into an embedding.&lt;/p&gt;

&lt;p&gt;Now it has a vector representing the meaning of the question.&lt;/p&gt;

&lt;p&gt;Instead of scanning documents for exact words, it searches for nearby vectors.&lt;/p&gt;

&lt;p&gt;The results might include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PostgreSQL replication strategies&lt;/li&gt;
&lt;li&gt;Database sharding techniques&lt;/li&gt;
&lt;li&gt;Read replica architectures&lt;/li&gt;
&lt;li&gt;Partitioning large databases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notice something interesting.&lt;/p&gt;

&lt;p&gt;The exact phrase:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;scale PostgreSQL&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;might not appear anywhere.&lt;/p&gt;

&lt;p&gt;Yet the results are still relevant.&lt;/p&gt;

&lt;p&gt;That's the power of semantic search.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Keyword Search Isn't Enough
&lt;/h2&gt;

&lt;p&gt;Keyword search is fantastic for certain problems.&lt;/p&gt;

&lt;p&gt;If you're searching for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Order ID 928372&lt;/li&gt;
&lt;li&gt;User account mangesh&lt;/li&gt;
&lt;li&gt;Error code ERR_403&lt;/li&gt;
&lt;li&gt;Invoice number INV-1024&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;you want exact matches.&lt;/p&gt;

&lt;p&gt;But humans rarely communicate using identical words.&lt;/p&gt;

&lt;p&gt;We paraphrase.&lt;/p&gt;

&lt;p&gt;We use synonyms.&lt;/p&gt;

&lt;p&gt;We describe concepts in different ways.&lt;/p&gt;

&lt;p&gt;Someone might search:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How can I speed up my database?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;while the document says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Improving PostgreSQL query performance&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The meaning is similar.&lt;/p&gt;

&lt;p&gt;The wording is not.&lt;/p&gt;

&lt;p&gt;Keyword search struggles here.&lt;/p&gt;

&lt;p&gt;Similarity search thrives.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is a Vector, Really?
&lt;/h2&gt;

&lt;p&gt;The word vector sounds intimidating, but the idea is simple.&lt;/p&gt;

&lt;p&gt;A vector is just a list of numbers.&lt;/p&gt;

&lt;p&gt;For AI systems, those numbers represent learned patterns.&lt;/p&gt;

&lt;p&gt;Think of a vector as a coordinate in a giant multidimensional map.&lt;/p&gt;

&lt;p&gt;If two pieces of information are related, their coordinates tend to be nearby.&lt;/p&gt;

&lt;p&gt;If they're unrelated, they tend to be further apart.&lt;/p&gt;

&lt;p&gt;The embedding model learns those relationships during training.&lt;/p&gt;

&lt;p&gt;By the time the vectors are created, similar concepts have naturally clustered together.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Geometry Behind AI Search
&lt;/h2&gt;

&lt;p&gt;One of the coolest things about embeddings is that semantic search becomes a geometry problem.&lt;/p&gt;

&lt;p&gt;The system isn't asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Which document contains these words?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It's asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Which vectors are closest to this vector?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's a fundamentally different approach.&lt;/p&gt;

&lt;p&gt;Distance becomes a proxy for meaning.&lt;/p&gt;

&lt;p&gt;Near vectors imply related concepts.&lt;/p&gt;

&lt;p&gt;Far vectors imply unrelated concepts.&lt;/p&gt;

&lt;p&gt;Search suddenly becomes less about language and more about mathematics.&lt;/p&gt;




&lt;h2&gt;
  
  
  Measuring Similarity
&lt;/h2&gt;

&lt;p&gt;Of course, we need a way to determine whether two vectors are close together.&lt;/p&gt;

&lt;p&gt;Several approaches exist, but the most common is &lt;strong&gt;Cosine Similarity&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Rather than measuring physical distance, cosine similarity measures how closely two vectors point in the same direction.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Similar meanings
      ↘
       ↘
        ↘

High similarity score
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Vectors pointing in similar directions tend to represent similar concepts.&lt;/p&gt;

&lt;p&gt;This works surprisingly well for text, code, and many other forms of data.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Becomes Difficult at Scale
&lt;/h2&gt;

&lt;p&gt;Now imagine storing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;100 million document embeddings&lt;/li&gt;
&lt;li&gt;1,536 dimensions each&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A straightforward approach would compare the query vector against every single vector.&lt;/p&gt;

&lt;p&gt;For every search.&lt;/p&gt;

&lt;p&gt;That's a lot of math.&lt;/p&gt;

&lt;p&gt;Even modern hardware would struggle to deliver fast results at that scale.&lt;/p&gt;

&lt;p&gt;We need a smarter approach.&lt;/p&gt;




&lt;h2&gt;
  
  
  Enter Approximate Nearest Neighbor Search
&lt;/h2&gt;

&lt;p&gt;This is where things get interesting.&lt;/p&gt;

&lt;p&gt;Most AI systems don't search every vector.&lt;/p&gt;

&lt;p&gt;Instead, they use algorithms designed to find vectors that are &lt;em&gt;probably&lt;/em&gt; the closest.&lt;/p&gt;

&lt;p&gt;This technique is called:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approximate Nearest Neighbor (ANN) Search&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The tradeoff is simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Slightly less precision&lt;/li&gt;
&lt;li&gt;Dramatically faster retrieval&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In practice, ANN search is so effective that it powers most production vector databases today.&lt;/p&gt;

&lt;p&gt;Users get results in milliseconds instead of seconds.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Vector Databases Exist
&lt;/h2&gt;

&lt;p&gt;Traditional databases were built for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Transactions&lt;/li&gt;
&lt;li&gt;Joins&lt;/li&gt;
&lt;li&gt;Aggregations&lt;/li&gt;
&lt;li&gt;Structured queries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They weren't designed for questions like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Find the 20 most semantically similar documents.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Vector databases were built specifically for that problem.&lt;/p&gt;

&lt;p&gt;Their job is to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Store embeddings&lt;/li&gt;
&lt;li&gt;Build efficient indexes&lt;/li&gt;
&lt;li&gt;Run similarity searches&lt;/li&gt;
&lt;li&gt;Filter results using metadata&lt;/li&gt;
&lt;li&gt;Return relevant matches quickly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Popular options include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pinecone&lt;/li&gt;
&lt;li&gt;Qdrant&lt;/li&gt;
&lt;li&gt;Weaviate&lt;/li&gt;
&lt;li&gt;Milvus&lt;/li&gt;
&lt;li&gt;pgvector&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each approaches the problem slightly differently, but the goal remains the same:&lt;/p&gt;

&lt;p&gt;Find nearby meaning as quickly as possible.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where You Already Use Similarity Search
&lt;/h2&gt;

&lt;p&gt;Even if you've never built a vector database, you're probably using similarity search every day.&lt;/p&gt;

&lt;h3&gt;
  
  
  ChatGPT and RAG Systems
&lt;/h3&gt;

&lt;p&gt;When an AI assistant retrieves documents before answering a question, similarity search is often doing the retrieval.&lt;/p&gt;

&lt;p&gt;The system embeds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The user's question&lt;/li&gt;
&lt;li&gt;The stored documents&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and finds the closest matches.&lt;/p&gt;

&lt;h3&gt;
  
  
  GitHub Copilot
&lt;/h3&gt;

&lt;p&gt;Copilot searches your codebase for relevant functions, files, and examples before generating suggestions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Enterprise Search
&lt;/h3&gt;

&lt;p&gt;Tools like Notion AI, Slack AI, and Confluence AI use semantic retrieval to search large collections of internal knowledge.&lt;/p&gt;

&lt;h3&gt;
  
  
  Recommendation Engines
&lt;/h3&gt;

&lt;p&gt;Netflix, Spotify, Amazon, and many other platforms use embeddings to find content similar to what users previously enjoyed.&lt;/p&gt;

&lt;p&gt;Different application.&lt;/p&gt;

&lt;p&gt;Same core idea.&lt;/p&gt;

&lt;p&gt;Find nearby vectors.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Matters for RAG
&lt;/h2&gt;

&lt;p&gt;Many developers first encounter similarity search while building Retrieval-Augmented Generation systems.&lt;/p&gt;

&lt;p&gt;RAG works because:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Documents are converted into embeddings.&lt;/li&gt;
&lt;li&gt;User questions are converted into embeddings.&lt;/li&gt;
&lt;li&gt;Similarity search finds relevant chunks.&lt;/li&gt;
&lt;li&gt;Those chunks are sent to the LLM.&lt;/li&gt;
&lt;li&gt;The LLM generates a response using retrieved context.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Without similarity search, RAG would largely fall back to keyword matching.&lt;/p&gt;

&lt;p&gt;The quality of retrieval would drop significantly.&lt;/p&gt;

&lt;p&gt;In many RAG systems, retrieval quality matters as much as model quality.&lt;/p&gt;

&lt;p&gt;Sometimes more.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Bigger Idea
&lt;/h2&gt;

&lt;p&gt;One of the most important shifts in modern AI is that we're increasingly moving away from exact matching.&lt;/p&gt;

&lt;p&gt;Instead of asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Does this text contain these words?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;we ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Does this information mean something similar?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Vectors and similarity search make that possible.&lt;/p&gt;

&lt;p&gt;They allow machines to retrieve concepts rather than keywords.&lt;/p&gt;

&lt;p&gt;That's why modern AI systems feel so much more intuitive than traditional search systems.&lt;/p&gt;

&lt;p&gt;They're operating on meaning, not just text.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Embeddings turn meaning into numbers.&lt;/p&gt;

&lt;p&gt;Similarity search turns those numbers into retrieval.&lt;/p&gt;

&lt;p&gt;Vector databases make that retrieval practical at scale.&lt;/p&gt;

&lt;p&gt;Together, they form the foundation of semantic search, RAG systems, recommendation engines, enterprise search platforms, and many of the AI products we use every day.&lt;/p&gt;

&lt;p&gt;Once you understand vectors and similarity search, a lot of AI starts feeling less magical.&lt;/p&gt;

&lt;p&gt;It's still impressive.&lt;/p&gt;

&lt;p&gt;But you can finally see the engineering underneath.&lt;/p&gt;




&lt;h2&gt;
  
  
  Explore It Visually
&lt;/h2&gt;

&lt;p&gt;Reading about vector search is useful.&lt;/p&gt;

&lt;p&gt;Watching a query move through embeddings, vector space, ANN retrieval, and semantic search makes the whole process much easier to understand.&lt;/p&gt;

&lt;p&gt;I've created an interactive visual walkthrough here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://seeitflow.com/ai/ai-foundations/vectors-similarity-search" rel="noopener noreferrer"&gt;https://seeitflow.com/ai/ai-foundations/vectors-similarity-search&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because some concepts click faster when you can actually see them work.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>machinelearning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Embeddings Explained: How AI Turns Meaning Into Numbers</title>
      <dc:creator>MANGESH MANDLIK</dc:creator>
      <pubDate>Sat, 19 Sep 2026 09:25:57 +0000</pubDate>
      <link>https://dev.to/mangeshmandlik/embeddings-explained-how-ai-turns-meaning-into-numbers-1hop</link>
      <guid>https://dev.to/mangeshmandlik/embeddings-explained-how-ai-turns-meaning-into-numbers-1hop</guid>
      <description>&lt;p&gt;In the previous post, we looked at tokens — the units language models use to process text. But tokens alone don't carry meaning. To a model, they're just IDs.&lt;/p&gt;

&lt;p&gt;That's where embeddings come in.&lt;/p&gt;

&lt;p&gt;Embeddings are one of the most important ideas in modern AI. They power semantic search, RAG systems, recommendation engines, AI memory, code search, and much more. If you've ever searched for something and found relevant results even when the exact words didn't match, embeddings were probably involved.&lt;/p&gt;

&lt;p&gt;Let's break down how they work.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem: Computers Don't Understand Meaning
&lt;/h2&gt;

&lt;p&gt;Humans naturally understand that these ideas are related:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dog&lt;/li&gt;
&lt;li&gt;Puppy&lt;/li&gt;
&lt;li&gt;Golden Retriever&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And we instantly know they're unrelated to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PostgreSQL sharding&lt;/li&gt;
&lt;li&gt;Redis caching&lt;/li&gt;
&lt;li&gt;Kafka partitions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Computers don't have that intuition.&lt;/p&gt;

&lt;p&gt;Traditional software only sees text as symbols. It can match exact words, but it doesn't inherently understand relationships between concepts.&lt;/p&gt;

&lt;p&gt;That's a problem because people rarely search using the exact words that appear in documents.&lt;/p&gt;

&lt;p&gt;Imagine a user searches:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How do I scale PostgreSQL?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Your documentation contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PostgreSQL Horizontal Scaling&lt;/li&gt;
&lt;li&gt;Database Sharding Strategies&lt;/li&gt;
&lt;li&gt;PgBouncer Connection Pooling&lt;/li&gt;
&lt;li&gt;Scaling Postgres Databases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A keyword search might miss some of the most useful results simply because the wording differs.&lt;/p&gt;

&lt;p&gt;Humans see the connection immediately.&lt;/p&gt;

&lt;p&gt;Computers need a way to represent meaning mathematically.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is an Embedding?
&lt;/h2&gt;

&lt;p&gt;An embedding is a vector of numbers that represents the meaning of some input.&lt;/p&gt;

&lt;p&gt;That input could be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Text&lt;/li&gt;
&lt;li&gt;Code&lt;/li&gt;
&lt;li&gt;Images&lt;/li&gt;
&lt;li&gt;Audio&lt;/li&gt;
&lt;li&gt;Documents&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A simple example might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"I love pizza"

↓

[0.12, -0.44, 0.89, 0.31, -0.72, ...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Real embeddings are much larger.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Dimensions&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;OpenAI text-embedding-3-small&lt;/td&gt;
&lt;td&gt;1536&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OpenAI text-embedding-3-large&lt;/td&gt;
&lt;td&gt;3072&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google text-embedding-004&lt;/td&gt;
&lt;td&gt;768&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sentence-BERT (all-MiniLM-L6)&lt;/td&gt;
&lt;td&gt;384&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The important thing isn't any individual number.&lt;/p&gt;

&lt;p&gt;The meaning comes from the entire pattern across the vector.&lt;/p&gt;

&lt;p&gt;Think of it like GPS coordinates.&lt;/p&gt;

&lt;p&gt;A single coordinate doesn't tell you much. Together, all coordinates define a location.&lt;/p&gt;

&lt;p&gt;Embeddings do the same thing for ideas.&lt;/p&gt;




&lt;h2&gt;
  
  
  From Tokens to Meaning
&lt;/h2&gt;

&lt;p&gt;In the previous article, we saw that tokenization converts text into token IDs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"The quick brown fox"

↓

[791, 4062, 14198, 39935]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those IDs contain no semantic meaning.&lt;/p&gt;

&lt;p&gt;An embedding model takes those token representations and transforms them into a dense vector that captures relationships, context, and meaning.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Text
 ↓
Tokens
 ↓
Token IDs
 ↓
Embedding Model
 ↓
Vector Representation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is a numerical representation where similar concepts end up near each other.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Magic: Similar Ideas End Up Close Together
&lt;/h2&gt;

&lt;p&gt;This is the key property that makes embeddings useful.&lt;/p&gt;

&lt;p&gt;Suppose we embed thousands of technical documents.&lt;/p&gt;

&lt;p&gt;Documents about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PostgreSQL&lt;/li&gt;
&lt;li&gt;Database scaling&lt;/li&gt;
&lt;li&gt;Replication&lt;/li&gt;
&lt;li&gt;Sharding&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;naturally cluster together.&lt;/p&gt;

&lt;p&gt;Documents about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Redis&lt;/li&gt;
&lt;li&gt;Caching&lt;/li&gt;
&lt;li&gt;CDN strategies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;form another cluster.&lt;/p&gt;

&lt;p&gt;Documents about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Recipes&lt;/li&gt;
&lt;li&gt;Pizza&lt;/li&gt;
&lt;li&gt;Baking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;end up somewhere completely different.&lt;/p&gt;

&lt;p&gt;The model was never explicitly told:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;PostgreSQL and sharding are related.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It learned those relationships from patterns in training data.&lt;/p&gt;

&lt;p&gt;As a result, semantic similarity becomes geometric distance.&lt;/p&gt;

&lt;p&gt;In embedding space:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Near = similar meaning&lt;/li&gt;
&lt;li&gt;Far = unrelated meaning&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's the entire foundation of semantic search.&lt;/p&gt;




&lt;h2&gt;
  
  
  Finding Similar Content
&lt;/h2&gt;

&lt;p&gt;Once everything is represented as vectors, search becomes a geometry problem.&lt;/p&gt;

&lt;p&gt;Instead of asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Which documents contain these exact words?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;we ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Which vectors are closest to this vector?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When a user searches:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How do I scale PostgreSQL?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;the query is converted into an embedding.&lt;/p&gt;

&lt;p&gt;Then the system searches for nearby vectors among stored documents.&lt;/p&gt;

&lt;p&gt;The closest vectors are usually the most relevant results.&lt;/p&gt;

&lt;p&gt;Even if none of those documents contain the exact phrase "scale PostgreSQL."&lt;/p&gt;

&lt;p&gt;This is why semantic search feels much smarter than keyword search.&lt;/p&gt;




&lt;h2&gt;
  
  
  How Similarity Is Measured
&lt;/h2&gt;

&lt;p&gt;To compare embeddings, we need a distance metric.&lt;/p&gt;

&lt;p&gt;The most common approaches are:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Measures&lt;/th&gt;
&lt;th&gt;Common Use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cosine Similarity&lt;/td&gt;
&lt;td&gt;Angle between vectors&lt;/td&gt;
&lt;td&gt;Text similarity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dot Product&lt;/td&gt;
&lt;td&gt;Direction + magnitude&lt;/td&gt;
&lt;td&gt;Normalized embeddings&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Euclidean Distance&lt;/td&gt;
&lt;td&gt;Straight-line distance&lt;/td&gt;
&lt;td&gt;Images and some multimodal systems&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In practice, cosine similarity is the most widely used for text embeddings.&lt;/p&gt;

&lt;p&gt;It focuses on whether vectors point in the same direction rather than how large they are.&lt;/p&gt;

&lt;p&gt;That's useful because a short document and a long document about the same topic should still be considered similar.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Embeddings Matter for RAG
&lt;/h2&gt;

&lt;p&gt;Embeddings are one of the core building blocks of Retrieval-Augmented Generation (RAG).&lt;/p&gt;

&lt;p&gt;The workflow looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Question
      ↓
Create Query Embedding
      ↓
Search Vector Database
      ↓
Retrieve Relevant Chunks
      ↓
Send Context To LLM
      ↓
Generate Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without embeddings, retrieval would mostly rely on keyword matching.&lt;/p&gt;

&lt;p&gt;With embeddings, retrieval becomes semantic.&lt;/p&gt;

&lt;p&gt;That's why RAG systems can often find relevant information even when users don't use the same terminology as the source documents.&lt;/p&gt;




&lt;h2&gt;
  
  
  Real-World Applications
&lt;/h2&gt;

&lt;p&gt;Embeddings quietly power many products people use every day.&lt;/p&gt;

&lt;h3&gt;
  
  
  Semantic Search
&lt;/h3&gt;

&lt;p&gt;Instead of matching words, search systems match meaning.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enterprise knowledge bases&lt;/li&gt;
&lt;li&gt;Documentation search&lt;/li&gt;
&lt;li&gt;Internal company search&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  RAG Systems
&lt;/h3&gt;

&lt;p&gt;Knowledge is embedded, stored, retrieved, and injected into LLM prompts.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AI chatbots&lt;/li&gt;
&lt;li&gt;Customer support assistants&lt;/li&gt;
&lt;li&gt;Internal copilots&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Recommendation Engines
&lt;/h3&gt;

&lt;p&gt;Products, movies, songs, and articles can all be represented as vectors.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Netflix recommendations&lt;/li&gt;
&lt;li&gt;Spotify music discovery&lt;/li&gt;
&lt;li&gt;Amazon product suggestions&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  AI Memory
&lt;/h3&gt;

&lt;p&gt;Conversations can be embedded and stored.&lt;/p&gt;

&lt;p&gt;Later, the system retrieves semantically relevant memories rather than searching exact text.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Search and Copilots
&lt;/h3&gt;

&lt;p&gt;Tools like GitHub Copilot use embeddings to find relevant code context before generating suggestions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Misconceptions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  "Embeddings store the original text."
&lt;/h3&gt;

&lt;p&gt;They don't.&lt;/p&gt;

&lt;p&gt;Embeddings store a numerical representation of meaning, not the original text itself.&lt;/p&gt;

&lt;p&gt;You generally cannot reconstruct the original document from an embedding vector.&lt;/p&gt;

&lt;h3&gt;
  
  
  "Nearby vectors mean identical meaning."
&lt;/h3&gt;

&lt;p&gt;Not necessarily.&lt;/p&gt;

&lt;p&gt;Nearby vectors indicate similar meaning.&lt;/p&gt;

&lt;p&gt;Two documents can be closely related without being identical.&lt;/p&gt;

&lt;h3&gt;
  
  
  "Embeddings understand concepts like humans."
&lt;/h3&gt;

&lt;p&gt;Not really.&lt;/p&gt;

&lt;p&gt;Embeddings capture statistical patterns from training data.&lt;/p&gt;

&lt;p&gt;They don't possess human understanding.&lt;/p&gt;

&lt;h3&gt;
  
  
  "More dimensions always means better embeddings."
&lt;/h3&gt;

&lt;p&gt;Not always.&lt;/p&gt;

&lt;p&gt;A well-trained 384-dimensional model can outperform a poorly trained 3000-dimensional model.&lt;/p&gt;

&lt;p&gt;Training quality matters more than raw dimensionality.&lt;/p&gt;

&lt;h3&gt;
  
  
  "Embeddings are unbiased."
&lt;/h3&gt;

&lt;p&gt;They aren't.&lt;/p&gt;

&lt;p&gt;Embeddings inherit patterns and biases from the data they were trained on.&lt;/p&gt;




&lt;h2&gt;
  
  
  Scaling to Billions of Vectors
&lt;/h2&gt;

&lt;p&gt;A small demo might compare a query against a few thousand vectors.&lt;/p&gt;

&lt;p&gt;Production systems often store millions or billions.&lt;/p&gt;

&lt;p&gt;Comparing every vector one by one becomes too slow.&lt;/p&gt;

&lt;p&gt;That's why vector databases use Approximate Nearest Neighbour (ANN) algorithms such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HNSW&lt;/li&gt;
&lt;li&gt;IVF&lt;/li&gt;
&lt;li&gt;PQ&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Popular vector databases include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pinecone&lt;/li&gt;
&lt;li&gt;Weaviate&lt;/li&gt;
&lt;li&gt;Qdrant&lt;/li&gt;
&lt;li&gt;pgvector&lt;/li&gt;
&lt;li&gt;Milvus&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These systems can search enormous vector collections in milliseconds.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Embeddings convert meaning into vectors of numbers.&lt;/li&gt;
&lt;li&gt;Similar meanings become geometrically close in embedding space.&lt;/li&gt;
&lt;li&gt;Semantic search works by finding nearby vectors.&lt;/li&gt;
&lt;li&gt;RAG systems depend on embeddings for retrieval.&lt;/li&gt;
&lt;li&gt;Cosine similarity is the most common way to compare text embeddings.&lt;/li&gt;
&lt;li&gt;Vector databases make large-scale similarity search practical.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;Embeddings solve one problem:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How do we represent meaning as vectors?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The next challenge is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How do we efficiently search billions of those vectors in milliseconds?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's where vector databases come in.&lt;/p&gt;

&lt;p&gt;If you've ever used a RAG system, AI memory feature, semantic search engine, or recommendation system, a vector database was probably working behind the scenes.&lt;/p&gt;

&lt;p&gt;I also created an interactive visual walkthrough of embeddings and semantic search on SeeItFlow:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://seeitflow.com/ai/ai-foundations/embeddings-explained" rel="noopener noreferrer"&gt;https://seeitflow.com/ai/ai-foundations/embeddings-explained&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm curious — when did embeddings finally click for you?&lt;/p&gt;

&lt;p&gt;Was it semantic search, RAG, recommendation systems, or something else?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>machinelearning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Your LLM Has Never Read a Word: Tokenization Explained for Developers</title>
      <dc:creator>MANGESH MANDLIK</dc:creator>
      <pubDate>Sat, 19 Sep 2026 09:03:40 +0000</pubDate>
      <link>https://dev.to/mangeshmandlik/your-llm-has-never-read-a-word-tokenization-explained-for-developers-4g9l</link>
      <guid>https://dev.to/mangeshmandlik/your-llm-has-never-read-a-word-tokenization-explained-for-developers-4g9l</guid>
      <description>&lt;p&gt;You type a sentence into ChatGPT and it looks like normal English.&lt;/p&gt;

&lt;p&gt;The model doesn't see it that way.&lt;/p&gt;

&lt;p&gt;In fact, it never sees words at all. Before the model processes anything, your text is converted into a sequence of numbers. That's what the model actually works with.&lt;/p&gt;

&lt;p&gt;When I first started learning how LLMs work, I kept hearing terms like &lt;em&gt;tokens&lt;/em&gt;, &lt;em&gt;context windows&lt;/em&gt;, and &lt;em&gt;token limits&lt;/em&gt;. I understood them individually, but I didn't really appreciate how much of modern AI engineering revolves around tokens until I started building visual explanations for them.&lt;/p&gt;

&lt;p&gt;Once you understand tokenization, a lot of things suddenly make sense:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why AI APIs charge per token&lt;/li&gt;
&lt;li&gt;Why long prompts cost more&lt;/li&gt;
&lt;li&gt;Why context windows have limits&lt;/li&gt;
&lt;li&gt;Why RAG systems need chunking&lt;/li&gt;
&lt;li&gt;Why responses are generated gradually instead of all at once&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's start from the beginning.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Token?
&lt;/h2&gt;

&lt;p&gt;A token is the basic unit of text that a language model processes.&lt;/p&gt;

&lt;p&gt;People often assume a token is a word, but that's not quite true. In practice, tokens are usually pieces of words.&lt;/p&gt;

&lt;p&gt;For example, before the model sees:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, world!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it gets transformed into something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;["Hello", ",", " world", "!"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those tokens are then mapped to integer IDs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[15496, 11, 995, 0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At that point, the original text is gone. The model only sees those numbers.&lt;/p&gt;

&lt;p&gt;A few terms are worth knowing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Token&lt;/strong&gt; — a text fragment that maps to an integer&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tokenizer&lt;/strong&gt; — the component that splits text into tokens&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vocabulary&lt;/strong&gt; — the collection of all known tokens&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context Window&lt;/strong&gt; — the maximum number of tokens a model can process at once&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The analogy that helped me most was this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tokens are to LLMs what bytes are to computers.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We interact with files, images, and videos, but computers ultimately operate on bytes. In the same way, we interact with words and sentences, but language models operate on tokens.&lt;/p&gt;

&lt;p&gt;One subtle but important detail: the tokenizer is a separate preprocessing step. It is not part of the neural network itself. The same tokenizer used during training must also be used during inference.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Not Just Use Words?
&lt;/h2&gt;

&lt;p&gt;At first, giving every word its own ID sounds reasonable.&lt;/p&gt;

&lt;p&gt;The problem is that language is messy.&lt;/p&gt;

&lt;p&gt;Think about words like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;play
played
playing
player
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Should each be stored separately?&lt;/p&gt;

&lt;p&gt;Then there are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Typos&lt;/li&gt;
&lt;li&gt;URLs&lt;/li&gt;
&lt;li&gt;Programming code&lt;/li&gt;
&lt;li&gt;Emojis&lt;/li&gt;
&lt;li&gt;Newly invented words&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A pure word-based vocabulary quickly becomes enormous.&lt;/p&gt;

&lt;p&gt;The opposite approach is character-level tokenization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;c a t
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That solves the vocabulary problem, but creates a different one. Sequences become much longer, making training and inference significantly less efficient.&lt;/p&gt;

&lt;p&gt;Modern tokenizers use a compromise.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Middle Ground: Subword Tokenization
&lt;/h2&gt;

&lt;p&gt;Most modern models use some form of subword tokenization.&lt;/p&gt;

&lt;p&gt;Common words often remain intact, while uncommon words are broken into smaller reusable pieces.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;unbelievable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;might become:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;["un", "believ", "able"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows a relatively small vocabulary to represent almost any text.&lt;/p&gt;

&lt;p&gt;The exact algorithm varies between models. You'll often hear names like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;BPE (Byte Pair Encoding)&lt;/li&gt;
&lt;li&gt;WordPiece&lt;/li&gt;
&lt;li&gt;SentencePiece&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The details differ, but the underlying idea is the same: reuse smaller pieces instead of storing every possible word.&lt;/p&gt;




&lt;h2&gt;
  
  
  See It Yourself
&lt;/h2&gt;

&lt;p&gt;One of the easiest ways to understand tokenization is to experiment with it.&lt;/p&gt;

&lt;p&gt;Using OpenAI's &lt;code&gt;tiktoken&lt;/code&gt; library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;tiktoken&lt;/span&gt;

&lt;span class="n"&gt;enc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tiktoken&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_encoding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cl100k_base&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The quick brown fox&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;ids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;enc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;enc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now try:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A long technical term&lt;/li&gt;
&lt;li&gt;Source code&lt;/li&gt;
&lt;li&gt;Emojis&lt;/li&gt;
&lt;li&gt;Hindi text&lt;/li&gt;
&lt;li&gt;Japanese text&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You'll quickly notice that token counts vary much more than most people expect.&lt;/p&gt;

&lt;p&gt;A sentence with the same number of characters can produce very different token counts depending on the content.&lt;/p&gt;




&lt;h2&gt;
  
  
  Context Windows Are Measured in Tokens
&lt;/h2&gt;

&lt;p&gt;This is one of the most common misunderstandings around LLMs.&lt;/p&gt;

&lt;p&gt;When a model advertises a large context window, that number refers to tokens, not words.&lt;/p&gt;

&lt;p&gt;Everything shares that budget:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;System prompts&lt;/li&gt;
&lt;li&gt;Conversation history&lt;/li&gt;
&lt;li&gt;Retrieved documents&lt;/li&gt;
&lt;li&gt;User messages&lt;/li&gt;
&lt;li&gt;Model responses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the limit is reached, something has to be removed or the request fails.&lt;/p&gt;

&lt;p&gt;Modern models support context windows ranging from hundreds of thousands to over a million tokens, but the exact numbers change frequently as new models are released.&lt;/p&gt;

&lt;p&gt;As a rough rule of thumb:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;100 tokens ≈ 75 words&lt;/li&gt;
&lt;li&gt;1,000 tokens ≈ 750 words&lt;/li&gt;
&lt;li&gt;100,000 tokens ≈ 75,000 words&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This becomes particularly important when you're working with large documents. A PDF that looks manageable to a human can easily consume a significant portion of the available context.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Tokens Matter in Production
&lt;/h2&gt;

&lt;p&gt;For most engineers, tokenization becomes important when real-world constraints appear.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cost
&lt;/h3&gt;

&lt;p&gt;Most AI APIs charge based on token usage.&lt;/p&gt;

&lt;p&gt;More input tokens increase prompt costs.&lt;/p&gt;

&lt;p&gt;More output tokens increase generation costs.&lt;/p&gt;

&lt;p&gt;Small inefficiencies can become surprisingly expensive when requests scale.&lt;/p&gt;

&lt;h3&gt;
  
  
  Latency
&lt;/h3&gt;

&lt;p&gt;Longer prompts require more computation before the model can start generating a response.&lt;/p&gt;

&lt;p&gt;Longer outputs require more generation steps.&lt;/p&gt;

&lt;p&gt;More tokens generally means more waiting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Memory
&lt;/h3&gt;

&lt;p&gt;Long contexts require larger attention caches and more GPU memory.&lt;/p&gt;

&lt;p&gt;This becomes one of the major engineering challenges behind large-context models.&lt;/p&gt;

&lt;h3&gt;
  
  
  Throughput
&lt;/h3&gt;

&lt;p&gt;If each request contains fewer tokens, the same infrastructure can handle more requests.&lt;/p&gt;

&lt;p&gt;That's why production teams often track token usage as closely as API latency.&lt;/p&gt;




&lt;h2&gt;
  
  
  Responses Are Generated One Token at a Time
&lt;/h2&gt;

&lt;p&gt;This was probably the biggest surprise for me.&lt;/p&gt;

&lt;p&gt;When ChatGPT produces a paragraph, it isn't generating the entire paragraph at once.&lt;/p&gt;

&lt;p&gt;It predicts a single token.&lt;/p&gt;

&lt;p&gt;Then another.&lt;/p&gt;

&lt;p&gt;Then another.&lt;/p&gt;

&lt;p&gt;Each new token becomes part of the context for predicting the next one.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"The capital of France is" → "Paris"
"The capital of France is Paris" → "."
"The capital of France is Paris." → " It"
"The capital of France is Paris. It" → " is"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Streaming makes the process feel instant, but under the hood it's a sequence of individual predictions.&lt;/p&gt;

&lt;p&gt;That's one reason longer responses take longer to generate.&lt;/p&gt;




&lt;h2&gt;
  
  
  The 100-Page PDF Problem
&lt;/h2&gt;

&lt;p&gt;This is where tokenization stops being theory and becomes a practical engineering problem.&lt;/p&gt;

&lt;p&gt;Suppose you have a 100-page PDF and want an LLM to answer questions about it.&lt;/p&gt;

&lt;p&gt;You can't simply send the entire document every time.&lt;/p&gt;

&lt;p&gt;The document may contain tens of thousands of tokens, leaving little room for prompts or responses.&lt;/p&gt;

&lt;p&gt;This is why RAG systems exist.&lt;/p&gt;

&lt;p&gt;Instead of sending everything:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Split the document into chunks&lt;/li&gt;
&lt;li&gt;Retrieve only relevant sections&lt;/li&gt;
&lt;li&gt;Send those sections to the model&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once you start thinking in tokens rather than pages or words, these design decisions become much easier to reason about.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem&lt;/th&gt;
&lt;th&gt;Token-Related Cause&lt;/th&gt;
&lt;th&gt;Typical Fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PDF won't fit&lt;/td&gt;
&lt;td&gt;Too many tokens in one request&lt;/td&gt;
&lt;td&gt;Chunk into token-sized pieces&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API bill too high&lt;/td&gt;
&lt;td&gt;Too many tokens per request&lt;/td&gt;
&lt;td&gt;Compress prompts, cache, smaller models&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Slow responses&lt;/td&gt;
&lt;td&gt;Long output sequences&lt;/td&gt;
&lt;td&gt;Stream and cap output length&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Context keeps truncating&lt;/td&gt;
&lt;td&gt;Conversation history grows&lt;/td&gt;
&lt;td&gt;Summarize older turns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RAG results don't fit&lt;/td&gt;
&lt;td&gt;Retrieved chunks exceed context&lt;/td&gt;
&lt;td&gt;Keep top-K within token budget&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Common Misconceptions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  One Token Equals One Word
&lt;/h3&gt;

&lt;p&gt;Not necessarily. Some words are one token. Others may be several.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characters and Tokens Are the Same Thing
&lt;/h3&gt;

&lt;p&gt;They're related, but not equivalent. Five characters can be one token, while a single emoji may become multiple tokens.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Model Reads Text Directly
&lt;/h3&gt;

&lt;p&gt;The model ultimately operates on numerical representations derived from token IDs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Long Prompts Are Basically Free
&lt;/h3&gt;

&lt;p&gt;Prompt length affects cost, latency, memory usage, and throughput.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;The more I learn about LLMs, the more I feel that tokenization is one of the foundational concepts people skip over too quickly.&lt;/p&gt;

&lt;p&gt;It's not just a preprocessing step.&lt;/p&gt;

&lt;p&gt;It influences pricing, context limits, performance, retrieval systems, and even the way responses are generated.&lt;/p&gt;

&lt;p&gt;Once you start looking at AI systems through the lens of tokens, many of the engineering trade-offs become much easier to understand.&lt;/p&gt;

&lt;p&gt;While building the AI Foundations section on SeeItFlow, I created an animated walkthrough showing the entire flow:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Text → Tokens → Token IDs → Embeddings → Transformer → Response&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of reading about tokenization, you can watch the process happen step by step and see how the same input text gets transformed before reaching the model.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://seeitflow.com/ai/ai-foundations/tokens-explained" rel="noopener noreferrer"&gt;https://seeitflow.com/ai/ai-foundations/tokens-explained&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next logical question is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If token IDs are just numbers, how do they become something that captures meaning?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's where embeddings come in.&lt;/p&gt;

&lt;p&gt;I'll cover that in the next article.&lt;/p&gt;




&lt;p&gt;I built an interactive visualization of this entire process on &lt;strong&gt;SeeItFlow&lt;/strong&gt;, where you can watch text become tokens, tokens become IDs, and responses get generated step by step.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://seeitflow.com" rel="noopener noreferrer"&gt;https://seeitflow.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What was the moment tokenization finally clicked for you? Let me know in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>machinelearning</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
