Free Margins for Rare Labels: Horospherical Heads Against Tail-Label Attacks

Text classifiers that pick relevant tags from tens of thousands of labels are easiest to fool on their rarest labels. On Wikipedia-31K, word-substitution attacks that remove a correct label succeed more than 90% of the time, and they succeed about 30% more often on rare "tail" labels than on frequent ones (Adversarial examples for extreme multilabel text classification). The usual remedy is adversarial training: retrain the model on attacked inputs. Here that remedy does not scale. Each discrete attack needs many forward passes, and there are thousands of labels to protect. We propose a cheaper fix aimed at what we take to be the cause. Tail labels sit at the leaves of a label hierarchy. Flat (Euclidean) space has too little room near its edge for exponentially many leaves, so their decision boundaries get crammed close to the data.

The proposal keeps the text encoder frozen and replaces only the final label layer with a classifier in hyperbolic space. Hyperbolic space is a curved geometry whose volume grows exponentially with distance from the center, much as the number of nodes in a tree grows with depth. Each label becomes a horosphere, a curved boundary that wraps around a branch of the tree. A horosphere has a useful property: the worst-case effect of any feature perturbation of size $\alpha$ on a point's distance to it has an exact closed form. That makes adversarial training of the head free. No inner attack loop runs. We train on the exact worst-case loss in feature space, on cached encoder features. In two sentences: the rarest labels are the least robust because flat space crowds them, so give them exponentially more room in a curved label layer. Then train that layer against the exact worst case, which costs essentially nothing extra.

Core Claim

Tail-label adversarial vulnerability in extreme multilabel classification is partly a geometric crowding effect. A horospherical head, trained with closed-form margin losses on a frozen encoder, should shrink the head–tail gap in attack success. It should do so beyond what a Euclidean head gets from the same margin training at the same dimension, and beyond loss rebalancing. It should also cost under a few percent of standard encoder fine-tuning. Two things would be new. First, the work uses hyperbolic geometry to allocate robustness margin to rare labels, rather than to resist curved attacks. Second, it drops adversarial-training overhead by moving the min-max problem into a part of the model where the inner maximization is exact.

The mechanism rests on one fact. For a point $z$ in the Lorentz model of hyperbolic space and a label $\ell$ with ideal point $p_\ell$ on the boundary at infinity and offset $b_\ell$, the label score is $s_\ell(z) = b_\ell - B_{p_\ell}(z)$. Here $B_p$ is the Busemann function, which measures signed distance "toward" the ideal point $p$. $B_p$ is 1-Lipschitz along geodesics. So for every feature perturbation within geodesic radius $\alpha$, the worst-case score is exactly $s_\ell(z) - \alpha$ for a positive label and $s_\ell(z) + \alpha$ for a negative one. The robust training loss is then

$$\mathcal{L}_\alpha(z, Y) = \sum_{\ell \in Y} \phi\big(s_\ell(z) - \alpha\big) + \sum_{\ell \notin Y} \phi\big(-s_\ell(z) - \alpha\big),$$

where $Y$ is the set of correct labels, $\phi$ is a logistic or hinge loss, and $\alpha$ is the feature-space attack budget. The loss is computed in one pass. It is also geodesically convex in the head parameters, a property Horospherical Decision Boundaries for Large Margin Classification in Hyperbolic Space proved for horospherical SVMs, which they found globally solvable and faster to train than geodesic hyperboloid SVMs (3.73 s vs 6.57 s on their synthetic benchmark).

How This Relates to Prior Work

Our closest relative is Robust Large-Margin Learning in Hyperbolic Space.. It proves that plain gradient descent on hyperbolic linear classifiers can take exponential time to reach large margins. It also shows that injecting worst-case perturbations during training restores polynomial-time convergence, and that an 8-dimensional hyperbolic classifier reaches zero error on WordNet subtrees where 16-dimensional Euclidean logistic regression struggles. We reuse its central idea, that adversarial perturbation is a cheap optimizer for margin. We differ on three counts. We use horospheres rather than geodesic hyperplanes. We work with thousands of labels on top of a deep frozen text encoder rather than with shallow linear models. And we judge success by robustness to real discrete text attacks.

