The dominant approaches for controlling language models are based on fine-tuning large language models or prompt engineering. However, these methods often require condition-specific data or considerable hand-crafting. We propose a new simple guided decoding method, Gamma Sampling, which does not require complex engineering and any extra data. Gamma Sampling introduces attribute-related information (provided by humans or language models themselves) into the sampling process to guide language models to generate texts with desired attributes. Experiments on controlling topics and sentiments of generated text show Gamma Sampling to be superior in diversity, attribute relevance and overall quality of generated samples while maintaining a fast generation speed. In addition, we successfully applied Gamma Sampling to control other attributes of language such as relatedness and repetition, which further demonstrates the versatility and effectiveness of this method. Gamma Sampling is now available in the python package samplings via import gamma sampling from samplings.
翻译:控制语言模型的主要方法以微调大型语言模型或迅速工程为基础,但这些方法往往需要特定条件的数据或大量手工制作。我们建议采用新的简单解码法,即Gamma抽样法,不需要复杂的工程和任何额外数据。伽马抽样法在取样过程中引入与属性有关的信息(由人或语言模型本身提供),以指导语言模型产生具有预期属性的文本。关于控制主题和生成文本的感知的实验显示伽马抽样在多样性方面优异,在保持快速生成速度的同时对生成样品的相关性和总体质量进行分辨。此外,我们成功地应用伽马取样法来控制其他语言属性,例如关联性和重复性,这进一步显示了这一方法的多功能性和有效性。目前,在Python一揽子抽样中,通过从抽样中进口的伽马抽样,可以找到伽马抽样。