Fine-Grained Controllable Text Generation Using Non-Residual Prompting

Fredrik Carlsson, Joey Öhman, Fangyu Liu, Severine Verlinden, Joakim Nivre, Magnus Sahlgren

Abstract

Large Language Models (LLMs) often struggle to balance instruction following with linguistic coherence. Standard prompting techniques tend to "fade" over long sequences, while decoding-time modifications can lead to ungrammatical outputs. This paper presents Non-Residual Prompting (NRP), an architecture designed for fine-grained control. By injecting prompts through a novel non-residual attention mechanism, NRP maintains high constraint satisfaction without "polluting" the model's internal state. Evaluated on CommonGen and the new Contextualized CommonGen ($C^2$GEN) dataset, NRP demonstrates superior performance in keyword coverage and contextual relevance compared to existing baselines.

Introduction

Controlling Causal Language Models (CLMs) like GPT-2 or GPT-3 presents a "Goldilocks" problem. Decoding strategies that modify token probabilities on the fly are precise but often lack the ability to "plan" ahead, resulting in nonsensical jumps. Conversely, standard prompting is expressive but its influence weakens as generated text grows longer. The authors address this gap by proposing a method that ensures fine-grained instructions (e.g., "Include the words 'firetruck' and 'duty'") remain powerful throughout the generation process while ensuring the model stays true to a provided background context.

Non-Residual Prompting Architecture

The core innovation is the Non-Residual Prompting (NRP) architecture. It consists of a separate "prompt model" (an encoder cloned from the pre-trained CLM) that processes instructions to generate keys and values. Unlike standard Transformers where every input affects the subsequent hidden state, NRP uses a non-residual attention mechanism.

The NRP architecture overview, illustrating the interaction between the Prompt Model, the CLM, and the resulting attention matrix.

In this setup, the decoder attends to the prompt model's outputs, but these values are not passed back into the CLM's internal state for the next step. This prevents the prompt from deteriorating the model's ability to track the linguistic context, ensuring the "train of thought" remains clear.

Positional Invariance and Training

A significant challenge in using external prompts with pre-trained models is positional encoding. Most LLMs use absolute encodings, meaning a prompt's influence can vary depending on its position in the sequence. To resolve this, the authors introduced a learned positional invariant transformation ($C$). This transformation acts as a translator, allowing the prompt to function effectively at any time step without breaking the pre-trained model's logic.

The training pipeline for NRP, highlighting the transformation layer (Trans) used to achieve positional invariance.

The training process is highly resource-efficient: the original CLM weights remain frozen. Only the prompt model and the transformation layer are trained, making it significantly cheaper to implement than full fine-tuning.

Experimental Results

The model was tested on CommonGen and a new dataset introduced in this paper, Contextualized CommonGen ($C^2$GEN). $C^2$GEN requires generating sentences that follow a specific three-sentence story context while including target words—a significantly harder task than standard constrained generation.

  • Superior Coverage: NRP achieved 98.4% word coverage on CommonGen, compared to 72.2% for standard prompting.
  • Contextual Robustness: On $C^2$GEN, NRP maintained 96.9% coverage, while standard prompting dropped to 57%.
  • Human Evaluation: Judges rated NRP's output as having better "Common Sense" and "Contextual Relevancy" than specialized non-autoregressive models like POINTER.

Conclusion

Non-Residual Prompting offers a robust solution for fine-grained control in text generation. By decoupling prompt influence from the internal state and ensuring positional invariance, NRP allows LLMs to follow complex constraints without losing narrative flow. While the current pipeline involves multiple training phases, future work may explore end-to-end training and scaling this architecture to massive models like GPT-3 or Llama-3.

Summary updated

BibTeX
@inproceedings{carlsson2022fine,
  author = {Fredrik Carlsson and Joey Öhman and Fangyu Liu and Severine Verlinden and Joakim Nivre and Magnus Sahlgren},
  title = {{Fine-Grained Controllable Text Generation Using Non-Residual Prompting}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.acl-long.471},
}
Figure