Semantic Swap Kernels for Training Label-Set Energy Models Without Sampling

Many text classification problems ask for a set of labels rather than one. A paper gets several subject tags, and a product gets several categories. The labels in such a set depend on each other: some co-occur, some exclude each other, and the labels are themselves pieces of language with names and definitions. Energy-based models are a natural fit for scoring whole label sets. They assign each candidate (document, label set) pair a single number, the "energy", where low energy means compatible. They are hard to train, though. The standard recipe needs negative examples drawn from the model itself, usually by running slow Markov-chain samplers (MCMC). Energy Discrepancy, a recent loss, avoids sampling. It compares the energy of the true answer against the energy of randomly perturbed versions of it. Its known weakness is that generic perturbations land in places the data never visits, so they carry no learning signal.

This proposal joins the two problems. The perturbations used to train a label-set energy model should be built from label semantics. A true tag set is corrupted by swapping a tag for a semantically nearby tag, by adding a tag related to the ones already present, or by dropping one. Nearness is measured by embeddings of the label descriptions. The energy itself is written as a function of those description embeddings, so the same model can score sets containing labels never seen in training. The resulting model is trained without sampling, captures dependencies between labels, and transfers to new label vocabularies. The central test is whether the semantic perturbation kernel beats generic bit-flips and simpler contrastive or pseudolikelihood training.

Core Claim

