<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Varunprasath on Medium]]></title>
        <description><![CDATA[Stories by Varunprasath on Medium]]></description>
        <link>https://medium.com/@varunprasath184?source=rss-0503416132e5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mw7rvQcgAG_uCwzL</url>
            <title>Stories by Varunprasath on Medium</title>
            <link>https://medium.com/@varunprasath184?source=rss-0503416132e5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:31:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@varunprasath184/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Counting Words to Understanding Meaning: A Complete Guide to Text Vectorization in NLP]]></title>
            <link>https://medium.com/@varunprasath184/from-counting-words-to-understanding-meaning-a-complete-guide-to-text-vectorization-in-nlp-bb90bce9f83e?source=rss-0503416132e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb90bce9f83e</guid>
            <dc:creator><![CDATA[Varunprasath]]></dc:creator>
            <pubDate>Thu, 16 Apr 2026 07:50:36 GMT</pubDate>
            <atom:updated>2026-04-16T07:51:50.997Z</atom:updated>
            <content:encoded><![CDATA[<p>Natural Language Processing (NLP) starts with a simple but critical challenge: <strong>how do we convert text into numbers so machines can understand it?</strong></p><p>Over the years, several techniques have evolved — from simple word counting to advanced semantic embeddings. In this article, we’ll walk through five major methods, understand how they work, and when to use each.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hiZKm68DI2ZmzMvcqAQ-Tg.png" /></figure><h3>1. Bag of Words (BoW)</h3><h3>Definition</h3><p>Bag of Words is the simplest technique that converts text into numbers by <strong>counting how many times each word appears</strong>.</p><h3>How It Works</h3><p>You first create a vocabulary of all unique words, then represent each document as a vector of counts.</p><h3>Example</h3><p><strong>Vocabulary:</strong><br>[batman, crime, hero, ocean, family, adventure]</p><p><strong>Documents:</strong></p><ul><li>The Dark Knight → “batman crime hero”</li><li>Finding Nemo → “ocean family adventure”</li></ul><p><strong>Vectors:</strong></p><ul><li>Dark Knight → [1, 1, 1, 0, 0, 0]</li><li>Finding Nemo → [0, 0, 0, 1, 1, 1]</li></ul><h3>Why Use It</h3><ul><li>Simple and fast</li><li>Easy to implement</li></ul><h3>Limitations</h3><ul><li>Ignores word order</li><li>Treats all words equally</li></ul><h3>When to Use</h3><ul><li>Small datasets</li><li>Baseline models</li></ul><h3>2. TF-IDF (Term Frequency — Inverse Document Frequency)</h3><h3>Definition</h3><p>TF-IDF improves BoW by assigning <strong>higher importance to rare words</strong> and reducing the weight of common words.</p><h3>Formula</h3><p>TF-IDF=TF×log(N / df​)</p><h3>Example</h3><p><strong>Documents:</strong></p><ol><li>“batman fights crime”</li><li>“crime thriller movie”</li><li>“family movie fun”</li></ol><p>For the word <strong>“crime”</strong>:</p><ul><li>Appears in 2 documents → low importance</li></ul><p>For <strong>“batman”</strong>:</p><ul><li>Appears in 1 document → high importance</li></ul><h3>Why Use It</h3><ul><li>Removes noise from common words</li><li>Highlights meaningful terms</li></ul><h3>When to Use</h3><ul><li>Search engines</li><li>Document similarity tasks</li></ul><h3>3. Word2Vec</h3><h3>Definition</h3><p>Word2Vec is a neural network-based approach that learns <strong>word meaning based on context</strong>.</p><h3>How It Works</h3><p>It predicts:</p><ul><li>CBOW: context → word</li><li>Skip-gram: word → context</li></ul><h3>Example</h3><p>From sentences like:</p><ul><li>“batman fights crime”</li><li>“joker is villain”</li></ul><p>The model learns vectors like:</p><ul><li>batman → [0.2, 0.8, 0.5]</li><li>joker → [0.21, 0.79, 0.48]</li></ul><p>Similar words have similar vectors.</p><h3>Why Use It</h3><ul><li>Captures semantic meaning</li><li>Understands relationships between words</li></ul><h3>When to Use</h3><ul><li>NLP tasks</li><li>Recommendation systems</li></ul><h3>4. GloVe (Global Vectors)</h3><h3>Definition</h3><p>GloVe captures meaning using <strong>global word co-occurrence statistics</strong>.</p><h3>How It Works</h3><p>It builds a matrix showing how often words appear together and factorizes it.</p><h3>Example</h3><p>Wordwatericesteamice10–1steam91 —</p><p>Learns relationships like:</p><ul><li>ice ≈ cold</li><li>steam ≈ hot</li></ul><h3>Why Use It</h3><ul><li>Uses global context</li><li>Captures deeper relationships</li></ul><h3>When to Use</h3><ul><li>Pretrained embeddings</li><li>Semantic understanding tasks</li></ul><h3>5. FastText</h3><h3>Definition</h3><p>FastText improves embeddings by using <strong>character-level n-grams instead of whole words</strong>.</p><h3>How It Works</h3><p>Words are broken into sub-parts.</p><h3>Example</h3><p>Word: <strong>“running”</strong><br>N-grams:<br>run, unn, nni, nin, ing</p><p>Vector = average of all n-grams</p><p>Works even for:</p><ul><li>“runing” (typo)</li><li>“runner”</li></ul><h3>Why Use It</h3><ul><li>Handles unknown words</li><li>Works well with typos</li></ul><h3>When to Use</h3><ul><li>Real-world noisy data</li><li>Morphological languages</li></ul><h3>Cosine Similarity (How We Compare Text)</h3><h3>Definition</h3><p>Cosine similarity measures the <strong>angle between two vectors</strong>, not their distance.</p><h3>Formula</h3><p><strong>cos(θ)=A⋅B​ /∣A∣∣B∣</strong></p><h3>Example</h3><ul><li>Short review → [1, 1]</li><li>Long review → [5, 3]</li></ul><p>👉 Cosine similarity = <strong>0.97 (very similar)</strong></p><h3>Why Use It</h3><ul><li>Ignores length differences</li><li>Focuses on meaning</li></ul><h3>When to Use</h3><ul><li>Text similarity</li><li>Recommendation systems</li></ul><h3>Final Intuition (Interview Gold)</h3><ul><li><strong>BoW &amp; TF-IDF → Word Matching</strong></li><li><strong>Word2Vec, GloVe, FastText → Meaning Matching</strong></li></ul><h3>One-Line Differences</h3><ul><li>BoW → Counts words</li><li>TF-IDF → Weighs important words</li><li>Word2Vec → Learns meaning from context</li><li>GloVe → Learns meaning from global relationships</li><li>FastText → Understands word parts</li></ul><h3>Conclusion</h3><p>The evolution from BoW to FastText shows a clear shift:</p><p>👉 From <strong>counting words</strong><br>👉 To <strong>understanding meaning</strong></p><p>If you’re building real-world NLP systems today, <strong>embedding-based methods (Word2Vec, GloVe, FastText)</strong> are essential — while <strong>TF-IDF remains a strong baseline</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb90bce9f83e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>