Two papers motivate the geometric argument. Large-Margin Classification in Hyperbolic Space raised Macro-AUPR on the WordNet mammal subtree from 0.41 to 0.70 with a hyperbolic SVM. The horospherical paper raised F1 on the "Animal" subtree from 0.39 (Euclidean) to 0.57. Both evaluate only clean accuracy. Your Extreme Multi-label Classifier is Secretly a Hierarchical Text Classifier for Free shows that extreme classifiers internally build hierarchical label trees. This supplies the tree we embed, and it is why we expect tail labels to behave like leaves.

Two papers constrain the design. Clipped Hyperbolic Classifiers Are Super-Hyperbolic Classifiers shows that Euclidean backbones feeding a hyperbolic classifier push features toward the boundary, where gradients vanish. Capping feature norms before the map into hyperbolic space fixes this and also improves FGSM/PGD resilience. We adopt the clipping. It has a second job here: it bounds how far a Euclidean feature shift can move a point in hyperbolic distance, which is what lets us convert a measured attack size into the budget $\alpha$.

Adversarial Attacks on Hyperbolic Networks builds curved-space attacks and finds that on CIFAR they behave almost like flat attacks. The reason is that small perturbations only see the locally flat neighborhood around a point. The authors explicitly leave hyperbolic adversarial training undone because of its cost. This "local Euclidean" result could seem to cut against us. Our claim does not rely on curvature at the scale of a perturbation. It relies on how much room each label's region gets at the scale of the whole label tree. If anything, their result explains why a feature-space $\alpha$ calibrated with ordinary distances should transfer.

Other cheap defenses differ in where they act. Robustness tokens freeze a vision transformer and learn about ten extra input tokens, restoring DINOv2-Giant accuracy under white-box attack from 0.3% to 63.1% in 200 steps (Robustness Tokens: Towards Adversarial Robustness of Transformers). They still generate attacks during training and are not designed around label structure. Hyperbolic prompt learning (Hyperbolic Representations for Prompt Learning) and hyperbolic prompt filtering (Harnessing Hyperbolic Geometry for Harmful Prompt Detection and Sanitization) use curved geometry for clean accuracy or input screening. Neither shapes the robustness of the classifier itself.

Research Program

The work has four parts.

Building the head. We take trained extreme multilabel encoders from the attack paper, APLC-XLNet and AttentionXML, and cache their features on Wikipedia-31K and AmazonCat-13K. We build a label tree by the clustering these models already use. We initialize the ideal points $p_\ell$ by embedding that tree in hyperbolic space, so that sibling leaves start near one another on the boundary. We then train the ideal points, offsets, a learned curvature, and a small linear map before the clipped map into hyperbolic space, all using $\mathcal{L}_\alpha$.

Calibrating $\alpha$. We run the discrete word-substitution attack on a few hundred held-out training documents. We measure how far the attacked features move after clipping and the hyperbolic map, and set $\alpha$ near the 90th percentile of that displacement. This is the only place attack generation enters, and it is a one-time cost.

Checking the mechanism. For each label we record its worst-case score margin, $s_\ell(z) - \alpha$ for positives, and the attack success rate against it. We then ask whether, under the Euclidean head, margin shrinks with label rarity and predicts attack success, and whether the horospherical head breaks that link.

A secondary transfer check. CIFAR-100 has a 20-superclass hierarchy. On it, the same head on a frozen backbone is compared with fast adversarial training. This tests whether the effect needs a deep label tree, and connects the results to the vision robustness literature.

Baselines

