Skip to main content
QUICK REVIEW

[Paper Review] Stay on topic with Classifier-Free Guidance

Guillaume Sanchez, Honglu Fan|arXiv (Cornell University)|Jun 30, 2023
Topic ModelingComputer Science5 citations
TL;DR

This paper introduces Classifier-Free Guidance (CFG) as an inference-time technique for autoregressive language models, demonstrating that increasing the guidance weight $γ$ improves prompt adherence, coherence, and factual consistency across diverse tasks. It achieves state-of-the-art performance on LAMBADA with LLaMA-7B, outperforming PaLM-540B, and enables models to match the performance of twice their size while improving alignment in complex, form-driven prompts.

ABSTRACT

Classifier-Free Guidance (CFG) has recently emerged in text-to-image generation as a lightweight technique to encourage prompt-adherence in generations. In this work, we demonstrate that CFG can be used broadly as an inference-time technique in pure language modeling. We show that CFG (1) improves the performance of Pythia, GPT-2 and LLaMA-family models across an array of tasks: Q\&A, reasoning, code generation, and machine translation, achieving SOTA on LAMBADA with LLaMA-7B over PaLM-540B; (2) brings improvements equivalent to a model with twice the parameter-count; (3) can stack alongside other inference-time methods like Chain-of-Thought and Self-Consistency, yielding further improvements in difficult tasks; (4) can be used to increase the faithfulness and coherence of assistants in challenging form-driven and content-driven prompts: in a human evaluation we show a 75\% preference for GPT4All using CFG over baseline.

Motivation & Objective

  • To investigate whether Classifier-Free Guidance (CFG) can improve alignment and performance in pure language modeling without fine-tuning.
  • To evaluate CFG’s effectiveness across diverse prompting paradigms, including zero-shot, chain-of-thought, long-form, and chatbot-style prompting.
  • To determine if CFG can achieve performance equivalent to a model twice its size, reducing compute and data costs.
  • To assess CFG’s compatibility with other inference-time methods like Chain-of-Thought and Self-Consistency.
  • To evaluate human preference for CFG-guided generations in complex, content-driven assistant interactions.

Proposed method

  • Adapt CFG from text-to-image diffusion models to autoregressive language models by using the model’s own logits as an implicit classifier.
  • Apply a guidance weight $\gamma$ to scale the logits during decoding, increasing attention to prompt-relevant tokens.
  • Use a negative prompt to enable granular control over which aspects of the prompt are emphasized during generation.
  • Apply CFG during decoding by modifying the logit distribution as $\text{logits}_{\text{guided}}} = \text{logits} + \gamma \cdot (\text{logits} - \text{logits}_{\text{uncond}})$, where $\text{logits}_{\text{uncond}}$ is the model’s output without the prompt.
  • Evaluate CFG across multiple benchmarks: LAMBADA, GSM8K, HumanEval, MMLU, and machine translation tasks.
  • Conduct human evaluations comparing CFG-guided generations to vanilla sampling, particularly in assistant-style and complex prompt scenarios.
Figure 1: A notional 2D projection of a textual latent space showing how increasing the guidance weight $\gamma$ increases the importance of the prompt “Today in France,”.
Figure 1: A notional 2D projection of a textual latent space showing how increasing the guidance weight $\gamma$ increases the importance of the prompt “Today in France,”.

Experimental results

Research questions

  • RQ1Can CFG improve prompt adherence and generation quality in autoregressive language models without fine-tuning or additional training?
  • RQ2Does CFG improve performance across diverse prompting styles, including zero-shot, chain-of-thought, and complex assistant-style prompts?
  • RQ3To what extent does CFG improve model performance relative to model size—can it achieve the performance of a model twice as large?
  • RQ4How does CFG interact with other inference-time techniques like Chain-of-Thought and Self-Consistency?
  • RQ5Can CFG improve human preference and coherence in assistant-style generation, especially in form-driven and content-driven prompts?

Key findings

  • CFG achieves state-of-the-art performance on the LAMBADA benchmark with LLaMA-7B, outperforming PaLM-540B.
  • CFG improves performance across multiple tasks, including Q&A, reasoning, code generation, and machine translation, with consistent gains.
  • For the same inference cost, a model with half the parameters and CFG achieves performance comparable to a larger, unguided model.
  • CFG improves human preference in assistant-style generation: 75% of human evaluators preferred GPT4All outputs with CFG over vanilla sampling.
  • CFG reduces entropy in the token sampling distribution, leading to more focused and coherent generations.
  • Visualizations show that CFG increases attention to prompt-relevant words, providing interpretability and aiding prompt engineering.
Figure 3: CFG impact on chain-of-thought prompting with respect to GSM8K dataset. For small CFG values, using CFG increases the percentage of chains which end in a valid answer structure while increasing the model accuracy. For large values the invalid percentage remains small but the accuracy drop.
Figure 3: CFG impact on chain-of-thought prompting with respect to GSM8K dataset. For small CFG values, using CFG increases the percentage of chains which end in a valid answer structure while increasing the model accuracy. For large values the invalid percentage remains small but the accuracy drop.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.