<?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 Surabiga Thangarajah on Medium]]></title>
        <description><![CDATA[Stories by Surabiga Thangarajah on Medium]]></description>
        <link>https://medium.com/@surabythangarajah?source=rss-2801fb33b4ef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*kXshkcZ9Yu9P-TY9</url>
            <title>Stories by Surabiga Thangarajah on Medium</title>
            <link>https://medium.com/@surabythangarajah?source=rss-2801fb33b4ef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 08:06:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@surabythangarajah/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[LLM Series Chapter 05: Transformer Architecture-The Breakthrough That Revolutionized AI]]></title>
            <link>https://medium.com/@surabythangarajah/llm-series-chapter-05-transformer-architecture-the-breakthrough-that-revolutionized-ai-36051e1f4efb?source=rss-2801fb33b4ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/36051e1f4efb</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Surabiga Thangarajah]]></dc:creator>
            <pubDate>Sun, 02 Aug 2026 12:36:59 GMT</pubDate>
            <atom:updated>2026-08-02T12:36:59.636Z</atom:updated>
            <content:encoded><![CDATA[<p>Over the past few chapters, we’ve explored how Large Language Models (LLMs) learn from vast amounts of text and how words are transformed into mathematical representations through <strong>tokenization</strong> and <strong>embeddings</strong>. However, one fundamental question still remains.</p><blockquote><strong><em>How does an LLM understand the relationship between words in a sentence?</em></strong></blockquote><blockquote><strong><em>The animal did not cross the road because it was tired.</em></strong></blockquote><p>As humans, we immediately understand that <strong>“it”</strong> refers to <strong>“the animal.”</strong> We don’t consciously analyze every word.we naturally connect the pronoun with the correct subject using context.</p><p>For computers, this task is far more challenging.Earlier Natural Language Processing (NLP) models struggled to capture long-range relationships between words, especially in lengthy sentences and documents. They processed words one at a time, often forgetting important information as the sequence grew longer.The breakthrough came in <strong>2017</strong> with the publication of the landmark paper <strong>“Attention Is All You Need.”</strong> This paper introduced the <strong>Transformer architecture</strong>, a new way of processing language that replaced sequential computation with <strong>attention mechanisms</strong>, allowing models to understand relationships between all words simultaneously.Today, nearly every modern Large Language Model including GPT, Gemini, Claude, and Llama is built on this architecture.</p><h3>1. Problems Before Transformers</h3><p>Before Transformers, NLP relied heavily on <strong>Recurrent Neural Networks (RNNs)</strong> and later <strong>Long Short-Term Memory (LSTM)</strong> networks.These models process text <strong>one word at a time</strong>, carrying information forward through a hidden state.This approach allowed models to understand sequences but introduced several major limitations.</p><h4>1.Sequential Processing</h4><p>RNNs cannot process all words simultaneously.Every new word must wait until the previous one has been processed.This makes training slow and difficult to parallelize, especially for long documents.</p><h4>2.Slow Training</h4><p>Since each computation depends on the previous step, GPUs cannot efficiently process the entire sequence in parallel.Training very large models becomes time-consuming.</p><h4>3.Forgetting Long Context</h4><p>Perhaps the biggest challenge is remembering information from earlier in a sentence.Although LSTMs improved memory through gating mechanisms, they still processed words sequentially and struggled with very long contexts.Researchers needed a fundamentally different approach.</p><h3>2. Transformer Architecture Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hgY-Zg8Ddo185N53Z-0fKQ.png" /></figure><p>Instead of reading words one after another, Transformers process <strong>all tokens simultaneously</strong>.This allows them to examine relationships between every word in the sentence at the same time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lkY6c8OIOG51yPihBey28g.png" /></figure><h4>Input Text</h4><p>The raw sentence entered by the user.</p><p>Example:</p><blockquote><em>“The animal did not cross the road because it was tired.”</em></blockquote><h4>Tokenization</h4><p>The sentence is divided into tokens.</p><h4>Embeddings</h4><p>Each token is converted into a dense numerical vector representing its semantic meaning.</p><h4>Positional Encoding</h4><p>Unlike RNNs, Transformers process all words simultaneously.To preserve word order, positional information is added to each embedding.Without positional encoding, the model would not distinguish between: Dog bites man and Man bites dog.</p><h4>Self-Attention</h4><p>Every token examines every other token to determine which words are most relevant for understanding its meaning.This is the core innovation of the Transformer.</p><h4>Feed Forward Network</h4><p>The contextual representations produced by attention are refined using fully connected neural network layers.</p><h4>Output Prediction</h4><p>Finally, the model predicts the next token based on everything it has learned.</p><h3>3. Self-Attention: The Heart of the Transformer</h3><p>Self-Attention allows every word to look at every other word in the sentence before deciding what it means.Instead of remembering previous words through hidden states, each token asks:</p><blockquote><em>Which other words should I pay attention to?</em></blockquote><p>This makes it possible to capture both nearby and distant relationships.</p><h4>Query, Key, and Value</h4><p>Self-Attention is built around three learned vectors for every token.</p><p><strong>Query (Q)</strong></p><p>The Query represents what the current token wants to find in other tokens.</p><p><strong>Key (K)</strong></p><p>The Key describes the information each token offers to others.</p><p><strong>Value (V)</strong></p><p>The Value contains the actual contextual information that may be shared.</p><p>The attention mechanism compares <strong>Queries</strong> with <strong>Keys</strong> to determine how much attention should be paid to each token, then combines the corresponding <strong>Values</strong> to produce a richer representation.</p><p>Example</p><blockquote><strong><em>The animal did not cross the road because it was tired.</em></strong></blockquote><p>When the model processes the token it, its Query searches for the most relevant Key. The highest attention score points to animalTherefore, the model understands it as animal rather than another unrelated word.This ability to directly connect distant words is what made Transformers revolutionary.</p><h3>4. Multi-Head Attention</h3><p>One attention calculation is useful, but language contains many different kinds of relationships.Instead of using a single attention mechanism, Transformers perform several attention operations in parallel.Each one is called an <strong>Attention Head</strong>.Different heads learn different aspects of language.</p><h4><strong>Head 1-Grammar</strong></h4><p>Identifies grammatical relationships.</p><p>Example: Subject ↔ Verb</p><h4>Head 2-Word Relationships</h4><p>Captures semantic similarity.</p><p>Example: doctor ↔ hospital</p><h4>Head 3-Long-Range Dependencies</h4><p>Connects words separated by many tokens.</p><p>Example: The animal ... it</p><p>Different heads specialize in different patterns, allowing the model to understand syntax, semantics, and context simultaneously. The outputs of all heads are then combined, giving the Transformer a richer understanding of the sentence than any single attention mechanism could provide.</p><h3>5.Why Transformers Changed AI</h3><p>The Transformer architecture solved many limitations of earlier sequence models.Unlike previous approaches that relied on sequential processing, Transformers introduced parallel processing, allowing models to analyze multiple words simultaneously and significantly improving training efficiency. They enabled faster training through better utilization of GPU computation and overcame the difficulty of remembering long contexts by using self-attention to capture long-range dependencies between words. This improved scalability made it possible to train models with billions of parameters, while their ability to understand complex contextual relationships resulted in significantly stronger language understanding compared to earlier NLP architectures.</p><p>These advantages made it possible to train the massive language models that power today’s AI assistants.</p><p>Example:</p><p>Imagine asking an AI assistant:</p><blockquote><strong><em>“Summarize this 200-page technical document.”</em></strong></blockquote><p>A Transformer can examine relationships across the entire context window, identify the most important sections, and generate a coherent summary without processing the document strictly one word at a time.</p><p>This capability is one of the key reasons why Transformers underpin applications such as:</p><ul><li>Conversational AI</li><li>Machine Translation</li><li>Code Generation</li><li>Document Summarization</li><li>Question Answering</li></ul><h3>Summary</h3><p>The Transformer architecture marked a turning point in the history of Artificial Intelligence. By replacing sequential processing with <strong>self-attention</strong>, it enabled models to understand relationships between all words in a sentence simultaneously. Combined with <strong>multi-head attention</strong>, <strong>positional encoding</strong>, and <strong>feed-forward networks</strong>, Transformers became the foundation of every modern Large Language Model.</p><p>Understanding the Transformer architecture is essential because it explains <strong>how LLMs move beyond simple word prediction to capture context, meaning, and long-range relationships at scale</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36051e1f4efb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LLM Series Chapter 04: From Words to Numbers-How Large Language Models Understand Text]]></title>
            <link>https://medium.com/@surabythangarajah/llm-series-chapter-04-from-words-to-numbers-how-large-language-models-understand-text-e40e30f01bc1?source=rss-2801fb33b4ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/e40e30f01bc1</guid>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Surabiga Thangarajah]]></dc:creator>
            <pubDate>Fri, 31 Jul 2026 15:33:07 GMT</pubDate>
            <atom:updated>2026-07-31T15:33:07.453Z</atom:updated>
            <content:encoded><![CDATA[<p>In the previous chapter, we explored what a Large Language Model (LLM) is and learned that it is essentially a mathematical model trained to recognize patterns in language. However, this raises an important question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p4qiUGhjBfR6f53LuWt-OA.png" /></figure><p>Humans naturally understand words because we associate them with meanings, experiences, and real-world knowledge. When we hear the word <strong>“apple,”</strong> you immediately think of a fruit, while a programmer might think of the technology company. Our brains interpret language effortlessly using context and prior knowledge.Computers, however, cannot understand words directly.To a computer, words such as <strong>“apple,” “computer,”</strong> or <strong>“intelligence”</strong> are simply sequences of characters. A computer cannot assign meaning to these characters unless they are transformed into a mathematical representation that algorithms can process.This transformation is one of the most fundamental ideas behind Large Language Models.</p><p>In this chapter, we will explore how text is transformed into numbers through <strong>tokenization</strong>, how those numbers become meaningful <strong>embeddings</strong>, and how embeddings exist within a <strong>vector space</strong> that enables Large Language Models to understand semantic relationships between words.</p><h3>1. Why Computers Cannot Understand Words Directly?</h3><p>As we discussed in the chapter 1 of this series, Humans process language through meaning.</p><p>For example, when we read:</p><blockquote><strong><em>The cat sat on the mat.</em></strong></blockquote><p>we instantly understand:</p><ul><li>what a cat is,</li><li>what sitting means,</li><li>and that the cat is on top of the mat.</li></ul><p>You never think about individual letters.Computers work very differently.</p><p>They only understand numerical computations. For a computer, the word Cat is simply c, a, t. It is merely a sequence of character codes.A machine cannot reason about language until text is converted into numbers.This leads to the first stage of every LLM pipeline.This simple difference explains why LLMs require tokenization and embeddings before any language understanding can occur.</p><h3>2. Tokenization</h3><p>Before a model can process text, it must first divide it into smaller pieces called <strong>tokens</strong>.A <strong>token</strong> is the smallest unit of text that an LLM processes.</p><p>Depending on the tokenizer, a token might represent:</p><ul><li>a complete word,</li><li>part of a word,</li><li>a punctuation mark,</li><li>or even a single character.</li></ul><p>For example: Artificial Intelligence might become [“Artificial”, “Intelligence”] or [“Art”, “ificial”, “Intelligence”] depending on the tokenizer.Tokens are not fixed,they depend on the tokenization algorithm used by the model.</p><h4>Vocabulary</h4><p>Every LLM maintains a predefined <strong>vocabulary</strong>.A vocabulary is simply the complete list of tokens that the model recognizes.Instead of storing every possible word in every language, modern LLMs store a carefully selected vocabulary of common words, subwords, punctuation, and symbols.Every token in the vocabulary is assigned a unique numerical identifier.Once text has been split into tokens, each token is converted into its corresponding <strong>Token ID</strong>.</p><p>Example: Artificial Intelligence</p><p>might become: Artificial : 4821 , Intelligence: 7643</p><p>The sequence becomes: [4821, 7643]</p><p>At this stage, the computer no longer sees words it sees only numbers.</p><h4>Token Limits</h4><p>Every LLM has a maximum number of tokens it can process at one time.</p><p>This is known as the <strong>context window</strong>.</p><p>Examples:</p><ul><li>8K tokens</li><li>32K tokens</li><li>128K tokens</li><li>1M+ tokens (for some modern models)</li></ul><p>If the input exceeds this limit, older tokens must be removed or summarized before new ones can be processed.</p><p>Token limits directly affect:</p><ul><li>long conversations</li><li>document analysis</li><li>Retrieval-Augmented Generation (RAG).</li></ul><h4>Common Tokenization Algorithms</h4><p>Different LLMs use different tokenization strategies.</p><p>The three most common algorithms are:</p><h4>1.Byte Pair Encoding (BPE)</h4><p>BPE starts with individual characters and repeatedly merges frequently occurring character combinations.</p><p>For example:</p><p>play<br>playing<br>played<br>player</p><p>The tokenizer learns common fragments such as:</p><p>play<br>ing<br>er<br>ed</p><p>Instead of storing every possible word, it stores reusable pieces.</p><p>This greatly reduces vocabulary size.Models using BPE include GPT models.</p><h4>2.WordPiece</h4><p>WordPiece also splits words into subword units.However, unlike BPE, it chooses subwords that maximize prediction performance during training.</p><p>Example: Unbelievable</p><p>learns like:</p><p>un<br>believ<br>able</p><p>This allows models to understand unseen words by combining familiar pieces.WordPiece is widely used in BERT.</p><h4>3.SentencePiece</h4><p>SentencePiece treats text as a raw sequence of characters without requiring spaces between words.This makes it especially effective for multilingual languages.It is commonly used in models such as T5 and Llama.</p><h3>3. Embeddings</h3><p>Token IDs are only identifiers.The number: 7643, contains no information about meaning.The model therefore converts every token into an <strong>embedding</strong>.An embedding is a dense numerical vector representing the semantic meaning of a token.</p><p>Instead of:</p><p>King :- 4821</p><p>the model creates something like:</p><p>King:- [0.21, 0.56, -0.87, 0.42, …]</p><p>These vectors may contain hundreds or even thousands of numerical dimensions.</p><h4>Why Embeddings Matter?</h4><p>Embeddings allow the model to capture relationships between words.Words with similar meanings produce similar vectors.</p><p>For example: King is mathematically close to Queen,while Banana is much farther away.The model therefore learns meaning through geometry rather than dictionary definitions.</p><h4>Semantic Similarity</h4><p>Imagine a map where every word occupies a position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/0*tu_9PQaNP-Xn1bw_.png" /></figure><p>The closer two vectors are, the more semantically similar they are. This is called <strong>semantic similarity</strong>.</p><h4>Vector Space</h4><p>The multidimensional environment where embeddings exist is known as <strong>vector space</strong>.Every word, sentence, paragraph, or document can be represented as a point within this space.Instead of comparing exact words, LLMs compare distances between vectors.</p><p>This allows them to recognize:</p><ul><li>synonyms</li><li>similar ideas</li><li>related concepts</li><li>contextual meaning</li></ul><h4>Vector Databases</h4><p>A vector database stores embeddings instead of plain text.</p><p>Examples:</p><ul><li>ChromaDB</li><li>Pinecone</li><li>Weaviate</li><li>Milvus</li><li>FAISS</li></ul><p>Instead of searching for exact keywords, vector databases search for the most semantically similar vectors.</p><h4>Semantic Search</h4><p>Traditional keyword search asks:</p><blockquote><em>Does this document contain the word “password”?</em></blockquote><p>Semantic search asks:</p><blockquote><em>Which document has the most similar meaning?</em></blockquote><p>This produces much more relevant results.</p><h4>Retrieval-Augmented Generation (RAG)</h4><p>Modern enterprise AI systems combine embeddings with vector databases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1TBB_aMAoJ9YhWS7h3WX2Q.png" /></figure><p>This enables LLMs to answer questions using private company knowledge while reducing hallucinations and improving accuracy.</p><h3>Summary</h3><p>Large Language Models cannot understand text directly. Before any learning or reasoning can occur, human language must be transformed into a mathematical representation.</p><p>This transformation begins with <strong>tokenization</strong>, where text is divided into tokens and converted into numerical IDs. These IDs are then mapped into <strong>embeddings</strong>, allowing the model to capture semantic meaning within a high-dimensional <strong>vector space</strong>. These concepts not only enable LLMs to understand language but also form the foundation of modern techniques such as <strong>semantic search</strong>, <strong>vector databases</strong>, and <strong>Retrieval-Augmented Generation (RAG)</strong>.</p><p>In the next chapter, we will explore the breakthrough that made modern LLMs possible: the <strong>Transformer architecture</strong>, including <strong>self-attention</strong>, <strong>multi-head attention</strong>, and the innovations that revolutionized Natural Language Processing.</p><p><strong>Note:</strong> This chapter provides a high-level understanding of tokenization, embeddings, vector spaces, and vector databases to build the foundation for the upcoming topics. If you’d like a much deeper dive into any of these concepts such as how tokenization algorithms work, how embeddings are generated, how vector databases perform similarity search, or the mathematics behind vector representations, I’d be happy to write dedicated, in-depth articles on each topic.</p><p><strong>Let me know in the comments which concept you’d like me to cover next in detail!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e40e30f01bc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LLM Series Chapter 03: What Exactly Is an LLM?]]></title>
            <link>https://medium.com/@surabythangarajah/llm-engineering-series-chapter-03-what-exactly-is-an-llm-45058ca59ff9?source=rss-2801fb33b4ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/45058ca59ff9</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Surabiga Thangarajah]]></dc:creator>
            <pubDate>Thu, 30 Jul 2026 07:07:22 GMT</pubDate>
            <atom:updated>2026-07-30T07:13:07.267Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>LLM Series Chapter 03: What Exactly Is an LLM? A Deep Dive into Models, Parameters, and Foundation Models</strong></h3><p>By now, we have explored why human language is difficult for machines to understand and how Natural Language Processing (NLP) evolved from rule-based systems to today’s Large Language Models (LLMs). We have seen the progression from handcrafted linguistic rules to statistical methods, machine learning, deep learning, transformers, and ultimately modern LLMs.But this naturally raises an important question:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hB9DMNGyG1WBtQchJ8qjqw.png" /></figure><p>When people hear names like GPT, Gemini, Claude, or Llama, they often imagine that these systems somehow understand language like humans do. Others believe they are simply enormous databases that store answers to every possible question. Neither assumption is entirely correct. At their core, Large Language Models are sophisticated mathematical models trained to discover patterns in massive collections of text. They do not memorise every sentence they encounter, nor do they reason in the same way humans do. Instead, they learn statistical relationships between words, phrases, concepts, and contexts, allowing them to generate remarkably coherent and contextually relevant responses.</p><p>To understand how LLMs work, we first need to understand four fundamental concepts:</p><ul><li>What is a model?</li><li>What are parameters?</li><li>What is training data?</li><li>What is a foundation model?</li></ul><p>These concepts form the building blocks of every modern Large Language Model.</p><h3>What Is a Model?</h3><p>A <strong>model</strong> is a mathematical function that learns patterns from data so that it can make predictions about information it has never seen before.Instead of following manually written rules, a model learns by analysing examples.</p><p>Imagine teaching a child to recognise cats. Rather than giving thousands of rules such as:</p><ul><li>Cats have four legs.</li><li>Cats have whiskers.</li><li>Cats have pointed ears.</li></ul><p>We simply show the child thousands of pictures of cats.Eventually, the child begins recognising new cats without anyone explicitly explaining every possible characteristic.Machine learning models work in a very similar way.Instead of receiving handcrafted rules, they are exposed to enormous amounts of data and gradually learn the underlying patterns.For a Large Language Model, those patterns exist within human language.Rather than learning what a cat looks like, an LLM learns relationships between:</p><ul><li>words</li><li>sentences</li><li>grammar</li><li>meaning</li><li>context</li><li>facts</li><li>writing styles</li></ul><p>Its goal is not to memorise every sentence but to learn the probability of language itself.</p><p>Suppose a model repeatedly encounters sentences such as:</p><ul><li>The sun rises in the east.</li><li>Birds build nests.</li><li>Water freezes at 0°C.</li><li>The capital of France is Paris.</li></ul><p>After seeing millions or billions of similar examples, the model begins recognising patterns.</p><p>When given the prompt:</p><blockquote><em>The capital of France is……..</em></blockquote><p>it predicts that <strong>Paris</strong> is the most probable continuation.</p><p>Here,the model is <strong>not searching a database</strong> for the answer.Instead, it generates the next token based on the statistical patterns it learned during training.This simple idea forms the basis of every modern Large Language Model.</p><h3>Understanding Parameters: The Knowledge Inside an LLM</h3><p>If a model is the mathematical function, then <strong>parameters</strong> are the numerical values that store what the model has learned during training.We can think of parameters as the model’s internal memory,not memory in the human sense, but billions (or even trillions) of numerical values that encode relationships between language patterns.During training, these parameters are adjusted repeatedly to improve the model’s predictions.</p><p>Initially, the parameter values are random.The model therefore produces meaningless predictions.After processing billions of sentences, the parameters gradually change until they capture increasingly complex relationships in language.Every time the model makes a mistake, the training algorithm updates these parameters slightly.Over billions of updates, the model becomes progressively better at predicting the next word.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dH4WIrOK_VhsN-lpXhaMLg.png" /></figure><p>More parameters generally allow a model to represent more complex patterns in language.However, a larger parameter count does <strong>not automatically</strong> make a model better. Model architecture, training quality, data quality, and optimisation techniques also play major roles.</p><h3>What Is Training Data?</h3><p>A Large Language Model cannot learn without data.<strong>Training data</strong> is the massive collection of text used to teach the model about human language.</p><p>This data may include:</p><ul><li>Books</li><li>Scientific papers</li><li>Websites</li><li>Encyclopedias</li><li>Programming code</li><li>Research articles</li><li>Public discussions</li><li>Educational materials</li></ul><p>During training, the model repeatedly reads these documents and learns statistical patterns.It does <strong>not</strong> store every document word for word. Instead, it adjusts its parameters to improve its ability to predict missing or subsequent tokens.For example, after reading millions of articles about medicine, the model learns relationships between diseases, symptoms, treatments, and medical terminology, not by memorising every article, but by identifying recurring patterns.This distinction is important because training is fundamentally about <strong>learning patterns</strong>, not building a searchable library of text.</p><h3>What Is a Foundation Model?</h3><p>Early AI systems were usually built to perform one specific task.</p><p>For example:</p><ul><li>spam detection</li><li>machine translation</li><li>sentiment analysis</li><li>document classification</li></ul><p>Each task typically required a separate model.Modern AI takes a different approach.Instead of training a model for every individual task, researchers first train a very large, general-purpose model on diverse data. This is known as a <strong>foundation model</strong>.</p><p>A foundation model develops broad capabilities in language understanding and generation, which can then be adapted for many downstream applications through prompting, fine-tuning, or retrieval techniques.</p><p>One foundation model can support many applications:</p><ul><li>Chatbots</li><li>Coding assistants</li><li>Financial analysis</li><li>Medical support</li><li>Document summarisation</li><li>Translation</li><li>Question answering</li><li>Enterprise search</li></ul><p>This versatility is one of the defining characteristics of modern LLMs.</p><h3>Popular Foundation Models</h3><p>Today, several organisations have developed powerful foundation models.</p><p>Some well-known models are:</p><ul><li>OpenAI’s GPT family</li><li>Google’s Gemini family</li><li>Anthropic’s Claude family</li><li>Meta’s Llama family</li></ul><p>Although these models differ in architecture, training methods, and capabilities, they all share the same fundamental idea that they are general-purpose foundation models that can be adapted to perform a wide range of language tasks.</p><h3>Common Misconceptions About LLMs</h3><h4><strong>1.An LLM is just a database</strong></h4><p>An LLM does not retrieve pre-written answers from a database. It generates responses by predicting the most probable next token based on learned patterns.</p><h4>2.More parameters always mean a better model</h4><p>Parameter count is only one aspect of model performance. Training data quality, architecture, optimisation methods, and alignment significantly influence capability.</p><h4>3.LLMs understand language exactly like humans</h4><p>LLMs model statistical relationships in language remarkably well, but their internal mechanisms differ fundamentally from human cognition.</p><h3>Conclusion</h3><p>A Large Language Model is far more than a collection of stored text. It is a mathematical model that learns patterns from enormous amounts of language by adjusting billions of numerical parameters during training. Understanding the concepts of <strong>models, parameters, training data, and foundation models</strong> provides the foundation for everything that follows in LLM engineering.</p><p>In the next chapter, we will explore how human language is transformed into a mathematical representation that machines can process, beginning with <strong>tokenisation</strong>, <strong>embeddings</strong>, and <strong>vector spaces</strong>. These concepts explain how words become numbers the essential first step in enabling LLMs to understand and generate language.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45058ca59ff9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LLM Series Chapter 02: Evolution of NLP - From Rule-Based Systems to Large Language Models]]></title>
            <link>https://medium.com/@surabythangarajah/llm-series-chapter-02-evolution-of-nlp-from-rule-based-systems-to-large-language-models-6ed3b8531918?source=rss-2801fb33b4ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ed3b8531918</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Surabiga Thangarajah]]></dc:creator>
            <pubDate>Mon, 27 Jul 2026 12:46:37 GMT</pubDate>
            <atom:updated>2026-07-27T13:35:13.206Z</atom:updated>
            <content:encoded><![CDATA[<p>Natural Language Processing (NLP) has evolved over several decades, driven by one fundamental objective, enabling computers to understand and generate human language.The journey from simple rule-based systems to today’s Large Language Models was not a sudden breakthrough. Instead, it was a series of innovations, each attempting to overcome the limitations of its predecessor.Every generation of NLP answered one question while exposing new challenges that inspired the next wave of research.</p><p>The evolution can be visualised as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EOrdlAGHux2wqizcQvsjpw.png" /></figure><p>Understanding this progression is essential because modern LLMs did not emerge in isolation,they are built upon decades of research, experimentation, and technological advancement.</p><h3>1. Rule-Based NLP: Teaching Computers Through Explicit Rules</h3><p>The earliest NLP systems relied entirely on manually written linguistic rules.Researchers believed that if they could describe grammar, vocabulary, and sentence structures precisely enough, computers would be able to understand language.These systems consisted of thousands of handcrafted rules developed by linguists and programmers.</p><p>For example, a rule might specify that if a sentence follows a particular grammatical structure, it belongs to a specific category, or that a certain word should always be interpreted in a predefined way.This approach worked reasonably well for highly structured and predictable tasks.</p><p>However, human language is far more flexible than a collection of fixed rules.People constantly invent new expressions, use sarcasm, omit information, and rely heavily on context. Capturing every possible variation through manually written rules proved impossible.As languages evolved, maintaining these systems became increasingly difficult. Adding new rules often introduced unexpected conflicts with existing ones, making the systems complex and fragile.</p><p>The fundamental limitation was that rule-based systems processed language according to predefined instructions rather than learning from experience. They could only understand situations that had already been anticipated by their developers.This demonstrated that language could not be fully described using explicit rules alone.</p><h3>2. Statistical NLP: Learning from Data Instead of Rules</h3><p>To overcome the rigidity of rule-based systems, researchers introduced statistical methods.Instead of manually defining every rule, computers began analysing large collections of text to identify patterns and calculate probabilities.The underlying idea was simple yet powerful.Words that frequently appear together are likely to be related.</p><p>For example, after analysing millions of sentences, a model might learn that the word “bank” often appears alongside “money,” “loan,” and “account” in financial contexts, while also appearing with “river,” “water,” and “shore” in geographical contexts.Rather than relying on handcrafted rules, the system estimated which interpretation was statistically more likely.</p><p>This represented a significant improvement because computers could now learn from data instead of relying entirely on human expertise.However, statistical models still had important limitations.They focused mainly on local word relationships and struggled to capture long-range dependencies within sentences.Most importantly, they did not truly understand language. They simply estimated probabilities based on observed patterns.</p><h3>3. Machine Learning NLP: Allowing Computers to Learn Patterns</h3><p>The next major shift was the adoption of machine learning.Instead of programmers specifying rules or statistical formulas directly, algorithms began learning patterns automatically from labelled examples.</p><p>If thousands of emails were labelled as either spam or legitimate, a machine learning model could identify the characteristics that distinguished the two categories.This marked an important transition from explicitly programming behaviour to allowing computers to discover patterns independently.</p><p>Machine learning significantly improved many NLP tasks, including:</p><ul><li>Sentiment analysis</li><li>Spam detection</li><li>Document classification</li><li>Named Entity Recognition(NER)</li><li>Language identification</li></ul><p>Despite these improvements, traditional machine learning still relied heavily on manually designed features.Researchers needed to decide which characteristics of text were important before training could begin.As language became more complex, designing these features became increasingly difficult and time-consuming.The next breakthrough would remove much of this manual effort.</p><h3>4. Deep Learning: Letting Neural Networks Discover Language Representations</h3><p>Deep learning fundamentally changed NLP by enabling models to learn hierarchical representations directly from raw text.Instead of engineers deciding which features were important, neural networks automatically discovered increasingly complex linguistic patterns during training.</p><p>Early layers learned simple relationships such as characters and words.Intermediate layers captured grammatical structures.Deeper layers began recognising semantic relationships, sentence structure, and contextual information.This dramatically reduced the need for handcrafted features and enabled models to perform far better on many language tasks.</p><p>However, deep learning introduced another challenge.Language is inherently sequential.Every word depends on the words that came before it.Researchers therefore needed architectures specifically designed to process sequences.This led to Recurrent Neural Networks.</p><h3>5. Recurrent Neural Networks (RNNs) and LSTMs: Learning from Sequences</h3><p>Recurrent Neural Networks introduced memory into language models.Unlike previous approaches, an RNN processed words one after another while maintaining an internal state representing information from earlier parts of the sentence.This allowed models to consider previous words when interpreting the current one.</p><p>For the first time, computers could analyse entire sequences instead of isolated words.However, RNNs suffered from a serious limitation.As sentences became longer, they gradually forgot information from earlier words.This made it difficult to understand long documents or capture relationships between distant parts of a sentence.</p><p>Long Short-Term Memory (LSTM) networks were introduced to address this issue by providing mechanisms that helped preserve important information over longer sequences.Although LSTMs represented a significant improvement, they still processed text sequentially.Each word depended on the processing of the previous word, making training slow and difficult to parallelise.Researchers realised that an entirely different architecture was needed.</p><h3>6. Transformers: A Revolutionary Change in NLP</h3><p>In 2017, researchers introduced the Transformer architecture in the landmark paper <em>Attention Is All You Need</em>.Rather than processing words sequentially, transformers process all words in a sentence simultaneously.This dramatically increased training efficiency and enabled models to learn from vastly larger datasets.</p><p>More importantly, transformers introduced the attention mechanism.Instead of remembering previous words through a hidden state, attention allows every word to directly examine every other word in the sequence and determine which ones are most relevant.This enables models to capture long-range dependencies far more effectively than RNNs or LSTMs.</p><p>For example, when interpreting the pronoun “it” in a sentence, a transformer can directly identify the earlier word to which it refers, even if they are separated by many other words.The Transformer architecture solved many of the problems that had constrained earlier NLP systems.Its scalability made it possible to train models containing billions and eventually trillions of parameters.This single innovation became the foundation for nearly every modern Large Language Model.</p><h3>7. Large Language Models: Learning Language at Massive Scale</h3><p>The introduction of transformers enabled researchers to train models on unprecedented amounts of text.Rather than learning specific tasks individually, these models learned general language representations by predicting the next word in billions of sentences.</p><p>After pre-training, the same model could perform translation, summarisation, question answering, code generation, reasoning, and many other tasks with little or no additional training.Examples include GPT, Gemini, Claude, and Llama.</p><p>Large Language Models transformed NLP from task-specific systems into general-purpose AI capable of adapting to diverse applications.Yet even these models have limitations.They cannot directly interact with external systems, retrieve real-time information, or independently execute complex workflows.This led to the next stage in the evolution of AI.</p><h3>8. Agentic AI: Beyond Language Generation</h3><p>The latest evolution extends LLMs beyond generating text.Agentic AI combines language models with planning, reasoning, memory, external tools, and decision-making capabilities.</p><p>Instead of simply responding to prompts, AI agents can break complex goals into smaller tasks, retrieve information from databases, use external APIs, execute software tools, and collaborate with other specialised agents.This transforms LLMs from conversational assistants into intelligent systems capable of solving real-world problems.</p><p>Agentic AI represents a shift from passive language understanding to autonomous problem-solving and is increasingly becoming the foundation of enterprise AI applications.</p><h3>Why This Evolution Matters?</h3><p>The history of NLP is a story of overcoming limitations.Each generation emerged because the previous approach could not fully capture the complexity of human language.</p><ul><li>Rule-Based NLP struggled with flexibility.</li><li>Statistical NLP improved learning from data but lacked deep understanding.</li><li>Machine Learning automated pattern recognition but depended on handcrafted features.</li><li>RNNs and LSTMs introduced memory but struggled with long-term dependencies and sequential computation.</li><li>Transformers revolutionised NLP through attention and parallel processing.</li><li>Large Language Models scaled transformers into powerful general-purpose AI systems.</li><li>Agentic AI is now extending these models into autonomous systems capable of reasoning, planning, and acting.</li></ul><p>Understanding this evolution is essential because every modern AI application from conversational assistants to enterprise AI platforms builds upon these decades of innovation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ed3b8531918" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LLM Series Chapter 01: Understanding Large Language Models-Why Is Human Language Difficult for…]]></title>
            <link>https://medium.com/@surabythangarajah/understanding-large-language-models-part-1-why-human-language-is-difficult-for-machines-22f39fc10658?source=rss-2801fb33b4ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/22f39fc10658</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Surabiga Thangarajah]]></dc:creator>
            <pubDate>Mon, 27 Jul 2026 08:42:55 GMT</pubDate>
            <atom:updated>2026-07-27T12:55:16.710Z</atom:updated>
            <content:encoded><![CDATA[<h3>LLM Series Chapter 01: Understanding Large Language Models-Why Is Human Language Difficult for Machines?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GHi8M98dmMiaKrINLScOvg.png" /></figure><h3>Introduction</h3><p>Human language is one of the most powerful tools humans use to communicate knowledge, emotions, intentions, and experiences. However, teaching machines to understand human language is one of the hardest challenges in Artificial Intelligence.</p><p>Humans do not understand language by looking at individual words separately. We combine words with:</p><ul><li>Context</li><li>Previous experiences</li><li>Background knowledge</li><li>Understanding of the real world</li></ul><p>For example, when humans read a sentence, they automatically understand hidden meanings, relationships between words, and the intention behind communication.Machines, however, do not naturally understand meaning. They process symbols and must learn the hidden patterns behind those symbols.</p><p>This creates a fundamental challenge in Natural Language Processing (NLP):</p><p><strong>How can machines move from processing words to understanding meaning?</strong></p><p>The difficulty comes from four major challenges:</p><ol><li>Ambiguity</li><li>Multiple meanings</li><li>Context dependency</li><li>World knowledge requirement</li></ol><p>Although these challenges are related, they represent different problems in language understanding.</p><h3>1. Multiple Meanings - One Word, Different Concepts</h3><p>Multiple meanings occur when a single word represents different concepts depending on the domain or situation.The problem starts at the word level.A word does not always have only one fixed meaning.</p><p><strong>Example 01: Mouse</strong></p><p>In biology:</p><blockquote><em>A mouse is a small animal.</em></blockquote><p>But In computing:</p><blockquote><em>A mouse is an input device used to control a computer.</em></blockquote><p>The same word represents two completely different concepts.</p><p><strong>Example 02: Apple</strong></p><blockquote><em>“I ate an apple.”</em></blockquote><p>Here, <strong>apple</strong> represents a fruit.</p><blockquote><em>“Apple released a new laptop.”</em></blockquote><p>Here, <strong>Apple</strong> represents a technology company.</p><p>The word itself has multiple possible meanings.</p><p>However, simply having multiple meanings does not always create a problem.The real challenge appears when the machine must decide which meaning is intended.This leads to ambiguity.</p><h3>2. Ambiguity- Choosing the Correct Interpretation</h3><p>Ambiguity occurs when a word, phrase, or sentence has multiple possible interpretations, and the intended meaning is unclear.The problem is not that the word has different meanings.The problem is which meaning should the machine choose.</p><p><strong>Example:</strong></p><blockquote><em>“I went to the bank.”</em></blockquote><p>The word <strong>bank</strong> can mean:</p><ul><li>A financial institution</li><li>The side of a river</li></ul><p>The sentence alone does not provide enough information.The machine must determine Does the speaker mean:</p><blockquote><em>“I went to deposit money.”</em></blockquote><p>or</p><blockquote><em>“I went near the river.”</em></blockquote><p>The ambiguity comes from uncertainty about the intended meaning.</p><h4>How Humans Resolve Ambiguity</h4><p>Humans use additional information.</p><p><strong>Example:</strong></p><blockquote><em>“I deposited money in the bank.”</em></blockquote><p>Words like deposited and money provide clues.</p><p>Therefore, bank+deposited+money represent a financial institution.</p><p>The word itself does not contain complete meaning.The meaning emerges from relationships between words.</p><h3>3. Context Dependency - Using Surrounding Information to Understand Meaning</h3><p>Context dependency means that the meaning of a word depends on the surrounding information.Context is the mechanism humans use to <strong>resolve ambiguity and select the correct meaning.</strong></p><p><strong>Example:</strong></p><blockquote><em>“The room is cold.”</em></blockquote><p>Here: Cold refers to Low temperature</p><blockquote><em>“I caught a cold.”</em></blockquote><p>Here: Cold refers to Illness</p><p>The word is identical.The meaning changes because the context changes.</p><p>Humans understand context using:</p><ul><li>Previous words</li><li>Following words</li><li>Situation</li><li>Speaker intention</li><li>Background knowledge</li></ul><p>Machines also need to learn this ability.</p><h4>Understanding Relationships Between Words</h4><p>Consider:</p><blockquote><em>“The animal did not cross the road because it was tired.”</em></blockquote><p>What does <strong>“it”</strong> refer to?</p><p>A human understands it refers to the animal.Because humans know that animals can become tired and roads cannot become tired.This is called <strong>coreference understanding</strong>.The machine must understand relationships between concepts, not only individual words.</p><h3>4. World Knowledge Requirement-Understanding Reality Behind Language</h3><p>Language often contains information that is not directly written in the sentence.Humans understand language because they have knowledge about the real world.</p><p>This includes:</p><ul><li>Physics</li><li>Society</li><li>Human behaviour</li><li>Culture</li><li>Cause and effect</li><li>Common sense</li></ul><p>Machines do not experience the world directly.So, They must learn these relationships from data.</p><p><strong>Example 01:</strong></p><blockquote><em>“She gave me a cold shoulder.”</em></blockquote><p>A machine using only word definitions may think Cold refers to Temperature and Shoulder refers to Body part.</p><p>But, humans can understand Cold shoulder refers to Ignoring or rejecting someone.</p><p>This requires:</p><ul><li>Cultural knowledge</li><li>Language experience</li><li>Understanding human behaviour</li></ul><h3>Why Traditional NLP Systems Struggled?</h3><p>Traditional NLP systems mainly depended on Words and Rules.Developers manually created rules to handle language.</p><p><strong>Example:</strong></p><p>Bank + money → Financial institution</p><p>Bank + river → River edge</p><p>However, human language is too complex.</p><p>It contains millions of words, different sentence structures, cultural expressions, hidden meanings and changing language patterns.So creating rules for every situation is impossible.Machines needed the ability to learn language patterns automatically.</p><h3>How Modern Large Language Models Solve These Challenges?</h3><p>Modern Large Language Models (LLMs) solve these challenges by learning relationships between words, concepts, and real-world information from massive amounts of data.They do not simply memorize definitions.They learn words, relationships, concepts, patterns, meaning and representations.</p><h4>1. Contextual Representations</h4><p>LLMs learn that the meaning of a word changes depending on surrounding words.This helps to solve multiple meanings and ambiguity challenges.</p><p><strong>Example: </strong>Bank + money + deposit refers to Financial concept.</p><p>Bank + river + water refers to Geographical concept.</p><h4>2. Transformer Attention Mechanism</h4><p>Transformers introduced the attention mechanism.Attention allows models to identify which words are important when interpreting another word.</p><p><strong>Example:</strong></p><blockquote><em>“The animal did not cross the road because it was tired.”</em></blockquote><p>The model learns it refers to animal. Because the relationship between words provides meaning.</p><h4>3. Learning World Knowledge</h4><p>LLMs are trained on massive datasets containing books, articles, websites and research material. Through training, models learn relationships such as Rain → Wet roads, Heat → Melting etc.</p><p>This helps models understand information that is not directly stated.</p><h4>4. Retrieval-Augmented Generation (RAG)</h4><p>LLMs have limitations because their learned knowledge may not contain updated or specialized information.RAG solves this by connecting LLMs with external knowledge sources.</p><p><strong>Without RAG:</strong></p><p><strong>Question → LLM memory → Answer</strong></p><p><strong>With RAG:</strong></p><p><strong>Question → Retrieve relevant information → LLM process knowledge → Answer</strong></p><p>This allows AI systems to use private documents of a particular company, research papers, databases and updated information.</p><p>Human language is challenging for machines because meaning is not contained within individual words. Understanding language requires recognizing relationships between words, interpreting context, connecting concepts, and applying knowledge about the real world.</p><p>Modern Large Language Models address these challenges by learning patterns from massive amounts of data and using techniques such as embeddings, transformers, attention mechanisms, and retrieval-based approaches.However, understanding these challenges is only the first step in understanding how LLMs work.</p><h3>Feedback and Discussion</h3><p>Thank you for reading! I would appreciate your feedback and thoughts on this blog. Your suggestions and insights will help me improve future parts of this LLM series.</p><blockquote><em>In the upcoming parts of this LLM series, we will explore the core technologies behind these models, including tokens, embeddings, transformers, RAG, and agentic AI.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22f39fc10658" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BloodLens AI: An AI-Powered Blood Report Analyzer Using LangChain, Gemini, and Streamlit]]></title>
            <link>https://medium.com/@surabythangarajah/bloodlens-ai-an-ai-powered-blood-report-analyzer-using-langchain-gemini-and-streamlit-5b213fa4d826?source=rss-2801fb33b4ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b213fa4d826</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[health]]></category>
            <dc:creator><![CDATA[Surabiga Thangarajah]]></dc:creator>
            <pubDate>Tue, 07 Jul 2026 15:43:32 GMT</pubDate>
            <atom:updated>2026-07-07T16:22:08.374Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Medical reports often contain a large amount of technical information that can be difficult for non-medical users to understand. Blood test reports include many parameters, reference ranges, and abbreviations, making it challenging for people to identify what values require attention.With the advancement of Generative AI, Large Language Models (LLMs) can help transform complex medical information into simple, understandable insights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B24UWrRopxIBSHl-ZpIwvA.png" /></figure><p>In this project, I built <strong>BloodLens AI</strong>, an AI-powered blood report analysis assistant that extracts blood test information, identifies abnormal values, and generates simple health summaries with practical dietary recommendations.The project combines <strong>Streamlit, LangChain, and Google Gemini/Gemma LLMs</strong> to create an end-to-end Generative AI application.</p><h3>What is BloodLens AI?</h3><p>BloodLens AI is a web application that analyzes blood reports and provides:</p><ul><li>Blood test value extraction</li><li>HIGH / LOW / NORMAL classification</li><li>Simple health explanations</li><li>Personalized diet recommendations</li></ul><p>The goal is not to replace medical professionals but to demonstrate how Generative AI can assist users in understanding healthcare information more easily.</p><h3>Project Workflow</h3><p>The complete workflow consists of several stages:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ujFOuPLMXpkv2FqFIID6Pw.png" /></figure><h3>1. User Input</h3><p>The user provides a blood report by pasting the report content into the Streamlit application.</p><p>Example:</p><pre>Hemoglobin: 11.5 g/dL<br>Reference Range: 13-17 g/dL</pre><pre>Total Cholesterol: 235 mg/dL<br>Reference Range: &lt;200 mg/dL</pre><p>The report is then passed to the AI processing pipeline.</p><h3>2. Streamlit Application Layer</h3><p>The frontend interface was developed using Streamlit.</p><p>Streamlit handles:</p><ul><li>User input collection</li><li>Displaying analysis progress</li><li>Showing AI-generated results</li></ul><p>The interface provides separate sections for:</p><ul><li>Blood report input</li><li>Health summary</li><li>Diet recommendations</li></ul><h3>3. Application Logic Using Python</h3><p>The Python application manages the complete workflow.</p><p>Responsibilities include:</p><ul><li>Preparing prompts</li><li>Sending requests to the LLM</li><li>Processing responses</li><li>Formatting outputs for display</li></ul><h3>4. LangChain Integration</h3><p>LangChain acts as the application framework that connects the Python application with the Large Language Model.</p><p>It manages:</p><ul><li>Prompt templates</li><li>LLM communication</li><li>Response handling</li></ul><p>Instead of directly interacting with the model, LangChain provides a structured way to build LLM-powered applications.</p><h3>5. Google Gemini / Gemma LLM Processing</h3><p>The application uses Google’s Generative AI model to analyze the blood report.</p><p>The LLM performs two major tasks.</p><h4>Stage 1: Blood Report Extraction</h4><p>The model extracts:</p><ul><li>Test names</li><li>Measured values</li><li>Reference ranges</li><li>Health status</li></ul><p>Example:</p><pre>Hemoglobin: 11.5 g/dL | Status: LOW</pre><pre>Cholesterol: 235 mg/dL | Status: HIGH</pre><h4>Stage 2: Health Analysis</h4><p>The extracted information is passed to the LLM again to generate:</p><ul><li>Simple health summary</li><li>Possible health concerns</li><li>Dietary suggestions</li></ul><p>The final output is presented in a user-friendly format.</p><h3>Technology Stack</h3><h4>Programming Language</h4><p><strong>Python</strong></p><p>Used for application development and AI workflow management.</p><h4>Frontend</h4><p><strong>Streamlit</strong></p><p>Used to build the interactive web interface.</p><h4>AI Framework</h4><p><strong>LangChain</strong></p><p>Used for managing prompts, LLM calls, and response processing.</p><h4>Large Language Model</h4><p><strong>Google Gemini</strong></p><p>Used for:</p><ul><li>Understanding blood reports</li><li>Extracting information</li><li>Generating health insights</li></ul><h3>Key Learnings From This Project</h3><p>Building BloodLens AI helped me understand several important concepts in Generative AI development:</p><h3>1. LLM Application Architecture</h3><p>Understanding how user input flows through:</p><pre>User<br> ↓<br>Application<br> ↓<br>LangChain<br> ↓<br>LLM API<br> ↓<br>Generated Response<br> ↓<br>User Interface</pre><h3>2. Prompt Engineering</h3><p>The quality of LLM output depends heavily on prompt design.</p><p>I learned how to create structured prompts that guide the model to:</p><ul><li>Extract specific information</li><li>Follow a required format</li><li>Generate useful responses</li></ul><h3>3. Building End-to-End AI Applications</h3><p>Instead of only training models, modern AI engineering involves building complete systems:</p><ul><li>User interfaces</li><li>API integration</li><li>Prompt pipelines</li><li>Response formatting</li><li>Deployment-ready applications</li></ul><h3>Future Improvements</h3><p>Some improvements planned for BloodLens AI:</p><ul><li>Add PDF blood report upload support</li><li>Implement OCR for scanned reports</li><li>Add Retrieval Augmented Generation (RAG) using medical knowledge sources</li><li>Store previous reports for comparison</li><li>Deploy the application on cloud platforms</li><li>Improve medical reasoning with specialized models</li></ul><h3>Conclusion</h3><p>BloodLens AI demonstrates how Generative AI can be used to make complex healthcare information more understandable.</p><p>By combining <strong>Streamlit, LangChain, and Google Gemini</strong>, this project shows the potential of LLM-powered applications in creating practical solutions for real-world problems.</p><p>This project strengthened my understanding of Generative AI workflows, LLM integration, and building complete AI applications from concept to implementation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b213fa4d826" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Foundations of AI & LLMs: Understanding Generative AI, Transformers, Temperature, and Context…]]></title>
            <link>https://medium.com/@surabythangarajah/foundations-of-ai-llms-understanding-generative-ai-transformers-temperature-and-context-6e370a13c5f3?source=rss-2801fb33b4ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e370a13c5f3</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Surabiga Thangarajah]]></dc:creator>
            <pubDate>Sun, 05 Jul 2026 15:08:45 GMT</pubDate>
            <atom:updated>2026-07-05T15:08:45.434Z</atom:updated>
            <content:encoded><![CDATA[<h3>Foundations of AI &amp; LLMs: Understanding Generative AI, Transformers, Temperature, and Context Windows</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/0*tdgUIuwZl9R30JQZ" /></figure><p>Artificial Intelligence has become one of the most transformative technologies of our time. From ChatGPT answering questions to Gemini generating code and Claude summarizing lengthy documents, Large Language Models (LLMs) are reshaping the way we learn, work, and create.</p><p>But have you ever wondered how these AI systems actually work? What enables them to generate human-like responses? And what do terms like Transformer, Temperature, and Context Window really mean? In this article, we’ll break down these core concepts in a simple, beginner-friendly way.</p><h4>The Journey from AI to Generative AI</h4><p>Artificial Intelligence is a broad field focused on creating systems capable of performing tasks that typically require human intelligence, such as understanding language, recognizing images, making decisions, and solving problems.</p><p>Within AI lies <strong>Machine Learning (ML)</strong>, where computers learn patterns from data instead of being explicitly programmed. Rather than writing countless rules to identify spam emails.For example, a machine learning model learns from thousands of examples and discovers the patterns on its own.</p><p>A further evolution of Machine Learning is <strong>Deep Learning</strong>, which uses neural networks with many interconnected layers. These deep neural networks have dramatically improved AI’s ability to understand language, images, speech, and complex patterns.The latest breakthrough in this evolution is <strong>Generative AI</strong>.</p><p>Unlike traditional AI, which focuses on classifying or predicting existing information, Generative AI creates entirely new content. It can write articles, generate images, compose music, create videos, produce code, and even engage in conversations that feel remarkably natural.</p><p>Popular Generative AI applications include ChatGPT, Gemini, Claude, DALL·E, Midjourney, and Llama.</p><h4>What Exactly is a Large Language Model?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*_rqxoKgsgScGJQwa.jpg" /></figure><p>A Large Language Model (LLM) is a deep learning model trained on enormous amounts of text collected from books, research papers, websites, articles, and other publicly available sources.Although these models appear intelligent, their primary objective is surprisingly Predict the next most likely token.</p><p>For example, if the prompt is:</p><blockquote><strong><em>Artificial Intelligence is</em></strong></blockquote><p>the model may predict:</p><blockquote><strong><em>transforming</em></strong></blockquote><p>followed by:</p><blockquote><strong><em>the</em></strong></blockquote><p>and then:</p><blockquote><strong><em>world.</em></strong></blockquote><p>By repeating this prediction process thousands of times within seconds, the model generates coherent paragraphs, conversations, and even entire documents.</p><h4>Understanding Tokens</h4><p>One common misconception is that LLMs process complete words. In reality, they process <strong>tokens</strong>.</p><p>A token may represent:</p><ul><li>A complete word</li><li>Part of a word</li><li>A punctuation mark</li><li>A number</li><li>A symbol</li></ul><p>For instance, the sentence “Artificial Intelligence is amazing!” is internally divided into smaller tokens before the model processes it.Since every prompt and response is measured in tokens, token count directly influences processing speed, computational cost, and the amount of information the model can remember.</p><h4>The Transformer</h4><p>Before 2017, language models processed text sequentially, reading one word after another. While this approach worked reasonably well for short sentences, it struggled to understand long-range relationships within larger documents.Everything changed in 2017 when researchers introduced the <strong>Transformer architecture</strong> in the landmark paper Attention Is All You Need.</p><p>Today, nearly every modern Large Language Model,including ChatGPT, Gemini, Claude, and Llama is built upon this architecture.The Transformer allows a model to process all words in a sentence simultaneously rather than one at a time. This dramatically improves both speed and understanding.</p><h4>Self-Attention: How Transformers Understand Context</h4><p>The Transformer relies on a mechanism known as <strong>Self-Attention</strong>.</p><p>Imagine reading the sentence, “The student submitted the assignment because she finished it yesterday”.</p><p>Humans naturally understand that:</p><ul><li><strong>she</strong> refers to <strong>the student</strong></li><li><strong>it</strong> refers to <strong>the assignment</strong></li></ul><p>A Transformer learns these relationships automatically by assigning different levels of attention to different words.Instead of treating every word equally, it determines which previous words are most relevant when interpreting the current one.This ability to capture relationships between words,even when they are far apart is one of the main reasons modern LLMs produce such coherent and context-aware responses.</p><h4>Temperature</h4><p>One important parameter when interacting with an LLM is <strong>Temperature</strong>. Temperature controls the randomness of the model’s output.</p><p><strong>Low Temperature (0.0–0.3)</strong></p><p>Responses become:</p><ul><li>More factual</li><li>More deterministic</li><li>More consistent</li></ul><p>This setting is ideal for coding, mathematics, technical writing, and factual question answering.</p><p><strong>Medium Temperature (0.5–0.8)</strong></p><p>Responses are balanced between creativity and accuracy, making this range suitable for most everyday conversations and educational tasks.</p><p><strong>High Temperature (0.9–1.5)</strong></p><p>Responses become:</p><ul><li>More creative</li><li>More diverse</li><li>Less predictable</li></ul><p>Higher temperatures are useful for storytelling, brainstorming, creative writing, and generating multiple unique ideas. However, they can also increase the likelihood of incorrect or inconsistent responses.</p><h4>Context Window</h4><p>Another critical concept is the <strong>Context Window</strong>.The context window represents the maximum amount of text an LLM can consider at one time, measured in tokens.Imagine having a conversation with someone who only remembers the last few sentences. They may forget important details discussed earlier.LLMs behave similarly.If the conversation exceeds the model’s context window, earlier information may no longer be available to the model.</p><p>Larger context windows enable models to:</p><ul><li>Understand lengthy conversations</li><li>Summarize books and research papers</li><li>Analyze large codebases</li><li>Maintain consistency across long documents</li></ul><p>As context windows continue to grow, AI systems become increasingly capable of handling complex, information-rich tasks.</p><p>Understanding these foundational concepts helps us use AI more effectively.</p><p>For example:</p><ul><li>Use <strong>low temperature</strong> for coding and technical tasks.</li><li>Increase <strong>temperature</strong> when brainstorming or writing creatively.</li><li>Select models with <strong>larger context windows</strong> for long documents.</li><li>Recognize that the <strong>Transformer architecture</strong> is the foundation of nearly every modern LLM.</li></ul><p>These ideas also serve as stepping stones toward more advanced topics such as Retrieval-Augmented Generation (RAG), AI Agents, Fine-tuning, Function Calling, and Agentic AI.</p><h4>Summary</h4><p>Large Language Models may seem almost magical, but they are built upon well-established concepts in machine learning and deep learning.By understanding Generative AI, Tokens, Transformer architecture, Self-Attention, Temperature, and Context Windows, we gain a clearer picture of how modern AI systems generate meaningful, context-aware responses.The future of AI isn’t just about using powerful models, it’s about understanding the ideas that make them possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e370a13c5f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Word2Vec to BERT: The Evolution of Word Embeddings in NLP]]></title>
            <link>https://medium.com/@surabythangarajah/from-word2vec-to-bert-the-evolution-of-word-embeddings-in-nlp-a2a1c0587cc5?source=rss-2801fb33b4ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2a1c0587cc5</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[word-embeddings]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Surabiga Thangarajah]]></dc:creator>
            <pubDate>Wed, 17 Jun 2026 14:53:50 GMT</pubDate>
            <atom:updated>2026-06-17T14:58:30.294Z</atom:updated>
            <content:encoded><![CDATA[<p>Natural Language Processing (NLP) has significantly evolved over the past decade, especially in how machines represent and understand human language. One of the most important developments in this field is word embeddings, which convert text into numerical representations that machine learning models can process.Here we will look deep into the evolution of word embeddings, starting from early approaches like Word2Vec and GloVe to modern contextual models like BERT and sentence embeddings.</p><h3>What are Word Embeddings?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S5m65TfutS8aXZ92.png" /></figure><p>Word embeddings are dense vector representations of words that capture their meaning in a continuous vector space. Instead of treating words as discrete symbols, embeddings represent them as numerical vectors so that semantically similar words are located closer to each other.</p><p>In the above example, words like “king” and “queen” or “dog” and “cat” will have similar vector representations because they appear in similar contexts.The main idea behind word embeddings is,words with similar meanings should have similar representations.</p><h3>Word2Vec: The Beginning of Modern Embeddings</h3><p>Word2Vec, introduced by Google, was one of the earliest successful methods for learning word embeddings. It learns word representations based on the surrounding context of words in large text corpora.</p><p>There are two main architectures in Word2Vec:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1sXosQBS5wUbPnUO.png" /></figure><ul><li>Continuous Bag of Words (CBOW): Predicts a target word based on its surrounding context words.</li><li>Skip-gram: Predicts surrounding context words given a target word.</li></ul><p><strong>Advantages of Word2Vec:</strong></p><ul><li>Captures semantic relationships between words</li><li>Computationally efficient</li><li>Produces meaningful vector representations</li></ul><p><strong>Limitations:</strong></p><ul><li>Each word has a single fixed representation regardless of context</li><li>Cannot handle polysemy (words with multiple meanings)</li></ul><h3>GloVe: Global Word Representations</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*ih2nhsEkEWhl4Oxm.jpg" /></figure><p>GloVe (Global Vectors for Word Representation), developed by Stanford, improves upon Word2Vec by incorporating global statistical information from the entire corpus.</p><p>Instead of relying only on local context windows, GloVe uses word co-occurrence statistics to learn embeddings.</p><p><strong>Advantages of GloVe:</strong></p><ul><li>Captures global relationships between words</li><li>Performs well on many NLP tasks</li></ul><p><strong>Limitations:</strong></p><ul><li>Still produces static embeddings</li><li>Cannot handle contextual meaning differences</li></ul><h3>FastText: Subword-Level Embeddings</h3><p>FastText, developed by Facebook AI, extends Word2Vec by representing words as combinations of character n-grams.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/0*-emYF6C9nOoYcOST.png" /><figcaption>n=3</figcaption></figure><p><strong>This approach helps in:</strong></p><ul><li>Handling rare words</li><li>Managing misspellings</li><li>Supporting morphologically rich languages</li></ul><p><strong>Advantages of FastText:</strong></p><ul><li>Better handling of out-of-vocabulary words(OOV)</li><li>More robust than Word2Vec and GloVe</li></ul><p><strong>Limitations:</strong></p><ul><li>Still produces static embeddings</li><li>Does not capture full sentence context</li></ul><h3>Limitations of Traditional Word Embeddings</h3><p>Despite their success, Word2Vec, GloVe, and FastText share a key limitation: they produce static embeddings. This means a word has only one representation regardless of its context.</p><p><strong>For example:</strong><br> “He went to the bank to deposit money”<br> “He sat near the river bank”</p><p>In both cases, the word “bank” has the same vector representation, even though the meanings are different.This limitation led to the development of contextual embeddings.</p><h3>BERT: Contextual Word Embeddings</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/0*TWVJYkDlx12a6YAZ.png" /></figure><p>BERT (Bidirectional Encoder Representations from Transformers) introduced a major shift in NLP by generating contextual embeddings.</p><p>Unlike traditional embeddings, BERT considers the entire sentence when generating word representations. It processes text bidirectionally, it takes into account both left and right context simultaneously.</p><p>As a result, the word “bank” will have different representations depending on whether it refers to a financial institution or a riverbank.</p><p><strong>Advantages of BERT:</strong></p><ul><li>Context-aware word representations</li><li>State-of-the-art performance on many NLP tasks</li><li>Strong understanding of language semantics</li></ul><p>BERT has become the foundation for many modern NLP applications, including search engines, chatbots, and question-answering systems.</p><h3>Sentence Embeddings: Moving Beyond Words</h3><p>Modern NLP systems often go beyond word-level representations and focus on sentence-level embeddings. These embeddings represent entire sentences as single vectors.</p><p><strong>Popular models include:</strong></p><ul><li>Sentence-BERT (SBERT)</li><li>Universal Sentence Encoder</li><li>OpenAI embedding models</li></ul><p><strong>Sentence embeddings are widely used in:</strong></p><ul><li>Semantic search</li><li>Information retrieval</li><li>Chatbot systems</li><li>Retrieval-Augmented Generation (RAG)</li></ul><p>For example, the sentences:<br> “I love pizza”<br> “Pizza is my favorite food”</p><p>will have very similar embeddings because they convey similar meanings.</p><h3>Conclusion</h3><p>Word embeddings have evolved from simple statistical methods to highly advanced contextual representations. Early models like Word2Vec and GloVe laid the foundation for understanding semantic relationships between words. FastText improved robustness, while BERT revolutionized NLP by introducing context-aware embeddings.</p><p>Today, modern NLP systems rely heavily on contextual and sentence-level embeddings to understand and process human language more effectively. This evolution marks a major step toward building more intelligent and human-like language systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2a1c0587cc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chain Rule in Deep Learning Explained Simply]]></title>
            <link>https://medium.com/@surabythangarajah/chain-rule-in-deep-learning-explained-simply-321d79e772b4?source=rss-2801fb33b4ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/321d79e772b4</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Surabiga Thangarajah]]></dc:creator>
            <pubDate>Fri, 22 May 2026 12:29:10 GMT</pubDate>
            <atom:updated>2026-05-22T12:33:28.547Z</atom:updated>
            <content:encoded><![CDATA[<p>The chain rule is one of the most important mathematical concepts used in deep learning. It helps the neural network understand how a small change in a weight affects the final loss and the output. In a neural network, the loss does not directly depend on the weights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QDBwFwJpdelvGQjJA15jcA.png" /></figure><h3>1. Inputs</h3><p>The neural network first receives the input features. In this example, the inputs are the <strong>area of the house</strong> (x1)and the <strong>number of bedrooms</strong> (x2). These are called input neurons because they provide the information the model uses to make a prediction of house price. The inputs represent the characteristics of the house that may affect its price.</p><h3>2. Weights and Bias</h3><p>Each input is connected to a weight. The area input has weight w1, and the bedroom input has weight w2​. These weights determine how important each feature is in predicting the output. A larger weight means that feature has a stronger influence on the prediction. The model also includes a bias term b, which helps shift the output value and improves the flexibility of the model. During training, the neural network learns the best values for these weights and bias.</p><h3>3. Linear Equation (Weighted Sum)</h3><p>The neuron combines the inputs, weights, and bias using a linear equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*QYn7cFaE3f0JVC5umMU5AA.png" /></figure><p>This process is called the weighted sum. Here, each input is multiplied by its corresponding weight, and then all values are added together with the bias. The result z is the raw output of the neuron before activation. This step allows the network to mathematically combine all input information into a single value.</p><h3>4. Activation Function (Sigmoid)</h3><p>After calculating the weighted sum z, the value is passed through an activation function. In this example, the sigmoid activation function is used:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*tMTh2enmGmmlotSCkLK0Fg.png" /></figure><p>The sigmoid function converts the output into a value between 0 and 1. Activation functions introduce non-linearity into the neural network, allowing it to learn more complex patterns instead of only simple linear relationships.</p><h3>5. Prediction</h3><p>The output of the sigmoid function becomes the prediction y^. This predicted value represents the neural network’s estimated house price or output value. The prediction depends on the current weights and bias. At the beginning, predictions may not be accurate because the weights are random, but during training the model gradually improves them.</p><h3>6. Loss Function (MSE)</h3><p>The prediction is then compared with the true value y. The difference between them is called the error. To measure how bad the prediction is, the Mean Squared Error (MSE) loss function is used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*-wcth--LIcsePiGMu9pNwQ.png" /></figure><p>The loss function gives a numerical value representing the model’s mistake. A larger loss means the prediction is far from the true value, while a smaller loss means the prediction is more accurate.</p><p>The main goal here is the neural network wants to reduce the loss.So it asks <em>“</em>How should I change the weights to reduce the error?”.That’s where derivatives and chain rule come.</p><blockquote><em>“For a given weight(w1 or w2) change, how much does the loss change?” Here,finding this is the utmost goal of chain rule.</em></blockquote><blockquote><em>The loss does not directly depend on weights(w1 or w2)​.</em></blockquote><p>There’s a chain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*4F6itVN_04vRZ-9PDarvfw.png" /></figure><p>So to know how w1 or w2​ affects loss, we move through the whole chain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*JIaW4kRtElPZvPzWFxhNAg.png" /></figure><p>Likethis, we move through the whole chain step by step using this chain rule. The neural network calculates how each small change in a weight changes the weighted sum, prediction, and the loss. By finding these gradients, the model understands which direction the weights should move to reduce the error. This is how neural networks learn from mistakes and gradually improve their predictions during training.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=321d79e772b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Gradient Descent Types: Batch, Stochastic, and Mini-Batch Methods]]></title>
            <link>https://medium.com/@surabythangarajah/understanding-gradient-descent-types-batch-stochastic-and-mini-batch-methods-b4b3e635688a?source=rss-2801fb33b4ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4b3e635688a</guid>
            <category><![CDATA[gradient-descent]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Surabiga Thangarajah]]></dc:creator>
            <pubDate>Fri, 22 May 2026 09:50:46 GMT</pubDate>
            <atom:updated>2026-05-22T09:50:46.867Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o3QfIpdzi9RtQphyKsmpNQ.png" /></figure><p>Gradient Descent is an optimization algorithm used in machine learning to minimize the loss function by updating model parameters (weights and biases).</p><p>Depending on how much data is used in each update, Gradient Descent is divided into three main types: Batch Gradient Descent, Stochastic Gradient Descent, and Mini-Batch Gradient Descent.</p><h3>1. Batch Gradient Descent</h3><p>Batch Gradient Descent means the model uses the <strong>entire training dataset at once</strong> to calculate the gradient and update the weights. In each epoch, the algorithm looks at all data points, computes the average error (loss), and then updates the model parameters. Because it processes the full dataset per update, each epoch is computationally heavy but very stable. The cost function decreases smoothly because the gradient is accurate and not noisy. However, it becomes very slow for large datasets since every update requires going through all samples. This method is mainly used for <strong>small to medium-sized datasets</strong>, where memory and computation are not major issues.</p><h3>2. Stochastic Gradient Descent (SGD)</h3><p>Stochastic Gradient Descent updates the model using <strong>only one data point at a time</strong>. In every epoch, the dataset is shuffled, and the model updates weights after each individual sample. This makes training very fast and allows the model to start learning immediately. However, the cost function fluctuates heavily during training because each update is based on a single example, making the learning path noisy. Even though it is unstable, it can help the model escape local minima. SGD is widely used for <strong>very large datasets or streaming data</strong>, where processing the full dataset at once is not practical.</p><h3>3. Mini-Batch Gradient Descent</h3><p>Mini-Batch Gradient Descent is a <strong>combination of Batch and SGD</strong>. Instead of using the full dataset or a single sample, it uses small groups of data samples called mini-batches (for example 32, 64, or 128 samples). In each epoch, the dataset is divided into multiple mini-batches, and the model updates weights after each batch. This makes the learning process faster and more stable than SGD while still being efficient for large datasets. The cost curve is smoother than SGD but slightly noisier than Batch Gradient Descent. This is the <strong>most commonly used method in deep learning</strong>, especially for <strong>medium to very large datasets</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4b3e635688a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>