<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Brenner Cruvinel - roteiro</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/roteiro/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/roteiro/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>
</feed>
