<?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 Tahsir Ahmed Munna on Medium]]></title>
        <description><![CDATA[Stories by Tahsir Ahmed Munna on Medium]]></description>
        <link>https://medium.com/@tahsirmunna?source=rss-fee8a217c172------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2x6vwI0IemRiT-i5kii-Sw.jpeg</url>
            <title>Stories by Tahsir Ahmed Munna on Medium</title>
            <link>https://medium.com/@tahsirmunna?source=rss-fee8a217c172------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 16:51:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tahsirmunna/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[Finding Similarity in the Feature Space—How Vision–Language Models Understand Images and Text: An…]]></title>
            <link>https://medium.com/@tahsirmunna/finding-similarity-in-the-feature-space-how-vision-language-models-understand-images-and-text-an-4bdd75e91fb0?source=rss-fee8a217c172------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bdd75e91fb0</guid>
            <category><![CDATA[multimodal]]></category>
            <category><![CDATA[vision-language-model]]></category>
            <category><![CDATA[semantic-similarity]]></category>
            <dc:creator><![CDATA[Tahsir Ahmed Munna]]></dc:creator>
            <pubDate>Thu, 14 Aug 2025 15:10:59 GMT</pubDate>
            <atom:updated>2025-08-14T15:10:59.448Z</atom:updated>
            <content:encoded><![CDATA[<h3>Finding Similarity in the Feature Space—How Vision–Language Models Understand Images and Text: An easy explanation</h3><h3>1. What is the Feature Space?</h3><p>Imagine you have a <strong>map</strong> where every possible image and text description can be placed as a <strong>point</strong>.<br> This map isn’t 2D like a city map — it can have hundreds or thousands of dimensions.</p><p>In <strong>vision–language models</strong>:</p><ul><li><strong>Images</strong> are processed by a <strong>vision encoder</strong> (like a CNN or Vision Transformer) into a <strong>vector</strong> — a long list of numbers.</li><li><strong>Texts</strong> are processed by a <strong>language encoder</strong> (like BERT) into another <strong>vector</strong> of the same length.</li></ul><p>Both vectors reside in the <strong>same feature space,</strong> allowing for direct comparison.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6e6YdGGuqnXKUNHcl_Rnfg.png" /></figure><p><strong>Example:</strong></p><ul><li>Image: 🐶 <em>Dog running in the park</em> → Encoded to a vector vvv</li><li>Text: “A dog running in the park” → Encoded to a vector ttt</li><li>Both<em> v</em> and <em>t</em> might be <strong>512-dimensional vectors</strong> like:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0-svjns5LTASpMtZBH02hg.png" /></figure><h3>2. What Does “Similar” Mean in This Space?</h3><p>In the feature space:</p><ul><li><strong>Similar</strong> = vectors are <strong>close together</strong>.</li><li><strong>Dissimilar</strong> = vectors are <strong>far apart</strong>.</li></ul><p>Closeness is measured using a <strong>similarity function</strong>, usually <strong>cosine similarity</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9mg3OQ5x-vykHMdZ5Sib1Q.png" /></figure><h3>3. How Do Models Decide Something is Semantically Similar?</h3><p><strong>Semantic similarity</strong> means the <strong>meaning</strong> matches, not just the words or pixels.</p><p>The encoders are trained on <strong>millions of image–text pairs</strong> so that:</p><ul><li>If the text describes what’s in the image, their vectors move closer.</li><li>If the text doesn’t describe the image, their vectors move apart.</li></ul><p>Over time, the model learns:</p><ul><li>“Dog” in text ↔ actual dogs in images</li><li>“Running” in text ↔ motion patterns in images</li><li>Relationships like <em>“dog running in park” ↔ green grass + motion + dog shape</em></li></ul><p>This is why two captions like</p><ul><li>“A dog running in the park”</li><li>“A canine sprinting on the grass”</li></ul><p>will both be <strong>close</strong> to the same image in feature space—they mean the same thing.</p><h3>4. How is Similarity Calculated Between Image and Text?</h3><p><strong>Step-by-step:</strong></p><ol><li><strong>Image Encoding</strong></li></ol><ul><li>Vision encoder extracts <strong>visual features</strong> → vector <em>v</em></li><li>Sometimes includes <strong>patch embeddings</strong> (small sections of the image). <em>Example: 224×224 image → 16×16 patches → 14×14 grid → 196 patch embeddings.</em></li></ul><p><strong>2. Text Encoding</strong></p><ul><li>Language encoder extracts <strong>semantic features</strong> → vector <em>t</em></li><li>Can also output embeddings for <strong>each word</strong> and for the <strong>whole sentence</strong>.</li></ul><p><strong>3. Mapping to the Same Space</strong></p><ul><li>Both vectors are projected to the same <strong>dimension</strong> (e.g., 512).</li><li>This allows <strong>direct similarity calculation</strong>.</li></ul><ol><li><strong>Similarity Calculation</strong></li></ol><ul><li><strong>Global similarity</strong>: Compare the whole-image vector with the whole-sentence vector.</li><li><strong>Local similarity</strong>: Compare each image patch with each word.</li></ul><p><em>Useful for grounding tasks (e.g., “find the cat” in an image).</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d5bI6aaATS3ZUyL35BvawQ.png" /></figure><h3>5. Why This Works</h3><p>Vision–language models trained with <a href="https://medium.com/@tahsirmunna/contrastive-learning-in-vision-language-models-a-simple-explanation-8672e5ecda95"><strong>contrastive learning</strong></a>:</p><ul><li>Pull matching pairs (image ↔ correct caption) closer.</li><li>Push mismatching pairs (image ↔ wrong caption) apart.</li></ul><p>This way, “semantic meaning” becomes <strong>geometry</strong> in the feature space — similar meanings are literally <strong>closer together</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bdd75e91fb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Contrastive Learning in Vision–Language Models — A Simple Explanation]]></title>
            <link>https://medium.com/@tahsirmunna/contrastive-learning-in-vision-language-models-a-simple-explanation-8672e5ecda95?source=rss-fee8a217c172------2</link>
            <guid isPermaLink="false">https://medium.com/p/8672e5ecda95</guid>
            <category><![CDATA[multimodal]]></category>
            <category><![CDATA[vision-language-model]]></category>
            <category><![CDATA[constractive-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Tahsir Ahmed Munna]]></dc:creator>
            <pubDate>Thu, 14 Aug 2025 14:35:21 GMT</pubDate>
            <atom:updated>2025-08-14T14:35:21.072Z</atom:updated>
            <content:encoded><![CDATA[<h3>Contrastive Learning in Vision–Language Models — A Simple Explanation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0eUZK2fklXN9iQwysDAx-w.png" /><figcaption>Constructive Learning</figcaption></figure><h3>1. What is Contrastive Learning?</h3><p>Contrastive learning is a machine learning approach that focuses on <strong>distinguishing similarity and dissimilarity</strong> between data samples.<br> The goal is to <strong>bring similar data points closer</strong> in a shared feature space while <strong>pushing dissimilar data points apart</strong>. This is especially useful in scenarios where data comes from <strong>different modalities</strong> (e.g., images and text).</p><h3>2. Why Contrastive Learning Matters in Vision–Language Models</h3><p>In <strong>vision–language models</strong>, data points usually consist of <strong>image–text pairs</strong>.</p><ul><li><strong>Matched pair example:</strong> An image of a dog running on grass + the caption <em>“A dog running on grass”</em>.</li><li><strong>Mismatched pair example:</strong> The same dog image paired with the caption <em>“A cat sleeping on the sofa”</em>.</li></ul><p>A model trained with contrastive learning will:</p><ul><li>Pull matched pairs <strong>closer together</strong> in the feature space.</li><li>Push mismatched pairs <strong>further apart</strong> in the feature space.</li></ul><p>This is done using a <strong>contrastive loss function</strong>, such as <a href="https://medium.com/@mlshark/infonce-explained-in-details-and-implementations-902f28199ce6"><strong><em>InfoNCE loss</em></strong></a><em> </em>, which is designed to <strong>maximize similarity between correct matches and minimize similarity between incorrect matches</strong>.</p><h3>3. How It Works</h3><p>Imagine we map both images and texts into the <strong>same vector space</strong>:</p><ul><li>If an image and caption <strong>match</strong>, their vector representations should be <strong>close</strong> (high similarity).</li><li>If they don’t match, their vectors should be <strong>far apart</strong> (low similarity).</li></ul><p><strong>Example:</strong></p><ul><li>Image: 🐶 Dog running in the park</li><li>Text A (correct): “A dog running in the park” → similarity score <strong>0.92</strong> (high)</li><li>Text B (incorrect): “A cat sleeping indoors” → similarity score <strong>0.05</strong> (low)</li></ul><h3>4. Applications in Vision–Language AI</h3><p>Contrastive learning is a foundation for many multimodal tasks:</p><ul><li><strong>Image Captioning</strong> — Generating accurate captions for images.</li><li><strong>Visual Question Answering (VQA)</strong> — Answering questions about an image.</li><li><strong>Cross–Modal Retrieval</strong> — Finding images from text queries or finding captions from images.</li><li><strong>Vision–Language Grounding in Medical AI</strong> — Detecting abnormalities in X-rays, CT scans, or MRIs by linking medical images to diagnostic text descriptions.</li></ul><p><strong>Medical Example:</strong></p><ul><li>Input Image: Chest X-ray showing pneumonia.</li><li>Correct Caption: “Opacity in the lower right lung consistent with pneumonia.”</li><li>Incorrect Caption: “No abnormality detected in the chest.”<br> Contrastive learning ensures the correct caption is <strong>strongly associated</strong> with the image while rejecting unrelated captions.</li></ul><h3>5. Why It’s Powerful</h3><p>The impact of contrastive learning on vision–language models is profound because it:</p><ul><li>Improves <strong>accuracy</strong> in multimodal understanding.</li><li>Enables <strong>generalisation</strong> to new, unseen data.</li><li>Enhances <strong>semantic alignment</strong> between images and text.</li><li>Reduces errors in complex scenarios where multiple objects, actions, or details are present.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8672e5ecda95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Build Triples for Knowledge Graph [Part 1]]]></title>
            <link>https://medium.com/@tahsirmunna/how-to-build-triples-for-knowledge-graph-part-1-9a2f3105a4a1?source=rss-fee8a217c172------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a2f3105a4a1</guid>
            <category><![CDATA[triples]]></category>
            <category><![CDATA[machine-learning-python]]></category>
            <category><![CDATA[gk]]></category>
            <category><![CDATA[knowledge-graph]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Tahsir Ahmed Munna]]></dc:creator>
            <pubDate>Tue, 16 Jun 2020 20:40:47 GMT</pubDate>
            <atom:updated>2020-06-16T21:27:38.011Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Create Triples for Knowledge Graph [Part 1]</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BwnlV5Zf_o0h3bpT7dmk7Q.png" /></figure><p>Hello Tech Lovers!! This is my very first write. I am very much frequent user of ‘Medium’. I learn lots of unknown and known lesson in different field like Machine learning, Programming, Math etc. from Medium. Now, I realized I have to contribute something for all. It’s a kind of responsibility. How ever, today I am going to discuss a very interesting and state-of-the-art data representing technique called ‘Knowledge Graph(KG)’ and it’s data format called triples. This is a very basic concept of KG but important. So, Let’s start ☺</p><p><strong>Knowledge Graph:</strong> A Knowledge Graph is a model of a knowledge domain created by subject-matter experts with the help of intelligent machine learning algorithms. It provides a structure and common interface for all of your data and enables the creation of smart multilateral relations throughout your databases. Structured as an additional virtual data layer, the Knowledge Graph lies on top of your existing databases or data sets to link all your data together at scale – be it structured or unstructured [For more information visit <a href="https://www.poolparty.biz/what-is-a-knowledge-graph"><strong>Here</strong></a>].</p><p><strong>Triples: </strong>Triples is data representing structure of KG. This is a kind of sentence making like ‘subject- predicate-object’. So, making a sentence we need to maintain these three pattern to make the sentence meaningful. KG has also the same kind of format that we can present it like ‘<strong>Entity — Relation — Entity or Note- Edge- Node’.</strong> This is the basic data pattern for KG. Now, We are trying to build this data format or structure for KG by simple python programming.</p><p><strong>Implementation</strong></p><p>Let’s make a very simple implementation for understanding. In part 2, I will implement a complete project like Link prediction or Clustering by KG embeddings.</p><p>Code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*YT3IpXcKMXdnbjGXc6Y-CA.png" /><figcaption><strong>Make a sample dataset</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*ijTxcW4maCpA_AkSt6JINQ.png" /><figcaption><strong>Making triples using for loop in python</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*SAQ_DMmp0iYAAtIi5R_cLA.png" /><figcaption><strong>Convert the triples in data frame format. You can see here triples format like Subject — predicate-Object (Entity-Relation-Entity or Node-Edge-Node)</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*dXmfr2bBY5tOvVQAMeYE4g.png" /><figcaption><strong>By using </strong><a href="https://networkx.github.io/"><strong>Networkx</strong></a><strong> package we can plot our Knowledge Graph</strong></figcaption></figure><p>You can find the code in <a href="https://github.com/tahsirahmed/Tutorial/blob/master/KG_triples_making.ipynb">GitHub</a>.</p><p>Thanks for reading and stay tuned :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a2f3105a4a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>