<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>Attention :: Tag</title>
    <link>https://turingcodex.com/tags/attention/index.html</link>
    <description><![CDATA[]]></description>
    <image>
      <url>https://turingcodex.com/android-chrome-512x512.png</url>
      <title>Attention</title>
      <link>https://turingcodex.com/tags/attention/</link>
    </image>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Fri, 01 May 2026 15:24:57 +0300</lastBuildDate>
    <atom:link href="https://turingcodex.com/tags/attention/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Introduction to LLMs: Final Part</title>
      <link>https://turingcodex.com/ai/intro-llm-final/index.html</link>
      <pubDate>Fri, 01 May 2026 15:24:57 +0300</pubDate>
      <guid>https://turingcodex.com/ai/intro-llm-final/index.html</guid>
      <description><![CDATA[<h2 id="the-mechanics-of-query-key-and-value-vectors">The Mechanics of Query, Key, and Value Vectors<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg"></i></button></span></h2>
<p>In the architecture of a Transformer model, the transition from raw text to contextual understanding relies on a sophisticated mathematical transformation. While it is common to wonder if the Query ($Q$), Key ($K$), and Value ($V$) vectors used in self-attention are simply the word embeddings themselves, they actually represent a specialized evolution of those embeddings. They are derived from the base embedding to perform distinct functional roles.</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
    <item>
      <title>Introduction to LLMs: Part Two</title>
      <link>https://turingcodex.com/ai/intro-llm-two/index.html</link>
      <pubDate>Fri, 01 May 2026 14:37:45 +0300</pubDate>
      <guid>https://turingcodex.com/ai/intro-llm-two/index.html</guid>
      <description><![CDATA[<h2 id="how-llms-prevent-infinite-looping">How LLMs Prevent Infinite Looping<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg"></i></button></span></h2>
<p>Large Language Models function through a process called autoregressive generation. Essentially, they predict the next token in a sequence based on all the tokens that came before it. Without specific guardrails, this process could theoretically continue forever, leading to infinite loops that drain computational resources and produce repetitive, useless text.</p>
<p>To ensure every conversation has an end, developers employ a multi-layered strategy involving training logic, hard constraints, and mathematical penalties.</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
    <item>
      <title>Introduction to LLMs: Part One</title>
      <link>https://turingcodex.com/ai/intro-llm-one/index.html</link>
      <pubDate>Sun, 26 Apr 2026 15:59:52 +0300</pubDate>
      <guid>https://turingcodex.com/ai/intro-llm-one/index.html</guid>
      <description><![CDATA[<h2 id="introduction">Introduction<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg"></i></button></span></h2>
<p>Large Language Models (LLMs) represent a milestone in Artificial Intelligence, marking a shift from rigid, rule-based systems to fluid, deep-learning models capable of mimicking human-like communication. By processing massive datasets, these systems have moved beyond simple pattern recognition to master the complexities of linguistic structure, context, and intent.</p>
<p>The primary driver behind the success of modern LLMs is the <strong>Transformer architecture</strong>. Unlike earlier models that processed text sequentially, Transformers utilize a <strong>self-attention mechanism</strong> to look at an entire sequence of words simultaneously. This enables the model to weigh the relevance of different words regardless of their distance from one another, capturing long-range dependencies in parallel.</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
    <item>
      <title>Introduction to MCP</title>
      <link>https://turingcodex.com/ai/intro-mcp/index.html</link>
      <pubDate>Sun, 19 Apr 2026 12:06:46 +0300</pubDate>
      <guid>https://turingcodex.com/ai/intro-mcp/index.html</guid>
      <description><![CDATA[<p><strong>Model Context Protocol (MCP)</strong> is an open-source standard that unifies the communication between AI applications and external data sources, tools, and workflows.</p>
<p>Anthropic launched MCP on November 25, 2024, and donated it in December 2025 to the Agentic AI Foundation (AAIF)—a directed fund under the Linux Foundation—where it is now stewarded neutrally alongside projects from Block and OpenAI, with support from Google, Microsoft, AWS, and others.<br>
MCP has rapidly become the de-facto industry standard for building interoperable, scalable, and secure AI agents.</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
    <item>
      <title>How to think like a programmer</title>
      <link>https://turingcodex.com/posts/think-like-programmer/index.html</link>
      <pubDate>Sun, 08 Feb 2026 17:02:50 +0200</pubDate>
      <guid>https://turingcodex.com/posts/think-like-programmer/index.html</guid>
      <description><![CDATA[<h2 id="the-problem">The problem<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg"></i></button></span></h2>
<p>Imagine I hand you a piece of paper with three numbers on it: <code>456</code>, <code>123</code>, and <code>789</code>. Your task is to find their sum.</p>
<p>To a human, this looks like a single process. You might look at the numbers, scribble some carries on paper, and arrive at <code>1,368</code>.</p>
<p>But as a programmer, you cannot treat this as a single action because a computer can only follow a specific set of instructions.</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
    <item>
      <title>How to express optional values in C&#43;&#43;</title>
      <link>https://turingcodex.com/posts/optional-values-cpp/index.html</link>
      <pubDate>Sun, 01 Feb 2026 14:42:19 +0200</pubDate>
      <guid>https://turingcodex.com/posts/optional-values-cpp/index.html</guid>
      <description><![CDATA[<h2 id="the-problem">The problem<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg"></i></button></span></h2>
<p>Implement a function that accepts a player ID, an activity ID and returns the player&rsquo;s score
for that activity.
The returned score depends on the activity ID and it is not guaranteed that the player has a score for the given activity.</p>
<h2 id="the-bad-solution">The bad solution<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg"></i></button></span></h2>
<p>One possible solution is to use <code>-1</code> to represent the absence of a score.</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
    <item>
      <title>8 ways to iterate a container in C&#43;&#43;</title>
      <link>https://turingcodex.com/posts/iterate-in-cpp/index.html</link>
      <pubDate>Sun, 25 Jan 2026 19:34:11 +0200</pubDate>
      <guid>https://turingcodex.com/posts/iterate-in-cpp/index.html</guid>
      <description><![CDATA[<p>You can try the below examples in <a href="https://cpp.sh/" rel="external">C++ Shell</a>.</p>
<h3 id="1-traditional-for-loop">1. Traditional for loop<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg"></i></button></span></h3>
<p>It is the oldest way to iterate over a container.
It was part of the C language and was later included in C++ when it was created.
This <code>for</code> loop variant uses the index to access the elements of the array.</p>
<div class="highlight actionbar-wrapper wrap-code" dir="auto"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp">
</span></span></span><span class="line"><span class="cl"><span class="cp">#include</span> <span class="cpf">&lt;array&gt;</span><span class="cp">
</span></span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kt">int</span> <span class="nf">main</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="n">std</span><span class="o">::</span><span class="n">array</span><span class="o">&lt;</span><span class="kt">int</span><span class="p">,</span> <span class="mi">5</span><span class="o">&gt;</span> <span class="n">arr</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">};</span>
</span></span><span class="line"><span class="cl">    <span class="k">for</span> <span class="p">(</span><span class="n">size_t</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">arr</span><span class="p">.</span><span class="n">size</span><span class="p">();</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">    <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="n">arr</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">&lt;&lt;</span> <span class="s">&#34; &#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="p">}</span>
</span></span><span class="line"><span class="cl">    <span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre></div>
<h3 id="2-while-loop">2. While loop<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg"></i></button></span></h3>
<p>Same as the previous example, but using a <code>while</code> (or <code>do while</code>) loop and the initialization of the index variable happens outside the loop.
The index is incremented inside the loop, at the end of each iteration.</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
    <item>
      <title>Clean Code: A Psychological Perspective</title>
      <link>https://turingcodex.com/posts/clean-code/index.html</link>
      <pubDate>Sun, 18 Jan 2026 14:18:20 +0200</pubDate>
      <guid>https://turingcodex.com/posts/clean-code/index.html</guid>
      <description><![CDATA[<h2 id="introduction">Introduction<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg"></i></button></span></h2>
<p>Software engineering is frequently evaluated through technical metrics such as time complexity and space complexity.<br>
However, a significant constraint in software engineering is often the programmer&rsquo;s ability to comprehend the system, rather than the hardware&rsquo;s processing capacity.</p>
<p>The <em>Clean Code</em> philosophy suggests various heuristics and stylistic conventions to address this. While these practices may appear subjective, their effectiveness can be explained by principles of cognitive psychology.</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
    <item>
      <title>Advent of Code 2025 - Day 3</title>
      <link>https://turingcodex.com/posts/aoc/2025/day3/index.html</link>
      <pubDate>Thu, 08 Jan 2026 12:49:55 +0200</pubDate>
      <guid>https://turingcodex.com/posts/aoc/2025/day3/index.html</guid>
      <description><![CDATA[<details open class="box cstyle notices important">
  <summary class="box-label" tabindex="-1">
    <i class="fa-fw fas fa-bolt"></i> 
    Important
  </summary>
  <div class="box-content">
<p>Before reading the solution, attempt to solve the problem on your own.</p>
  </div>
</details>
<h2 id="part-1">Part 1<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg"></i></button></span></h2>

<details class="box cstyle notices transparent expand">
  <summary class="box-label">
    <i class="expander-icon fa-fw fas fa-chevron-right"></i> 
    Show solution
  </summary>
  <div class="box-content">
<p>In this problem, we are given a list of lines of digits and asked to find the<br>
largest 2-digit number that can be found in each line.<br>
The idea is to form the number by taking the max digits from the line.<br>
The first digit in our number cannot be the last digit of the line, because we need at least one digit after it.<br>
For the second digit, we can take any digit from the line but past the first chosen digit.</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
    <item>
      <title>Nicomachus&#39;s Theorem: the Sum of Cubes and the Square of Sums</title>
      <link>https://turingcodex.com/posts/nicomachus/index.html</link>
      <pubDate>Thu, 01 Jan 2026 18:51:37 +0200</pubDate>
      <guid>https://turingcodex.com/posts/nicomachus/index.html</guid>
      <description><![CDATA[<p>Nicomachus&rsquo;s Theorem describes a fundamental identity in number theory relating
sums of cubic numbers to sums of integers. It states that the sum of the first
\( n \) cubes is equal to the square of the sum of the first \( n \) integers.</p>
<p>Mathematically, this is expressed as:</p>
$$
\sum_{k=1}^{n} k^3 = \left( \sum_{k=1}^{n} k \right)^2
$$<p>This article explores the numerical verification, geometric intuition, algebraic
proof, and the deeper connections to Triangular numbers, Faulhaber’s formula,
and Calculus.</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
    <item>
      <title>Advent of Code 2025 - Day 2</title>
      <link>https://turingcodex.com/posts/aoc/2025/day2/index.html</link>
      <pubDate>Mon, 22 Dec 2025 17:25:20 +0200</pubDate>
      <guid>https://turingcodex.com/posts/aoc/2025/day2/index.html</guid>
      <description><![CDATA[<details open class="box cstyle notices important">
  <summary class="box-label" tabindex="-1">
    <i class="fa-fw fas fa-bolt"></i> 
    Important
  </summary>
  <div class="box-content">
<p>Before reading the solution, attempt to solve the problem on your own.</p>
  </div>
</details>
<h2 id="part-1">Part 1<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg"></i></button></span></h2>

<details class="box cstyle notices transparent expand">
  <summary class="box-label">
    <i class="expander-icon fa-fw fas fa-chevron-right"></i> 
    Show solution
  </summary>
  <div class="box-content">
<p>The core of the problem is to correctly identify the invalid ids. Once we have this, we can iterate over the list of ids and sum the invalid ones.</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
    <item>
      <title>Modular Arithmetic</title>
      <link>https://turingcodex.com/posts/mod-math/index.html</link>
      <pubDate>Mon, 15 Dec 2025 14:58:29 +0200</pubDate>
      <guid>https://turingcodex.com/posts/mod-math/index.html</guid>
      <description><![CDATA[<h2 id="what-is-modular-arithmetic">What is Modular Arithmetic?<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg"></i></button></span></h2>
<p>Modular arithmetic is a special type of arithmetic where numbers wrap around after a fixed value. For example, in a clock with 12 hours, numbers like 12, 24, 36, etc., are all equivalent to 0 modulo 12. We say that 24 is congruent to 0 modulo 12, meaning that 24 leaves a remainder of 0 when divided by 12. Mathematically, we write this as \( 24 \equiv 0 \pmod{12} \).</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
    <item>
      <title>About</title>
      <link>https://turingcodex.com/about/index.html</link>
      <pubDate>Wed, 10 Dec 2025 15:59:53 +0200</pubDate>
      <guid>https://turingcodex.com/about/index.html</guid>
      <description><![CDATA[<p>My name is Gabriel, and I am a software engineer with 9 years of experience in the field.</p>
<p>On this website, you will find articles about computer science, mathematics, and other topics that I find interesting.</p>
<p>If you find any errors in my articles or have questions, you can send me an email at <a href="mailto:contact@turingcodex.com" rel="external">contact@turingcodex.com</a>.</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
    <item>
      <title>Advent of Code 2025 - Day 1</title>
      <link>https://turingcodex.com/posts/aoc/2025/day1/index.html</link>
      <pubDate>Wed, 10 Dec 2025 12:32:38 +0200</pubDate>
      <guid>https://turingcodex.com/posts/aoc/2025/day1/index.html</guid>
      <description><![CDATA[<details open class="box cstyle notices important">
  <summary class="box-label" tabindex="-1">
    <i class="fa-fw fas fa-bolt"></i> 
    Important
  </summary>
  <div class="box-content">
<p>Before reading the solution, attempt to solve the problem on your own.</p>
  </div>
</details>
<h2 id="part-1">Part 1<span class="btn cstyle anchor copyanchor scrollanchor link noborder notitle interactive"><button type="button" title="Copy link to clipboard"><i class="fa-fw fas fa-link fa-lg"></i></button></span></h2>

<details class="box cstyle notices transparent expand">
  <summary class="box-label">
    <i class="expander-icon fa-fw fas fa-chevron-right"></i> 
    Show solution
  </summary>
  <div class="box-content">
<p>First, we define some helpful constants.</p>
<div class="highlight actionbar-wrapper wrap-code" dir="auto"><pre tabindex="0" class="chroma"><code class="language-fsharp" data-lang="fsharp"><span class="line"><span class="cl"><span class="k">let</span> <span class="nv">FILE</span> <span class="o">=</span> <span class="s">&#34;input.txt&#34;</span>
</span></span><span class="line"><span class="cl"><span class="k">let</span> <span class="nv">MAX_DIAL</span> <span class="o">=</span> <span class="n">100</span></span></span></code></pre></div>
<p>In F# the <code>%</code> operator does not perform a true mathematical modulo operation where the result has the same sign as the divisor.</p>]]></description>
      <media:content url="https://turingcodex.com/android-chrome-512x512.png" medium="image" type="image/png" width="512" height="512" />
    </item>
  </channel>
</rss>
