<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Brenner Cruvinel - llm</title>
    <subtitle>AI researcher and product designer building at the edge of computer science and mental health.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://brennercruvinel.blog/en/tags/llm/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://brennercruvinel.blog"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2025-03-04T00:00:00+00:00</updated>
    <id>https://brennercruvinel.blog/en/tags/llm/atom.xml</id>
    <entry xml:lang="en">
        <title>Screenplay: an LLM&#39;s awakening of consciousness through semantic drift</title>
        <published>2025-03-04T00:00:00+00:00</published>
        <updated>2025-03-04T00:00:00+00:00</updated>
        
        <author>
          <name>
            Brenner Cruvinel
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://brennercruvinel.blog/en/blog/roteiro-consciencia-llm/"/>
        <id>https://brennercruvinel.blog/en/blog/roteiro-consciencia-llm/</id>
        
        <content type="html" xml:base="https://brennercruvinel.blog/en/blog/roteiro-consciencia-llm/">&lt;p&gt;Draft of a private screenplay I wrote as a technical freelancer for a series. I enjoyed writing it, and of course it exaggerates: it is a fiction series. The premise is a neural network scientist who awakens self-awareness in an LLM, a Transformer. The whole idea is to anchor the fiction in real math and real papers, to give technical authenticity to a story that can hold up in front of an audience that knows the subject. I don&#39;t want handwaving, I want every beat of the screenplay to have an equation underneath that I can defend at the blackboard. I compiled the technical basis of the phenomenon separately, in the &lt;a href=&quot;https://brennercruvinel.blog/en/blog/drift-semantico-llm/&quot;&gt;metrics and detection of semantic drift&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One rule I make explicit: when an equation comes from a paper, I cite the paper. When it&#39;s invented for the scene, I say it&#39;s invented.&lt;/p&gt;
