<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Brenner Cruvinel - pesquisa</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/pesquisa/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://brennercruvinel.blog"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-04-08T00:00:00+00:00</updated>
    <id>https://brennercruvinel.blog/en/tags/pesquisa/atom.xml</id>
    <entry xml:lang="en">
        <title>Extraction attacks against black-box models: a reading list</title>
        <published>2026-04-08T00:00:00+00:00</published>
        <updated>2026-04-08T00:00:00+00:00</updated>
        
        <author>
          <name>
            Brenner Cruvinel
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://brennercruvinel.blog/en/blog/model-extraction-attacks/"/>
        <id>https://brennercruvinel.blog/en/blog/model-extraction-attacks/</id>
        
        <content type="html" xml:base="https://brennercruvinel.blog/en/blog/model-extraction-attacks/">&lt;p&gt;I put this list together for a security and intelligence research project. The first version was a dump of search results: the same Tramèr paper showed up eight times under different links, and half the items had nothing to do with model extraction. I deduplicated it, checked every source and removed what was off topic. What remains is what I would read again.&lt;/p&gt;
&lt;p&gt;The question that ties it together: if I can only query a model through an API, without seeing the weights, how much of it can be rebuilt? And, going the other way, how much of the training data can be recovered from the model or from its gradients?&lt;/p&gt;
&lt;h2 id=&quot;stealing-the-model-through-the-api&quot;&gt;Stealing the model through the API&lt;/h2&gt;
&lt;p&gt;The starting point is &lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/1609.02943&quot;&gt;Stealing Machine Learning Models via Prediction APIs&lt;/a&gt;, by Tramèr and colleagues, presented at USENIX Security 2016. They showed that cloud machine learning services, by returning prediction confidence, let an attacker rebuild models such as logistic regression and decision trees with few queries. The code is at &lt;a rel=&quot;external&quot; href=&quot;https://github.com/ftramer/Steal-ML&quot;&gt;ftramer/Steal-ML&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/1602.02697&quot;&gt;Practical Black-Box Attacks against Machine Learning&lt;/a&gt;, by Papernot and colleagues, AsiaCCS 2017, is a close relative: it trains a substitute model by querying the target and uses that substitute to craft adversarial examples that transfer to the original.&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/1812.02766&quot;&gt;Knockoff Nets&lt;/a&gt;, by Orekondy, Schiele and Fritz, CVPR 2019, steals the functionality of an image network by querying it with random natural images. &lt;a rel=&quot;external&quot; href=&quot;https://doi.org/10.1609/aaai.v34i01.5432&quot;&gt;ActiveThief&lt;/a&gt;, by Pal and colleagues, AAAI 2020, does the same while choosing queries by active learning over unlabelled public data. &lt;a rel=&quot;external&quot; href=&quot;https://doi.org/10.14722/ndss.2020.24178&quot;&gt;CloudLeak&lt;/a&gt;, by Yu and colleagues, NDSS 2020, uses adversarial examples to extract models from commercial services with fewer queries.&lt;/p&gt;
&lt;p&gt;More recent: &lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/2409.14122&quot;&gt;Efficient and Effective Model Extraction&lt;/a&gt;, by Zhu and colleagues, 2024, and &lt;a rel=&quot;external&quot; href=&quot;https://doi.org/10.1016/j.knosys.2024.112144&quot;&gt;A realistic model extraction attack against graph neural networks&lt;/a&gt;, by Guan and colleagues, in Knowledge-Based Systems 2024, which takes the problem to graph networks.&lt;/p&gt;
&lt;p&gt;The milestone for language models is &lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/2403.06634&quot;&gt;Stealing Part of a Production Language Model&lt;/a&gt;, by Carlini and colleagues, 2024. With API access alone, they recovered the final projection layer of production models and their hidden dimension.&lt;/p&gt;
&lt;p&gt;For the full map, the survey &lt;a rel=&quot;external&quot; href=&quot;https://doi.org/10.1145/3595292&quot;&gt;I Know What You Trained Last Summer&lt;/a&gt;, by Oliynyk, Mayer and Rauber, ACM Computing Surveys 2023, covers attacks and defences, and the &lt;a rel=&quot;external&quot; href=&quot;https://github.com/kzhao5/ModelExtractionPapers&quot;&gt;kzhao5/ModelExtractionPapers&lt;/a&gt; repository keeps a list of papers in the area.&lt;/p&gt;
&lt;h2 id=&quot;inverting-the-model-and-leaking-through-gradients&quot;&gt;Inverting the model and leaking through gradients&lt;/h2&gt;
&lt;p&gt;&lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/1906.08935&quot;&gt;Deep Leakage from Gradients&lt;/a&gt;, by Zhu, Liu and Han, NeurIPS 2019, is the paper that changed the conversation about federated learning: from the shared gradients, they rebuilt training images and text almost pixel by pixel.&lt;/p&gt;
&lt;p&gt;The ones that followed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/2309.13016&quot;&gt;Understanding Deep Gradient Leakage via Inversion Influence Functions&lt;/a&gt;, by Zhang and colleagues, NeurIPS 2023, gives a way to analyse leakage without running the attack&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://pmc.ncbi.nlm.nih.gov/articles/PMC10217429/&quot;&gt;Wasserstein Distance-Based Deep Leakage from Gradients&lt;/a&gt;, from 2023, changes the distance used in the reconstruction&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://doi.org/10.1186/s42400-024-00227-7&quot;&gt;Iterative and mixed-spaces image gradient inversion attack in federated learning&lt;/a&gt;, by Fang and colleagues, Cybersecurity 2024&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://doi.org/10.1145/3658644.3690292&quot;&gt;Uncovering Gradient Inversion Risks in Practical Language Model Training&lt;/a&gt;, by Feng and colleagues, CCS 2024, takes the attack to language model training&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://arxiv.org/abs/2410.21453&quot;&gt;Inverting Gradient Attacks Makes Powerful Data Poisoning&lt;/a&gt;, by Bouaziz and colleagues, 2024, uses inversion to poison training&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://doi.org/10.1007/978-3-031-30648-8_1&quot;&gt;A Survey of the Implementations of Model Inversion Attacks&lt;/a&gt;, by Song and Namiot, 2023&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;weights-as-an-attack-surface&quot;&gt;Weights as an attack surface&lt;/h2&gt;
&lt;p&gt;If the attacker gets the weights file, extraction ends there. Two sides of that interest me.&lt;/p&gt;
&lt;p&gt;The first is the format. &lt;a rel=&quot;external&quot; href=&quot;https://github.com/safetensors/safetensors&quot;&gt;safetensors&lt;/a&gt; exists because PyTorch&#39;s pickle format can execute code on load; safetensors stores only tensors. The &lt;a rel=&quot;external&quot; href=&quot;https://huggingface.co/blog/ngxson/common-ai-model-formats&quot;&gt;Hugging Face post on common formats&lt;/a&gt; compares safetensors, GGUF and others, and &lt;a rel=&quot;external&quot; href=&quot;https://github.com/justinchuby/onnx-safetensors&quot;&gt;onnx-safetensors&lt;/a&gt; connects ONNX to safetensors.&lt;/p&gt;
&lt;p&gt;The second is protecting the weights of frontier models. RAND&#39;s report &lt;a rel=&quot;external&quot; href=&quot;https://doi.org/10.7249/RRA2849-1&quot;&gt;Securing AI Model Weights&lt;/a&gt;, from 2024, organizes the attack vectors and the security levels needed against each kind of attacker.&lt;/p&gt;
&lt;h2 id=&quot;what-was-left-out&quot;&gt;What was left out&lt;/h2&gt;
&lt;p&gt;The items from the original list on distributed training and sharding (FSDP), checkpoints, serving in general and neural networks applied to detecting vulnerabilities were removed. They are good, but they are not about model extraction. Also removed: B3, which is about backdoors, a 2025 adversarial attack unrelated to extraction, and the link to Carlini&#39;s talk at Virginia Tech, which now returns 404.&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Prompt templates for research with agents</title>
        <published>2025-09-15T00:00:00+00:00</published>
        <updated>2025-09-15T00:00:00+00:00</updated>
        
        <author>
          <name>
            Brenner Cruvinel
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://brennercruvinel.blog/en/blog/templates-prompt-pesquisa-agentica/"/>
        <id>https://brennercruvinel.blog/en/blog/templates-prompt-pesquisa-agentica/</id>
        
        <content type="html" xml:base="https://brennercruvinel.blog/en/blog/templates-prompt-pesquisa-agentica/">&lt;p&gt;I&#39;ve been testing a few prompt templates that push crawlers and LLMs into delivering research more accurately. Sharing what I have, still in testing.&lt;/p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;WIP, template under test. Still tuning it, not a final version.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The structure is always the same: role, objective, style, discovery sources, mandatory metadata and a benchmark rule. The most important line is the one that says to write &quot;no reliable public benchmarks&quot; instead of making up a number.&lt;/p&gt;
