An Unsupervised Method for Estimating Class Separability of Datasets with Application to LLMs Fine-Tuning

Najah Ghalyan, Kostis Gourgoulias, Yash Satsangi, Sean J. Moran, Maxime Labonne, Joseph Sabelja · DOI

Abstract

Fine-tuning Large Language Models (LLMs) for classification typically requires labeled validation sets to monitor performance. This paper introduces a novel unsupervised metric based on Persistent Homology (PH) to estimate class separability directly from text embeddings. By analyzing the topological simplification of the embedding manifold—specifically the birth and death of connected components ($H_0$)—we derive a "Persistence Score" that effectively signals training plateaus. Our results demonstrate that this score closely aligns with supervised metrics like Accuracy and ROC-AUC, providing a reliable early-stopping signal without the need for labeled data.

Introduction

The success of LLM fine-tuning often hinges on the availability of high-quality labeled validation data to determine when a model has reached peak performance. In many real-world scenarios, such labels are scarce or expensive. Existing unsupervised metrics, such as the Calinski-Harabasz (CH) Index, often fail to provide a clear stopping signal, as they may continue to increase even after the model's actual classification performance has plateaued.

This research addresses this gap by investigating the "shape" of data in the embedding space. We hypothesize that as a model learns to classify, it naturally simplifies the topology of the input data, moving from a chaotic distribution to one characterized by distinct, well-separated clusters.

Methodology

The proposed method leverages Persistent Homology (PH), a tool from Topological Data Analysis (TDA), to track the evolution of connected components ($H_0$) in the embedding space.

  1. Vietoris-Rips Filtration: Text embeddings are treated as a point cloud. We simulate growing "balls" around each point; as the radius ($\epsilon$) increases, these balls merge to form connected components.
  2. Persistence Times: We record the "lifespan" of these components—the duration they persist before merging into larger clusters.
  3. Persistence Score ($S$): We derive a statistic from the distribution of these persistence times. A well-clustered space features a few long-lived components and many short-lived ones.
Conceptual illustration of noise levels and persistence times.

A critical finding is that normalizing embeddings to a unit ball during fine-tuning significantly enhances the topological signal, forcing the model to organize data into well-defined connected components.

Results and Discussion

The method was evaluated on standard text classification benchmarks (e.g., sst2, emotion, financial_phrasebank) using various sentence transformers.

Alignment with Supervised Metrics

The Persistence Score ($S$) exhibits a "saturation" behavior that mirrors supervised metrics like Accuracy and ROC-AUC. Unlike the CH Index, which often grows linearly throughout training, the Persistence Score levels off precisely when the model's classification performance plateaus.

Metric behavior during fine-tuning epochs.

Key Insights

  • Topological Simplification: Neural networks naturally simplify data topology during learning, creating distinct high-confidence clusters.
  • Unsupervised Monitoring: On the financial_phrasebank dataset, the Persistence Score correctly identified a performance plateau after two epochs, while the CH Index continued to rise, potentially leading to over-training.
  • Sufficiency of $H_0$: While TDA can explore complex shapes like loops ($H_1$), the simplest topological feature—connected components—is sufficient for capturing class separability in high-dimensional text embeddings.

Conclusion and Future Work

We have presented an unsupervised method for monitoring LLM fine-tuning that rivals supervised metrics in detecting performance plateaus. While computationally more intensive than simple indices, the use of $H_0$ remains feasible for many datasets. Future research will explore the application of this method to regression and text generation tasks, as well as the potential insights provided by higher-order homology ($H_1, H_2$) into the internal logic of LLM embeddings.

Summary updated

BibTeX
@article{ghalyan2024unsupervised,
  author = {Najah Ghalyan and Kostis Gourgoulias and Yash Satsangi and Sean J. Moran and Maxime Labonne and Joseph Sabelja},
  title = {{An Unsupervised Method for Estimating Class Separability of Datasets with Application to LLMs Fine-Tuning}},
  journal = {Accepted by TMLR},
  year = {2024},
  url = {https://openreview.net/forum?id=8DWrIMuLya},
}
Figure