Controlled Text Generation (CTG) aims to produce texts that exhibit specific desired attributes. In this study, we introduce a pluggable CTG framework for Large Language Models (LLMs) named Dynamic Attribute Graphs-based controlled text generation (DATG). This framework utilizes an attribute scorer to evaluate the attributes of sentences generated by LLMs and constructs dynamic attribute graphs. DATG modulates the occurrence of key attribute words and key anti-attribute words, achieving effective attribute control without compromising the original capabilities of the model. We conduct experiments across four datasets in two tasks: toxicity mitigation and sentiment transformation, employing five LLMs as foundational models. Our findings highlight a remarkable enhancement in control accuracy, achieving a peak improvement of 19.29% over baseline methods in the most favorable task across four datasets. Additionally, we observe a significant decrease in perplexity, markedly improving text fluency.
翻译:可控文本生成(CTG)旨在生成具有特定期望属性的文本。本研究提出了一种适用于大型语言模型(LLMs)的可插拔CTG框架,称为基于动态属性图的可控文本生成(DATG)。该框架利用属性评分器评估LLM生成句子的属性,并构建动态属性图。DATG通过调控关键属性词与关键反属性词的出现,在不损害模型原始能力的前提下实现有效的属性控制。我们在毒性缓解和情感转换两项任务中,使用五个LLM作为基础模型,在四个数据集上进行了实验。研究结果表明,控制精度得到显著提升,在四个数据集的最优任务中相比基线方法最高提升了19.29%。此外,我们观察到困惑度显著下降,文本流畅性得到明显改善。