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.
- 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.
- Persistence Times: We record the "lifespan" of these components—the duration they persist before merging into larger clusters.
- 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.
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.
Key Insights
- Topological Simplification: Neural networks naturally simplify data topology during learning, creating distinct high-confidence clusters.
- Unsupervised Monitoring: On the
financial_phrasebankdataset, 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