Taxonomy Aware Loss Functions for Hierarchical Classification

This direction is merged into another direction: hierarchical loss function. Its last version stays readable and citable here.

Version 1 of 128 papers37 conceptsfrozen 2026-10-04

In standard machine learning, all errors are created equal. If a model is trained to classify animals and mistakes a "Siberian Tiger" for a "Bengal Tiger," a standard cross-entropy loss treats that mistake with the same severity as mistaking a "Siberian Tiger" for a "Toaster."

This "flat" view of the world ignores the rich, structured relationships inherent in almost all real-world data. Research into taxonomy-aware loss functions seeks to fix this by "baking" the structure of category hierarchies—like "is-a" relationships or phylogenetic trees—directly into the model’s optimization process.

The Intuition of Semantic Distance

The core idea is to replace uniform penalties with a distance-aware penalty. As Hyun-Je Song and colleagues argue in A Cost Sensitive Part-of-Speech Tagging, mistaking a singular noun for a plural noun is a minor "whoops," while mistaking a noun for a verb is a structural failure.

To quantify this, researchers like Deng Cai in Locality Sensitive Discriminant Analysis use the symmetric difference between ancestor sets. If two labels share almost all their ancestors in a tree (like "Husky" and "Beagle" both being "Dogs" and "Mammals"), the penalty for confusing them is small. If they share no ancestors except the root, the penalty is maximized. This ensures that even when a model is wrong, it is "semantically close" to the truth.

Large-Margin Taxonomy Embeddings

How do we force a neural network to respect these distances? One dominant approach is the Large-Margin framework.

In Large Margin Taxonomy Embedding for Document Categorization, Kilian Q Weinberger and Olivier Chapelle introduced Taxem. Instead of just trying to get the right answer, the model tries to project documents into a latent space where the distance to the correct class prototype is smaller than the distance to any incorrect prototype by a specific margin. Crucially, this margin isn't a constant; it is scaled by the cost of the error defined by the taxonomy.

Jack Valmadre refined this in Hierarchical classification at multiple operating points by introducing a soft-max-margin loss. This allows the model to maintain a separation between classes that is proportional to their taxonomic distance, which is particularly effective in high-precision scenarios where being "correct but vague" (e.g., predicting "Bird" instead of a specific but wrong species) is preferred.

Enforcing Logical Consistency

A common failure in hierarchical models is "logical inconsistency": a model might correctly identify a "Tiger" at a fine-grained level but simultaneously label it a "Person" at a coarse level.

To solve this, Tz-Ying Wu and Nuno Vasconcelos developed ProTeCt (Prompt Tuning for Hierarchical Consistency). They use a node-centric loss that forces the model to distinguish between sibling categories under the same parent.

Taking this further, Seulki Park and Youren Zhang introduced H-CAST (Visually Consistent Hierarchical Image Classification). Their loss function treats the entire path from the root to a leaf as a single probability distribution. This ensures that the probability of a child node is mathematically nested within the probability of its parent, preventing the model from making contradictory predictions across different levels of granularity.

Why It Works: Better Priors and Data Efficiency

Taxonomy-aware losses act as a powerful structural prior. By telling the model which classes are "related," we reduce the amount of data needed to learn effective decision boundaries.

  • Few-Shot Learning: In Diagnostic Text-guided Representation Learning, Qiehe Sun shows that by aligning image features with textual descriptions along a diagnostic path (e.g., "Tissue" -> "Lung" -> "Adenocarcinoma"), models can learn complex medical classifications even when data is scarce.
  • The Long Tail: Vidit Jain and colleagues demonstrate in HiGen that level-guided losses significantly boost performance on "long-tailed" classes—rare categories that the model might otherwise ignore if it weren't for the structural signal provided by their more common parent categories.

Ultimately, these methods move us away from treating labels as arbitrary integers and toward a system where the model understands the semantic context of what it is classifying. As Pascal Mettes explores in Searching for Actions on the Hyperbole, by embedding these hierarchies into specialized geometries like hyperbolic space, we can create retrieval systems that naturally understand the "family tree" of concepts.

Papers in this version

History & citationVersion 1 · 2026-10-04

Merged into another direction · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_taxonomy_aware_loss_functions_for_hierar_60fb74bc,
  title = {Taxonomy Aware Loss Functions for Hierarchical Classification},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/taxonomy-aware-loss-functions-for-hierarchical-classification/rdr_60fb74bc6aad4568b1f677f399cbfb3c},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-28},
}

This exact version (version 1, frozen text):

@misc{lacuna_taxonomy_aware_loss_functions_for_hierar_60fb74bc_v1,
  title = {Taxonomy Aware Loss Functions for Hierarchical Classification},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/taxonomy-aware-loss-functions-for-hierarchical-classification/rdr_60fb74bc6aad4568b1f677f399cbfb3c/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-28},
}