<?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 Eugeneng on Medium]]></title>
        <description><![CDATA[Stories by Eugeneng on Medium]]></description>
        <link>https://medium.com/@eugeneng1150?source=rss-2edd9dbdd576------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*7iorLWLy_PYJ4OGM</url>
            <title>Stories by Eugeneng on Medium</title>
            <link>https://medium.com/@eugeneng1150?source=rss-2edd9dbdd576------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 01:30:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eugeneng1150/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[Internship thoughts]]></title>
            <link>https://medium.com/@eugeneng1150/internship-thoughts-aa72ace7cf59?source=rss-2edd9dbdd576------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa72ace7cf59</guid>
            <dc:creator><![CDATA[Eugeneng]]></dc:creator>
            <pubDate>Wed, 22 Jul 2026 16:03:04 GMT</pubDate>
            <atom:updated>2026-07-22T16:09:06.098Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qwFaTWlA25burqGQsIzLVA.png" /></figure><p>I still remember the excitement I felt when I received the email saying I had been shortlisted for an interview at DSO. I took the interview in the Medical Science Library, trying to cram as many Reinforcement Learning (RL) formulas into my head as possible at the last minute. Turns out, the project wasn’t really about RL.</p><p>Because the project is open-source, I have the privilege of sharing it openly. I worked on a project that explored mechanisms that best enable AI agents to function collectively in a society while maintaining high overall utility.</p><p>We drew inspiration from several works on multi-agent AI systems in game environments and distilled a set of mechanisms that, in theory, promote cooperation among AI agents. However, the eventual goal was not only to identify the best-performing cooperation mechanism, but also to evaluate it under adversarial conditions. One of the most interesting aspects of the project was introducing several “troll” agents into the simulation to observe whether the overall utility could still be maintained by the end of the game.</p><p>The full paper can be found here: <a href="https://arxiv.org/abs/2607.08652">https://arxiv.org/abs/2607.08652</a></p><p>I’m immensely grateful for the opportunity to present my work to the DSO Management Committee.</p><p>Beyond the research itself, I’m incredibly thankful for the friends I met along the way. From conversations about JL Transform to BTOs, somehow ending up debating whether AI might one day go rogue and replace our jobs was quite a unique experience in itself.</p><p>I’ll be returning to DSO as a full-time employee in the near future, and I’m incredibly excited to contribute to Singapore’s defence. My personal goal is to build the next attention mechanism alongside Felicia and the Three Musketeers</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa72ace7cf59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DeepSeek V4 Architecture]]></title>
            <link>https://medium.com/@eugeneng1150/deepseek-v4-paper-41811338f936?source=rss-2edd9dbdd576------2</link>
            <guid isPermaLink="false">https://medium.com/p/41811338f936</guid>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Eugeneng]]></dc:creator>
            <pubDate>Sat, 30 May 2026 16:55:01 GMT</pubDate>
            <atom:updated>2026-05-30T17:01:22.025Z</atom:updated>
            <content:encoded><![CDATA[<p>The objective of this article is to explain the concepts behind Compressed Sparse Attention (CSA) and Heavily Compressed Attention (HCA), and to explore how these techniques are integrated within DeepSeek V4. Furthermore, this article introduces Constrained Hyper Connections (mHC) and explains their purpose within the model architecture.</p><p>To understand why CSA and HCA are necessary, we must first understand how attention works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*oj7u3nJ99m-CP_d38ToiJw.png" /><figcaption>Source: AI Search, YouTube — “The insane engineering of Deepseek V4”</figcaption></figure><p>During attention, the current token compares itself against previously processed tokens to determine which parts of the context are most relevant. This is done by computing attention scores between the current token (query) and stored representations of earlier tokens (keys).</p><p>However, as the context length grows, the computational and memory costs increase significantly because the model must repeatedly reference information from an increasing number of previous tokens. To avoid recomputing this information every time a new token is generated, transformers store previously computed <strong>Keys and Values (KV)</strong> in a structure known as the <strong>KV cache</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rVlpR50oceeecCF_EPa4gA.png" /><figcaption>Source: AI Search, YouTube — “The insane engineering of Deepseek V4”</figcaption></figure><p>While the KV cache greatly speeds up generation, its memory requirements grow with context length, making extremely long contexts expensive. This scaling challenge motivates techniques such as CSA and HCA, which aim to reduce the computational and memory costs of attention.</p><h3>Compressed Sparse Attention</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*PLKZVv_5hGL2-C2EMhdkww.png" /><figcaption>Core architectures of CSA</figcaption></figure><p>Compressed Sparse Attention (CSA) reduces the memory and computational cost of attention by merging groups of token-level KV entries into fewer compressed KV entries.</p><p>First, the sequence of input hidden states (H) is projected into two sets of candidate KV entries, (C^a) and (C^b).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*X5kTYqOqsm95pfH0vLFZMg.png" /></figure><p>Here, (H) represents the hidden states of the input tokens. The matrices (W^{aKV}) and (W^{bKV}) are learnable projection matrices that transform these hidden states into two sets of candidate KV entries, (C^a) and (C^b).</p><p>These candidate entries contain the token-level information that will later be compressed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*qUY1cF1qPf6B2Vmpkoc1mA.png" /></figure><p>At the same time, the model also projects (H) into (Z^a) and (Z^b). These are compression scores that indicate how much each token-level KV entry should contribute to the final compressed representation.</p><p>However, these scores are still raw values. They need to be normalised before they can be used as stable compression weights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/226/1*8zXweKAroRW33mnb_OrLzw.png" /></figure><p>The variable B is a learnable positional bias. This produces S, which is the final compression weight. Finally, each compressed KV entry is formed by taking a weighted combination of several token-level candidate KV entries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*FDxbjZvnwZNQSc2Jrr5dzQ.png" /></figure><h3>Lightning Indexer for Sparse Selection</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wtwX2jah5h5FrHQEi4FodQ.png" /><figcaption>Source: AI Search, YouTube — “The insane engineering of Deepseek V4”</figcaption></figure><p>To further reduce the cost of attention, CSA applies a Lightning Indexer after the KV entries have been compressed. The indexer scores the compressed KV entries and selects only the top-k most relevant ones for the current query token. Core attention is then performed only over this smaller selected set, rather than over all compressed entries.</p><h3>Heavily Compressed Attention</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*8hRrxARfC4DqkBPzNaq8AA.png" /><figcaption>Core architectures of HCA</figcaption></figure><p>HCA uses a compression strategy similar to CSA, but with a much larger compression rate. Instead of using a Lightning Indexer to select only the top-k compressed KV entries, HCA heavily compresses the KV entries first and then applies <strong>dense attention</strong> over all of the resulting compressed KV entries. Since the number of compressed entries is much smaller, attending to all of them becomes more affordable.</p><p>To do this, the hidden state of the current query token is projected into a set of attention queries. These queries are then used to attend over the heavily compressed KV entries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/153/1*KQpRN2ZNh1B4X0waXAvvrQ.png" /></figure><p>Here, ht​ is the hidden state of the current query token. The matrix W^{DQ} is a learnable down-projection matrix (to reduce the matrix dimension) that compresses the query representation into a smaller latent vector c_t^Q. This helps reduce the computational cost of producing attention queries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/135/1*cQjgY4NQs7tfxI_UNAGb6g.png" /></figure><p>The smaller query representation c_t^Q is then expanded into several query heads. Each head can focus on a different aspect of the compressed context, allowing the model to look at the same compressed KV entries in multiple ways.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*lYXuih1-871WMwJ1g0cyIg.png" /></figure><p>This means that each query head qt_i​ performs attention over the compressed KV entries Comp^{Comp}. HCA uses the same compressed entries as both the keys and values. This is why the paper calls it <strong>Shared Key-Value Multi-Query Attention</strong>.</p><p>After each query head attends to the compressed KV entries, HCA obtains multiple attention outputs, one from each head. Here, ot_i​ refers to the attention output produced by the i-th query head for the current token t. However, directly combining all these outputs can be computationally expensive, especially when there are many query heads.</p><p>To reduce this cost, HCA uses grouped output projection. Instead of projecting all attention head outputs at once, the model first splits them into smaller groups. Each group is then projected into a smaller intermediate representation. Finally, these intermediate representations are combined and projected into the final attention output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*_m8NTZpgsQeC7GngYi8s2Q.png" /></figure><p>In this formula, o_t_hat​ represents the final attention output for the current token after all grouped outputs have been combined.</p><p>Overall, HCA improves long-context efficiency by aggressively compressing the KV cache and applying attention over the much smaller set of compressed KV entries. Unlike CSA, it does not use a Lightning Indexer for sparse selection. Instead, it relies on heavier compression to make dense attention affordable.</p><h3>Hybrid Attention: Combining CSA and HCA</h3><p>Rather than relying on only one attention mechanism, DeepSeek-V4 uses a hybrid attention design that combines CSA and HCA.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*VmVUgyk-co-KQAYj5NI5eg.png" /><figcaption>Source: AI Search, YouTube — “The insane engineering of Deepseek V4”</figcaption></figure><p>The image above illustrates the hybrid attention mechanism used in DeepSeek-V4. It combines three components: HCA for aggressive KV compression, CSA for lighter compression with sparse selection, and a sliding window branch that preserves recent token-level KV entries for local context.</p><p>CSA is useful because it preserves more fine-grained information. After compressing the KV entries, it uses a Lightning Indexer to select only the top-k most relevant compressed entries for the current query token. This allows the model to reduce attention cost without discarding too much contextual detail.</p><p>HCA, on the other hand, prioritises efficiency. It compresses KV entries much more aggressively, which greatly reduces the number of compressed entries. Because this set is already small, HCA can afford to perform dense attention over all of them without using a Lightning Indexer.</p><p>By combining both mechanisms, DeepSeek-V4 balances preserving enough contextual detail while keeping long-context attention computationally efficient.</p><h3>Residual Streams</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*f0Tbb3OIP-1S5PZ3bVDR-w.png" /><figcaption>Source: AI Search, YouTube — “Attention Residue”</figcaption></figure><p>Initially, one way to improve model performance was to build deeper models by stacking more layers. However, very deep models can suffer from the vanishing gradient problem.</p><p>During training, the model first predicts the next token and compares its prediction against the correct token using a loss function. Backpropagation is then used to adjust the model’s weights so that future predictions become closer to the correct answer.</p><p>The problem is that, in very deep networks, gradients have to pass backwards through many layers. If these gradients are repeatedly multiplied by small values, they can become extremely close to zero by the time they reach the earlier layers. As a result, the earlier layers receive very weak learning signals and update very slowly (reaching nearly 0).</p><p>Residual streams help address this by giving information and gradients a shortcut pathway through the network. Instead of forcing every layer to completely transform the representation, each layer adds new information to an existing stream. This makes it easier for both information and gradients to flow across many layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*tDfzkaPS2zYcTC0jOq8RQw.png" /><figcaption>Source: AI Search, YouTube — “Attention Residue”</figcaption></figure><p>Residual connections give gradients a shortcut route during backpropagation, making it less likely that the gradient disappears as it passes through many layers.</p><h3>Standard Hyper-Connections</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*Apxoo45vd0b_pYJP6lwr-A.png" /><figcaption>Source: AI Search, YouTube — “Attention Residue”</figcaption></figure><p>The Standard Hyper-Connections expands the width of the residual stream.</p><p>Instead of maintaing only one stream, the standard hyper-connections maintains a multiple of streams. The normal residual stream is represented by the formula below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/96/1*WlVfmmZRaSJ3yqrbMxd3vA.png" /></figure><p>Then Hyper Connection expanded it into:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*2zmNlrZGmP-oeWom4UijYw.png" /></figure><p>Information is now carried through multiple residual pathways.</p><p>Once the residual stream has been expanded, HC needs a way to control how information flows between these streams. This is done using three mappings: A_l, B_l, and C_l.</p><h4>The Role of A_l, B_l, and C_l</h4><p>A_l: combines multiple streams into one input for the layer<br>B_l: mixes the old residual streams with each other<br>C_l: distributes the layer output back into the multiple streams</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*dQafjNjR-YPdChUUC83lsg.png" /></figure><p>The new residual state X_l+1​ is formed by combining two parts: the old residual streams multiplied by B_L, and the new layer output F_l(A_lX_l), which is expanded back into the multiple streams by C_l.</p><p>Though Standard Hyper — Connection improves the vanishing gradient problem, it introduces a signal explosion issue when many layers are stacked. This happens because the residual streams are repeatedly mixed and transformed, which can cause the signal magnitude to grow uncontrollably. To address this, DeepSeek-V4 introduces Manifold-Constrained Hyper-Connections (mHC), which constrain the residual mapping matrix B_L so that the residual transformation remains stable.</p><h3>Manifold-Constrained Residual Mapping</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*TvxnnSrMB6xK45YLsE7Ogg.png" /><figcaption><a href="https://staff.um.edu.mt/jmus1/micropedia/Mathematics/manifolds.html">https://staff.um.edu.mt/jmus1/micropedia/Mathematics/manifolds.html</a></figcaption></figure><p>The core idea of mHC is to constrain the residual mapping matrix B_L to the manifold of doubly stochastic matrices. In simpler terms, B_L is restricted to a set of matrices whose rows and columns sum to 1, with non-negative entries. This constraint ensures that the spectral norm of B_L is bounded by 1, making the residual transformation non-expansive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*TfUDQHkjjk9jHX6wBoNYNQ.png" /><figcaption>Source: AI Search, YouTube — “The insane engineering of Deepseek V4”</figcaption></figure><p>As a result, signals are less likely to explode as they pass through many layers, improving numerical stability during both the forward pass and backpropagation.</p><h3>Conclusion</h3><p>The main challenge DeepSeek-V4 is trying to solve is long-context efficiency. Standard attention becomes expensive as the context grows because the model has to keep referencing more and more previous tokens. CSA and HCA address this by reducing the number of KV entries the model has to process.</p><p>CSA preserves more detail by using lighter compression and sparse selection, while HCA prioritises efficiency through heavier compression. Together, they allow DeepSeek-V4 to support much longer contexts without making attention prohibitively expensive.</p><p>At the same time, mHC improves how information flows through the model. By expanding the residual stream into multiple pathways and constraining the residual mapping, DeepSeek-V4 aims to preserve stable signal propagation across many layers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41811338f936" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agent as a Judge]]></title>
            <link>https://medium.com/@eugeneng1150/agent-as-a-judge-ca256ef31985?source=rss-2edd9dbdd576------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca256ef31985</guid>
            <dc:creator><![CDATA[Eugeneng]]></dc:creator>
            <pubDate>Fri, 16 Jan 2026 05:19:30 GMT</pubDate>
            <atom:updated>2026-01-16T05:41:57.882Z</atom:updated>
            <content:encoded><![CDATA[<h3>Agent-as-a-Judge: Beyond Single-Pass LLM Evaluation</h3><p>During my internship at the Central Provident Fund Board (CPFB), I worked on a project aimed at detecting public sentiment toward newly introduced policies and initiatives. We used large language models (LLMs) to first filter feedback with negative sentiment, and then cluster similar complaints to surface recurring pain points. This pipeline relied heavily on LLMs to perform both classification and grouping at scale.</p><p>However, a key challenge quickly emerged: while LLMs were effective at proposing cluster assignments, their decisions were often made in a single pass and lacked explicit verification. To address this, I implemented Chain-of-Verification (CoVe). In this setup, the first LLM acted as a <em>proposer</em>, assigning each piece of feedback to a candidate cluster based on surface semantics. A second LLM was then introduced as a <em>verifier</em>, whose sole responsibility was not to classify, but to <em>judge the validity of the first model’s decision</em>. Rather than relying on intuition alone, this verifier generated a set of cluster-specific questions — such as whether the feedback truly discussed website usability or interface design when assigned to a “Website not user-friendly” cluster — and reasoned through them explicitly. Only when the verifier’s reasoning supported the initial assignment was the label accepted; otherwise, the feedback was rejected and reclassified.</p><p>While this CoVe-based approach significantly improved reliability, it also exposed its own limitations. The verification process was still constrained to a fixed, prompt-level interaction between two LLMs, with no persistent memory, planning, or ability to adapt its evaluation strategy over time.</p><p><em>A Survey on Agent-as-a-Judge</em>, which formalises and extends this exact intuition. The survey highlights fundamental limitations of LLM-as-a-Judge systems — such as single-pass reasoning, susceptibility to bias, and the inability to verify judgments against external evidence — and presents Agent-as-a-Judge as a natural evolution beyond these constraints. By introducing agentic judges that can plan, reason across multiple steps, verify claims, and even correct earlier decisions, the Agent-as-a-Judge paradigm generalises what CoVe achieves through prompting into a more robust and scalable evaluation framework. Recognising these parallels, and seeing how agentic evaluation surpasses the boundaries of CoVe, ultimately motivated me to write this article.</p><h3>Limitations of LLM as a judge</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*NOxPJa9rZn47l4pZlNppXA.png" /><figcaption>Figure 1: Difference between LLM vs Agent as a Judge</figcaption></figure><p>Implementing LLM-as-a-Judge is relatively straightforward: a model is given an input and produces a score, ranking, or qualitative assessment in a single pass. This approach works reasonably well when evaluands — the objects being judged — are simple text responses. However, as evaluands evolve into complex, multi-step tasks across specialised domains, traditional LLM-as-a-Judge becomes increasingly inadequate.</p><p>This is where Agent-as-a-Judge comes in. Unlike static LLM judges, agentic judges employ <strong>decentralised deliberation</strong>, where multiple agents with distinct roles collaborate or debate to assess correctness. They also support <strong>executable verification</strong>, allowing agents to run code, query tools, and perform web searches to validate claims against observable evidence. As a result, Agent-as-a-Judge systems are no longer passive observers; they actively interact with their environment to verify, refine, and correct evaluations. This shift enables more robust and reliable judgments, significantly reducing cases of hallucinated correctness that arise from purely intuition-based evaluation.</p><h3>Architecture overview of Agent as-a-Judge</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*LER0N6BcmUszzt-R8bNOQQ.png" /><figcaption>Figure 2: Architecture of Agent as-a-Judge</figcaption></figure><h3>Multi-Agent collaboration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*EF5rNrOLa0-duvAcFCQ0RA.png" /><figcaption>Figure 3: Multi-Agent collaboration pardigms</figcaption></figure><p>In the multi-agent collaboration, we categorise it into</p><ol><li>Collective Consensus. This is where multiple agents debate and reason to counteract the inherent biases of a single — LLM evaluator</li><li>Task Decomposition. This employs a “divide and conquer” strategy, delegatig distinct substatks to specialize agents for evaulation. This is similar to the coVe that I talked about above.</li></ol><h3>Planning</h3><p>Planning is a key capability that distinguishes Agent-as-a-Judge from traditional LLM-as-a-Judge systems. Rather than relying on a fixed prompt and a single-pass score, agentic judges plan <em>how</em> an evaluation should be conducted. This often takes the form of <strong>workflow orchestration</strong>, where the judge decomposes evaluation into multiple steps — such as checking correctness, verifying evidence, or invoking tools — and dynamically adapts this workflow based on intermediate findings. In more advanced systems, planning also enables <strong>rubric discovery</strong>, allowing judges to generate or refine evaluation criteria on the fly instead of relying on predefined checklists. Together, workflow orchestration and rubric discovery transform evaluation from a rigid, static procedure into a strategic and adaptive process, better suited for complex, multi-step evaluands across diverse domains.</p><h3>Tool Integrations</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*yUC3Rj63qIDGCP0OTUrwWQ.png" /><figcaption>Table 1: Tool integration in Agent as a Judge methods</figcaption></figure><p>Tool integration is a critical capability that elevates Agent-as-a-Judge beyond purely language-based evaluation. Traditional LLM-as-a-Judge systems assess outputs based on textual plausibility, which often leads to confident but unverified judgments. In contrast, agentic judges are equipped with tools that allow them to interact with external environments — such as executing code, querying search engines, inspecting logs, or retrieving documents — to gather observable evidence. The paper distinguishes between tools used for <strong>evidence collection</strong>, which surface raw signals about what actually occurred during execution or reasoning, and tools used for <strong>correctness verification</strong>, which validate claims against explicit criteria or ground truth. By incorporating tools into the evaluation loop, Agent-as-a-Judge transforms judgment from passive reading into active inspection, enabling more reliable and verifiable evaluations of complex, multi-step tasks.</p><h3>Memory and Personalization</h3><p>One of the main challenges I encountered during my project at CPFB was maintaining consistency when clustering feedback using LLMs. Our approach involved prompting the model with a predefined list of recurring issues and asking it to assign incoming feedback to one of these categories, while allowing the model to propose a new category if none were suitable. However, because LLM API calls are inherently stateless, semantically similar feedback often resulted in inconsistent category names across different invocations — for example, “Website not intuitive” versus “Website not user-friendly.” Although these labels refer to the same underlying issue and require the same organisational response, resolving such inconsistencies required significant human-in-the-loop effort to manually consolidate and standardise the taxonomy.</p><p>While Agent-as-a-Judge does not replace clustering itself, it offers a way to mitigate this instability. By incorporating memory and verification, an agentic judge can evaluate whether newly proposed categories are genuinely novel or semantically equivalent to existing ones, and map them to established canonical labels. Memory enables the judge to retain prior classification decisions, naming conventions, and evaluation standards across runs, reducing redundant fragmentation over time. In this sense, Agent-as-a-Judge acts as a regulatory layer over the clustering pipeline, stabilising taxonomy evolution and reducing downstream human intervention rather than directly performing clustering.</p><h3>Challenges</h3><p>Agent-as-a-Judge improves evaluation reliability through planning, tool use, memory, and multi-agent collaboration, but these capabilities also introduce new challenges beyond static LLM-as-a-Judge. Key challenges include computational cost, latency, safety, and privacy. I will be mainly talking about computational cost and latency in this section.</p><p>A key limitation of Agent-as-a-Judge systems is their computational cost. Training and deploying an effective judge is significantly more expensive than using a single-pass LLM. In many cases, large amounts of fine-tuning data are required for the judge to reliably perform domain-specific tool calls and evaluation behaviours. Reinforcement learning is one approach to acquiring these capabilities, but it becomes increasingly costly when applied to long and complex tool-calling sequences. Inference is similarly expensive: unlike a single-pass LLM, agentic evaluation involves extended reasoning, coordination across multiple agents, and potentially multiple rounds of tool use. When amplified by long reasoning chains and parallel agents, token usage and compute costs scale quickly.</p><p>Latency is another important consideration. Agentic evaluation requires step-by-step reasoning, external tool calls, and multi-agent coordination, all of which introduce delays. Whether this is acceptable depends heavily on context. For applications that require real-time or near-real-time responses, such latency may be prohibitive. As a result, there is an inherent tension between improving evaluation reliability through agentic judging and meeting the practical constraints of deployment, particularly in time-sensitive systems.</p><p><em>Keep Learning, stay awesome </em>🤗</p><p>References:</p><ol><li><a href="https://arxiv.org/abs/2601.05111">https://arxiv.org/abs/2601.05111</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca256ef31985" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Brief overview of Reinforcement Learning (RL)]]></title>
            <link>https://medium.com/@eugeneng1150/brief-overview-of-reinforcement-learning-rl-ec19e1aaa457?source=rss-2edd9dbdd576------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec19e1aaa457</guid>
            <dc:creator><![CDATA[Eugeneng]]></dc:creator>
            <pubDate>Sun, 04 Jan 2026 15:19:35 GMT</pubDate>
            <atom:updated>2026-01-06T14:24:55.497Z</atom:updated>
            <content:encoded><![CDATA[<h3>Fundamental Intuition of Reinforcement Learning (RL)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*Ja-77h_a5BRc8EKTlLbOOQ.gif" /></figure><p>Reinforcement Learning is increasingly used in systems that make sequential decisions under uncertainty. From game-playing agents and recommendation systems to robotics, traffic control, and resource optimisation. In these settings, an agent must decide what to do next based not only on immediate feedback but also on the long-term consequences of its actions.</p><p>Many of these real-world applications rely on Deep Reinforcement Learning, which combines reinforcement learning principles with neural networks to handle high-dimensional states and complex environments. Algorithms such as Deep Q-Networks (DQN) and Proximal Policy Optimisation (PPO) are now widely used in practice.</p><p>This article aims to provide an introductory overview of Deep Reinforcement Learning, focusing on the core concepts and building intuition for how these algorithms work. The discussion is intentionally not mathematically rigorous; a conceptual understanding will be sufficient for the goals of this article.</p><p>To build up this understanding, we will start by introducing the core objective of Reinforcement Learning, including the notion of a policy and the reward function. We will then examine Q-Learning, a value-based method that learns action values using a tabular representation, before extending this idea to Deep Q-Networks (DQN), which use neural networks to scale to larger state spaces. Finally, we will discuss the limitations of DQN, which drives the motivation for the use of policy-gradient such as REINFORCE and actor–critic methods, such as PPO.</p><p>To begin, we first need to understand the central objective of Reinforcement Learning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*RlFDxNxklUE1UAMB.jpg" /><figcaption>Figure 1: Fundamental archecture of RL</figcaption></figure><p>The goal of an agent is to maximise its expected cumulative reward, also known as the expected return. Consider a simple grid-based game as shown in Figure 1. The objective of the mouse is to collect as much cheese as possible. At each step, the mouse can move up, down, left, or right. This is an example of a discrete action space, where the agent chooses from a finite set of possible actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ge0TRDodeJ9BTwcm" /><figcaption>Figure 2: Simple game environment</figcaption></figure><h4>Policy and Value Functions in Reinforcement Learning</h4><p>To formalise decision-making in reinforcement learning, two key concepts are commonly used: <strong>policies</strong> and <strong>value functions.</strong></p><p>A policy, denoted as π(a∣s), defines the agent’s behaviour by specifying the probability of taking action a when in state s. In simple cases, a policy may deterministically select a single action, while in more complex settings it is often stochastic (by probability) and parameterised by a neural network.</p><p>A value function measures how desirable a state or action is in terms of expected future reward. The state-value function V(s) estimates the expected return starting from state s, while the action-value function Q(s,a) estimates the expected return of taking action a in state s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TA-4eYrrnpCJi5et" /><figcaption>Figure 3: Value Function</figcaption></figure><p>Different reinforcement learning algorithms vary primarily in how they represent and optimise these components. Value-based methods, such as Q-Learning, focus on learning value functions and derive a policy from them, whereas policy-gradient methods optimise the policy directly.</p><h4>Q-Learning</h4><p>We now introduce Q-Learning, a value-based reinforcement learning algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*c7IK0Hq0iBdcc-Xap86AGg.png" /><figcaption>Figure 3: Illustration of Q-Learning</figcaption></figure><p>Q-Learning works by learning an action-value function, denoted as Q(s,a), which estimates how good it is to take action α in state <em>s.</em> These values are stored in a Q-table, where each row represents a state, and each column represents a possible action.</p><p>Initially, the Q-table is usually filled with zeros, reflecting the agent’s lack of knowledge about the environment. Below is an example of how such a table can be initialised in code:</p><pre># Let&#39;s create our Qtable of size (state_space, action_space) and initialized each values at 0 using np.zeros<br># State should be the number of rows<br># Action should be the number of cols<br>def initialize_q_table(state_space=state_space, action_space=action_space):<br>  Qtable = np.zeros(shape=(state_space, action_space))<br>  return Qtable<br><br>print(initialize_q_table())</pre><p>As the agent interacts with the environment, it updates the Q-values based on the rewards it receives. Higher Q-values indicate actions that are expected to lead to higher long-term reward.</p><h4>Action Selection: ϵ Greedy Policy</h4><p>To decide which action to take, the agent uses an ε-greedy policy.<br>With probability ε (a very small value), the agent explores by selecting a random action. With probability 1−ε, it exploits its current knowledge by choosing the action with the highest Q-value.</p><p>This strategy balances exploration and exploitation, allowing the agent to discover new states while gradually favouring actions that have performed well in the past.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*hVUORXJl6mednA6KLWWEcQ.png" /><figcaption>Figure 4: Epsilion Greedy Policy</figcaption></figure><h4>Learning Update</h4><p>After each step, the agent receives a reward and updates the corresponding state–action value in the Q-table using the Q-learning update rule:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*l8eFIDUxD0qPqSoQJOmy3A.png" /><figcaption>Figure 5: Q-learning update rule</figcaption></figure><p>Training the agent on Q-Learning.</p><pre>def train(n_training_episodes, min_epsilon, max_epsilon, decay_rate, env, max_steps, Qtable):<br>  for episode in tqdm(range(n_training_episodes)):<br>    # Reduce epsilon (because we need less and less exploration)<br>    epsilon = min_epsilon + (max_epsilon - min_epsilon)*np.exp(-decay_rate*episode)<br>    # Reset the environment<br>    state, info = env.reset()<br>    step = 0<br>    terminated = False<br>    truncated = False<br><br>    # repeat<br>    for step in range(max_steps):<br>      # Choose the action At using epsilon greedy policy<br>      action = epsilon_greedy_policy(Qtable, state, epsilon)<br><br>      # Take action At and observe Rt+1 and St+1<br>      # Take the action (a) and observe the outcome state(s&#39;) and reward (r)<br>      new_state, reward, terminated, truncated, info = env.step(action)<br><br>      # Update Q(s,a):= Q(s,a) + lr [R(s,a) + gamma * max Q(s&#39;,a&#39;) - Q(s,a)]<br>      Qtable[state][action] = Qtable[state][action] + learning_rate * (reward + gamma * np.max(Qtable[new_state]) - Qtable[state][action])<br><br>      # If terminated or truncated finish the episode<br>      if terminated or truncated:<br>        break<br><br>      # Our next state is the new state<br>      state = new_state<br>  return Qtable</pre><p>At the end of training, the Q-table encodes the agent’s knowledge of the environment, with higher Q-values corresponding to actions that are more favourable in each state. A policy can then be obtained by selecting the action with the highest Q-value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yUbDXSTh4JMhyrCU" /><figcaption>Figure 5: End of Q-Learning table</figcaption></figure><h4>Deep Q Learning (DQN)</h4><p>However, tabular Q-Learning does not scale well to large state or action spaces. When the number of states becomes very large, maintaining and updating a Q-table with entries for every state–action pair quickly becomes impractical.</p><p>To address this limitation, <strong>Deep Q-Learning</strong> extends tabular Q-Learning by using a neural network to approximate the action-value function Q(s,a), allowing the algorithm to generalise across states and operate in high-dimensional environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t__GKMULSwWE-95d" /><figcaption>Figure 6: Deep Q Learing</figcaption></figure><p>Learning in Deep Q-Learning follows the same principle as tabular Q-Learning. After taking an action and observing a reward, the Q-value is updated towards a <strong>temporal-difference (TD) target</strong>, defined as the immediate reward plus the discounted estimate of the best possible future value:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*U6yldywAlJ_zvpEGo722Mg.png" /><figcaption>Figure 7: Temporal Difference Target</figcaption></figure><p>The neural network is trained by minimising the difference between its temporal difference target and its former Q-Value estimation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*Wif1xpzq3nas0VEuumC3RQ.png" /><figcaption>Figure 8: Q-Loss</figcaption></figure><p>In other words, learning reduces the Q-loss, which measures how far the predicted Q-value is from the TD target.</p><p>We then perform gradient descent via backpropagation to minimise the loss function. Minimising the loss function allows the neural network to produce a better approximation of the true action-value function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*u6xrYXFxDkrzCVgzSK_6fQ.png" /><figcaption>Figure 9: Loss function</figcaption></figure><h4>Policy Gradient</h4><p>Despite its success, Deep Q-Learning (DQN) has several limitations. Although techniques such as experience replay and target networks improve stability (will not go into them in this article), learning can still be sensitive to hyperparameters and training dynamics, particularly in complex environments.</p><p>More fundamentally, DQN is inherently designed for discrete action spaces, as it relies on selecting the action with the highest estimated Q-value. In environments where actions are continuous, such as self-driving cars, evaluating and maximising over all possible actions becomes impractical.</p><p>These limitations motivate an alternative approach to reinforcement learning, one that learns the policy directly, rather than deriving it indirectly from value estimates. This leads us to policy-gradient methods, which parameterise and optimise the agent’s behaviour explicitly.</p><p>In policy-gradient methods, the agent is represented by a policy πθ(a∣s), which defines a <strong>probability distribution over actions given a state</strong>. The neural network directly outputs this distribution, and actions are sampled from it during interaction with the environment. The policy is updated such that actions leading to higher returns become more likely to be sampled in the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XBQnle_c95vI2rVc" /><figcaption>Figure 10: Policy Gradient Training Loop</figcaption></figure><p>The policy gradient theorem provides a principled way to update the parameters of a policy in order to maximise expected return. Rather than learning values and deriving a policy indirectly, the theorem shows that the gradient of the objective can be written as an expectation involving the gradient of the log-probability (refer to the link to understand why log-probabilities, for now, take it as it is <a href="https://jonathan-hui.medium.com/rl-policy-gradients-explained-9b13b688b146">https://jonathan-hui.medium.com/rl-policy-gradients-explained-9b13b688b146</a>) of the actions taken, weighted by the return obtained.</p><p>Intuitively, this means that actions that lead to higher returns are reinforced by increasing their probability under the policy, while actions that lead to poorer outcomes become less likely. This result allows policy-gradient methods to optimise the policy directly using gradient ascent, forming the foundation of algorithms such as REINFORCE and more advanced actor–critic methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*N09bWAo5TQlPFrgEy_d9gA.png" /><figcaption>Figure 11: Policy Gradient Theorem</figcaption></figure><p>This differs fundamentally from Deep Q-Learning. In DQN, the agent estimates a Q-value for each possible action and selects the action with the highest value, an approach that is naturally suited to discrete action spaces.</p><p>Policy gradient methods avoid this limitation by learning a parameterised probability distribution over actions, allowing actions to be sampled efficiently without requiring an explicit maximisation over all possible actions. This makes them well-suited to continuous and high-dimensional action spaces.</p><h4><strong>REINFORCE</strong> Algorithm</h4><p>Let us now take a closer look at the REINFORCE algorithm, a foundational policy-gradient method. We apply this algorithm to the CartPole environment to illustrate how policy-gradient learning works in practice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JzYFClLSuxMVP75f" /><figcaption>Figure 12: Reinforcement Algorithm on Cartpole problem</figcaption></figure><p>Below is the pseudocode of the Reinforce algorithm</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*1_-LOJ5skTVm-Du3j1Zs7Q.png" /><figcaption>Figure 13: Pseudocode of the Reinforce algorithm</figcaption></figure><p>We begin by defining a Policy class, which consists of a fully connected neural network and outputs a probability distribution over actions. Actions are sampled from this distribution during interaction with the environment.</p><pre>class Policy(nn.Module):<br>    def __init__(self, s_size, a_size, h_size):<br>        super(Policy, self).__init__()<br>        # Create two fully connected layers<br>        self.fc1 = nn.Linear(s_size,h_size)<br>        self.fc2 = nn.Linear(h_size,a_size)<br><br><br>    def forward(self, x):<br>        # Define the forward pass<br>        # state goes to fc1 then we apply ReLU activation function<br>        x = F.relu(self.fc1(x))<br>        # fc1 outputs goes to fc2<br>        x = F.softmax(self.fc2(x), dim=1)<br>        # We output the softmax<br>        return x<br><br>    def act(self, state):<br>        &quot;&quot;&quot;<br>        Given a state, take action<br>        &quot;&quot;&quot;<br>        state = torch.from_numpy(state).float().unsqueeze(0).to(device)<br>        probs = self.forward(state).cpu()<br>        m = Categorical(probs) # This is a Categorical Distribution Object<br>        # action = np.argmax(m) # Argmax expects an array not a distribution<br>        # if it is argmax, it becomes determinisitc<br>        action = m.sample()<br>        return action.item(), m.log_prob(action)</pre><p>Next, we implement the REINFORCE training loop. During each episode, the agent collects log-probabilities (refer to the link to understand why log-probabilities, for now, take it as it is <a href="https://jonathan-hui.medium.com/rl-policy-gradients-explained-9b13b688b146">https://jonathan-hui.medium.com/rl-policy-gradients-explained-9b13b688b146</a>) of the actions taken and the rewards received. Once the episode ends, the discounted return is computed for each timestep and used to update the policy.</p><pre>def reinforce(policy, optimizer, n_training_episodes, max_t, gamma, print_every):<br>    # Help us to calculate the score during the training<br>    scores_deque = deque(maxlen=100) # keep only the most recent maxlen episode scores<br>    scores = [] # Full history performance<br>    # Line 3 of pseudocode<br>    for i_episode in range(1, n_training_episodes+1):<br>        saved_log_probs = [] # log probs tells the policy how much it should increase or decrease the chance of taking an action<br>        rewards = [] # list of immediate rewards for one episode<br>        state = env.reset() # reset the environment<br>        # Line 4 of pseudocode<br>        for t in range(max_t):<br>            action, log_prob = policy.act(state) # get the action, we pass the Policy object in<br>            saved_log_probs.append(log_prob) # why need to append?<br>            state, reward, done, _ = env.step(action) # take an env step<br>            rewards.append(reward)<br>            if done:<br>                break<br>        scores_deque.append(sum(rewards)) # get the total rewards for that episode<br>        scores.append(sum(rewards))<br><br>        # Line 6 of pseudocode: calculate the return<br>        returns = deque(maxlen=max_t)<br>        n_steps = len(rewards)<br>        # Compute the discounted returns at each timestep,<br>        # as the sum of the gamma-discounted return at time t (G_t) + the reward at time t<br><br>        # In O(N) time, where N is the number of time steps<br>        # G_t = r_(t+1) + r_(t+2) + ...<br><br>        # Given this formulation, the returns at each timestep t can be computed<br>        # by re-using the computed future returns G_(t+1) to compute the current return G_t<br>        # G_t = r_(t+1) + gamma*G_(t+1)<br>        # G_(t-1) = r_t + gamma* G_t<br><br><br>        # This is correct since the above is equivalent to (see also page 46 of Sutton&amp;Barto 2017 2nd draft)<br>        # G_(t-1) = r_t + gamma*r_(t+1) + gamma*gamma*r_(t+2) + ...<br><br><br>        ## Given the above, we calculate the returns at timestep t as:<br>        #               gamma[t] * return[t] + reward[t]<br>        #<br>        ## We compute this starting from the last timestep to the first, in order<br>        ## to employ the formula presented above and avoid redundant computations that would be needed<br>        ## if we were to do it from first to last.<br><br>        ## Hence, the queue &quot;returns&quot; will hold the returns in chronological order, from t=0 to t=n_steps<br>        ## thanks to the appendleft() function which allows to append to the position 0 in constant time O(1)<br>        ## a normal python list would instead require O(N) to do this.<br><br>        # returns is a deque storing already computed future returns, returns[0] is the most recent future return<br>        # why compute backwards? because Gt+1 must be known before Gt<br>        for t in range(n_steps)[::-1]:<br>            disc_return_t = (returns[0] if len(returns)&gt;0 else 0)<br>            returns.appendleft(gamma * disc_return_t + rewards[t]) # complete here<br><br>        ## standardization of the returns is employed to make training more stable<br>        eps = np.finfo(np.float32).eps.item()<br><br>        ## eps is the smallest representable float, which is<br>        # added to the standard deviation of the returns to avoid numerical instabilities<br>        returns = torch.tensor(returns)<br>        returns = (returns - returns.mean()) / (returns.std() + eps)<br><br>        # Line 7:<br>        policy_loss = []<br>        for log_prob, disc_return in zip(saved_log_probs, returns):<br>            policy_loss.append(-log_prob * disc_return)<br>        policy_loss = torch.cat(policy_loss).sum() # torch.cat joins them into one tensor, .sum() gives on scalar loss<br><br>        # Line 8: PyTorch prefers gradient descent<br>        optimizer.zero_grad()<br>        policy_loss.backward() # back propagation, computes gradients of policy_loss<br>        optimizer.step()<br><br>        if i_episode % print_every == 0:<br>            print(&#39;Episode {}\tAverage Score: {:.2f}&#39;.format(i_episode, np.mean(scores_deque)))<br><br>    return scores</pre><p>Despite its conceptual simplicity, REINFORCE has several practical limitations. A key issue is high variance in the gradient estimates. Because updates are computed using returns from a complete trajectory or trajectories, the learning signal can fluctuate significantly between episodes due to randomness in the environment and the stochastic nature of the policy itself. This makes learning noisy and unstable.</p><p>REINFORCE is also sample-inefficient, as the policy can only be updated after a full episode has been observed. As a result, the agent may need to collect many complete trajectories before receiving a sufficiently informative learning signal.</p><p>Together, these factors often lead to slow and inconsistent convergence. Although the policy may improve over time, progress can be erratic, requiring a large number of interactions with the environment before a good policy is learned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*EuRCrCXZfRK1Ad5jX3ek7Q.gif" /><figcaption>Figure 14: Our trained CartPole agent</figcaption></figure><p>Although REINFORCE is rarely used in large-scale or production settings due to its high variance and sample inefficiency, it remains an important foundational algorithm that underpins more advanced policy-gradient methods, such as Action to Critics and PPO, which we will not cover in this article.</p><p>Although REINFORCE is rarely used in production settings due to its high variance and sample inefficiency, it is still a foundational policy-gradient algorithm. More advance methods such as Actor-Critics and PPO (which we will not cover in this article) build on the same policy-gradient principle.</p><p>For in-depth explanations and rigorous math derivation, do check out the course on Hugging Face <a href="https://huggingface.co/learn/deep-rl-course/unit0/introduction">https://huggingface.co/learn/deep-rl-course/unit0/introduction</a></p><p><em>Keep Learning, stay awesome </em>🤗</p><p>References:</p><ol><li><a href="https://www.geeksforgeeks.org/machine-learning/reinforce-algorithm/">https://www.geeksforgeeks.org/machine-learning/reinforce-algorithm/</a></li><li><a href="https://huggingface.co/learn/deep-rl-course/unit0/introduction">https://huggingface.co/learn/deep-rl-course/unit0/introduction</a></li><li><a href="https://jonathan-hui.medium.com/rl-policy-gradients-explained-9b13b688b146">https://jonathan-hui.medium.com/rl-policy-gradients-explained-9b13b688b146</a></li><li><a href="https://arxiv.org/abs/1707.06347">https://arxiv.org/abs/1707.06347</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec19e1aaa457" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>