&lt;p&gt;And even with it, that&#39;s not enough. Variation A produced my &lt;a href=&quot;https://brennercruvinel.blog/en/blog/ecossistema-rust-open-source/&quot;&gt;survey of the Rust ecosystem&lt;/a&gt;. In 2026, when I checked every row of that table against the GitHub API, I found a repository that doesn&#39;t exist and a row pointing to the wrong project, one with a similar name. The prompt forbade making things up, and the agent made things up anyway. The template organizes the delivery, but the one who checks the result is still me.&lt;/p&gt;
&lt;h2 id=&quot;template-for-research-with-agents&quot;&gt;Template for research with agents&lt;/h2&gt;
&lt;p&gt;The prompts stay in Portuguese, exactly as I use them, because they ask the agent for output in Brazilian Portuguese. Variation A, the survey of Rust applications:&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;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;papel: pesquisador sênior em ecossistema open source e linguagens de sistemas, foco pesado em rust.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;objetivo: mapear e analisar pelo menos 369 aplicações open source em rust, explicando por que cada uma importa, com metadados completos, contexto de adoção em produção e benchmark comparativo em tabela sempre que houver.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;estilo: pt-br, sem emoji, sem bullet no corpo principal (parágrafo e tabela), todo recurso citado como Nome + URL com link markdown clicável, cabeçalhos markdown.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;fontes de descoberta: Awesome Rust, LibHunt Rust, OSS Insight, GitHub Stars Leaderboard, Github Ranking Top 100 Stars in Rust, listas &amp;quot;Rust in production&amp;quot; e &amp;quot;rust-in-production&amp;quot; (ImplFerris). priorizar alto número de stars/forks e atividade recente, uso em produção por empresa conhecida, diversidade de domínio (devtools, sistemas distribuídos, db, runtimes js/ts, ai infra, editores, cli, jogos, wasm, networking, segurança, observabilidade). evitar libs minúsculas ou experimentais salvo impacto desproporcional.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;metadados obrigatórios por app: nome, url do repo, descrição de 1 a 3 frases, categoria, subdomínio, maturidade, empresas que usam em produção, licença, stars/forks, crescimento 6 a 12 meses, data do último commit, número de contribuidores, &amp;quot;por que é foda&amp;quot; (2 a 4 frases).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;benchmark: pra cada projeto com benchmark público sério, colete tipo, contexto, setup (hardware, so, versão rust), comparação, números-chave com unidade, link da fonte. monte tabela por projeto: projeto, cenário, métrica, resultado, concorrente, resultado da concorrente, vantagem aproximada, link. sem benchmark crível, escreva &amp;quot;sem benchmarks públicos confiáveis&amp;quot;, nunca invente número. divergência entre fontes, explicite cenário, não consolide.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;organização: tabela geral com as 369+, mais tabelas por domínio (devtools, runtimes/plataformas, infra/observabilidade, terminais/shells/editores, web e apis, segurança/cripto/password managers, ai/ml infra, db e search, embedded/iot). análise final: distribuição por tipo, vantagem comparativa do rust, padrões técnicos (async/await/tokio, crates de observabilidade, arquiteturas), adoção corporativa vs go/c/c++/java/node, benchmark vs marketing, lacunas e oportunidades.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;details&gt;
&lt;summary&gt;Variation B: Rust + WebAssembly books and resources&lt;/summary&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;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;papel: pesquisador sênior em rust, wasm e desenvolvimento web de alta performance.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;objetivo: análise completa e atualizada de livros e recursos estruturados de rust + wasm, ecossistema global e contexto brasileiro, em tabelas com links clicáveis (livros, editoras, lojas, repos, doc oficial).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;estilo: idem variação A.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;escopo, cinco grupos: (1) livros-base de rust core relevantes pra wasm, com título, autor, ano, nível, temas, recomendação pra wasm, link oficial/compra/comunidade/repo. (2) livros específicos de rust + wasm, 20 a 30 obras, com tipo de recurso, público-alvo, escopo (browser/wasi/iot/mobile/desktop). (3) livros de wasm geral relevantes pra rust, com coluna &amp;quot;relevância pra rust&amp;quot;. (4) contexto brasil: traduções, autores brasileiros, livros específicos, disponibilidade real em e-book e loja br. (5) recursos oficiais e books online com profundidade de livro (the rust and webassembly book, doc de wasm-bindgen/web-sys/js-sys/wasm-pack/yew/leptos), com tipo, org, temas, link, repo, licença.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;análise final: pré-requisitos naturais antes de rust+wasm, quais livros são mais completos/atualizados/adequados por perfil (js dev migrando, rustacean avançado, dev de sistemas), como livros de wasm geral ajudam em performance/segurança/binário/interop, situação no brasil (lacunas e dependência de inglês), temas sub-representados (wasi, servidor, edge, frameworks modernos leptos/dioxus/tauri, segurança e fuzzing de módulos, casos além do browser).&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/details&gt;
&lt;details&gt;
&lt;summary&gt;Variation C: people and visualization projects in Rust + Wasm&lt;/summary&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;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;papel: pesquisador sênior em rust, wasm, visualização de dados e ecossistema open source.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;objetivo: mapeamento de pelo menos 50 pessoas relevantes em rust (foco rust+wasm) e pelo menos 50 projetos/libraries de grafos, charts e viz em wasm (idealmente rust, não exclusivamente), mais todos os links de presença online (github, site pessoal, redes, artigos, posts em dev.to e hacker news).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;estilo: idem, tabela como forma principal.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pessoas: nome completo, país/região, papel (autor, maintainer, contributor rustwasm, criador de framework, educador), 2 a 5 projetos principais, temas técnicos, github, site/blog, redes (twitter/x, mastodon, linkedin, youtube, twitch), páginas de autor (dev.to, medium, substack, conferências), discussões de destaque (hacker news, reddit r/rust, users.rust-lang.org). hubs de descoberta: awesome-rust, awesome-rust-and-webassembly, awesome-wasm, orgs rustwasm e bytecodealliance, github topics (topic:webassembly l:rust). validar que o link pertence à pessoa (evitar homônimo) e que o projeto é minimamente ativo.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;projetos: nome, descrição (2 a 3 frases), linguagem, tipo de viz (grafos, charts, heatmaps, mapas, dashboards, 2d, 3d), casos de uso, status, métricas (stars, contribuidores, downloads crates.io, uso citado), repo, site/docs, demos, artigos/talks/discussões.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;conexões: cruze pessoa↔projeto com nome, projeto, papel (criador, maintainer, core contributor, autor de módulo crítico), link de comprovação (readme de maintainers, palestra, artigo &amp;quot;introducing X&amp;quot;).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;contexto brasil (opcional): devs br relevantes com ênfase em viz/grafos, projetos br em rust com target wasm, conteúdo em português, talks em conferência br.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;análise final: núcleos de contribuição (rustwasm, bytecodealliance, empresas), clusters de viz (grafos, dashboards, jogos, ides, ferramentas científicas), perfis predominantes, lacunas (pouca bibliografia de grafos complexos, falta de tooling de alto nível, pouca doc pra iniciante), global vs brasil.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/details&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>
