Whitening Not Recommended for Classification Tasks in LLMs

Ali Forooghi, Shaghayegh Sadeghi, Jianguo LuACL 2024

TL;DR

This paper investigates the effectiveness of "whitening," a post-processing technique for sentence embeddings, and finds it surprisingly detrimental to classification tasks. While it can improve performance on some tasks like Semantic Text Similarity (STS) for certain models, it consistently degrades classification accuracy, suggesting that LLM embeddings are already well-suited for these tasks without this intervention.

What Problem Does This Paper Address?

Sentence embeddings, representations of text as numerical vectors, are crucial for many Natural Language Processing (NLP) tasks. Large Language Models (LLMs) have become powerful tools for generating these embeddings, but their raw outputs aren't always optimal. A common post-processing step called "whitening" aims to improve embedding quality by making them more isotropic (uniform in all directions) and uncorrelated. This is achieved by transforming the embeddings so their covariance matrix is close to an identity matrix. However, the actual benefit of whitening, especially for modern LLMs and various downstream tasks, remains an open question. This paper specifically examines whether whitening consistently improves LLM embeddings across different tasks and models, with a particular focus on classification.

Methods

The authors explore various whitening transformations, including Principal Component Analysis (PCA), Cholesky decomposition, and Zero-Phase Component Analysis (ZCA). They apply these transformations to sentence embeddings extracted from the last layer of several LLMs. To evaluate the impact, they use a comprehensive evaluation framework called SentEval+, which they developed as a more efficient way to assess LLM embeddings on commodity hardware. This platform provides pre-computed embeddings for evaluation datasets, streamlining the process. The evaluation involves training simple classifiers (like MLPs) on these embeddings for classification tasks and using correlation metrics for STS tasks.

Datasets

The paper uses standard datasets commonly found in the SentEval benchmark for evaluation. These include datasets for classification tasks such as MR, CR, SUBJ, MPQA, TREC, and MRPC, as well as datasets for Semantic Text Similarity (STS) tasks like STS12, STS13, STS14, STS15, and STS16. The paper notes that all classification datasets used are binary, except for SST-F, which has five classes.

Key Insights and Ideas

  • Whitening is task-dependent: The core finding is that whitening's effectiveness is not universal. It shows promise for STS tasks but is detrimental to classification.
  • Whitening harms classification: This is the most surprising and significant result. Instead of improving, whitening consistently degrades classification performance across all tested models and datasets.
  • Model dependency is crucial: The impact of whitening varies significantly between different LLMs. Some models benefit from it for STS, while others do not.
  • Fine-tuning matters: Fine-tuned models (like SBERT, SimCSE, AnglE-BERT, and AnglE-LLaMA) seem to be less affected by whitening, or even show a reduced benefit compared to base LLMs like BERT and LLaMA. This suggests that fine-tuning might already imbue embeddings with desirable properties.
  • Isotropy doesn't guarantee performance: While whitening successfully increases the isotropy of embeddings (measured by IsoScore), this enhanced isotropy does not translate to better performance on classification tasks. This highlights a potential disconnect between geometric properties of embeddings and their downstream utility.
  • SentEval+ is a valuable contribution: The development of an efficient evaluation platform for LLMs is a practical outcome that can help researchers conduct experiments more easily.

Key Results

  • For classification tasks, whitening consistently leads to a drop in accuracy. For example, LLaMA models experienced a drop of up to -11 in accuracy on the MR dataset after whitening.
  • For STS tasks, whitening showed improvements for some models, such as BERT, but not for others like SimCSE.
  • The paper visualizes embeddings before and after whitening, showing that while whitening makes embeddings more isotropic, it also makes them harder for classifiers to distinguish.
  • Fine-tuned models like AnglE-BERT and AnglE-LLaMA showed less improvement in isotropy after whitening compared to base models like LLaMA and BERT.

Limitations and Future Work

  • ChatGPT's mystery: The paper notes that the technical details of ChatGPT's embeddings remain somewhat opaque. Its reaction to whitening suggests it might be fine-tuned on NLI data, but this is speculative.
  • Model dependency: While the paper tests several models, the vast landscape of LLMs means that conclusions might not generalize to all future models.
  • Future work: The authors suggest that LLM providers might consider offering task-specific embeddings, understanding that whitening is not a one-size-fits-all solution. Further investigation into why fine-tuning mitigates the negative effects of whitening could be fruitful. The SentEval+ platform itself is a contribution that can facilitate future research.

Summary updated

BibTeX
@inproceedings{forooghi2024whitening,
  author = {Ali Forooghi and Shaghayegh Sadeghi and Jianguo Lu},
  title = {{Whitening Not Recommended for Classification Tasks in LLMs}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
}
Figure