Training Discrete Energy-Based Models with Energy Discrepancy trains discrete energy models with fixed perturbation processes $q(y'\mid y)$: random bit flips, coarse-graining, and flips of neighbouring grid bits. Its loss has a global minimum at the data distribution. Both that paper and its continuous predecessor, Energy Discrepancies: A Score-Independent Loss for Energy-Based Models, name the "manifold problem" as their main limitation.

Multi-label outputs show this problem in an extreme form. A true tag vector over $K$ labels typically has a handful of active entries. A random bit flip almost always turns on an irrelevant label. The model then learns only the trivial lesson "don't add random tags". It never learns to distinguish "machine learning" from "statistics", which is where real errors happen.

Our claim is that a perturbation kernel that moves along a label-similarity graph, built from description embeddings, puts the training signal where confusions actually occur. Combined with an energy whose label-interaction term is a function of description embeddings rather than label indices, the result is a structured, zero-shot-capable multi-label model trained with a provably consistent, sampling-free loss.

The graph construction borrows from Schröder et al., who use heat-equation kernels on graphs for tabular discrete data. Our graph is over label semantics rather than over data coordinates.

Research Program

The energy. For a document $x$ and a candidate label set $S$, each label $i$ has a description embedding $d_i$ from a frozen-then-fine-tuned sentence encoder. The energy is

$$E_\theta(x,S) = -\sum_{i\in S} s_\theta(x,d_i) + g_\theta(\{d_i\}_{i\in S}, x),$$

where $s_\theta$ is a dual-encoder compatibility score and $g_\theta$ is a permutation-invariant set network (attention pooling over description embeddings). The first term is per-label matching, as in Description-Enhanced Label Embedding Contrastive Learning for Text Classification, which matches sentences to WordNet definitions but scores labels independently. The second term plays the role of the global label energy in Structured Prediction Energy Networks. SPEN's global term is defined over index vectors $y\in[0,1]^K$ and cannot see an unseen label. Ours reads descriptions, so co-occurrence patterns learned on seen labels can carry over to semantically similar unseen ones.

The kernel. We build a $k$-nearest-neighbour graph over description embeddings. The kernel $q(S'\mid S)$ makes a fixed number of moves, each chosen with set probabilities:

  • replace an active label with one of its graph neighbours;
  • add a neighbour of an active label;
  • drop an active label.

Move probabilities are symmetrized so the kernel satisfies the conditions the Energy Discrepancy loss needs.

The loss. We use the stabilized, sampled loss from the discrete Energy Discrepancy paper. For each training pair, we draw $S'\sim q(\cdot\mid S)$ and then $M$ contrast sets $S_j\sim q(\cdot\mid S')$, and minimize

$$\log\Big(\tfrac{w}{M} + \tfrac{1}{M}\textstyle\sum_{j=1}^{M} e^{E_\theta(x,S)-E_\theta(x,S_j)}\Big).$$

Here $w>0$ is the stabilization constant that prevents divergence. No inner optimization or Markov chain is run, which avoids SPEN's loss-augmented inference loop.

Inference. We restrict to a candidate pool, the dual-encoder top-$C$ labels. Within that pool we run greedy local search using the same add, drop and swap moves, warm-started from thresholded per-label scores. We report wall-clock cost against SPEN's continuous relaxation.

Analysis. We will measure where each kernel's contrast sets fall: their size distribution and their semantic distance to the true set. We will also measure how often the trained model's errors are near-synonym confusions versus spurious additions. This directly tests the manifold-problem story.

Baselines

The naive reference point is independent binary relevance over label embeddings. It uses the same dual encoder $s_\theta$ with a sigmoid per label, trained with binary cross-entropy, so $g_\theta$ is removed. Most zero-shot description-based classifiers, including The Benefits of Label-Description Training for Zero-Shot Text Classification, effectively make this independence assumption. Any gain we claim must come from the joint term and the kernel, not from the encoder.

The strongest structured competitor is SPEN with SSVM training. We will run it in two versions: as published with index labels, and with our description-based global term swapped in. The second version isolates the training objective from the architecture. Both versions receive the same encoder, data, and tuning budget, measured in GPU-hours, not epochs, since SPEN's inner loop is costlier.

The strongest sampling-free structured competitor is the min-min partition-network method of Joint Learning of Energy-based Models and their Partition Function. It learns a log-partition network $\tau(x)$ using a reference distribution $q(y)$. We run it in two versions: with its uniform reference, and with our semantic kernel's stationary distribution as reference. The second version is a fair head-to-head of the two sampling-free objectives on equal footing.

For extreme zero-shot, the strongest existing method is MACLR from Extreme Zero-Shot Learning for Extreme Text Classification. It reports Precision@1 of 18.13% on LF-Amazon-131K, against 13.94% for MPNet and 12.38% for TF-IDF. We will use MACLR's released-style pipeline as the candidate generator and treat our energy model as a set-level reranker over its top-100. Beating it means a statistically reliable gain in Precision@1 or in example-level F1 over MACLR's own ranking, on the same candidates.

On Bibtex, Bookmarks and Delicious, the file says SPEN beats binary relevance but contains no transcribed figures. For exact SPEN or min-min numbers on these datasets, no reported result was found on Lacuna. We will therefore rerun all baselines ourselves under one protocol.

The key ablation swaps the kernel while holding everything else fixed. We compare three kernels: Bernoulli bit flips (ED-Bern), uniform random add/drop/swap with no semantics, and the semantic swap kernel. A second ablation replaces description embeddings in $g_\theta$ with learned index embeddings. This tells us whether semantic grounding in the energy matters separately from semantic grounding in the kernel.

Why not just…?

Why not just train independent label-description matching, as dense retrieval does? This is the baseline that most often wins in practice. It is fast, and on datasets with weak label dependencies the joint term may add nothing. SPEN found that binary relevance underperforms label-interaction models on Bibtex and Bookmarks, but that was with index labels and older encoders. We do not assume the gap survives modern sentence encoders. The binary-relevance row is the first result we will look at. If the joint model's gain over it is within noise on all three structured datasets, the structured part of the claim fails.

Why not just use contrastive training with semantically hard negative label sets? This is the closest real threat. Sampling near-miss sets from the same graph and applying a softmax or margin loss could capture most of the benefit. The difference is in what the losses converge to. Energy Discrepancy has a minimizer at the data distribution. Hard-negative contrastive losses with a model-independent negative distribution are generally biased toward over-penalizing the chosen negatives. In practice this tends to show up as overconfident rejection of plausible alternative sets. We will run this baseline with identical negatives and compare set-level F1. We will also compare the calibration of top-set scores, normalized over the candidate neighbourhood. If contrastive training matches Energy Discrepancy on both, we will report the kernel as the contribution and the loss as interchangeable.

Why not just use pseudolikelihood on a pairwise label model? Pseudolikelihood is also sampling-free. Applied to an energy with pairwise interactions computed from description embeddings, it is a natural cheaper competitor. Its conditionals flip one label at a time against the full vocabulary, which recreates the sparse-flip problem the semantic kernel is meant to fix. We include it as a baseline with the same energy. A large win for pseudolikelihood would show the manifold argument is wrong for label sets.

Why not just use entailment-based zero-shot verification? Issues with Entailment-based Zero-shot Text Classification shows that NLI verifiers depend on lexical overlap. Their accuracy swings from about 10% to over 70% across datasets, and raw BERT next-sentence prediction (50.6% on Yahoo! Answers) often beats them. They also score labels independently. We include an NLI verifier only on the zero-shot split, as a reference rather than as the main competitor.

Proposed Experiments

Structured setting. Bibtex (159 labels), Bookmarks (208) and Delicious (983), using their tag strings as descriptions, optionally expanded with WordNet glosses as in DELE. Metrics are example-level F1 and Hamming loss, averaged over five seeds, under the matched-compute protocol above.

Zero-shot structured split. On the same datasets we hold out a quarter of labels and remove them from all training sets. At test time the model must predict sets containing held-out labels from their descriptions alone. This is impossible for index-based SPEN and the plain min-min model. It is the setting where the description-based global term must prove its value against binary relevance.

Extreme setting. LF-Amazon-131K in zero-shot mode, reranking MACLR's top-100. Metrics are Precision@1, Precision@5 and Recall@100, compared directly to the reported 18.13% Precision@1.

Decisive checks. Three outcomes will determine whether the idea holds:

  1. The semantic kernel beats both the Bernoulli and the uniform-swap kernels under Energy Discrepancy. Without this, the main claim fails.
  2. The joint model beats binary relevance with the same encoder on the zero-shot split. Without this, semantic grounding of the interaction term buys nothing.
  3. Energy Discrepancy matches or beats SPEN-with-SSVM accuracy at a fraction of training time, and beats contrastive hard-negative training on set-level calibration.

The contrast-set diagnostics will show whether any success comes for the stated reason: contrast sets that differ from the truth by plausible near-miss labels rather than random additions.