用确定性转换让语言模型输出适配下游任务
Transducing Language Models
- 通过有限状态转换器将模型输出映射到目标格式
- 可精确或近似计算目标输出的条件概率分布
- 无需微调即可适配字节、词汇和蛋白质序列生成
现代语言模型定义字符串上的概率分布,但下游任务常需不同输出格式。例如,生成字节对的模型无法直接输出词级预测,DNA模型也无法直接生成氨基酸序列。此时,可通过确定性字符串到字符串的变换将模型输出转为所需形式。这在概率论中是经典方法:对随机变量 $X\sim p$ 应用函数 $f$ 得到新随机变量 $f(X)$ 及其诱导分布。尽管此类变换偶有使用,但以往工作未将其视为生成全新、完整可用的语言模型。本文正式化该视角,提出基于确定性字符串变换的通用语言模型框架,聚焦可由有限状态转换器(FST)表示的变换——一种高效字符串映射的状态机抽象。我们开发算法,将语言模型与FST组合,实现对映射至给定目标串的所有源串进行边际化,通过转换器传播概率而不修改模型参数,支持基于变换后输出的条件推断。提供精确算法、高效近似及理论分析。在三个领域实验:将分词模型转为字节输出、将分词模型转为词输出、将DNA模型转为氨基酸序列。结果表明,可在推理阶段适配预训练模型以匹配应用需求。
原文摘要 · Abstract (English)
Modern language models define distributions over strings, but downstream tasks often require different output formats. For instance, a model that generates byte-pair strings does not directly produce word-level predictions, and a DNA model does not directly produce amino-acid sequences. In such cases, a deterministic string-to-string transformation can convert the model's output to the desired form. This is a familiar pattern in probability theory: applying a function $f$ to a random variable $X\sim p$ yields a transformed random variable $f(X)$ with an induced distribution. While such transformations are occasionally used in language modeling, prior work does not treat them as yielding new, fully functional language models. We formalize this perspective and introduce a general framework for language models derived from deterministic string-to-string transformations. We focus on transformations representable as finite-state transducers -- a commonly used state-machine abstraction for efficient string-to-string mappings. We develop algorithms that compose a language model with an FST to *marginalize* over source strings mapping to a given target, propagating probabilities through the transducer without altering model parameters and enabling *conditioning* on transformed outputs. We present an exact algorithm, an efficient approximation, and a theoretical analysis. We conduct experiments in three domains: converting language models from tokens to bytes, from tokens to words, and from DNA to amino acids. These experiments demonstrate inference-time adaptation of pretrained language models to match application-specific output requirements.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。