Contrastive Distillation Is a Sample-Efficient Self-Supervised Loss Policy for Transfer Learning

Chris Lengerich, Gabriel Synnaeve, Amy Zhang, Hugh Leather, Kurt Shuster, François Charton, Charysse RedwoodarXiv 2022 · DOI

Abstract

We introduce Contrastive Distillation (CD), a self-supervised method designed to enhance knowledge transfer between disparate tasks. By manifesting a model's latent knowledge into explicit token sequences (rationales) and utilizing an episodic memory, CD enables sample-efficient adaptation in low-data regimes. Our approach uses a Bayesian sampling strategy to generate high-quality training pairs, bridging the gap between "implicit" weight updates and "explicit" reasoning. Experiments on bAbI and Com2Sense benchmarks show significant improvements over standard fine-tuning, demonstrating the power of text as a portable medium for transfer.

Introduction

The standard "pre-train then fine-tune" paradigm often fails under significant distribution shifts or when target data is scarce. While humans adapt by reasoning through "why" and "how," current AI models often lack the mechanisms to explicitly bridge task-specific knowledge. We propose Contrastive Distillation as a self-supervised loss policy that forces models to externalize their internal reasoning into tokens, creating a "connective tissue" for transfer learning.

Methodology

The core of our approach is the transformation of latent variables from weights into explicit tokens. This is achieved through two primary mechanisms: Bayesian Contrastive Distillation and a modular agent architecture.

Bayesian Contrastive Distillation

The model generates "prior" rationales (pre-answer) and "posterior" rationales (post-answer). By comparing these, we create high-quality training pairs that are more informative than random negative samples.

Algorithm 1: Bayesian Contrastive Distillation sampling procedure.

Agent Architecture

The agent is decomposed into four functional modules:

  1. Proposer: Suggests the current task $C_t$.
  2. Solver: Generates the answer and associated rationales ($x_t, r_0, f_0$).
  3. Verifier: Evaluates the quality of the generated output.
  4. Updater: Manages updates to the model weights and the episodic memory $M_t$.
The four-part agent architecture: Proposer, Solver, Verifier, and Updater, integrated with an episodic memory $M_t$.

Episodic Memory

We implement a flat, key-value memory using FAISS. This allows the model to store generated rationales and retrieve them later using PCA-based sampling, enabling the model to "improvise" by applying reasoning structures from past experiences to new contexts.

Experimental Results

We evaluated our method on the bAbI (logical reasoning) and Com2Sense (commonsense reasoning) datasets, focusing on low-data configurations (5-100 training points). Performance was measured using the BLEURT score (range -2 to 1).

  • bAbI to Com2Sense: The baseline T5 model achieved a score of -1.62, while our CD-memory model improved this to -1.08.
  • Com2Sense to bAbI: The baseline scored -1.31, whereas the CD-memory model reached -0.65.

Qualitative analysis suggests the model successfully adapts the logical structure of bAbI rationales to solve commonsense problems in Com2Sense.

Discussion and Limitations

While Contrastive Distillation improves sample efficiency, it introduces a compute-generalization tradeoff due to the overhead of decoding rationales. Current limitations include a reliance on teacher oracles (e.g., GPT-3) for initial training and occasional coherence issues in multi-step reasoning. Future work will explore self-generation in larger models and multi-hop reasoning via beam search.

Conclusion

Contrastive Distillation demonstrates that explicit text is a superior medium for transfer compared to implicit weight updates. By externalizing reasoning, models can more effectively bridge disparate domains, paving the way for more autonomous and adaptable AI systems.

Summary updated

Abstract

Traditional approaches to RL have focused on learning decision policies directly from episodic decisions, while slowly and implicitly learning the semantics of compositional representations needed for generalization. While some approaches have been adopted to refine representations via auxiliary self-supervised losses while simultaneously learning decision policies, learning compositional representations from hand-designed and context-independent self-supervised losses (multi-view) still adapts relatively slowly to the real world, which contains many non-IID subspaces requiring rapid distribution shift in both time and spatial attention patterns at varying levels of abstraction. In contrast, supervised language model cascades have shown the flexibility to adapt to many diverse manifolds, and hints of self-learning needed for autonomous task transfer. However, to date, transfer methods for language models like few-shot learning and fine-tuning still require human supervision and transfer learning using self-learning methods has been underexplored. We propose a self-supervised loss policy called contrastive distillation which manifests latent variables with high mutual information with both source and target tasks from weights to tokens. We show how this outperforms common methods of transfer learning and suggests a useful design axis of trading off compute for generalizability for online transfer. Contrastive distillation is improved through sampling from memory and suggests a simple algorithm for more efficiently sampling negative examples for contrastive losses than random sampling.
BibTeX
@misc{lengerich2022contrastive,
  author = {Chris Lengerich and Gabriel Synnaeve and Amy Zhang and Hugh Leather and Kurt Shuster and François Charton and Charysse Redwood},
  title = {{Contrastive Distillation Is a Sample-Efficient Self-Supervised Loss Policy for Transfer Learning}},
  year = {2022},
  eprint = {2212.11353},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2212.11353},
}
Figure