Naive reference. The unmodified encoder with its original label layer, attacked with the same positive-to-negative and negative-to-positive substitution attacks. The attack paper reports positive-to-negative success above 90% on Wikipedia-31K, a roughly 30% higher success rate on tail labels, and negative-to-positive success often below 20% on AmazonCat-13K. We reproduce these numbers before running anything else. For clean accuracy, the file reports R-Precision 38.93 for XR-Transformer on Wikipedia-31K (from the hierarchical-classifier paper). No reported clean precision@k for APLC-XLNet or AttentionXML was found on Lacuna, so we measure our own.

Strongest existing method: rebalanced loss. This is the defense from Adversarial examples for extreme multilabel text classification, reported to improve tail-label robustness by 10% to 40% with no attack passes. It is the strongest competitor because it targets exactly the tail gap at the same near-zero cost. We apply it to a retrained head on the same cached features, with the same tuning budget, and also in combination with our head. Beating it means a lower tail-bin attack success at equal or better clean precision@5. Being complementary to it, so that the combination beats both alone, also counts as a meaningful result.

Key ablation: Euclidean head with the same margin loss. A Euclidean linear head trained with the exact Euclidean analogue of $\mathcal{L}_\alpha$, which is also closed form (score minus $\alpha$ times the weight norm). It uses the same dimension, budget calibration, rebalancing options and hyperparameter search. This isolates geometry from margin training. We run it at the hyperbolic dimension and at two, four and eight times that dimension.

Feature clipping alone. The clipped hyperbolic multinomial-logistic head of Guo et al., trained without the margin term.

Expensive reference. Full attack-based adversarial fine-tuning of the encoder, on a 10% subset of training documents. It is reported with wall-clock cost to place our method on the cost–robustness curve, not as a fully tuned competitor.

Why not just…?

Why not just use rebalanced losses? This is the most serious threat. Rebalancing already buys 10–40% tail robustness for free. However, the attack paper reports that tail labels remain disadvantaged afterward. Rebalancing changes how much each error counts. It does not change how much room the classifier has to put a boundary far from a tail label's documents. The ablation that combines our head with rebalancing settles this. If rebalancing alone matches the combination on tail-bin attack success, the geometric claim fails, and we will report that.

Why not just widen the Euclidean head and train it with the same margin loss? If the cheap closed-form margin training does all the work, geometry is decoration. The 8-versus-16-dimension result of Weber et al. and the 2-versus-25-dimension result of Cho et al. suggest that flat space needs much more dimension to match. Those results are on clean data and small trees, though. The dimension sweep in the Euclidean ablation is the direct test. If a Euclidean head at four times the dimension closes the gap at equal parameter count, we would reframe the contribution as free margin training for extreme classifiers and drop the geometric claim.

Why not just use fast adversarial training or robustness tokens on the encoder? Both still generate attacks during training. For discrete text, attack generation is the cost the attack paper calls intractable at this label scale. Single-step training also risks catastrophic overfitting, in which robustness suddenly collapses, as Taxonomy Driven Fast Adversarial Training documents. Our expensive reference measures how much robustness the encoder-level approaches add per GPU-hour. The CIFAR-100 check compares directly with that paper's method, which reports up to 1.62% PGD-10 robust-accuracy gains over earlier fast methods.

Decisive Checks

We will measure precision@1/3/5, positive-to-negative and negative-to-positive attack success binned by label frequency, the head–tail success gap, and training wall-clock time relative to one epoch of encoder fine-tuning.

The method succeeds if, on Wikipedia-31K, the horospherical head with rebalancing cuts tail-bin positive-to-negative success by a clearly larger margin than rebalancing plus the Euclidean margin head at matched dimension. It must do so while staying within one point of the original clean precision@5, and at under 5% of fine-tuning cost.

The mechanism holds only if per-label worst-case margin predicts attack success under the Euclidean head and this dependence on rarity weakens under the hyperbolic head. A robustness gain without that change would point to some other cause.

Two outcomes would falsify the idea: a Euclidean head at four times the dimension matching the hyperbolic one, or the gain disappearing when $\alpha$ is set from measured attack displacements rather than tuned against the test attack.