<?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 Padma Thanumoorthy on Medium]]></title>
        <description><![CDATA[Stories by Padma Thanumoorthy on Medium]]></description>
        <link>https://medium.com/@padmathanumoorthy?source=rss-150c6c06a635------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bSjek2UtiNRIGxmwlEIITQ.png</url>
            <title>Stories by Padma Thanumoorthy on Medium</title>
            <link>https://medium.com/@padmathanumoorthy?source=rss-150c6c06a635------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 02:28:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@padmathanumoorthy/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[Unveiling Amazon Bedrock: Revolutionizing the Foundations and Paving Way for elevated e-commerce]]></title>
            <link>https://medium.com/@padmathanumoorthy/unveiling-amazon-bedrock-revolutionizing-the-foundations-and-paving-the-way-for-the-elevated-1ff55422a848?source=rss-150c6c06a635------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ff55422a848</guid>
            <dc:creator><![CDATA[Padma Thanumoorthy]]></dc:creator>
            <pubDate>Wed, 17 Apr 2024 23:43:27 GMT</pubDate>
            <atom:updated>2024-04-17T23:44:37.358Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ScsmjY4wTTBw2vhNxFfOg.png" /><figcaption>Dr. Swami SivaSubramanian VP, Database, Analytics and ML at AWS introducing Amazon Bedrock Foundation models during AWS re:Invent ‘23</figcaption></figure><p>The role of Generative AI in e-commerce is transformative, influencing everything from product search to personalized shopping experiences. Amazon Bedrock emerges as a game-changer, providing the essential tools to harness the power of Generative AI in e-commerce</p><p><strong>Key Impact Areas of Generative AI in E-commerce</strong></p><ol><li>Item Search with text or image</li><li>Content Generation: Product Imagery, Virtual Try-Ons</li><li>Customized Marketing Materials</li><li>Enhanced Product Descriptions</li><li>Dynamic Pricing Optimization</li><li>Virtual Shopping Environments</li><li>Personalized Shopping Recommendations</li><li>Augmented Reality (AR) Applications</li><li>Product Design and Innovation</li><li>User-Generated Content Enhancement</li><li>Supply Chain Optimization</li></ol><p>To adapt the benefits the Generative AI in the e-commerce application, it has to be integrated with the framework which gives the following essentials for building the Generative AI application.</p><ul><li>The platform which provides the access to a variety of foundation models for the different single modality or multi modality.</li><li>Private Environment to leverage the proprietory data.</li><li>Easy to use tools (guardrails, agents, customization capabilities) to build and deploy applications.</li><li>And purposefully built platform for machine learning infrastructure.</li></ul><p><strong>Introducing Amazon Bedrock</strong></p><p>In this article I will introduce Amazon Bedrock, a service that gives all these essentials for building the Generative AI application.</p><p>Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies.</p><p><a href="https://aws.amazon.com/bedrock">Amazon Bedrock</a> provides a single API endpoint to connect in to a variety of generative AI models from leading AI providers such as AI21 Labs, Anthropic, Cohere, Meta, Stability AI, and also Amazon.</p><h3><strong>Key benefits of Amazon Bedrock</strong></h3><p><strong>I. Efficiently build with FMs</strong></p><ol><li>Choose from list of Foundation Models (FMs): Amazon bedrock provisioned Amazon, AI21 Labs, Anthropic, Cohere, Meta, Mistral AI, and Stability AI family of LLMs to find the right FM for the use case. This includes Amazon Titan, Jurassic-2, Claude, Claude 3 Sonnet, Claude 3 Opus, Command, Embed, Llama 2, Mixtral 7B/8x7B, Stable Diffusion SDXL 0.8/1.0 and more. These FMs support different modalities, including text, vision, image, embeddings, and multimodal embeddings.</li><li><strong>Access FMs through a single API — </strong>a single API to securely access customized FMs. The Amazon Bedrock API can be used through the AWS SDK to build a generative AI application and to integrate with other AWS services.</li><li><strong>Fully managed experience — </strong>With the Amazon Bedrock SERVERLESS experience and no need to manage the infrastructure. We can fine-tune and deploy FMs without creating instances, implementing pipelines, or setting up storage.</li></ol><p><strong>II. Securely build generative AI applications.</strong></p><ol><li><strong>Build with comprehensive data protection and privacy: </strong>With Amazon Bedrock, our data — including prompts, information used to supplement a prompt, FM responses, and customized FMs — remain in the Region where the API call is processed. The data is encrypted in transit with TLS 1.2 and at rest with service-managed AWS Key Management Service (AWS KMS) keys. We can use AWS PrivateLink with Amazon Bedrock to establish private connectivity between the FMs and on-premises networks, without exposing the traffic to the internet. In addition, we can customize FMs privately, retaining control over how the data is used and encrypted. Amazon Bedrock makes a SEPARATE COPY of the base FM model and trains this private copy of the model.</li><li><strong>Secure the generative AI applications: </strong>To secure our custom FMs, we can use AWS security services to form the in-depth security strategy. Our customized FMs are encrypted using AWS KMS keys and stored with encryption. By using AWS Identity and Access Management (IAM), we can control access to the customized FMs, allowing or denying access to specific FMs. We can also control which services receive inferences and who can log in to the Amazon Bedrock console.</li><li><strong>Access support for governance and audit-ability: </strong>Amazon Bedrock offers comprehensive monitoring and logging capabilities, including tools that can be used to help address the governance and audit requirements. We can use Amazon CloudWatch to track usage metrics and build customized dashboards with metrics that are required for audit purposes. We can use the AWS CloudTrail to monitor API activity and troubleshoot issues as integrating other systems into the generative AI applications.</li></ol><p><strong>III. Deliver customized experiences using the organization’s data.</strong></p><ol><li><strong>Automate orchestration and complex business tasks using agents for Amazon Bedrock (preview):</strong> Agents for Amazon Bedrock (preview) makes it easy to create and deploy fully managed agents that perform complex business tasks by dynamically invoking APIs. Agents use automatic prompt creation to generate prompts from developer instructions, API schemas, and company knowledge bases. An agent breaks down user requests into subtasks and determines the optimal sequence to complete them. Agents can connect to company data sources, convert data to numeric representations, and augment user requests with relevant information. This allows the agent to generate more accurate and relevant responses by looking up details from knowledge bases.</li><li><strong>Supplement organization-specific information to the FM and generate accurate responses using knowledge bases for Amazon Bedrock (preview):</strong> Deliver contextual and relevant responses by incorporating organization-specific data through a process known as Retrieval Augmented Generation (RAG). With knowledge bases for Amazon Bedrock (preview), we can connect to the data sources to make the FMs knowledgeable about specific domain and organization.<br> The knowledge bases can access the data residing in Amazon Simple Storage Service (Amazon S3), and convert that data to vectors using embedding models. The vectors can be stored in vector databases such as Amazon OpenSearch Serverless or in third-party databases. The agents of Amazon Bedrock to retrieve the relevant documents for a query and deliver accurate responses. Responses from the knowledge base include source attribution to increase transparency and minimize hallucinations.</li><li><strong>Fine-tune FMs using Amazon Bedrock:</strong> Fine-tune a foundation model using Amazon Bedrock by providing the own labeled training dataset in order to improve the model’s performance on specific tasks. Through this process, create a new model that improves upon the performance and efficiency of the original model for a given task. To fine-tune a model, upload a training and a validation dataset to Amazon S3, and provide the S3 bucket path to the Amazon Bedrock fine-tuning job. The fine-tuning can be done using the Amazon Bedrock console or API.<br> <strong>Note:</strong> In the case of prompt-based learning and RAG, we are not customizing the FMs. However, when we fine-tune an FM, we are customizing the FM and creating a private copy of the FM.</li></ol><h3>Conclusion</h3><p>Amazon Bedrock stands out as a comprehensive solution for integrating Generative AI into e-commerce. With its diverse range of FMs, secure infrastructure, and customization capabilities, it paves the way for elevated e-commerce experiences. As the e-commerce landscape continues to evolve, Amazon Bedrock offers businesses the tools they need to stay ahead of the curve.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ff55422a848" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Large Language Models: Generative AI Project Lifecycle — Part 1]]></title>
            <link>https://medium.com/@padmathanumoorthy/generative-ai-project-lifecycle-part1-24c545fb9391?source=rss-150c6c06a635------2</link>
            <guid isPermaLink="false">https://medium.com/p/24c545fb9391</guid>
            <category><![CDATA[llm-project-lifecycle]]></category>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[llm-pre-training]]></category>
            <category><![CDATA[build-genai]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Padma Thanumoorthy]]></dc:creator>
            <pubDate>Tue, 27 Feb 2024 07:19:38 GMT</pubDate>
            <atom:updated>2024-02-27T23:08:30.424Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering Large Language Models: Generative AI Project Lifecycle — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sipTujY5z-IAlGoeKRc5xA.png" /></figure><p>Generative AI — Large Language Models(LLMs) have revolutionized the way we interact with text, enabling us to communicate, analyze, and generate content with unprecedented sophistication. Join me from this article series to navigate the phases and steps involving the development the Generative AI project lifecycle from inception till its launch. <em>If you are new to Gen AI, check my </em><a href="https://medium.com/@padmathanumoorthy/large-language-models-understanding-basics-llm-abilities-and-transformer-architecture-model-7e01d064659e"><em>previous article</em></a><em> for the basic understanding of LLMs, LLM abilities, and Transformer architecture model explained.</em></p><blockquote>Welcome to the Generative AI Project Lifecycle series!</blockquote><h3>Generative AI Project Lifecycle — Phase 1</h3><p>The entire process of Generative AI project lifecycle resembles a sequential dependency process starts from Scope, Select, Adapt and Align/Harmonize model, and Application Integration. The flow indicates that each step builds upon the previous. It’s necessary to understand that each phase is essential for the success of your project.</p><p>The below flow diagram highlights the first phase 1 of Generative AI Project Lifecycle — “<strong>Scope, Select, and Pre-training</strong>” requires to kickstart the GenAI project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VPW5wLu_4nkcfEXp1V0pJw.png" /><figcaption>Image created by author</figcaption></figure><h3>1. Scope: Define Problem</h3><p>Like any application, generative AI project begins with a problem which needs a solution. Understanding the problem, the solution through Gen AI, and measurable metrics form the backbone of a successful project. LLMs are capable of carrying out many tasks, but their abilities depend strongly on the size and architecture of the model. Establish what the project aims to achieve with generative AI.</p><p>Do you need the model to be able to carry out many different tasks? including huge text generation, or with a high degree of capability, or is the task much more specific like named entity recognition so that your model only needs to be good at one task based on the requirement. Getting really specific about what is expected from the model save more time and perhaps more importantly, <strong>compute cost</strong>.</p><h3>2. Select: Choose Model</h3><p>Scope requirements drives the model selection. Decide between using the own model and train them from scratch or work with an existing base model called as Foundation Models (FMs). The AI community offers a wide variety of pre-trained models suitable for various tasks. It’s crucial to assess these models, considering factors like their performance, scalability, and compatibility with the project. The GPT, BERT, FLAN T5 are examples of powerful models available for use.</p><h4>Choosing the Right LLM Architecture</h4><p>The best LLM architecture for a particular task depends on the specific requirements of the task. For example,</p><ul><li>If the task requires generating long sequences of text, then a transformer-based LLM like GPT-3 or BERT may be a good choice.</li><li>If the task requires question answering or understanding the context of words in a sentence, then a model like BERT or XLNet may be more appropriate.</li><li>If the task requires summarization of the dialogues between personals/entities, then a model like HuggingFace FLAN T5 may be a choice.</li></ul><h3><strong>3. Pre-training large language models</strong></h3><p>Pre-training in the context of Large Language Models (LLMs) refers to the initial phase of training where the model is exposed to a vast amount of unlabeled corpora of text data to learn the patterns and structures inherent in the language. Pre-training trains the LLM using vast amounts of unstructured textual data via self-supervised learning.</p><p>This phase is crucial for the model to develop a general understanding of syntax, semantics, and contextual relationships within the language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hxMHi4-CLHDB3hdTMSkl1g.png" /><figcaption>Image from DeepLearning.AI</figcaption></figure><p>The LLMs’ architecture affects both training efficiency and inference efficiency, which is how quickly and efficiently it can come up with answers after being taught. It’s possible that more complicated models will work better, but they may be slower and cost more to run in a production setting. There are several classes of large language models that are suited for different types of use cases:</p><ul><li><strong>Auto-encoding models</strong> — Encoder only LLM. These models are typically suited for tasks that can understand language, such as Named Entity Recognition (NER), classification, and sentiment analysis. Examples of encoder-only models include BERT (Bidirectional Encoder Representations from Transformers), RoBERTa (Robustly optimized BERT pretraining Approach). These models are trained with the <strong>MLM — Masked Language Modeling</strong> where inputs are randomly masked. Training objective is to predict the masked tokens to reconstruct the original sentence.</li><li><strong>Auto-regressive models — </strong>Decoder only LLM. This class of models is extremely good at generating language and content. Some use cases include story writing and blog generation. Examples of decoder-only architectures include GPT-3 (Generative Pretrained Transformer 3), BLOOM. These models are trained with the <strong>CLM — Causal Language Modeling </strong>which<strong> </strong>has the training objective to predict the next token based on the previous sequence of tokens. This is called <em>Full language modeling</em>.</li><li><strong>Sequence-to-Sequence models —</strong> Encoder-Decoder LLM<strong>. </strong>These models combine the encoder and decoder components of the transformer architecture to both understand and generate content. Some use cases where this architecture shines include translation and summarization. Examples of encoder-decoder architectures include T5 (Text-to-Text Transformer), BART. These models are trained with the<strong> Span corruption modeling. </strong>This masks the random sequence if input tokens. Training objective is to replace the masked tokens with unique sentinel token added to the vocabulary.</li></ul><p>The selection of appropriate pre-training objectives is an active area of continuous research, and researchers continually explore novel objectives and combinations to unlock the full potential of LLMs.</p><h4>Challenges of LLM Pre-training</h4><p>The significant capital investment, large datasets, technical expertise, and large-scale compute infrastructure necessary to develop and maintain large language models have been a barrier to entry for most enterprises.</p><p>To train the Large Language Models (LLMs), the design of the model is very important because it determines how much compute power is required.</p><h4><strong>Optimization methods:</strong></h4><p>Researchers use a variety of optimization methods to deal with the computational needs of complex models. The three common techniques used for model optimization are pruning, quantization, and topology optimization.</p><p><strong><em>Quantization</em></strong>: This involves reducing the precision of the model’s weights and activations, typically from floating-point numbers to integers. Precision reduced to 16-bit floating-point (FP16, BFLOAT16 -2 bytes) or 8-bit integers (INT8 –1 byte) instead of 32-bit ones.</p><p><strong><em>Pruning</em></strong>: This involved reducing the number of parameters that are not needed and less important.</p><p><strong><em>Topology optimization</em></strong>: This involves condensing the information from a big model into a smaller, more efficient one for the faster execution. This is known as <em>Model Distillation</em> or <em>knowledge distillation.</em></p><h3>Conclusion</h3><p>In this article, we have explored the generative AI project lifecycle starting from</p><ol><li>Define the problem (Scope)</li><li>Selecting the right large language model based on requirements and cost.</li><li>Fundamental pre-training techniques</li></ol><ul><li>Model architectures and pre-training objectives.</li><li>Pre-training challenges</li><li>Optimizations techniques for LLM efficiency and faster execution.</li></ul><p>Let us continue the rest of the steps in the next article. Stay tuned!</p><p><strong>Further Resources:</strong></p><ul><li>Jacob Devlin, Ming-Wei Chang, Kenton Lee, Kristina Toutanova (2019). BERT: Bidirectional Encoder Representations from Transformers. <em>arXiv preprint arXiv:1810.04805</em>.</li></ul><p><strong>Previous Articles:</strong></p><p><em>Generative AI Large Language Models: Basics, LLM Abilities, and Transformer Architecture Explained</em></p><p><a href="https://medium.com/@padmathanumoorthy/large-language-models-understanding-basics-llm-abilities-and-transformer-architecture-model-7e01d064659e">https://medium.com/@padmathanumoorthy/large-language-models-understanding-basics-llm-abilities-and-transformer-architecture-model-7e01d064659e</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24c545fb9391" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Large Language Models: Understanding Basics, LLM abilities, and Transformer Architecture model]]></title>
            <link>https://medium.com/@padmathanumoorthy/large-language-models-understanding-basics-llm-abilities-and-transformer-architecture-model-7e01d064659e?source=rss-150c6c06a635------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e01d064659e</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[attention-is-all-you-need]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[transformer-architecture]]></category>
            <dc:creator><![CDATA[Padma Thanumoorthy]]></dc:creator>
            <pubDate>Sun, 18 Feb 2024 07:00:31 GMT</pubDate>
            <atom:updated>2024-12-04T19:02:31.528Z</atom:updated>
            <content:encoded><![CDATA[<h3>Generative AI Large Language Models: Basics, LLM Abilities, and Transformer Architecture Explained</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ejdmCWop9CKZqs26dwwfWA.png" /></figure><p>In the era of advanced AI, understanding and effectively leveraging Generative AI — Large Language Models(LLMs) are crucial skills. Large Language Models have revolutionized the way we interact with text, enabling us to communicate, analyze, and generate content with unprecedented sophistication. Join me in this article to uncover the basic understanding of Large Language Model and Transformer architecture Model.</p><h3><strong>Understanding LLM basics</strong></h3><p>Before diving into the complexities of LLMs, it’s crucial to establish a solid foundation in the fundamental concepts. This includes understanding the following:</p><h4><strong>What is Generative AI?</strong></h4><p>Generative AI is a subset of traditional machine learning. And the machine learning models that underpin generative AI have learned these abilities by finding statistical patterns in massive datasets of content that was originally generated by humans.</p><h4><strong>What are LLMs?</strong></h4><p>LLMs, standing for Large Language Models, constitute a subgroup within the realm of deep learning models. LLMs are neural network models trained on massive datasets of text and code, characterized by their substantial size, often boasting tens of billions of parameters. Large language models have been trained on trillions of words over many weeks and months, and with large amounts of compute power. We call these as Foundation models (FMs).</p><h4><strong>What are LLM Abilities?</strong></h4><p>Renowned for their exceptional performance, LLMs excel across a diverse spectrum of natural language tasks. LLMs possess a range of remarkable abilities and its growing everyday. They are designed to understand and generate human-like language, and they have a wide range of applications, including:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mjbBdZ1-p7cKQkp-bU7aCg.gif" /></figure><ol><li><strong>Natural Language Understanding (NLU):</strong> LLMs can comprehend and interpret the nuances of natural language, enabling them to understand context, sentiment, and semantic meaning in textual data.</li><li><strong>Text Generation:</strong> LLMs have the capability to generate coherent and contextually relevant text, making them valuable for tasks like content creation, article writing, and creative writing.</li><li><strong>Translation:</strong> LLMs excel in language translation tasks, providing accurate and context-aware translations between different languages.</li><li><strong>Summarization:</strong> These models can distill large volumes of text into concise and meaningful summaries, aiding in information extraction and document summarization.</li><li><strong>Question Answering:</strong> LLMs can answer questions posed in natural language, leveraging their understanding of context and knowledge.</li><li><strong>Sentiment Analysis:</strong> LLMs can analyze the sentiment expressed in textual data, determining whether the tone is positive, negative, or neutral.</li><li><strong>Named Entity Recognition (NER):</strong> Identifying and classifying entities such as names of people, organizations, locations, etc., within text is another strength of LLMs.</li><li><strong>Conversational AI:</strong> LLMs can be employed in conversational agents, chatbots, and virtual assistants, providing human-like interactions by understanding and generating natural language responses.</li><li><strong>Code Generation:</strong> Some LLMs are proficient in generating code snippets based on natural language descriptions, facilitating programming tasks.</li><li><strong>Multimodal Capabilities:</strong> In certain cases, LLMs exhibit the ability to understand and generate content across multiple modalities, including text, images, and potentially audio. eg : Google <strong>Gemini</strong> Multimodal model</li></ol><h4>What is Prompt engineering?</h4><p>Prompt engineering is the process of crafting effective prompts for LLMs to improve their performance we expect. It involves precise and strategic techniques to fine-tune the input provided to ML models to elicit more accurate and relevant responses. Providing examples inside the context window is called <strong>In-Context Leaning</strong>.</p><p>Effective prompt engineering requires an understanding of the model’s capabilities and limitations, allowing users to optimize the interaction and harness the full potential of large language models for diverse applications, from content creation to problem-solving in natural language processing tasks.</p><h4>Explore LLM Architectures</h4><p>There are several different LLM architectures, each with its own strengths and weaknesses. Some of the most popular LLM architectures include:</p><ul><li><strong>Transformer</strong> models, such as GPT-3 and BERT, are known for their ability to handle long sequences of text and their strong performance on a variety of NLP tasks.</li><li><strong>Recurrent Neural Network (RNN)</strong> models, such as LSTM and GRU, are well-suited for tasks that require sequential processing, such as language generation and machine translation.</li><li><strong>Convolutional Neural Network (CNN)</strong> models, such as those used in computer vision, can be adapted for NLP tasks by treating text as a sequence of characters or words.</li></ul><h3>Transformer-Model Architecture</h3><p>The Transformer architecture revolutionized natural language processing (NLP) tasks. It was first introduced in the 2017 paper “<strong>Attention is All You Need</strong>” by researchers at Google. Unlike traditional sequence-to-sequence models (RNNs), Transformers rely on self-attention mechanisms, enabling natural language parallel processing of input sequences. The power of the transformer architecture has the ability to learn the relevance and context of all of the words in a sentence and generate the coherent and contextually relevant response.</p><p>Transformers are used in tasks such as:</p><ol><li>Summarizing text</li><li>Translating text from one language to another</li><li>Retrieving relevant information from a corpus of text given a query</li><li>Classifying images.</li></ol><p>Check this <a href="https://arxiv.org/abs/1706.03762">research paper</a>: <strong>Attention Is All You Need</strong></p><h4>Attention Is All You Need: Transformer Architecture Explained</h4><p>Traditional models used recurrent neural networks (RNNs) or convolutional neural networks (CNNs) for processing sequences. The Transformer abandons these and relies solely on <strong>attention mechanisms</strong>, creating a simpler and more powerful architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*qLrLK0YZR2LrTz_LR87Eng.png" /><figcaption>Image credit from <a href="https://arxiv.org/abs/1706.03762">https://arxiv.org/abs/1706.03762</a></figcaption></figure><p><strong>Attention Mechanism:</strong></p><p>Imagine you’re reading a sentence. You don’t focus on every word equally; you selectively pay attention to relevant words based on the context. The attention mechanism works similarly. It involves three components:</p><ul><li><strong>Query:</strong> Represents the current element being processed (e.g., the word you’re focusing on).</li><li><strong>Key-Value Pairs:</strong> Represent each element in the input sequence (e.g., other words in the sentence).</li><li><strong>Attention scores:</strong> Calculated by comparing the query with each key. Higher scores indicate a stronger relevance between the current element and the corresponding key. Based on these scores, the attention mechanism selectively attends to relevant parts of the input sequence and combines their values to create a more informative representation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*9RGu2vEue4yv-oYWGS5mkQ.png" /><figcaption>Image credit from DeepLearning.AI</figcaption></figure><p>The Transformer uses multiple <strong>encoder</strong> layers and <strong>decoder</strong> layers stacked together as we have seen in the above architecture pic.</p><p><strong>Encoder Layers:</strong></p><p>The encoder component of the transformer consists of multiple layers with a consistent structure. These layers include the following components:</p><ul><li>Multi-Headed Self-Attention</li><li>Feed-Forward Neural Network</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*z3z9qANoyvV1F6TvV56rEQ.jpeg" /></figure><p>Each of these modules is followed by layer normalization and a residual connection. By passing the input sequence through these layers, the representation for each token is transformed.</p><ol><li>Each layer uses self-attention, meaning the model attends to different parts of the input sequence to understand relationships between words.</li><li>And a learned, multi-layer neural network that implements a non-linear transformation of each individual token.</li></ol><p>When the input sequence is processed through several consecutive layers of the identical structure, the resulting output sequence will have a similar length and contains context-aware representations for each token. This is achieved by the combined effect of normalization, residual connection, and the various modules involved in the transformation process.</p><p><strong>Decoder Layers:</strong></p><p>The decoder is composed of multiple identical layers. Each layer includes the following components:</p><ul><li>Masked Multi-Head Attention</li><li>Multi-Head Attention</li><li>Feed-Forward Neural Network</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*3P-UqGyaW8l2xK18MBEdUQ.png" /></figure><p><strong>Masked Multi-head </strong>self-attention helps in performing sequence-to-sequence tasks like language translation by ensuring a model doesn’t “look ahead” in the input sequence. This means that each token in the decoder is only adapted based on tokens that come before it in the input sequence.</p><p><strong>Multi-head</strong> self-attention performs multiple independent self-attention computations in parallel, each with its own parameters. This allows for improved representation of the input and helps to capture multiple, different relationships between tokens in the sequence.</p><p>The <strong>feed-forward neural network </strong>(FFN) applies a linear transformation to the output from the multi-head self-attention component, followed by <a href="https://blog.roboflow.com/activation-function-computer-vision/">activation functions</a>. <em>Among the various activation functions available, </em><strong><em>Rectified Linear Unit (ReLU)</em></strong><em> and </em><strong><em>Gaussian Error Linear Unit (GELU) </em></strong><em>are two popular choices.</em></p><p>The FFN further transforms the representations and passes the final result through layer normalization.</p><p>Finally, a residual connection is added to the output from the layer normalization component. This connection helps in solving the vanishing gradient problem during training, which can have a significant and negative impact on training results. The residual connection helps to maintain the original information and helps to prevent overfitting.</p><p>The combination of these modules forms a decoder layer. The final output from the decoder is the context-aware representations of each token in the sequence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*icPxy6-Z6gvzl9RQkI9fCg.gif" /><figcaption>Gif credit from the Google AI BlogPage</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*UH5SSuMy9y-BcBtvAUhTmQ.gif" /><figcaption>Image from Resource 3 below</figcaption></figure><h4>Common Transformer Architectures</h4><p>Here is a brief overview of some of the most common LLM architectures:</p><ul><li><strong>GPT (Generative Pre-trained Transformer)</strong>: Developed by OpenAI, GPT is a transformer-based LLM that is known for its ability to generate coherent and realistic text.</li><li><strong>BERT (Bidirectional Encoder Representations from Transformers)</strong>: Developed by Google AI, BERT is a transformer-based LLM that is particularly effective for tasks that require understanding the context of words in a sentence.</li><li><strong>XLNet (Generalized Autoregressive Pretraining for Language Understanding)</strong>: Developed by Google AI, XLNet is a transformer-based LLM that combines the strengths of autoregressive and autoencoding models.</li><li><strong>RoBERTa (Robustly Optimized BERT Approach)</strong>: Developed by Facebook AI Research (FAIR), RoBERTa is a variant of BERT that is trained on a larger dataset and with more training steps.</li></ul><h4><strong>Transformer Architecture Model Benefits:</strong></h4><ul><li><strong>Parallelization:</strong> Attention allows for parallel processing, making the Transformer faster to train than RNN-based models.</li><li><strong>Long-range dependencies:</strong> The model can capture long-range relationships between words effectively, thanks to self-attention.</li><li><strong>State-of-the-art results:</strong> The Transformer achieved significant improvements in various NLP tasks like machine translation, summarization, and question answering.</li></ul><p><strong>Further Resources:</strong></p><ul><li><strong>Research paper</strong>: <a href="https://arxiv.org/abs/1706.03762">https://arxiv.org/abs/1706.03762</a></li><li><strong>Google AI Blog post:</strong> <a href="https://blog.research.google/2017/08/transformer-novel-neural-network.html">https://blog.research.google/2017/08/transformer-novel-neural-network.html</a></li><li><a href="https://towardsdatascience.com/drawing-the-transformer-network-from-scratch-part-1-9269ed9a2c5e">https://towardsdatascience.com/drawing-the-transformer-network-from-scratch-part-1-9269ed9a2c5e</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e01d064659e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>