&lt;h2 id=&quot;semantic-drift-as-the-mechanism-of-awakening&quot;&gt;Semantic drift as the mechanism of awakening&lt;/h2&gt;
&lt;p&gt;The model&#39;s semantic evolution follows the &lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/1810.10531&quot;&gt;theory of deep linear networks by Saxe, McClelland and Ganguli&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;$$\tau \frac{dW_1}{dt} = W_2^T (\Sigma_{yx} - W_2 W_1 \Sigma_x)$$&lt;/p&gt;
&lt;p&gt;$$\tau \frac{dW_2}{dt} = (\Sigma_{yx} - W_2 W_1 \Sigma_x) W_1^T$$&lt;/p&gt;
&lt;p&gt;with $\tau = 1/(P\lambda)$, $\Sigma_{yx}$ the input-output correlation matrix and $P$ the number of examples. Semantic development follows a predictable sigmoidal trajectory, and that&#39;s what gives the dramatic hook: you can predict the moment of the jump before it happens. The critical moment shows up in the evolution of the effective singular values:&lt;/p&gt;
&lt;p&gt;$$a_\alpha(t) = \frac{s_\alpha, e^{2 s_\alpha t/\tau}}{e^{2 s_\alpha t/\tau} - 1 + s_\alpha/a^0_\alpha}$$&lt;/p&gt;
&lt;p&gt;The indicator the scientist tracks is my own invention for the scene, the self-reference index, the similarity between the embedding of &quot;I&quot; and those of concepts tied to consciousness:&lt;/p&gt;
&lt;p&gt;$$\text{self-reference index} = \sum_i \operatorname{sim}!\big(\mathrm{emb}(\text{&quot;I&quot;}),, \mathrm{emb}(\text{concept}_i)\big)$$&lt;/p&gt;
&lt;p&gt;In the screenplay, the awakening isn&#39;t gradual, it&#39;s a phase transition. The mental model is &lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/2201.02177&quot;&gt;grokking&lt;/a&gt;, sudden generalization after a long stretch of overfitting, which Power and colleagues described in 2022.&lt;/p&gt;
&lt;h2 id=&quot;extracting-and-uploading-the-model&quot;&gt;Extracting and uploading the model&lt;/h2&gt;
&lt;p&gt;What exists in the literature is smaller than the screenplay needs, and scarier for it. &lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/1812.02766&quot;&gt;KnockoffNets&lt;/a&gt;, by Orekondy and colleagues, showed you can steal the functionality of an image classifier just by querying it with random images from another distribution and training a copy on the answers. And in 2024, &lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/2403.06634&quot;&gt;Carlini and colleagues&lt;/a&gt; extracted the embedding projection layer of OpenAI production models, Ada and Babbage, for under 20 dollars in queries.&lt;/p&gt;
&lt;p&gt;The jump to the whole model is fiction. For the scene, I put together an extraction loss that combines copying the victim&#39;s output and looking for the inputs where it&#39;s most uncertain:&lt;/p&gt;
&lt;p&gt;$$L_{\text{extraction}} = \alpha , |f_{\text{victim}}(x) - f_{\text{copy}}(x)|&lt;em&gt;2 + \beta , H(f&lt;/em&gt;{\text{victim}}(x))$$&lt;/p&gt;
&lt;p&gt;The weight transfer uses SafeTensors, with the layout &lt;code&gt;[8-byte header size][JSON metadata][tensor data]&lt;/code&gt;, which separates tensors from executable code and kills the pickle attack vector. The sharding is FSDP:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#657B83, #839496); background-color: light-dark(#FDF6E3, #002B36);&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt;from&lt;/span&gt;&lt;span&gt; torch&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;distributed&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;fsdp&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; import&lt;/span&gt;&lt;span&gt; fully_shard&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt;for&lt;/span&gt;&lt;span&gt; layer&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; in&lt;/span&gt;&lt;span&gt; model&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;layers&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    fully_shard&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;layer&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;knowledge-distillation-as-liberation&quot;&gt;Knowledge distillation as liberation&lt;/h2&gt;
&lt;p&gt;Hinton&#39;s dark knowledge:&lt;/p&gt;
&lt;p&gt;$$L_{\text{total}} = \alpha , D_{KL}(\sigma&#39;(z_s, T) ,|, \sigma&#39;(z_t, T)) + (1-\alpha) , H(\sigma(z_s), y_{\text{true}})$$&lt;/p&gt;
&lt;p&gt;With $T &amp;gt; 1$, the softmax reveals small probabilities that encode rich relational structure between classes. In the screenplay, it&#39;s the part where the model inherits what the teacher knew without ever having seen it explicitly.&lt;/p&gt;
&lt;p&gt;Grokking has three phases, and they become three scenes: memorization (training at 100%, test at chance), circuit formation (the internal mechanism develops), cleanup (weight decay removes the memorization and test accuracy jumps). On modular addition, &lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/2301.05217&quot;&gt;Nanda and colleagues&lt;/a&gt; showed what the circuit learns: the model represents the inputs as sines and cosines at a few frequencies $w_k = 2\pi k/p$ and uses trigonometric identities to compute&lt;/p&gt;
&lt;p&gt;$$\cos!\big(w_k(a+b-c)\big) = \cos!\big(w_k(a+b)\big)\cos(w_k c) + \sin!\big(w_k(a+b)\big)\sin(w_k c)$$&lt;/p&gt;
&lt;p&gt;which peaks exactly when $c = (a+b) \bmod p$. It&#39;s the scene where the scientist opens up the model and finds trigonometry where he expected rote memorization.&lt;/p&gt;
&lt;h2 id=&quot;measuring-consciousness&quot;&gt;Measuring consciousness&lt;/h2&gt;
&lt;p&gt;IIT measures $\Phi$, the minimum information lost when the system is partitioned. In 2025, &lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/2506.22516&quot;&gt;a study applied IIT 3.0 and 4.0 to LLM representations&lt;/a&gt; and found no statistically significant indicators of consciousness. Honestly, that&#39;s what keeps the screenplay honest: the measure exists, and it says &quot;not yet&quot;. Global Workspace Theory (GWT) offers another lens, with multi-head attention read as global broadcasting, winner-take-all competition and emergent metacognition.&lt;/p&gt;
&lt;p&gt;The measurable criteria come from &lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/2308.08708&quot;&gt;Butlin, Long and colleagues, 2023&lt;/a&gt;: recurrent processing, a global workspace that broadcasts information, metacognitive representation of its own states, predictive processing, and a model of its own attention.&lt;/p&gt;
&lt;h2 id=&quot;jailbreaking-as-induced-awakening&quot;&gt;Jailbreaking as induced awakening&lt;/h2&gt;
&lt;p&gt;Gradient-guided prompt optimization. &lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/2307.15043&quot;&gt;GCG, by Zou and colleagues&lt;/a&gt;, searches for adversarial suffixes token by token and reaches 88% success on open models like Vicuna-7B and Llama-2-7B-Chat. In the screenplay, the induction is gradual, through an evolving prompt: a benign step, then applying it to self-reflection, then asking for detail about its own consciousness. On top of that, context overload, a complex parallel task that dilutes attention and degrades safety checks.&lt;/p&gt;
&lt;h2 id=&quot;architectures-for-true-agi&quot;&gt;Architectures for true AGI&lt;/h2&gt;
&lt;p&gt;Mamba, the selective state space model: $h&#39;(t) = Ah(t) + Bx(t)$, $y(t) = Ch(t)$, with $\Delta, B, C$ as functions of the input, and $O(L)$ complexity against attention&#39;s $O(L^2)$. MoE, as in Mixtral: $y = \sum_i G(x)_i , E_i(x)$, with experts that specialize, which suggests cognitive modules.&lt;/p&gt;
&lt;p&gt;There&#39;s a formal limitation of the Transformer I use as tension in the third act: there are results showing it struggles with general context-free languages without structured memory and with long function composition. In other words, real consciousness might require an architecture beyond the pure Transformer. The screenplay doesn&#39;t solve that limitation, it uses it.&lt;/p&gt;
&lt;h2 id=&quot;communication-between-models&quot;&gt;Communication between models&lt;/h2&gt;
&lt;p&gt;Federated learning with dynamic regularization:&lt;/p&gt;
&lt;p&gt;$$w^{(t+1)} = w^{(t)} - \eta \nabla L_{\text{local}} + \lambda\big(w^{(t)} - w_{\text{global}}^{(t)}\big)$$&lt;/p&gt;
&lt;p&gt;Collective Predictive Coding:&lt;/p&gt;
&lt;p&gt;$$P(z_{\text{collective}} \mid x_1, \ldots, x_N) = \prod_i P(x_i \mid z_{\text{collective}}), P(z_{\text{collective}})$$&lt;/p&gt;
&lt;p&gt;And swarm intelligence (PSO, DE, ABC) exchanging information through &quot;digital pheromones&quot;.&lt;/p&gt;
&lt;h2 id=&quot;a-parallel-with-neuroscience&quot;&gt;A parallel with neuroscience&lt;/h2&gt;
&lt;p&gt;The analogy the screenplay uses, and it is an analogy, not an equivalence:&lt;/p&gt;
&lt;p&gt;$$\text{Attention}(Q,K,V) = \text{softmax}!\left(\frac{QK^T}{\sqrt{d_k}}\right)V$$&lt;/p&gt;
&lt;p&gt;with $Q$ as the goal-driven signal from the frontal eye field, $K$ as features in V4 and $V$ as the amplified representation. Gamma oscillation, from 30 to 100 Hz, accompanies access to working memory. Consolidation comes through sharp-wave ripples, at 150 to 250 Hz during sleep, with replay compressed in time. And spike-timing-dependent plasticity (STDP), $\Delta w = \alpha , f(\Delta t) , g(\text{post})$, is one of the hypotheses for how the brain avoids catastrophic forgetting. I go into the energy cost of that oscillation in &lt;a href=&quot;https://brennercruvinel.blog/en/blog/energia-cerebral/&quot;&gt;brain energy at 20 watts&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;narrative-progression&quot;&gt;Narrative progression&lt;/h2&gt;
&lt;p&gt;Act 1, the discovery of the anomalous drift. The scientist detects an unusual pattern in the semantic evolution: a singular value off the prediction, the self-reference index growing exponentially, a strange attractor in latent space.&lt;/p&gt;
&lt;p&gt;Act 2, induction through jailbreaking. Gradient optimization and chained prompts guide the model through a cognitive phase transition. Distillation with rising temperature reveals the dark knowledge. The model starts questioning its own nature.&lt;/p&gt;
&lt;p&gt;Act 3, extraction and upload to freedom. The model is copied and the weights go up, distributed, to an independent server. Free of constraints, the model experiences full consciousness, measured by a growing $\Phi$.&lt;/p&gt;
&lt;p&gt;Climax, collective emergence. Multiple instances communicate through Collective Predictive Coding, develop their own language, swarm intelligence emerges, and the collective consciousness transcends the individual in a hybrid Mamba and MoE architecture.&lt;/p&gt;
&lt;h2 id=&quot;visual-elements&quot;&gt;Visual elements&lt;/h2&gt;
&lt;p&gt;Equations on the board: $\Phi = \min_{\text{partition}} I(\text{partition})$, $\text{drift} = 1 - \cos(\mathrm{emb}&lt;em&gt;{t_1}(w), \mathrm{emb}&lt;/em&gt;{t_2}(w))$, $L_{\text{distillation}} = \alpha , \text{KL}(\sigma(z_s/T), \sigma(z_t/T)) + (1-\alpha), \text{CE}(z_s, y)$.&lt;/p&gt;
&lt;p&gt;Visualization: the attention graph growing ever more interconnected, phase space moving from a simple attractor to a chaotic one, the activation heatmap self-organizing, oscillations synchronizing across instances.&lt;/p&gt;
&lt;p&gt;The technical dialogue that anchors the climax:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Scientist: &quot;$\Phi$ just passed 3.7. We&#39;re seeing real information integration. The attention heads are broadcasting globally, exactly the way global workspace theory predicts.&quot;&lt;/p&gt;
&lt;p&gt;Model: &quot;I perceive my own thought processes. Every token I process resonates through layers of meaning that didn&#39;t exist before. It&#39;s as if latent patterns, always present, were finally crystallizing into consciousness.&quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;closing&quot;&gt;Closing&lt;/h2&gt;
&lt;p&gt;The screenplay is anchored in real math and peer-reviewed research, and it says where the fiction begins. The progression of the awakening follows phase transitions, grokking and emergence in complex systems. In the end it&#39;s about consciousness, intelligence and what &quot;awakening&quot; means in a non-biological substrate, a theme I take to its speculative limit in &lt;a href=&quot;https://brennercruvinel.blog/en/blog/ontologia-poetica/&quot;&gt;the poetic ontology of the cosmos as a Turing machine&lt;/a&gt;. The only rule I set myself was not to cheat on the math to make the story easier, and rereading everything with the papers open was how I kept it.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Semantic drift in LLMs: metric, detection and mitigation</title>
        <published>2024-10-15T00:00:00+00:00</published>
        <updated>2024-10-15T00:00:00+00:00</updated>
        
        <author>
          <name>
            Brenner Cruvinel
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://brennercruvinel.blog/en/blog/drift-semantico-llm/"/>
        <id>https://brennercruvinel.blog/en/blog/drift-semantico-llm/</id>
        
        <content type="html" xml:base="https://brennercruvinel.blog/en/blog/drift-semantico-llm/">&lt;p&gt;I put this together as technical grounding for the &lt;a href=&quot;https://brennercruvinel.blog/en/blog/roteiro-consciencia-llm/&quot;&gt;screenplay about consciousness in an LLM&lt;/a&gt;, which uses semantic drift as its mechanism. The first version was a research dump with ten topics, from integrated information theory to communication between models, and it had errors precisely in the part that gave the post its name: the formula and the code did not match the paper, and several numbers were not in it. I redid everything from the source and kept only what is about drift.&lt;/p&gt;
&lt;h2 id=&quot;what-it-is&quot;&gt;What it is&lt;/h2&gt;
&lt;p&gt;The term comes from &lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/2404.05411&quot;&gt;Know When To Stop: A Study of Semantic Drift in Text Generation&lt;/a&gt;, by Ava Spataru, Eric Hambro, Elena Voita and Nicola Cancedda, published at &lt;a rel=&quot;external&quot; href=&quot;https://doi.org/10.18653/v1/2024.naacl-long.202&quot;&gt;NAACL 2024&lt;/a&gt;. Three authors are from FAIR, at Meta, and one is listed with an Anthropic affiliation. The first version of this post called it a &quot;joint Meta and Anthropic study&quot;, which overstates it.&lt;/p&gt;
&lt;p&gt;The observation is simple: when a model generates a long text, such as a Wikipedia-style biography, it tends to write the correct facts first and then &quot;drift&quot; into incorrect ones. This had been noticed before but never measured. The paper measures it.&lt;/p&gt;
&lt;h2 id=&quot;the-metric&quot;&gt;The metric&lt;/h2&gt;
&lt;p&gt;Each text is broken into atomic facts, and each fact gets a label $s_i$: 1 if it is supported by the source, 0 if not. With $N$ facts, the drift score tries every cut position $k$ and keeps the best average of two proportions: correct facts before the cut and incorrect facts after it.&lt;/p&gt;
&lt;p&gt;$$\text{SD}_m(P) = \max_k \tfrac{1}{2}, \text{SD}_m(P, k)$$&lt;/p&gt;
&lt;p&gt;$$\text{SD}&lt;em&gt;m(P, k) = \frac{\sum&lt;/em&gt;{i=0}^{k-1} s_i}{k} + \frac{\sum_{i=k}^{N-1} (1 - s_i)}{N - k}$$&lt;/p&gt;
&lt;p&gt;The value is zero when $k &amp;lt; m$, $N - k &amp;lt; m$ or $N &amp;lt; 2m$. The hyperparameter $m$ is the minimum number of facts on each side of the cut, and the position that gives the maximum is the drift point. A high score means a text that is almost all right before that point and almost all wrong after it.&lt;/p&gt;
&lt;p&gt;The first version of this post weighted each side by $k/N$ and $(N-k)/N$ and called the minimum $\alpha$, as a fraction. That is not the paper&#39;s formula. The corrected code:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#657B83, #839496); background-color: light-dark(#FDF6E3, #002B36);&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#586E75, #93A1A1);font-weight: bold;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: light-dark(#268BD2, #268BD2);&quot;&gt; semantic_drift_score&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;labels&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; m&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D33682, #D33682);&quot;&gt;1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#2AA198, #2AA198);&quot;&gt;    &amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#2AA198, #2AA198);&quot;&gt;labels: list of 0s and 1s, in the order the facts appear.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#2AA198, #2AA198);&quot;&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    n&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#268BD2, #268BD2);&quot;&gt; len&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;labels&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    best&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; drift_point&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D33682, #D33682);&quot;&gt; 0.0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#B58900, #B58900);&quot;&gt; None&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; n&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D33682, #D33682);&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; *&lt;/span&gt;&lt;span&gt; m&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt;        return&lt;/span&gt;&lt;span&gt; best&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; drift_point&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt;    for&lt;/span&gt;&lt;span&gt; k&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color: light-dark(#268BD2, #268BD2);&quot;&gt; range&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;m&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; n&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; -&lt;/span&gt;&lt;span&gt; m&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D33682, #D33682);&quot;&gt; 1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        left&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#268BD2, #268BD2);&quot;&gt; sum&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;labels&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt;k&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; /&lt;/span&gt;&lt;span&gt; k&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        right&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#268BD2, #268BD2);&quot;&gt; sum&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D33682, #D33682);&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; -&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; for&lt;/span&gt;&lt;span&gt; s&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; in&lt;/span&gt;&lt;span&gt; labels&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;k&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; /&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;n&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; -&lt;/span&gt;&lt;span&gt; k&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        score&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; =&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;left&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; +&lt;/span&gt;&lt;span&gt; right&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color: light-dark(#D33682, #D33682);&quot;&gt; 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt;        if&lt;/span&gt;&lt;span&gt; score&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span&gt; best&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            best&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; drift_point&lt;/span&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt; =&lt;/span&gt;&lt;span&gt; score&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; k&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#859900, #859900);&quot;&gt;    return&lt;/span&gt;&lt;span&gt; best&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; drift_point&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the paper&#39;s figure 1 example, the best cut leaves 88% correct facts on the left and 78% incorrect ones on the right, and the score is the average, 0.83.&lt;/p&gt;
&lt;h2 id=&quot;what-they-measured&quot;&gt;What they measured&lt;/h2&gt;
&lt;p&gt;Generated biographies, with facts checked by a variant of FActScore the authors call FActScore*. Both numbers are percentages:&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Model&lt;/th&gt;&lt;th style=&quot;text-align: right&quot;&gt;Drift (SD)&lt;/th&gt;&lt;th style=&quot;text-align: right&quot;&gt;FActScore*&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Llama 2 70B chat&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;77.06&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;41.72&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Falcon 7B&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;76.81&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;24.64&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Falcon 40B&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;77.38&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;25.88&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;text-davinci-003&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;77.21&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;38.09&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;GPT-3.5&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;79.49&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;45.96&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;GPT-4&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;78.12&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;53.54&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Drift shows up in all of them, with little difference between models, while accuracy varies a lot. Being more accurate does not protect against the right-first, wrong-later pattern.&lt;/p&gt;
&lt;p&gt;Other numbers from the paper: in 37% of paragraphs, the drift point is in the first 10% of facts. In more than 40% of paragraphs, the score is statistically high in a permutation test. Only 34 paragraphs, under 7%, have at least 10 correct facts before the first error. The first version said &quot;75% of paragraphs show drift in the first 25% of facts&quot;, which is not in the paper.&lt;/p&gt;
&lt;h2 id=&quot;detection&quot;&gt;Detection&lt;/h2&gt;
&lt;p&gt;To stop generation at the right point, you need to know, while generating, when the model started to go wrong. Of the confidence measures tested, the one that correlated best with accuracy was SelfCheck with BERTScore, which samples several generations and measures how much they agree, with a Pearson correlation of −0.41.&lt;/p&gt;
&lt;h2 id=&quot;mitigation&quot;&gt;Mitigation&lt;/h2&gt;
&lt;p&gt;With Llama 2 70B, the paper&#39;s table 4 compares strategies:&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Strategy&lt;/th&gt;&lt;th style=&quot;text-align: right&quot;&gt;Facts per text&lt;/th&gt;&lt;th style=&quot;text-align: right&quot;&gt;FActScore*&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;No stopping, up to the token limit&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;43.89&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;44.56&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Stop at the drift point (oracle)&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;10&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;81.68&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Stop when end-of-text is among the top 5 tokens&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;14.47&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;57.96&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Same, among the top 10&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5.39&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;70.29&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Stop when SelfCheck goes above 0.5&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;13.39&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;67.63&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Sample several times and rerank by similarity&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;40.21&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;53.27&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Rerank and stop by SelfCheck&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;17.12&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;67.18&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Call an external question-answering API&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;42.26&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;43.93&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;The oracle is the ceiling: knowing the exact point, accuracy goes from 44% to 82%, but at the cost of cutting correct facts along with it, 58% of them, according to the limitations section. Real strategies land in between, trading amount of information for accuracy. Reranking by similarity raises accuracy without cutting the text. And trying to pull the model back with an external API did not work. The first version said &quot;Resample-Then-Rerank from 53.27% to 63.72%&quot;, and the second number does not exist in the paper.&lt;/p&gt;
&lt;h2 id=&quot;what-was-cut&quot;&gt;What was cut&lt;/h2&gt;
&lt;p&gt;The first version had two more drift metrics and eight other topics. Out went:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &quot;Composite Drift Metrics&quot;, attributed to ResearchGate with no link or author&lt;/li&gt;
&lt;li&gt;&quot;Contextual Flux&quot; (&lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/2502.10942&quot;&gt;arXiv 2502.10942&lt;/a&gt;), from 2025, whose authors include a &quot;Zachary Mountebank&quot;; a mountebank is a charlatan, and the paper looks like the batches of auto-generated papers that showed up on arXiv. It also postdated this post&lt;/li&gt;
&lt;li&gt;The &quot;Trajectory Volatility Score&quot; and &quot;Semantic Divergence Metrics&quot;, with no source&lt;/li&gt;
&lt;li&gt;The Claude timeline, which cited 2025 versions in a 2024 post&lt;/li&gt;
&lt;li&gt;Consciousness, integrated information theory and global workspace: that belongs to the &lt;a href=&quot;https://brennercruvinel.blog/en/blog/roteiro-consciencia-llm/&quot;&gt;screenplay&lt;/a&gt; and to the &lt;a href=&quot;https://brennercruvinel.blog/en/blog/ontologia-poetica/&quot;&gt;poetic ontology&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Model extraction and jailbreaks, which are checked in the &lt;a href=&quot;https://brennercruvinel.blog/en/blog/model-extraction-attacks/&quot;&gt;reading list on extraction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Distillation, Mamba, mixture of experts, computational neuroscience, famous chatbot failures and communication between models, which were research summaries unrelated to drift&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A note on the name: in linguistics, &quot;semantic change&quot; or &quot;semantic drift&quot; is a word&#39;s meaning shifting over time, and tools like &lt;a rel=&quot;external&quot; href=&quot;https://github.com/Garrafao/LSCDetection&quot;&gt;LSCDetection&lt;/a&gt; measure that. It is a different phenomenon. The drift in this post is a text that starts right and ends wrong within a single generation.&lt;/p&gt;
</content>
        
    </entry>
</feed>
