Skip to main content
QUICK REVIEW

[Paper Review] BERT as a Teacher: Contextual Embeddings for Sequence-Level Reward

Florian Schmidt, Thomas Hofmann|arXiv (Cornell University)|Mar 5, 2020
Topic ModelingComputer Science50 references7 citations
TL;DR

This paper proposes a novel sequence-level reward function for unconditional text generation using contextual BERT embeddings instead of n-gram counts. By clustering BERT-encoded tokens into 'BERT-grams' and computing embedding-based similarity, the method provides a scalable, per-word reward signal that captures long-range dependencies and outperforms n-gram rewards in generating higher-quality, more diverse sequences under reinforcement learning.

ABSTRACT

Measuring the quality of a generated sequence against a set of references is a central problem in many learning frameworks, be it to compute a score, to assign a reward, or to perform discrimination. Despite great advances in model architectures, metrics that scale independently of the number of references are still based on n-gram estimates. We show that the underlying operations, counting words and comparing counts, can be lifted to embedding words and comparing embeddings. An in-depth analysis of BERT embeddings shows empirically that contextual embeddings can be employed to capture the required dependencies while maintaining the necessary scalability through appropriate pruning and smoothing techniques. We cast unconditional generation as a reinforcement learning problem and show that our reward function indeed provides a more effective learning signal than n-gram reward in this challenging setting.

Motivation & Objective

  • To address the limitations of n-gram-based rewards in sequence-level reinforcement learning, which are sparse, lack per-symbol signal, and fail to capture long-range semantics.
  • To leverage contextual word embeddings from BERT to create a more expressive and scalable reward function that naturally supports per-word contributions.
  • To enable effective reinforcement learning training in unconditional text generation, where no source input is available and the model must learn from a corpus of reference sequences.
  • To investigate whether pre-trained contextual embeddings can serve as a superior foundation for reward modeling compared to traditional n-gram statistics.
  • To evaluate whether the proposed reward improves both quality and diversity in unconditional generation, especially in the face of reward sparsity and policy collapse.

Proposed method

  • Replace n-gram counts with BERT-based embedding similarity by encoding each token in a reference sequence using BERT.
  • Cluster the resulting BERT embeddings into a compact set of representative 'BERT-grams' using vector quantization to ensure scalability independent of corpus size.
  • Compute the reward for a generated sequence as the sum of similarities between its tokens and the nearest BERT-grams in the reference corpus.
  • Apply pruning and smoothing techniques to the BERT-gram representation to maintain robustness and efficiency during training.
  • Use the resulting embedding-based reward in a REINFORCE-based reinforcement learning framework for unconditional text generation.
  • Train a policy network using the BERT-gram reward to optimize for both quality (measured by GPT-2 perplexity) and diversity (measured by unique n-gram ratios).

Experimental results

Research questions

  • RQ1Can contextual embeddings like BERT replace n-gram statistics in sequence-level reward functions while maintaining scalability?
  • RQ2Does an embedding-based reward provide a finer-grained, per-word learning signal compared to count-based n-gram rewards?
  • RQ3To what extent can BERT-grams capture long-range dependencies and complex semantics in reference corpora?
  • RQ4How does the proposed reward perform in unconditional text generation, where no source input is available?
  • RQ5Does the use of BERT-based rewards mitigate the mode collapse and diversity issues common in RL-based text generation?

Key findings

  • The BERT-gram reward outperforms n-gram rewards in all evaluation metrics, achieving significantly lower perplexity under GPT-2, indicating higher sequence quality.
  • The policy trained with the BERT-gram reward generates sequences with higher diversity, as evidenced by higher ratios of unique sequences (ρ), 2-grams (ρ2), and 4-grams (ρ4) compared to the n-gram baseline.
  • The BERT-gram reward provides a more effective learning signal than n-gram rewards, as shown by a steeper and sustained increase in reward during training, unlike the early saturation of n-gram rewards.
  • Despite improved performance, both reward functions lead to policy collapse, with 95% of generated sequences using direct speech under the BERT-gram reward and 99% under n-gram, indicating a strong mode bias.
  • The method successfully maintains expressiveness even under aggressive clustering of BERT embeddings, demonstrating robustness and scalability to large reference corpora.
  • The study confirms that the underlying REINFORCE training method still suffers from mode collapse in unconditional generation, even when using a more expressive reward function.

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.