<?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 The Build Log on Medium]]></title>
        <description><![CDATA[Stories by The Build Log on Medium]]></description>
        <link>https://medium.com/@theBuildLog?source=rss-6306c38a39c6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*b_Szo5eY2gAmUH6meXoWnA.png</url>
            <title>Stories by The Build Log on Medium</title>
            <link>https://medium.com/@theBuildLog?source=rss-6306c38a39c6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 02:45:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@theBuildLog/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[AI Fundamentals: A Guide to Feed-Forward Networks]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://pub.towardsai.net/ai-fundamentals-a-guide-to-feed-forward-networks-e6a26d8a6fa7?source=rss-6306c38a39c6------2"><img src="https://cdn-images-1.medium.com/max/1408/0*FAl8INSpRePK5twc" width="1408"></a></p><p class="medium-feed-snippet">How machines learn non-linear patterns, explained simply.</p><p class="medium-feed-link"><a href="https://pub.towardsai.net/ai-fundamentals-a-guide-to-feed-forward-networks-e6a26d8a6fa7?source=rss-6306c38a39c6------2">Continue reading on Towards AI »</a></p></div>]]></description>
            <link>https://pub.towardsai.net/ai-fundamentals-a-guide-to-feed-forward-networks-e6a26d8a6fa7?source=rss-6306c38a39c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6a26d8a6fa7</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[The Build Log]]></dc:creator>
            <pubDate>Wed, 04 Nov 2026 15:01:04 GMT</pubDate>
            <atom:updated>2026-11-04T15:01:04.409Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[AI Fundamentals: Attention Mechanisms in Transformers (Part 2)]]></title>
            <link>https://pub.towardsai.net/ai-fundamentals-attention-mechanisms-in-transformers-part-2-6f434906625b?source=rss-6306c38a39c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f434906625b</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[The Build Log]]></dc:creator>
            <pubDate>Wed, 23 Sep 2026 21:31:01 GMT</pubDate>
            <atom:updated>2026-09-23T21:31:01.911Z</atom:updated>
            <content:encoded><![CDATA[<p>Attention is one of the two major computational sublayers in a Transformer block; the other is the feed-forward network. Normalization, residual connections, positional mechanisms, and other details sit around these two operations. Part 1 covered the attention half of that pair: how relationships between tokens get scored, how far a token can see, which direction information flows, and how Q, K, and V get split across heads.</p><p>The next step is to look at how a real model might take in information and process it, because a few things change when training a model at scale.</p><p>Attention, as defined so far, is powerful but incomplete. It has no built-in sense of where a token sits in the sequence, no mechanism for skipping re-computation as generation proceeds one token at a time, and no answer for how the underlying matrix math survives contact with real hardware once sequences get long or the input stops being text altogether. Modern transformer engineering has settled on some clever, fairly durable answers to each of those gaps.</p><p>While research is large and still active, and new papers continue to add variants to each of these problem areas, this article covers four techniques that sit among the most widely adopted answers to date: RoPE, the KV cache, Flash attention, and cross-modal attention.</p><h3>1. Where is this token, exactly?</h3><p>Consider two short sentences built from the same three content words:</p><p>The cat ate the fish. The fish ate the cat.</p><p>The meaning is reversed, even though the two sentences use identical tokens. Whatever mechanism scores relationships between those tokens needs some signal that distinguishes “cat before ate” from “fish before ate,” or the two sentences become indistinguishable to it. Attention, as defined so far, has no such signal built in.</p><p>Here is that problem stated more precisely, hiding in plain sight in the scaled dot-product formula from Part 1:</p><p>Attention(Q, K, V) = softmax( (Q · Kᵀ) / √dₖ ) · V</p><p>Nothing in this equation cares about <em>order</em>. If the tokens in a sentence were scrambled and presented in a different order, the content-dependent Q·Kᵀ interactions would remain the same for the same token pairs, but their positions in the resulting attention matrix would be rearranged.</p><p>Transformers need to inject position information somehow. The original <em>Attention Is All You Need</em> paper did this by adding a fixed sinusoidal vector to each token’s embedding, and later models used learned position embeddings instead. Both provide positional information, but they encode position differently from RoPE: token 5 receives information associated with its absolute position, as does token 500, while relative-distance relationships have to be inferred from those positional representations.</p><p><strong>Rotary Position Embedding (RoPE)</strong> takes a different approach: instead of adding position information, it <em>rotates</em> the query and key vectors by an angle that depends on position.</p><p>Take a pair of dimensions from a vector, (x₂ᵢ, x₂ᵢ₊₁), and rotate them by an angle θ that grows with the token&#39;s position m:</p><pre>θ = m · base^(-2i/d)</pre><ul><li>m is the token&#39;s position in the sequence (token #0, token #1, and so on).</li><li>d is the vector&#39;s total dimensionality (64, 128, whatever the head dimension is).</li><li>2i identifies the starting dimension of the pair being rotated: 0, 2, 4, …, d−2. Pair i=0 contains dimensions 0 and 1, pair i=1 contains dimensions 2 and 3, and so on.</li><li>2i/d is therefore how deep into the vector that pair sits, as a fraction from 0 (the very first pair) to just under 1 (the last pair).</li><li>base (typically 10,000) anchors the overall range of rotation speeds. Because the exponent is negative, base^(-2i/d) is largest when 2i/d is near 0 and shrinks as 2i/d approaches 1, so the rotation angle θ = m · base^(-2i/d) is largest for the first dimension pair and smallest for the last. The first pair rotates fastest, the last pair rotates slowest, and every pair in between rotates at its own speed set by how deep it sits in the vector, similar in spirit to how sinusoidal embeddings assigned different frequencies to different dimensions.</li></ul><p>A simple picture helps here. Think of each pair of dimensions as a clock hand. Position 0 leaves the hand untouched; each later position nudges the hand forward by a fixed angle:</p><pre>Position 0        Position 1        Position 2<br>    ↑                 ↗                 →<br>    |   (0°)         (θ)              (2θ)</pre><blockquote>Each step adds another angular increment.<br> Different dimension-pairs rotate at different speeds, encoding positional information.</blockquote><p>The part that makes RoPE genuinely useful is what happens at the scoring step. When the query is rotated by its position m and the key is rotated by its position n, and the two are then combined via dot product, the absolute positions m and n do not vanish from the computation; instead, their difference appears as a relative rotation of (n − m).</p><pre>(Rₘ Q) · (Rₙ K) = Qᵀ Rₙ₋ₘ K</pre><p>Two concepts from the formula above:</p><ul><li><strong>The triplet (Q, K, V).</strong> For every token passing through an attention head, the model generates three vectors: the Query (Q), the question being asked by the token at position m; the Key (K), the feature tags advertised by the token at position n; and the Value (V), the actual content payload delivered forward if Q and K match well.</li><li><strong>Relative distance.</strong> RoPE rotates Q by m and K by n. When they are combined via dot product, the positional component can be expressed through the relative offset (n − m).</li></ul><pre>Token at position 50           Token at position 3050<br>        ↓                              ↓<br>   rotate by 50θ                  rotate by 3050θ<br>        ↓                              ↓<br>        └──────────── dot product ─────────────┘<br>                        ↓<br>positional component reflects the relative offset: <br>50 − 3050 = −3000</pre><p>RoPE’s relative-position property does not make it immune to context-length extrapolation problems. When a model is evaluated substantially beyond the positional range represented during training, its learned use of the rotary frequencies can degrade, motivating techniques such as position interpolation, frequency rescaling, or YaRN.</p><pre>import torch<br>def apply_rope(x, base=10000):<br>    # x: (seq_len, dim), applied as a preprocessing step to Q or K.<br>    seq_len, dim = x.shape<br>    positions = torch.arange(seq_len).unsqueeze(1).float()   # (seq_len, 1), this is m<br>    freq_idx = torch.arange(0, dim, 2).float()                # (dim/2,), this is 2i<br>    # inv_freq[i] = base^(-2i/d)<br>    inv_freq = 1.0 / (base ** (freq_idx / dim))                # (dim/2,)<br>    theta = positions * inv_freq.unsqueeze(0)                  # (seq_len, dim/2), outer product: m * base^(-2i/d)<br>    cos, sin = torch.cos(theta), torch.sin(theta)<br>    # Note: interleaving even/odd dimensions matches the original RoPE<br>    # paper.<br>    x1, x2 = x[..., 0::2], x[..., 1::2]                       # even/odd dims<br>    rotated = torch.empty_like(x)<br>    rotated[..., 0::2] = x1 * cos - x2 * sin<br>    rotated[..., 1::2] = x1 * sin + x2 * cos<br>    return rotated</pre><p>Note that RoPE is applied to Q and K before the dot product, never to V, since V carries content, not position.</p><h3>2. Why redo work that has already been done?</h3><p>Recall causal self-attention from Part 1: each token can only attend to itself and everything before it. That constraint has a useful side effect. Once a token’s key and value vectors are computed, they never change, because nothing that comes <em>after</em> a token can influence its own K or V, since attention only flows backward.</p><p>Consider what this means for text generation, one token at a time. Naively, at every single step, the model would recompute Q, K, and V for the <em>entire</em> sequence so far, run full attention, and keep only the last token’s output. Five hundred tokens into generation, that means recalculating the K and V for all 499 earlier tokens at every single step, even though those values are identical to what was computed the step before. It is comparable to rewriting the first five hundred pages of a book from scratch every time a single new sentence gets added to page 501.</p><p>The <strong>KV cache</strong> simply avoids that redundancy. Keys and values for already-processed tokens are stored once and reused. On each new step, the model computes Q, K, and V only for the <em>newest</em> token, appends that K and V to the cache, and attends the new query against everything stored so far.</p><pre>Step 1: &quot;The&quot;<br>  cache:  K₁ V₁</pre><pre>Step 2: &quot;The cat&quot;<br>  cache:  K₁ V₁ | K₂ V₂            ← K₁,V₁ reused, not recomputed</pre><pre>Step 3: &quot;The cat sat&quot;<br>  cache:  K₁ V₁ | K₂ V₂ | K₃ V₃    ← only K₃,V₃ are new</pre><pre>Each step appends one token’s K/V representation.</pre><pre>class KVCache:<br>    def __init__(self):<br>        self.k_cache = None<br>        self.v_cache = None<br><br>    def update(self, new_k, new_v):<br>        # new_k, new_v: (1, dim) for the newest token<br>        if self.k_cache is None:<br>            self.k_cache, self.v_cache = new_k, new_v<br>        else:<br>            # Pedagogical only. Production caches preallocate<br>            # or use block-based storage.<br>            self.k_cache = torch.cat([self.k_cache, new_k], dim=0)<br>            self.v_cache = torch.cat([self.v_cache, new_v], dim=0)<br><br>        return self.k_cache, self.v_cache<br><br><br>def generate_step(q_new, k_new, v_new, cache):<br>    k_full, v_full = cache.update(k_new, v_new)<br>    d_k = q_new.size(-1)<br>    scores = (q_new @ k_full.transpose(-2, -1)) / (d_k ** 0.5)<br>    weights = torch.softmax(scores, dim=-1)<br>    return weights @ v_full</pre><p>Without a cache, the attention portion of generation repeatedly recomputes the entire prefix at every decoding step. At step i, this can require O(i²) attention work, and summed across n decoding steps, the cumulative attention work reaches O(n³).</p><p>By using a KV cache during decoding, a single new query token only needs to attend against the i keys already stored in memory. That drops a single decoding step down to O(i) compute, turning the overall generation process into O(n²).</p><p>But that saving introduces a new memory-bandwidth bottleneck. Every layer and every attention head needs its own set of K and V vectors saved for every generated token. These vectors get stored in the GPU’s high-bandwidth memory (HBM, effectively its VRAM). HBM stores the large tensors, while the GPU’s compute units perform the matrix operations using data brought through the GPU’s memory hierarchy, including much smaller and faster on-chip memories such as registers and shared memory/SRAM. At each decoding step, the GPU must repeatedly read the accumulated KV cache through the memory hierarchy so the new query can compare against the stored keys and combine their values. With a small batch size, this means repeatedly moving large amounts of cached data through the GPU’s memory hierarchy for relatively little new arithmetic.</p><p>This pressure motivated <strong>multi-query and grouped-query attention</strong>. Multi-query attention (MQA) forces every head to share a single K/V pair, shrinking the cache drastically at the expense of some model capacity. Grouped-query attention (GQA) strikes a balance, sharing K/V pairs within small groups of heads instead of across all of them or none of them. A smaller cache means less data shuttling between HBM and SRAM on every single token, freeing the GPU to run larger batch sizes and deliver much higher throughput.</p><h3>3. Making the math faster</h3><p>Part 1 noted that global attention costs O(n²) in both compute and memory: the attention matrix has one entry for every pair of tokens. For a sequence of 32,000 tokens, that matrix has over a billion entries, and a naive implementation has to <em>materialize</em> that entire matrix in GPU memory before it can run SoftMax on it.</p><p>GPUs can do the floating-point operations fast enough; the slow part is moving a matrix that large between two tiers of GPU memory: the large, comparatively slow high-bandwidth memory (HBM) where tensors normally live, and the small, very fast on-chip SRAM where the GPU actually performs computation. Memory bandwidth, not compute, is often what limits the whole operation.</p><p><strong>Flash attention</strong> never materializes the full n×n matrix in HBM. It avoids writing intermediate n×n attention scores back out to HBM. Blocks of Q, K, and V are loaded through the GPU memory hierarchy into on-chip memory, where tiled matrix multiplication, scaling, and online softmax can be performed without materializing the full attention matrix in HBM. Q is processed in row blocks while K and V are processed along their sequence dimension, creating nested Q-block and K/V-block loops.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*HtkqF9wgG235P6hMqCWs2A.png" /><figcaption>Source: Image generated using AI.</figcaption></figure><p>A useful mental picture: rather than printing out an enormous spreadsheet in full just to perform one calculation, the tiles are kept in fast, on-chip memory and processed a small block at a time, with the matrix multiplication and softmax steps fused together so intermediate results never have to round-trip through slower memory.</p><p>The mechanism that makes this possible is the <strong>online softmax</strong>. Ordinarily, softmax needs to see every score in a row before normalizing any of them, since the normalizing sum depends on all of them. Flash attention tracks a running maximum and sum, rescaling the output computed so far whenever a new, larger maximum appears.</p><pre># Simplified online-softmax example.<br># q is one block of query rows; K and V are processed in sequence blocks.<br># Production FlashAttention additionally tiles Q and optimizes GPU execution.<br>def flash_attention_block(q, k_blocks, v_blocks):<br>    # q:            (Q_len, d_k)<br>    # each k_block: (K_block_len, d_k)<br>    # each v_block: (K_block_len, d_v)<br>    d_k = q.size(-1)<br>    running_max = torch.full((q.size(0),), float(&#39;-inf&#39;))     # (Q_len,)<br>    running_sum = torch.zeros(q.size(0))                       # (Q_len,)<br>    output = torch.zeros(q.size(0), v_blocks[0].size(-1))       # (Q_len, d_v)<br>    for k_block, v_block in zip(k_blocks, v_blocks):<br>        scores = (q @ k_block.transpose(-2, -1)) / (d_k ** 0.5)  # (Q_len, K_block_len)<br>        block_max = scores.max(dim=-1).values                    # (Q_len,)<br>        new_max = torch.maximum(running_max, block_max)          # (Q_len,)<br>        correction = torch.exp(running_max - new_max)             # (Q_len,), rescales prior blocks<br>        block_weights = torch.exp(scores - new_max.unsqueeze(-1)) # (Q_len, K_block_len)<br>        # correction and running_sum are (Q_len,); unsqueeze(-1) broadcasts<br>        # them against the (Q_len, d_v) output so each query row is scaled<br>        # by its own running max, not a single shared scalar.<br>        output = output * correction.unsqueeze(-1) + block_weights @ v_block  # (Q_len, d_v)<br>        running_sum = running_sum * correction + block_weights.sum(dim=-1)     # (Q_len,)<br>        running_max = new_max<br>    return output / running_sum.unsqueeze(-1)  # (Q_len, d_v)</pre><p>The online-softmax result is mathematically equivalent to standard attention. Flash attention is exact and can recompute needed attention values during the backward pass instead of storing the full n×n matrix. That IO-conscious design, on both passes, is what “IO-aware” in the algorithm’s name refers to: it is built around the cost of moving data between HBM and SRAM, not just the number of floating-point operations it performs. This dual tiling and recomputation are also why a correct, efficient Flash attention implementation is considerably harder to get right than the single-loop sketch above suggests.</p><p>A standard implementation that materializes the full attention matrix moves roughly O(n²) worth of data between HBM and SRAM, since the whole n×n score matrix gets written out and read back in. Flash attention’s tiling reduces HBM traffic by keeping intermediate attention blocks on chip instead of repeatedly materializing them in HBM. Its IO complexity depends on sequence length, head dimension, and available SRAM; importantly, Flash attention does not turn the quadratic attention computation into linear-time computation. Its major memory advantage is that its memory footprint grows linearly with sequence length rather than requiring an O(n²) attention matrix. The FLOP count changes little; the main savings come from reducing memory traffic.</p><h3>4. Attention beyond text</h3><p>Part 1 introduced cross-attention as “Q comes from one sequence, K and V come from another,” a decoder generating text while attending to an encoder’s output. That same pattern is what lets attention step outside text entirely.</p><p>The trick is that an image can be turned into something that <em>looks like</em> a sequence of tokens. In patch-based vision models, an image is split into fixed-size patches that are projected into vectors. Each patch becomes a vector, and a grid of patches becomes a “sequence” of patch embeddings, no different in shape from a sequence of word embeddings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zWuWLGKuJum2YVNIpzQ6sw.jpeg" /><figcaption>Source: Image generated using AI.</figcaption></figure><p>Once represented as tokens, image features can participate in cross-attention, allowing text queries to incorporate visual information.</p><pre>Text query: &quot;cat&quot;<br>        │<br>        ▼<br>  compares against every patch key<br>        │<br>        ▼<br>p1:0.02  p2:0.03  p6:0.71  p7:0.15  ...  p16:0.01<br>                     ↑<br>           strongest attention weight<br>           falls on a visual token</pre><pre>def cross_modal_attention(text_q, image_k, image_v):<br>    # text_q:  (text_len, d_model), queries from the text decoder<br>    # image_k: (num_patches, d_model), keys from image patch embeddings<br>    # image_v: (num_patches, d_model), values from image patch embeddings<br>    d_k = text_q.size(-1)<br>    scores = (text_q @ image_k.transpose(-2, -1)) / (d_k ** 0.5)<br>    weights = torch.softmax(scores, dim=-1)<br>    return weights @ image_v, weights</pre><p>Related attention mechanisms are widely used in image captioning, text-conditioned image generation, and multimodal assistants, although the direction of the Q, K, and V projections and the surrounding architecture can differ substantially between systems. The same idea extends to audio in older encoder-decoder systems such as Whisper, where waveform segments or spectrogram patches take the place of image patches as the sequence being attended over via cross-attention. Some audio-language models instead tokenize audio with a neural codec and process those tokens alongside text using self-attention.</p><p>Two simplifications are worth flagging in the walkthrough above. First, production vision-language models rarely feed raw patch embeddings straight into the language model. A dedicated vision encoder (CLIP or SigLIP, for instance) produces the patch representations first, and those typically pass through additional pooling or a small projection network that compresses the patch count substantially before anything reaches the language model, both to control compute cost and to align the vision encoder’s representation space with the language models. Second, cross-attention in the Part 1 sense, where Q comes from text and K/V come from a separate encoder, is only one way to combine modalities. A number of multimodal architectures instead project visual representations into a form that can be processed alongside language tokens, allowing self-attention to mediate interactions between the modalities. Other architectures retain dedicated cross-attention or use an intermediate module to connect the vision and language representations.</p><h3>Conclusion</h3><blockquote>The river carved through the canyon for centuries. Eventually, the canyon began to shape how the river flowed.</blockquote><p>A production model can combine these techniques around the same attention operation. When it reaches the second occurrence of “canyon,” self-attention connects that token back to the first one, however many tokens separate them, exactly as in Part 1. What changes in production is everything running around that connection:</p><ul><li><strong>Causal masking</strong> ensures the connection only forms for tokens already generated, never future ones.</li><li><strong>RoPE</strong> supplies positional information to their attention interaction.</li><li><strong>GQA</strong> shares K/V projections across groups of query heads.</li><li><strong>The KV cache</strong> stores the first “canyon” token’s K and V once, rather than recomputing them at every later step.</li><li><strong>Flash attention</strong> computes those attention scores in tiles without materializing the full n × n attention matrix in HBM.</li></ul><p>They are the layers built around the core operations from Part 1: compare Q against K, scale, mask, turn scores into weights with softmax, and use those weights to combine V. RoPE makes attention position-aware; the KV cache reduces redundant computation; FlashAttention reduces memory traffic; and cross-modal attention extends the same mechanism beyond text.</p><p>One caution is worth carrying forward. A single attention weight is not a window into a model’s reasoning. It is a learned signal that shapes what gets blended into a token’s representation, not a labeled trace of a thought process. Attention can still play causal roles, but establishing those roles requires systematic circuit analysis, not a glance at one high attention weight.</p><p>Together, these ideas show why attention is more than the equation suggests. The core operation is simple; making it useful in modern Transformers requires solving the problems around it: position, computation, memory, and modality.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f434906625b" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/ai-fundamentals-attention-mechanisms-in-transformers-part-2-6f434906625b">AI Fundamentals: Attention Mechanisms in Transformers (Part 2)</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Fundamentals: Attention Mechanisms in Transformers (Part 1)]]></title>
            <link>https://pub.towardsai.net/ai-fundamentals-attention-mechanisms-in-transformers-part-1-a91cce62fbab?source=rss-6306c38a39c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/a91cce62fbab</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[The Build Log]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 23:31:01 GMT</pubDate>
            <atom:updated>2026-09-08T23:31:01.187Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w2nbGIZ3eaMAcys2HIpdiA.jpeg" /><figcaption>Image generated using AI.</figcaption></figure><p>Consider the sentence:</p><p><em>Lily smiled brightly as </em><strong><em>she</em></strong><em> watched the puppy chase its tail.</em></p><p>Your brain instantly connects “<em>she</em>” back to the name.</p><p>A transformer needs mechanisms that allow information from one token to influence the representation of another, using vectors, matrices, and a mechanism called attention.</p><p>Attention is what gives a transformer a way to look around its input and ask: <strong>“Which pieces of information actually matter to me right now?”. </strong>The<strong> </strong>remainder of this article works through what that means in practice.</p><h3>What is attention?</h3><p>At its core, attention is a mathematical way for a model to measure relationships between pieces of information. Think about walking into a crowded room. There might be 100 people talking.</p><p>If someone across the room says your name, your brain immediately goes:</p><p><strong>Wait. That matters.</strong></p><p>Your attention shifts.</p><p>Transformers do something surprisingly similar. For every token, the model looks at other tokens and calculates how relevant they are. Important relationships receive larger weights; less relevant ones receive smaller weights.</p><p>So instead of treating a sentence like a pile of unrelated words, the model can build a contextual representation of each token. There are four useful questions to keep in mind when learning attention:</p><ol><li>How do we score relationships?</li><li>Where is a token allowed to look?</li><li>Which direction does information flow?</li><li>How are Q, K, and V shared across attention heads?</li></ol><h3>1. How do we score relationships?</h3><p>The underlying question is simple: how related are two pieces of information? Several mechanisms answer it differently.</p><h4>Additive attention</h4><p>Introduced by Bahdanau et al. in 2014, additive attention combines two vectors and passes the result through a small neural network to produce a score:</p><p>score(q, k) = vᵀ · tanh(W₁q + W₂k)</p><p>W₁ and W₂ are learned weight matrices applied to the query and key vectors respectively, and v is a learned weight vector that reduces the result to a single scalar score.</p><p>This uses an additional nonlinear computation step for each query-key pair, whereas dot-product attention can express all pairwise scores as a matrix multiplication (QKᵀ), making it particularly efficient on accelerators.</p><h4>Multiplicative / dot-product attention</h4><p>The idea is to j<strong>ust calculate the dot product. </strong>The dot product gives us a measure of how aligned two vectors are. And because dot products can be expressed as matrix multiplication, GPUs absolutely love this approach.</p><h4>Scaled dot-product attention</h4><p>This is the version introduced in the famous 2017 paper <em>Attention Is All You Need</em>.</p><p>Attention(Q, K, V) = softmax( (Q · Kᵀ) / √dₖ ) · V​​</p><p><strong>Step 1: Q · Kᵀ</strong></p><p>Every query is compared against every key and the result gives us a collection of raw relevance scores. Basically, every token asks:<em> “how relevant is everyone else to me?”</em></p><p>The resulting matrix contains those answers.</p><p><strong>Step 2: divide by √dₖ</strong></p><p>As vector dimensions become larger, dot products can also become very large. If those numbers get too extreme, softmax becomes overly confident. Its output can become very close to 0 or 1, which makes gradients tiny and learning harder. Dividing by √dₖ keeps the numbers under control.</p><p><strong>Step 3: softmax</strong></p><p>Now we turn those raw scores into weights. Softmax converts the scores into normalized attention weights where everything adds up to 1.</p><p>Taking an example query token: “smiled”</p><pre>Key/token → Attention Weights<br>Lily → 0.65<br>smiled → 0.20<br>brightly → 0.10 <br>...​​</pre><p><strong>Step 4: multiply by V</strong></p><p>Finally, those attention weights are used to calculate a weighted combination of the value vectors. The token doesn’t just remain the vector it started with. It becomes <strong>context-aware</strong>.</p><h4>Code Sample</h4><pre>import torch<br>import torch.nn.functional as F<br>def scaled_dot_product_attention(q, k, v, mask=None):<br>    d_k = q.size(-1)<br>    scores = torch.matmul(<br>        q,<br>        k.transpose(-2, -1)<br>    ) / (d_k ** 0.5)<br>    if mask is not None:<br>        scores = scores.masked_fill(<br>            mask == 0,<br>            float(&#39;-inf&#39;)<br>        )<br>    weights = F.softmax(scores, dim=-1)<br>    return torch.matmul(weights, v), weights</pre><h3>2. Where is a token allowed to look?</h3><p>If a token can look around, <strong>how far can it look?</strong></p><p>There are a couple of choices:</p><ul><li>Global vs. local attention</li><li>Soft vs. hard attention</li></ul><h4>Global vs. local attention</h4><p>Imagine you’re at a party. With <strong>global attention</strong>, you can talk to anyone in the room and every token can attend to every other token. Given n tokens, you’re potentially calculating relationships between every pair of tokens. Computing the attention scores has roughly O(n²d) time complexity, while storing the attention matrix requires O(n²) memory, so the cost grows quickly.</p><p>A sequence of 100 tokens? Not a big deal.</p><p>A sequence of 100,000 tokens? Now we’re talking about a <em>lot</em> of relationships.</p><p><strong>Local attention</strong> instead gives the tokens a smaller window and dramatically reduces computation. The trade-off is obvious: <strong>cheaper computation, but less global information.</strong></p><p>Note that local attention is an attention mechanism that restricts which tokens directly interact. The context window of a model, by contrast, refers to the maximum sequence length the model can process in a given context.</p><h4>Soft vs. hard attention</h4><p>Now imagine looking through the crowd for a friend. With <strong>soft attention</strong>, you don’t immediately pick one person. It produces continuous weights over candidate tokens, making the operation differentiable. You might look at everyone and assign probabilities:</p><pre>Person A → 5%<br>Person B → 10%<br>Person C → 70%<br>Person D → 15%</pre><p>You distribute your attention. That’s basically what standard transformer attention does. It’s differentiable, which means gradients can flow through it during training.</p><p><strong>Hard attention </strong>would be more like: “That’s my friend. Ignore everyone else.” That sounds simpler, but now we have a problem. The decision is discrete, so you can’t directly differentiate through the selection operation. Training hard attention therefore typically requires specialized estimators or continuous relaxations.</p><h3>3. Which direction does information flow?</h3><p>There are three common terms seen in attention:</p><ul><li>Self-attention</li><li>Cross-attention</li><li>Causal self-attention</li></ul><h4>Self-attention</h4><p>In self-attention, Q, K, and V all come from the <strong>same sequence</strong>. So, every token can look at other tokens in that sequence.</p><p>For example:</p><blockquote>The river carved through the canyon for centuries. Eventually, the canyon began to shape how the river flowed.</blockquote><p>When both sentences are present in the same context, self-attention can allow tokens in the second sentence to incorporate information from tokens in the first:</p><p>&quot;the canyon&quot;<br> ↓<br>&quot;canyon&quot; from earlier</p><p>and:</p><p>&quot;the river&quot;<br> ↓<br>&quot;river&quot; from earlier</p><p>The model doesn’t need the words to be right next to each other.</p><p>Attention gives it a mechanism for making those connections.</p><h4>Causal self-attention</h4><p>This is a special type of self-attention, absolutely critical for autoregressive LLMs.</p><p>Imagine you’re writing:</p><blockquote><strong><em>The cat sat on the…</em></strong></blockquote><p>and the model is trying to predict the next token.</p><p>It would be cheating if the model could peek ahead and see:</p><blockquote><strong><em>mat</em></strong></blockquote><p>before predicting it.</p><p>So causal attention imposes a rule:</p><p><strong>You can look backward, but you cannot look into the future.</strong></p><p>For example:</p><pre>The<br>The cat<br>The cat sat<br>The cat sat on<br>The cat sat on the</pre><p>When predicting the next token, each position can only attend to itself and the tokens before it. Technically, a mask is applied to future positions.</p><p>Those future attention scores are set to -∞ before softmax.</p><p>And because softmax(-∞) ≈ 0, the model effectively gets zero attention from future tokens.</p><h4>Cross-attention</h4><p>Here, the query comes from one sequence while the keys and values come from another. Imagine a decoder generating a sentence while looking at information produced by an encoder. In some multimodal architectures, text features can similarly serve as queries over image features.</p><p>So instead of:</p><blockquote><em>“I’m looking around inside my own sequence.”</em></blockquote><p>it’s more like:</p><blockquote><em>“I’m looking at information coming from somewhere else.”</em></blockquote><p>This is one of the ideas that allows attention to move beyond text.</p><h3>4. How are Q, K, and V shared across attention heads?</h3><p>Before turning to how multiple heads share Q, K, and V, let’s first understand the vectors themselves, and the weight matrices that produce them.</p><p><strong>The vectors: Q, K, and V</strong></p><p>Returning to the crowded-room analogy from earlier: each conversation in the room broadcasts something identifiable like a topic, a name, a tone, etc., which corresponds to the <strong>key</strong>: a signal a token makes available for others to measure against. A listener holds a sense of what they are currently listening for. This is a <strong>query: a</strong>ttention shifts toward whichever key matches this query most closely. What ultimately gets absorbed once attention lands, however, is not the key itself but the actual content of that conversation, the <strong>value</strong>. In a transformer, every input token produces all three vectors: a query representing what it is looking for in the rest of the sequence, a key representing what it offers to be matched against, and a value representing the content it contributes once another token’s query matches its key.</p><p>These vectors are not stored anywhere between forward passes. Each one is computed fresh, every time, as a linear projection of the token’s current embedding:</p><pre>Q = X · Wq<br>K = X · Wk<br>V = X · Wv</pre><p><strong>The weights: Wq, Wk, and Wv</strong></p><p>These matrices are initialized before training according to the model’s initialization scheme, typically with values chosen to keep activations and gradients well behaved.</p><p>Training proceeds by running the model forward on a batch of text, comparing its predicted next tokens against the actual next tokens, and computing a loss from the difference. That loss is what eventually drives updates to every learnable parameter in the network, including Wq, Wk, and Wv. Once training ends, Wq, Wk, and Wv are frozen: training optimizers stop updating them, and they become fixed constants baked into the deployed model. The vectors are still computed fresh on every forward pass at inference time (that computation never stops) but it is now a matrix multiplication against fixed weights rather than a step in a learning process.</p><h4>Attention heads</h4><p><strong>Single-head attention</strong> produces one query, one key, and one value vector for each token. For an embedding of size 512, that&#39;s ultimately one attention output per token. The token has one &quot;opinion&quot; about what mattered around it, shaped by whatever single notion of relevance those weights happen to encode.</p><p><strong>Multi-Head Attention (MHA)</strong> runs several smaller attention operations per token in parallel, each projecting the full input representation into a lower-dimensional subspace. That same 512-dimensional embedding might get split into 8 heads of 64 each. Each head has its own learned Q/K/V projection parameters, allowing different heads to learn different patterns of interaction. For example, some may become sensitive to syntactic or positional relationships. Each head produces its own small attention output, and those outputs are concatenated back into one full-size vector, then passed through one more learned matrix to mix them together.</p><p>Each attention operation (or head) gets its own learned projections and performs attention independently.</p><pre><br>Input → Q/K/V ──────┼── Head 1<br>                    ├── Head 2<br>                    └── Head 3<br></pre><p>The outputs from all heads are concatenated and passed through another learned projection.</p><p>Every head maintains its own K and V and during generation, those K/V tensors have to be stored. That memory usage becomes expensive.</p><p>Enter MQA.</p><p><strong>Multi-query attention </strong>keeps separate Q projections for every head, but makes all the heads share one K and V.</p><p>Instead of:</p><pre>Head 1 → K₁ V₁<br>Head 2 → K₂ V₂<br>Head 3 → K₃ V₃<br>Head 4 → K₄ V₄</pre><p>Now:</p><pre>Head 1 ─┐<br>Head 2 ─┤<br>Head 3 ─┼── Shared K/V<br>Head 4 ─┘</pre><p>That’s a huge memory saving and less memory pressure can mean faster generation. But there is a trade-off.</p><p>Forcing different heads to share the same key/value representation saves memory, but some of the independence that full multi-head attention provides is lost.</p><p>And this is where <strong>Grouped-query attention (GQA)</strong> comes in. Instead of making <strong>every head</strong> share one K/V pair or giving <strong>every head</strong> its own K/V pair, heads are separated into groups.</p><p>For example:</p><pre>Head 1 ─┐<br>Head 2 ─┘ → K/V Group 1</pre><pre>Head 3 ─┐<br>Head 4 ─┘ → K/V Group 2</pre><p>Now we’ve got a middle ground. More flexibility than MQA. Less memory than MHA.</p><h4>Conclusion</h4><p>This part covered how attention decides what to look at: how relationships between tokens get scored (additive, dot-product, scaled dot-product), how far a token is allowed to look (global vs. local, soft vs. hard), which direction information flows (self-attention, causal masking, cross-attention), and how Q, K, and V get shared or split across attention heads (single-head, MHA, MQA, GQA).</p><p>Part 2 turns to the problems that show up once this mechanism runs at scale: how a model knows where a word sits in a sequence (RoPE), how repeated computation is avoided during generation (the KV cache), how the underlying matrix math is made efficient on real hardware (FlashAttention), and how attention extends beyond text into images and audio (cross-modal attention).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a91cce62fbab" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/ai-fundamentals-attention-mechanisms-in-transformers-part-1-a91cce62fbab">AI Fundamentals: Attention Mechanisms in Transformers (Part 1)</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Fundamentals: Understanding Activation Functions (Part 2)]]></title>
            <link>https://pub.towardsai.net/ai-fundamentals-understanding-activation-functions-part-2-ac15aa63b15b?source=rss-6306c38a39c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac15aa63b15b</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[The Build Log]]></dc:creator>
            <pubDate>Mon, 17 Aug 2026 13:31:01 GMT</pubDate>
            <atom:updated>2026-08-17T13:31:01.463Z</atom:updated>
            <content:encoded><![CDATA[<h4>Let’s trace the evolution of activation functions, moving from early milestones through the ReLU breakthrough to advanced gating architectures.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ib_Ezezcil7cblALo0-m0Q.png" /><figcaption>Source: Image generated by AI</figcaption></figure><p>In the earliest days, activation functions were literal binary gates. If an input crossed a specific threshold, the neuron output 1; otherwise, it output 0. While intuitive, it had a fundamental limitation: its derivative made it unsuitable for conventional gradient-based optimization and backpropagation.</p><p>To enable smooth, continuous learning, researchers transitioned to S-shaped bounding functions. <strong>Sigmoid </strong>compresses any real number into the open range from 0 to 1, while <strong>Tanh </strong>stretches that range from -1 to 1.</p><p>At first glance, this seemed ideal. A value between 0 and 1 echoes the idea of a biological neuron either firing or staying quiet. However, this design choice hid a flaw for deep networks: <strong>the vanishing gradient problem</strong>.</p><h4>The Vanishing Gradient Crisis</h4><p>The sigmoid curve has a steep slope near its center but approaches flat saturation at large positive and negative inputs.</p><p>Here’s why that flatness is a problem. Training a network means calculating an error at the end, then working backward through each layer to figure out how much each weight contributed to that error. To do this, the network multiplies gradients together layer by layer, using the chain rule:</p><p>If even a few of those gradients are close to zero, which happens whenever a neuron sits in the flat part of the Sigmoid or Tanh curve, the multiplication drags the whole product toward zero.</p><p>Multiply small gradients across many layers, and the error signal can become negligibly small. The earliest layers stop receiving any meaningful update, effectively frozen in place while the rest of the network continues to learn around them.</p><h4>Code and Gradient Decay in Action</h4><p>You can observe this collapse directly in Python:</p><pre>import numpy as np<br># Used during forward pass<br># Turns a weighted sum into activated output(value between 0 and 1)<br>def sigmoid(x):<br>    return 1 / (1 + np.exp(-x))<br># Used during backward pass <br># Measures how sensitive the output is to change in x<br>def sigmoid_grad(x):<br>    s = sigmoid(x)<br>    return s * (1 - s)<br># Simulate a backward pass through a tiny 5-layer network.<br># Each layer just multiplies by a weight, then applies Sigmoid<br>np.random.seed(0) <br>num_layers = 5<br># Apply a random weight per layer<br>weights = np.random.randn(num_layers) * 1.5 <br># A single starting input<br>x = 3.0                                        <br># Forward pass: save the pre-activation value (the weighted sum only)<br># This is used by sigmoid_grad to compute each layer&#39;s local gradient.<br>pre_activations = []<br>a = x<br>for w in weights:<br>    z = a * w #the weighted sum entering this layer<br>    pre_activations.append(z)<br>    a = sigmoid(z) # This layer&#39;s output becomes the next layer&#39;s input<br># Backward pass: start with a gradient of 1.0 at the output<br># Multiply by each layer&#39;s local gradient<br># (and its weight) as the signal travels back toward layer 1.<br>grad = 1.0<br>for i in reversed(range(num_layers)):<br>    grad *= sigmoid_grad(pre_activations[i]) * weights[i]<br>    print(f&quot;Gradient after stepping back through layer {i + 1}: {grad:.8f}&quot;)</pre><p>Most of the curve’s real estate is flat with only a narrow sliver near zero actually having meaningful slope. And since the gradient is literally the correction signal backprop uses to update a weight, a near-flat gradient means a near-nothing correction, no matter how wrong the network’s output actually was. The weight doesn’t get meaningfully nudged toward “more correct”; it just stays parked almost exactly where it already was. Stack several layers where this keeps happening, and most of the network is stuck getting these practically-nothing corrections, batch after batch, which is exactly why Sigmoid and Tanh do fine in shallow networks, but can make optimization difficult on deep networks.</p><h3>ReLU and Its Variants</h3><p>Rectified Linear Unit (<strong>ReLU</strong>) solves this problem by abandoning squashing entirely. Its logic is brutally simple: if an input is positive, let it pass untouched; if it is negative, zero it out.</p><p>ReLU(x) = max(0, x)​</p><p>For positive inputs, ReLU’s derivative is 1, so it avoids the gradient attenuation caused by sigmoid-like saturation. However, gradients can still vanish or explode because of the network’s weights and architecture.</p><p>Because ReLU’s gradient is strictly 0 for any negative input, a neuron that consistently receives negative values can become permanently inactive. It outputs zero, produces zero gradient, and never updates again, a phenomenon known as the <strong>dying ReLU problem</strong>.</p><p>To combat this, researchers developed variations like <strong>Leaky ReLU</strong>,<strong> </strong>which leaves a tiny, non-zero slope for negative inputs and <strong>Parametric ReLU (PReLU)</strong>, which allows the network to learn that negative slope dynamically during training.</p><pre>def relu(x):     <br>    return np.maximum(0, x)  <br>def relu_grad(x):     <br>    return np.where(x &gt; 0, 1.0, 0.0)  <br>for x in [-2, 0.1, 5]:     <br>    print(f&quot;x={x}: ReLU Grad = {relu_grad(x)}&quot;)</pre><h3>GELU, SiLU, and SwiGLU</h3><p>To fix the sharp corners and dead zones, modern architectures increasingly use smooth nonlinearities such as <strong>GELU</strong> (Gaussian Error Linear Unit) and <strong>SiLU</strong> (Sigmoid Linear Unit, also known as Swish), particularly in Transformer-based models.</p><p>Instead of making a hard binary choice at zero, these functions use smooth transitions. A slightly negative input might be scaled down rather than entirely wiped out, allowing a struggling neuron to maintain a faint training signal and crawl its way back.</p><ul><li><strong>SiLU Formula:</strong> SiLU(x)= x ⋅ sigmoid(x)</li><li><strong>GELU Formula:</strong> Relies on the cumulative distribution function of a normal distribution, though it is usually approximated with a fast tanh formula in practice.</li></ul><pre>def silu(x):<br>    return x * (1 / (1 + np.exp(-x)))<br>for x in [-2, -1, 0, 1, 2]:<br>    print(f&quot;x={x}, SiLU = {silu(x):.4f}&quot;)</pre><p>Both GELU and SiLU provide smoother gradients and can support effective training trajectories, allowing top-tier model architectures to combine these with gating mechanisms (such as <strong>SwiGLU</strong>), multiplying an activated path by a raw content path to maximize expressive power.</p><h3>The Architecture of Gating</h3><p>Traditional activation functions apply a fixed nonlinear transformation to each activation, whereas gated architectures use learned projections to dynamically modulate one representation with another.</p><p>Instead of running a single calculation, a gated layer takes the exact same input and splits it into two independent processing paths using separate sets of weights:</p><ul><li><strong>The Gate (W</strong>g<strong>):</strong> Rather than manually inspecting features, the network learns through <strong>W</strong>g and the SiLU activation function to determine which feature channels should be amplified or suppressed based on the input representation. It assigns a continuous multiplier to dynamically toggle a feature’s importance on the fly.</li><li><strong>The Content (Wu):</strong> This path serves as the raw data payload (the up-projection), transforming the input into a richer feature representation through a standard linear projection.</li></ul><p>Multiplying the gate and content together elementwise allows the network to modulate information contextually rather than relying on a fixed activation curve. The elementwise multiplication allows one projected representation to <strong>modulate</strong> another.</p><p>Below is a simplified implementation sample:</p><pre>import numpy as np<br><br>class SwiGLULayer:<br>    def __init__(self, in_features, hidden_features):<br>        # 1. Gate projection matrix<br>        self.gate_weights = np.random.randn(in_features, hidden_features) * np.sqrt(2.0 / in_features)<br><br>        # 2. Content projection matrix<br>        self.content_weights = np.random.randn(in_features, hidden_features) * np.sqrt(2.0 / in_features)<br><br>        # 3. Down-projection matrix<br>        self.down_weights = np.random.randn(hidden_features, in_features) * np.sqrt(2.0 / hidden_features)<br><br>        # Cache for backpropagation<br>        self.input_cache = None<br>        self.gate_pre_activation = None<br>        self.gate_final_output = None<br>        self.content_output = None<br>        self.elementwise_product = None<br><br>    def forward(self, input_tensor):<br>        self.input_cache = input_tensor       <br><br>        # 1. Compute Gate path: linear projection followed by SiLU activation<br>        self.gate_pre_activation = np.dot(input_tensor, self.gate_weights)<br>        sigmoid_gate = 1 / (1 + np.exp(-self.gate_pre_activation))<br>        self.gate_final_output = self.gate_pre_activation * sigmoid_gate     <br><br>        # 2. Compute Content path: linear projection of the content payload<br>        self.content_output = np.dot(input_tensor, self.content_weights)<br><br>        # 3. Element-wise multiplication: the gate dynamically scales the content<br>        self.elementwise_product = self.gate_final_output * self.content_output<br><br>        # 4. Down-projection: maps back to the original model dimension<br>        output_tensor = np.dot(self.elementwise_product, self.down_weights)<br>        return output_tensor<br><br>    def backward(self, upstream_gradient):<br>        # Gradient through down-projection<br>        # d_ : stands for derivative, indicating how much the weights need to be modified at each layer moving backwards<br>        d_down_weights = np.dot(self.elementwise_product.T, upstream_gradient)<br>        d_elementwise = np.dot(upstream_gradient, self.down_weights.T)        <br><br>        # Gradient split across the element-wise multiplication product<br>        d_gate_out = d_elementwise * self.content_output<br>        d_content_out = d_elementwise * self.gate_final_output<br><br>        # Gradient through Content path weights<br>        d_content_weights = np.dot(self.input_cache.T, d_content_out)<br><br>        # Gradient through SiLU activation on the Gate path<br>        sig = 1 / (1 + np.exp(-self.gate_pre_activation))<br>        d_gate_pre = d_gate_out * sig * (1.0 + self.gate_pre_activation * (1.0 - sig))<br><br>        # Gradient through Gate path weights<br>        d_gate_weights = np.dot(self.input_cache.T, d_gate_pre)<br><br>        # Gradient flowing back to the preceding layer&#39;s input<br>        d_input = np.dot(d_gate_pre, self.gate_weights.T) + np.dot(d_content_out, self.content_weights.T)<br><br>        return d_input, d_gate_weights, d_content_weights, d_down_weights<br><br># Example execution<br>np.random.seed(42)<br>batch_size, in_dim, hidden_dim = 2, 4, 8<br><br># A mini batch of input vectors (e.g., token representations)<br>x_input = np.random.randn(batch_size, in_dim)<br><br>layer = SwiGLULayer(in_features=in_dim, hidden_features=hidden_dim)<br>output = layer.forward(x_input)<br>print(&quot;Input shape:&quot;, x_input.shape)<br>print(&quot;SwiGLU output shape:&quot;, output.shape)<br>print(&quot;Sample output values:\n&quot;, output)</pre><h4>Key terms:</h4><p>in_features​ — <strong>size of the incoming feature dimension</strong>, or how many numbers are coming into the layer for a single sample.</p><p>hidden_features​ — is the <strong>expanded internal size</strong> of the layer. This layer usually takes an input(x), blows it up into a much larger hidden space to let the network think and mix features, and then shrinks it back down.</p><p>np.sqrt(2.0 / in_features)​ — is the <strong>scaling factor</strong> used in this example as a simple initialization strategy. It shrinks or stretches the random initial numbers just enough to keep the variance of the signals stable as they flow forward.</p><p>linear_projections​ — imagine input tokens packed into a tight, low-dimensional space. Different features might end up tangled together or compressed. By blowing it up into a massive hidden space, the network has room to separate those intertwined features, let individual neurons specialize, and mix information across different dimensions cleanly.</p><p>Because gated architectures have demonstrated strong optimization and modeling performance in modern language models, the computational cost can be worthwhile.</p><h3>Conclusion</h3><p>Activation function design has evolved from rigid binary steps into an intentional engineering discipline focused on precise gradient control, dynamic sparsity, and adaptive architectures. As AI continues to scale, the search for smarter ways to route and transform information remains an active frontier.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac15aa63b15b" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/ai-fundamentals-understanding-activation-functions-part-2-ac15aa63b15b">AI Fundamentals: Understanding Activation Functions (Part 2)</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Fundamentals: Understanding Activation Functions (Part 1)]]></title>
            <link>https://pub.towardsai.net/ai-fundamentals-understanding-activation-functions-part-1-fde15d65c735?source=rss-6306c38a39c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fde15d65c735</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[The Build Log]]></dc:creator>
            <pubDate>Sun, 02 Aug 2026 20:31:01 GMT</pubDate>
            <atom:updated>2026-08-02T20:31:01.305Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Let’s make a case for non-linearity in neural networks, and understand the Universal Approximation Theorem</em></h4><p>Stacking a hundred layers in a neural network without non-linear activation functions causes the entire architecture to suffer from <strong>linear collapse</strong>. Mathematically, every linear layer performs an <em>affine transformation</em>: a combination of matrix multiplication and vector addition, y = Wx + <strong>b</strong>. Because the composition of any number of affine transformations is itself just another affine transformation, a network with ten, a hundred, or a thousand linear layers simplifies directly into a single matrix operation:</p><p>output = Wₑ · x + <strong>bₑ</strong>​​</p><p>Breaking the above equation down further:</p><p>Layer 1: y₁ = W₁x + <strong>b</strong>₁​</p><p>Layer 2: y₂ = W₂y₁ + <strong>b</strong>₂​</p><p>Layer 3: y₃ = W₃y₂ + <strong>b</strong>₃​</p><p>Plugging each layer into the next: y₃ = W₃(W₂(W₁x + <strong>b</strong>₁) + <strong>b</strong>₂) + <strong>b</strong>₃​</p><p>Multiplying them: y₃ = (W₃W₂W₁)x + (W₃W₂<strong>b</strong>₁ + W₃<strong>b</strong>₂ + <strong>b</strong>₃)​</p><p>Instead of carrying those nested matrices around, group them into two variables:</p><p>Wₑ = W₃W₂W₁​ (the effective overall weight matrix) and,</p><p><strong>b</strong>ₑ = W₃W₂<strong>b</strong>₁ + W₃<strong>b</strong>₂ + <strong>b</strong>₃​ (the effective overall bias vector).</p><p>The entire 3-layer network collapses right back into that same single-layer formula: output = Wₑ · x + <strong>bₑ</strong></p><h3><strong>Why does a network need to separate anything?</strong></h3><p>Picture looking down at a map with a single small island surrounded entirely by ocean, then being handed a ruler and asked to draw one straight line that puts every bit of land on one side and every bit of water on the other. There’s no way to do it: any straight line drawn across that map cuts through both the island and the ocean around it. What’s needed instead is a nonlinear boundary that can wrap around the island and separate it from the surrounding ocean.</p><p>That’s the intuition behind what a neural network learns. Rather than being limited to simple straight-line separations, neural networks learn transformations that reshape data into representations where complex decision surfaces become possible.</p><p>So, when we talk about a network “separating datasets,” the real meaning is that it learns a decision function that divides the input space into regions: everything on one side belongs to class A, and everything on the other belongs to class B. Whether that boundary is a straight line, a curve, a circle, or a far more complex shape depends entirely on how the data is arranged.</p><h3>The activation function</h3><p>An activation function is a small non-linear operation applied after each layer’s linear step: squashing, clipping, or reshaping the output before it moves on. Instead of z = W₂(W₁x + <strong>b</strong>₁) + <strong>b</strong>₂​, the result becomes something like z = W₂·f(W₁x + <strong>b</strong>₁) + <strong>b</strong>₂​, where f is a non-linear function like a sigmoid, tanh, ReLU, etc.</p><blockquote>The activation function doesn’t need to be complicated to do its job. Even ReLU, which is max(0, x), a function that just clips negative values to zero, is enough to stop the network from collapsing into a single linear transformation.</blockquote><p>That single f breaks the algebra: there’s no matrix M​ and vector c such that f(W₁x + <strong>b</strong>₁) = Wx + <strong>b</strong>, for every x. Stack enough of these non-linear steps together, and the network stops being restricted to straight-line thinking; it can carve out circles, spirals, and shapes.</p><p>That’s the whole <em>purpose</em> of an activation function, at the most fundamental level: it’s the thing standing between “a network that can only draw straight lines” and “a network that can wrap a boundary around almost any shape thrown at it.”</p><p>Each neuron by itself contributes one tiny bend and a network is thousands of them, each bending things in a slightly different spot. Stack enough of them together, and the network can approximate curves and boundaries that no single neuron, or even a hundred of them, could pull off alone.</p><h4>How a model reads a sentence two ways</h4><p>Take an example: <em>“Time flies like an arrow; fruit flies like a banana.”</em> Read the first half and “flies” is a verb: time is moving, fast, like an arrow. Read the second half and “flies” is a noun: fruit flies are a kind of insect that seems to enjoy bananas. Same word, wildly different job, and the only thing signaling which is which is the surrounding context.</p><p>A model has to somehow pull those two uses of “flies” apart into different regions of its internal representation, even though at the input level they’re the identical token. This is where depth and non-linearity earn their keep together. Because <a href="https://pub.towardsai.net/ai-fundamentals-what-is-a-neuron-62e76a6f3500">each layer starts from a different random point</a>, each one ends up drawing its bent boundary through the data in a slightly different place.</p><p>As training proceeds, this quiet divergence gets shaped into something closer to specialization. The example above is an over-simplification: real models don’t cleanly assign “this layer = nouns, that layer = verbs” in a tidy labeled way, but a loose intuition is: earlier layers could pick up on more local, surface-level patterns (word order, part of speech, etc.), while deeper layers integrate more surrounding context and start representing something closer to <em>meaning</em>, which sense of “flies” is active, what “it” refers to, that sort of thing. It’s specifically the bending, layer after layer, that gives the network enough room to gradually tease “time flies” and “fruit flies” apart into different corners of its representation space, instead of being stuck treating “flies” as one fixed thing no matter what’s around it.</p><h3>The Universal Approximation Theorem</h3><p>The UAT states that a feedforward neural network with a non-linear activation function and a sufficiently large hidden layer can, in principle, approximate any continuous function on a bounded domain to any desired degree of accuracy.</p><p>One intuitive way to understand this capability is by imagining how networks combine many simple nonlinear components to create increasingly complex shapes and behaviors. These components can be thought of as localized building blocks, or “towers,” that each contribute a small part of the final function. By combining enough of these building blocks, a network can gradually approximate an arbitrary continuous function as closely as desired.</p><p>This same principle explains why neural networks can represent everything from simple decision boundaries to the complex internal representations used in tasks such as language understanding.</p><h4>How it works: connecting neurons, towers, and the math</h4><p>To understand the whole system, look at how raw neurons turn into local pixels, and how those pixels draw a curve.</p><p><strong>1. The core problem with single neurons</strong></p><p>A single ReLU neuron is global. Once it switches on, it never turns back off, so its influence isn’t confined to any one region; it keeps affecting every point further along the x-axis too. That means there’s no way to use a single raw neuron to nudge the curve at one specific location without that same nudge bleeding into every location past it, since the neuron has no way to turn back off and contain the effect.</p><p><strong>2. The solution: combining neurons into localized “bumps”</strong><br>Each neuron sets a threshold where it fires. Combining multiple neurons creates an active window, allowing the network to control local regions without affecting the entire domain.</p><p>Example,</p><ul><li>Neuron 1 (the start switch): turns on at x = 2.</li><li>Neuron 2 (the stop switch): turns on at x = 4(Neuron 2 subtracts from the signal, given negative vᵢ​, halting further growth past x = 4, flattening the output into a constant step).</li></ul><p>Each step represents the active window created by that pair of neurons, a range from x = 2 to x = 4 where they&#39;re allowed to influence the final answer.</p><p><strong>3. Reading the graph</strong></p><p>On a coordinate plane, each tower maps directly to network parameters:</p><ul><li>x-axis (input range): controlled by the hidden layer’s weights (W) and biases (<strong>b</strong>). It specifies where the tower sits, for example active between x = 2 and x = 4.</li><li>y-axis (output contribution, or height): controlled by the output layer weight (v). It specifies how tall the tower is, matching the height of the target curve at that location. While weights and biases are what set where a neuron fires, v is an output weight that determines how much that region contributes to the final answer.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t2RvkbVdXaRIBJIBNYWdAQ.gif" /><figcaption>Source: GIF by the author.</figcaption></figure><h3>Conclusion</h3><p>The Universal Approximation Theorem is an existence proof, not a construction manual: it guarantees that a network capable of approximating almost any function exists somewhere in the space of possible networks, but it doesn’t say how many neurons that takes, whether gradient descent can actually find the right weights, or how well the result generalizes. Representing a function and learning it from data are two different problems, and the UAT only answers the first one. Everything modern networks actually rely on, depth, attention, residual connections, optimizers, huge datasets, careful initialization, sits entirely outside what the theorem promises. It’s not an algorithm a network runs during training, nor is it a recipe for building one. Instead, it’s the mathematical justification for why introducing non-linearity fundamentally changes what a neural network is capable of representing in the first place.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fde15d65c735" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/ai-fundamentals-understanding-activation-functions-part-1-fde15d65c735">AI Fundamentals: Understanding Activation Functions (Part 1)</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Fundamentals: What is a Neuron?]]></title>
            <link>https://pub.towardsai.net/ai-fundamentals-what-is-a-neuron-62e76a6f3500?source=rss-6306c38a39c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/62e76a6f3500</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-neural-network]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[The Build Log]]></dc:creator>
            <pubDate>Tue, 21 Jul 2026 00:01:02 GMT</pubDate>
            <atom:updated>2026-07-21T00:01:02.670Z</atom:updated>
            <content:encoded><![CDATA[<p>An artificial neural network is built by combining simple computational units called neurons. Each neuron takes in some numbers, performs a few calculations, and outputs a single number. That’s it.</p><p>So where does the intelligence come from? Not from any one neuron. It comes from connecting thousands, or even millions, of these small building blocks together. As information flows through the network, each neuron contributes one small piece to the final prediction.</p><p>In this article, we’ll break down exactly how a neuron works, the math behind it, and then build it from scratch.</p><h3>Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*89ZT1VnZ_Ly2EAB5ee_DEg.gif" /><figcaption>Source: GIF by the author.</figcaption></figure><p>A neuron is a small math function with four moving parts:</p><h4>Inputs</h4><p>Inputs [x₁, x₂, x3, ..., xₙ] carry numerical values into the neuron. A neuron never sees raw text, pixels, or audio directly; it only ever sees numbers, organized as a vector. Before anything reaches the first layer of a network, the raw input has to be converted into that numerical form, and exactly how depends on the type of data:</p><ul><li><strong>Text:</strong> broken into tokens (roughly, word pieces), then each token is mapped to an embedding, a vector often several hundred to several thousand values long that represents that token’s meaning.</li><li><strong>Images:</strong> raw pixel values (red, green, and blue intensity per pixel), scaled to a range like 0 to 1, fed in as a large vector or grid of numbers.</li></ul><p>From there, every layer after the first builds on what came before it: each neuron’s inputs are simply the outputs produced by the neurons in the previous layer.</p><h4>Weights</h4><p>Weights (w₁, w₂, ..., wₙ) determine how much influence each input has, one weight per input. They&#39;re initialized to small random numbers rather than a fixed value like zero. This matters due to a problem called <strong>symmetry breaking</strong>: if every neuron in a layer started with identical weights, they&#39;d all compute the exact same output from the exact same inputs, and during training they&#39;d all get adjusted in exactly the same way, leaving every neuron in that layer stuck learning the same thing forever. Randomizing the starting weights gives each neuron a different starting point, so as training progresses, gradient descent, for example, can push each one to specialize and pick up on different patterns in the data.</p><h4>Summation and Bias</h4><p>The neuron sums the weighted inputs and adds a bias (b), producing a single number z. Summation multiplies each input (xᵢ) by its weight(wᵢ), then add all of those products together into one number. That&#39;s the z = w₁x₁ + w₂x₂ + ... + wₙxₙpart of the formula below. The bias is then added on top as one extra constant term.</p><blockquote><strong>Tip:</strong><em> </em>Think of the bias as an extension of the weights. It behaves like a weight attached to an input that’s always fixed at 1, so its value never depends on the actual data coming in. Without it, the neuron&#39;s weighted sum would pass through zero if every input is zero, which needlessly limits what the neuron can represent. The bias gives the neuron the freedom to shift its output up or down, similar to how b shifts the line up or down in y = mx + b.</blockquote><h4>Activation Function</h4><p>The result of the previous steps, z, could be any number, from -1,000 to 1,000. The activation function (f) takes this intermediate result and reshapes it into the neuron&#39;s actual output, f(z), usually squeezing it into a smaller, more useful range. Its real job is introducing <strong>non-linearity</strong>: without it, stacking layers would be pointless, because a chain of purely linear operations collapses down into just one bigger linear operation, no matter how many layers you stack. Non-linear activation functions are what let a multi-layer network learn curved, complex patterns instead of only straight lines and flat planes.</p><p>There are several common choices, including:</p><ul><li><strong>Sigmoid</strong> (output range 0 to 1): typically used in the final output layer of a binary classifier, since the output can be read as a probability.</li><li><strong>Tanh</strong> (output range -1 to 1): historically common in hidden layers of recurrent networks for sequence data like text or time series.</li><li><strong>ReLU</strong> (output range 0 to infinity): the default choice in hidden layers of most modern deep networks, including large image and language models; cheap to compute and avoids training problems sigmoid and tanh run into in very deep networks.</li></ul><h3>The formula</h3><p>Before jumping into the full neuron equation, it helps to start somewhere familiar: the equation for a straight line.</p><p>y = mx + b</p><ul><li>x the input value</li><li>m the slope, which controls how much y changes for a given change in x</li><li>b the y-intercept, a constant that shifts the line up or down</li><li>y the resulting output</li></ul><p>A single artificial neuron uses this exact idea, but instead of one x and one m, a neuron typically receives several inputs, each with its own weight. The same idea extended into higher dimensions: instead of drawing a line, the neuron is defining a flat plane (or hyperplane) that separates or weighs its inputs. In this higher-dimensional picture, the weights still control the tilt of that plane, and the bias still slides it up or down, just like m and b do for a simple line. The output from the neuron represents how strongly the neuron “activated” based on the inputs it received. The activation function, f, produces that final output:</p><p>output = f(x) = f(w₁x₁ + w₂x₂ + ... + wₙxₙ + b)</p><p>The activation function introduces non-linearity, which is what allows networks of neurons to learn complex patterns rather than just straight lines and flat planes. A simple choice is the sigmoid function, which squashes any input into a value between 0 and 1:</p><p>f(z) = 1 / (1 + e⁻ᶻ)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e5TY4_5AdIxjYy37A4j-aw.gif" /><figcaption>Source: GIF by the author.</figcaption></figure><h3>The Big Picture</h3><p>Let’s look at a simplified version of how a language model actually picks the next word. Every word in its vocabulary has a fixed coordinate in a massive, multi-dimensional space, its embedding. Words with related meanings tend to cluster near each other: “apple,” “banana,” and “fruit” sit close together in one region, while “car,” “engine,” and “highway” cluster somewhere else entirely.</p><p>Because deep networks commonly use <strong>ReLU</strong> as their activation function, and ReLU zeroes out every negative value, a large share of the network’s neurons stay inactive for any given input; only the neurons relevant to that input end up contributing to the result.</p><p>At the model’s output layer, there’s roughly one neuron per word in the vocabulary, and each one calculates a raw score for how well its word matches what the model currently expects to come next. If the model’s current internal representation lands close to the “fruit” cluster, the neuron for “banana” produces a high raw score (for example, 9.4), while the neuron for “car” produces a low, even negative, score (for example, -4.2), since “car” has nothing to do with the current context.</p><p>These raw scores, often called <strong>logits</strong>, aren’t probabilities on their own, since they can be any real number. A function called <strong>softmax</strong> converts the entire set of scores (across the model’s full vocabulary, often 100,000 or more words) into probabilities that add up to 1. Softmax pushes the highest score close to 1 (for example, 94%) while pushing low scores close to 0%.</p><p>Rather than picking the single highest-probability word, which tends to produce repetitive, robotic text, many language models sample from this probability distribution instead. A word with a 94% probability will almost always get picked, but a word sitting at 5% still has a small chance of being chosen, which is part of what gives generated text some natural variation.</p><h3>Code sample</h3><p>Below is a minimal Python implementation of a single artificial neuron, using the weighted-sum-plus-bias formula and a sigmoid activation function.</p><pre>import math<br><br># Note: this example skips training entirely. There&#39;s no dataset here,<br># and no code to learn from. The weights and bias below are just<br># hardcoded, standing in for values a real network would learn<br># by training on data.<br>class Neuron:<br>    def __init__(self, weights, bias):<br>        &quot;&quot;&quot;<br>        weights: list of floats, one weight per input<br>        bias: float, the neuron&#39;s bias term<br>        &quot;&quot;&quot;<br>        self.weights = weights<br>        self.bias = bias<br><br>    def sigmoid(self, z):<br>        &quot;&quot;&quot;Activation function: squashes z into a range between 0 and 1.&quot;&quot;&quot;<br>        return 1 / (1 + math.exp(-z))<br><br>    def forward(self, inputs):<br>        &quot;&quot;&quot;<br>        Computes the neuron&#39;s output for a given set of inputs.<br>        inputs: list of floats, same length as self.weights<br>        &quot;&quot;&quot;<br>        # Weighted sum: w1*x1 + w2*x2 + ... + wn*xn + b<br>        z = sum(w * x for w, x in zip(self.weights, inputs)) + self.bias<br><br>        # Apply the activation function<br>        return self.sigmoid(z)<br><br><br># Example usage<br>if __name__ == &quot;__main__&quot;:<br>    # A neuron with 3 inputs. In a real network, these weights and the bias<br>    # would be learned from a training dataset (for example, billions of<br>    # sentences), rather than set by hand like this.<br>    neuron = Neuron(weights=[0.5, -0.6, 0.1], bias=0.2)<br><br>    # For this example, treat these three numbers as a simplified<br>    # stand-in for an embedding representing one input.<br>    inputs = [1.0, 0.5, -1.5]<br>    output = neuron.forward(inputs)<br><br>    print(f&quot;Neuron output: {output:.4f}&quot;)<br></pre><p>Running this code passes the inputs [1.0, 0.5, -1.5] through the neuron&#39;s weighted sum and sigmoid activation, printing a single output value between 0 and 1, the neuron&#39;s decision.</p><h3>Conclusion</h3><p>Because every neuron starts with slightly different random weights, they naturally drift toward capturing different patterns as training progresses. One neuron’s line might end up separating verbs from nouns. Another’s might end up separating happy words from sad ones.</p><p>By the time training is finished, the network has a massive grid of billions of intersecting lines, carving the embedding space into precise conceptual territories: the foundation that everything else in a neural network, from recognizing images to generating language, is built on.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62e76a6f3500" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/ai-fundamentals-what-is-a-neuron-62e76a6f3500">AI Fundamentals: What is a Neuron?</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond the Root: A Guide to Architecting Your AWS Access]]></title>
            <link>https://medium.com/@theBuildLog/beyond-the-root-a-guide-to-architecting-your-aws-access-63e916feb38b?source=rss-6306c38a39c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/63e916feb38b</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-iam]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[The Build Log]]></dc:creator>
            <pubDate>Fri, 24 Apr 2026 22:18:52 GMT</pubDate>
            <atom:updated>2026-04-24T22:18:52.115Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Setting up an AWS account is easy; securing it correctly is where most users stumble. If you are logging in daily with your root email and password, you are operating with unnecessary risk. This guide walks through a modern, identity-first approach to AWS access, built around delegation and centralized control. At the center of this model is a principle: the <strong>Root Hand-Off</strong>.</blockquote><p>Use the root account once to establish a secure foundation, then remove it from daily operations.</p><p><strong>Part I: Establishing the Management Bridge</strong></p><p>Before anything else, set up MFA on the root account using a physical hardware key or a virtual authenticator app. Next, enable IAM Identity Center to establish centralized access management. Identity Center allows you to manage users, groups, and permissions from a single control plane. When integrated with AWS Organizations, it scales from a single account to a multi-account environment without requiring changes to your access model.</p><p><strong>Part II: Provisioning Access</strong></p><p>Access is composed through a structured permissions workflow. Users are created with organizational details and placed into groups (e.g., Admins, Developers).</p><ol><li><strong>Account Assignment:</strong> Assign a user or group to a specific AWS account with a defined permission set. Without this assignment, a user will not see any accounts or resources.</li><li><strong>Permission Sets:</strong> These define what actions are allowed, such as AdministratorAccess or PowerUserAccess, and map to IAM roles behind the scenes.</li></ol><p><strong>Note:</strong> Users created in Identity Center are not visible in the IAM Users menu. They exist in a separate workforce identity layer, distinct from IAM users within an account.</p><p><strong>Part III: Account Access URLs</strong></p><p>Access is granted through a unique access portal URL provided by the Identity Center. This portal is the primary entry point for users. Once authenticated, the user selects an account, assumes a role, and enters the AWS Management Console using temporary credentials.</p><p>For machine-to-machine access, use OIDC federation. This allows external systems such as GitHub Actions to assume roles securely without storing long-lived credentials.</p><h3>Conclusion</h3><p>Onboarding new team members or expanding existing user access becomes a straightforward process that does not require rethinking your access strategy. Every action in your environment is tied to a clear identity, giving you a reliable and auditable record of who is doing what.</p><p>The cloud evolves quickly, but the core principles of least privilege and the use of temporary credentials remain constant.</p><h3>Pro-Tip:</h3><p><em>If you are prompted for an account ID during login, you are likely not on the IAM Identity Center sign-in page. Your unique access portal URL is the front door to your organization’s cloud.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63e916feb38b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>