arXiv:2409.17027cs.LGcs.AI2024-09中稿 · CLeaR 2025被引 16

让大模型能回溯重演不同选择,探索故事的其他可能。

Counterfactual Token Generation in Large Language Models

  • 基于因果建模,让模型可生成反事实文本
  • 在不微调的前提下实现高效反事实生成
  • 可用于发现模型隐含偏见,适合研究者和开发者

尽管大语言模型生成的故事引人入胜,但无法回答‘如果主角是梅芙而非莉拉,情节会如何发展’这类问题。当前模型无状态,无法回溯已有生成内容进行反事实推理。本文提出一种基于Gumbel-Max结构因果模型的反事实词元生成方法,使任意大模型可在几乎零成本下生成反事实文本,无需微调或提示工程。我们在Llama 3 8B-Instruct与Ministral-8B-Instruct上实现并验证,通过定性与定量分析表明其有效性。最后应用于偏见检测,揭示了模型对世界的隐含认知结构,展现出潜在价值。

原文摘要 · Abstract (English)

"Sure, I am happy to generate a story for you: Captain Lyra stood at the helm of her trusty ship, the Maelstrom's Fury, gazing out at the endless sea. [...] Lyra's eyes welled up with tears as she realized the bitter truth - she had sacrificed everything for fleeting riches, and lost the love of her crew, her family, and herself." Although this story, generated by a large language model, is captivating, one may wonder -- how would the story have unfolded if the model had chosen "Captain Maeve" as the protagonist instead? We cannot know. State-of-the-art large language models are stateless -- they maintain no internal memory or state. Given a prompt, they generate a sequence of tokens as an output using an autoregressive process. As a consequence, they cannot reason about counterfactual alternatives to tokens they have generated in the past. In this work, our goal is to enhance them with this functionality. To this end, we develop a causal model of token generation that builds upon the Gumbel-Max structural causal model. Our model allows any large language model to perform counterfactual token generation at almost no cost in comparison with vanilla token generation, it is embarrassingly simple to implement, and it does not require any fine-tuning nor prompt engineering. We implement our model on Llama 3 8B-Instruct and Ministral-8B-Instruct and conduct a qualitative and a quantitative analysis of counterfactually generated text. We conclude with a demonstrative application of counterfactual token generation for bias detection, unveiling interesting insights about the model of the world constructed by large language models.

反事实生成大模型推理因果建模

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。