Label Forensics: Interpreting Hard Labels in Black-Box Text Classifier

Mengyao Du, Gang Yang, Han Fang, Quanjun Yin, Ee-Chien ChangarXiv 2025 · DOI · arXiv

Abstract

Modern text classifiers are often deployed as "black boxes," providing only hard labels without documentation or internal access. This lack of transparency creates significant accountability gaps for researchers and auditors. We present "Label Forensics," a framework designed to reconstruct the semantic meaning of these labels. By integrating LLM-guided seed generation with a specialized prompt-free sampler, our system maps the semantic regions associated with specific labels. Experimental results demonstrate over 92% consistency in identifying a classifier's hidden logic across various tasks, including sentiment analysis and toxicity detection.

Introduction

The proliferation of text classifiers for tasks like spam filtering and content moderation has led to an "opacity crisis." Many models are accessible only via APIs that return a single category or ID (a "hard label"), leaving the underlying decision logic hidden. For instance, if a model flags a specific sentence as "Label 1," it is often unclear whether this represents toxicity, a specific political bias, or a different category entirely. Label Forensics addresses this challenge by reverse-engineering the semantic intent behind these mysterious labels using only the model's final outputs.

Methodology

The Label Forensics framework utilizes a three-stage pipeline to uncover label semantics without requiring access to training data or model weights.

The proposed three-stage pipeline for label forensics, featuring WordNet initialization and a prompt-free sampler.
  1. Semantic Distribution Initialization: The process begins by traversing WordNet to identify "anchor words," which are then expanded into diverse "seed sentences" using an open-source LLM. Sentences that trigger the target label in the black-box classifier serve as initial prototypes.
  2. Prompt-free Sampler Construction: To explore the semantic space around these seeds, we developed a specialized encoder-decoder model based on T5. This sampler uses prefix tuning to generate variations directly from the embedding space, avoiding the biases inherent in human-written textual prompts.
  3. Iterative Optimization: The system searches for a set of sentences that are both precise (consistent label assignment) and general (broad semantic coverage). A binary search method estimates a "sampling radius," measuring the robustness of a label's semantic concept.
  4. Semantic Interpretation: Finally, recovered semantic regions are processed by an LLM to generate human-readable descriptions, which are validated using Natural Language Inference (NLI) models.

Evaluation and Datasets

The framework was evaluated against five distinct black-box classifiers: Emotion ($M_{emo}$), Sentiment ($M_{sent}$), Spam ($M_{spam}$), Jailbreak ($M_{jail}$), and Toxicity ($M_{tox}$). Additionally, a real-world case study was conducted on an undocumented binary classifier from the HuggingFace model hub to test the system's ability to identify a model's purpose from scratch.

Results and Key Insights

Our evaluation reveals that labels are best understood as specific "neighborhoods" in high-dimensional embedding space rather than isolated points. By mapping these boundaries, the framework provides a clear view of the model's internal logic.

t-SNE visualizations demonstrating the framework's ability to reconstruct distinct semantic clusters for emotion, sentiment, and spam labels.

Key findings include:

  • High Fidelity: The recovered semantic regions maintained an average label consistency of 92.24%, accurately capturing internal model boundaries.
  • Geometric Clarity: As shown in the t-SNE visualizations, the framework successfully reconstructed well-separated clusters for distinct labels, even in fine-grained tasks like 5-way sentiment analysis.
  • Real-World Utility: In the HuggingFace case study, the framework correctly identified an undocumented model as a sentiment classifier, specifically pinpointing "Label 0" as "Very Negative" with high similarity to reference models.
  • Robustness Measurement: The "sampling radius" served as an effective proxy for confidence; a larger radius indicates a more certain and stable semantic concept within the model.

Limitations and Future Work

While effective, Label Forensics relies on external knowledge bases like WordNet and general-purpose LLMs. This dependency may hinder performance on classifiers using highly specialized jargon (e.g., medical or legal domains). Furthermore, the iterative sampling process can be computationally intensive due to the volume of API queries required. Future research will focus on extending this approach to multi-modal models and developing techniques to detect intentionally obscured biases.

Summary updated

Abstract

The widespread adoption of natural language processing techniques has led to an unprecedented growth of text classifiers across the modern web. Yet many of these models circulate with their internal semantics undocumented or even intentionally withheld. Such opaque classifiers, which may expose only hard-label outputs, can operate in unregulated web environments or be repurposed for unknown intents, raising legitimate forensic and auditing concerns. In this paper, we position ourselves as investigators and work to infer the semantic concept each label encodes in an undocumented black-box classifier. Specifically, we introduce label forensics, a black-box framework that reconstructs a label's semantic meaning. Concretely, we represent a label by a sentence embedding distribution from which any sample reliably reflects the concept the classifier has implicitly learned for that label. We believe this distribution should maintain two key properties: precise, with samples consistently classified into the target label, and general, covering the label's broad semantic space. To realize this, we design a semantic neighborhood sampler and an iterative optimization procedure to select representative seed sentences that jointly maximize label consistency and distributional coverage. The final output, an optimized seed sentence set combined with the sampler, constitutes the empirical distribution representing the label's semantics. Experiments on multiple black-box classifiers achieve an average label consistency of around 92.24 percent, demonstrating that the embedding regions accurately capture each classifier's label semantics. We further validate our framework on an undocumented HuggingFace classifier, enabling fine-grained label interpretation and supporting responsible AI auditing.
BibTeX
@misc{du2025label,
  author = {Mengyao Du and Gang Yang and Han Fang and Quanjun Yin and Ee-Chien Chang},
  title = {{Label Forensics: Interpreting Hard Labels in Black-Box Text Classifier}},
  year = {2025},
  eprint = {2512.01514},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.01514},
}
Figure