Hybrid-NCE Loss for Audio-Text Retrieval
- Hybrid-NCE Loss is a hybrid objective that combines symmetric InfoNCE, cosine similarity, and L1 losses to align audio–text embeddings.
- The formulation augments pure contrastive learning with positive-only terms, reducing gradient variance and countering batch size limitations.
- Empirical results on datasets like Clotho and AudioCaps demonstrate improved retrieval performance and noise robustness compared to baselines.
“Hybrid-NCE loss” is an Editor’s term for the loss formulation described in "Robust Audio-Text Retrieval via Cross-Modal Attention and Hybrid Loss" (Liu et al., 25 Apr 2026). The paper itself does not introduce the label “Hybrid-NCE”; it consistently describes a hybrid loss combining cosine similarity, , and contrastive objectives for audio–text retrieval. In that formulation, a symmetric InfoNCE-style contrastive term with in-batch negatives is augmented by two positive-pair alignment terms: a cosine “directional” loss and an loss. The loss is designed for multimodal retrieval under long-form, noisy, and weakly labeled audio, and is coupled to a training regime in which cross-modal attention refines projection parameters during training while retrieval is performed with independent per-modality embeddings at inference time (Liu et al., 25 Apr 2026).
1. Conceptual definition and scope
The hybrid loss operates on a minibatch of matched audio–text pairs , with one shared-space audio embedding and one shared-space text embedding produced per pair. Its defining characteristic is the combination of three objectives with distinct roles: relative ranking through symmetric InfoNCE, directional alignment through cosine similarity, and elementwise proximity through distance.
Within the terminology of the paper, the contrastive component is a straight InfoNCE objective, not NCE with an explicit noise distribution. It is symmetrized over both retrieval directions, audio-to-text and text-to-audio, and uses standard in-batch normalization with no reported memory bank, no hard-negative mining, and no EMA memory. The additional cosine and terms are positive-only constraints defined on matched pairs. This structure makes the formulation an augmentation of standard dual-encoder retrieval losses rather than a replacement for InfoNCE itself (Liu et al., 25 Apr 2026).
A central design choice is that the loss is computed on the same independent, per-modality embeddings that are used at inference. Cross-modal attention is present during training, but only as a refinement mechanism for the projection stack. This avoids a train–test mismatch in which the retrieval score would depend on interactions unavailable at inference.
2. Mathematical formulation
Before similarity is computed, the embeddings are -normalized:
The similarity function is cosine similarity:
0
The contrastive component is symmetric InfoNCE with temperature 1:
2
3
4
The cosine “directional” term is
5
The 6 term is
7
The total loss is a convex combination:
8
The paper reports ablations on Clotho with HTSAT-tiny and RoBERTa-large, with frozen encoders, and identifies 9 as the best validation setting. A pure-contrastive baseline corresponds to 0. The temperature 1 is not specified in the paper; it is treated as a hyperparameter, with a suggested search range 2 for reproduction when no further guidance is available (Liu et al., 25 Apr 2026).
3. Embedding pathway and placement of the loss
The embeddings used in the loss are the outputs of a projection and refinement stack applied to encoder features. The audio encoder yields frame-level or chunk-level vectors, and the text encoder yields token-level vectors. For each modality, the refinement stack has three stages: a transformer-based projection, a linear mapping into the shared space, and a cross-modal attention stage used during training only.
For an input sequence 3, the transformer-based projection consists of one Transformer encoder block with multi-head attention using 8 heads, a GELU feed-forward network with hidden size 4, dropout 5, and residual connections:
6
The linear mapping into the shared space is
7
where 8 and 9.
During training, cross-modal attention is defined for shared-space sequences 0 and 1 by
2
3
with a symmetric text-to-audio path. At inference, cross-modal attention is disabled, so only the per-modality transformer projection and linear mapping remain. The paper explicitly states that this preserves dual-encoder efficiency (Liu et al., 25 Apr 2026).
The loss is applied after pooling and projection, on one audio embedding 4 and one text embedding 5 per pair, both in 6. The pooled audio vector and pooled text vector are the inputs to the projection module that yields these embeddings. Although cross-modal attention participates in training through backpropagation, the similarity function 7, the directional term, and the 8 term are all computed on the independent per-modality outputs. This design is explicitly intended to avoid train–test mismatch.
4. Small-batch behavior and robustness mechanism
The paper motivates the hybridization by identifying failure modes of pure InfoNCE under small-batch constraints. With 9 pairs per batch, each anchor has only 0 negatives. According to the paper, fewer negatives reduce the contrastive signal and increase gradient variance, while mislabeled negatives arising from weak labels can produce biased gradients that push semantically related items apart. It also notes that with small 1 and small 2, the softmax may become peaky and the loss can saturate early, leaving little gradient when positives already dominate the denominator (Liu et al., 25 Apr 2026).
The two positive-only terms are introduced precisely to counter those effects. The directional loss and the 3 loss do not depend on negatives, so they provide consistent, low-variance gradients that pull matched pairs together even when the contrastive signal is weak or noisy. The paper characterizes them as regularizers that anchor absolute alignment in the shared space while InfoNCE supplies the relative ranking signal.
The stated gradient intuition is explicit. Defining
4
the audio-to-text InfoNCE gradients satisfy
5
and, for 6,
7
The paper further states that the directional term contributes
8
which yields a constant attractive force on positives after the chain rule through cosine similarity and 9-normalization. The 0 term adds an attractive subgradient on each embedding dimension by reducing 1 and is described as less sensitive than 2 to occasional large errors. Increasing 3 smooths 4 and reduces the magnitude of the InfoNCE gradients, but the paper states that 5 tuning alone cannot compensate for a lack of negatives.
5. Long-form audio, noisy conditions, and pooling
The hybrid loss is integrated with a long-audio pipeline based on silence-aware chunking and attention-based pooling. Positive pairs are formed by each audio clip and its paired caption or captions. The paper does not restrict multiple captions per audio; it states that each caption can form a separate positive with the same audio embedding as typical practice. Negatives remain standard in-batch negatives in both retrieval directions.
The preprocessing rule for long audio is explicit: remove silences longer than 1 second and then segment the remaining signal into fixed 10-second chunks. Each chunk is encoded into an audio feature vector. During training, chunk-level features are pooled by attention using the paired text embedding as query:
6
The paper states that this routing focuses the audio embedding on segments relevant to the caption and implicitly downweights silent or noisy parts. At inference, the paired text embedding is unavailable, so a learned query 7 replaces 8 to allow precomputation of audio embeddings. An additional training trick is reported: with probability 9, the text-conditioned query is replaced by the learned 0 during training to reduce train–test mismatch (Liu et al., 25 Apr 2026).
The loss itself remains clip-level. The paper explicitly states that it does not include a chunk-level contrastive objective or explicit silence masking in the loss. Suppression of irrelevant segments comes instead from silence removal and attention pooling. This suggests that the hybrid loss is intended to operate on globally pooled semantic representations rather than local alignment units.
6. Empirical performance, ablations, and limitations
The paper reports consistent retrieval gains over Microsoft-CLAP and LAION-CLAP across several datasets. For audio-to-text retrieval, the reported results are: AudioCaps, 1 and 2; Clotho, 3 and 4; ESC-50, 5 and 6; FSD50K, 7 and 8. For text-to-audio retrieval, the reported results are: AudioCaps, 9 and 0; Clotho, 1 and 2. The paper also reports paired Wilcoxon signed-rank tests on per-audio 3, with 4 for audio-to-text and 5 for text-to-audio against the second-best baseline (Liu et al., 25 Apr 2026).
Ablations isolate the contribution of the hybrid loss on Clotho with HTSAT-tiny and RoBERTa-large, using frozen encoders. The pure contrastive setting 6 yields 7 for audio-to-text and 8 for text-to-audio, whereas the hybrid setting 9 yields 0 and 1, corresponding to gains of 2 and 3. The appendix further reports that replacing a linear projection with a Transformer projection and using the combined loss consistently yields the strongest performance across encoder choices.
Noise robustness is evaluated under additive MUSAN noise with SNR from 5 to 15. At SNR 10 for audio-to-text 4, the reported comparisons are: Clotho, 5 versus 6 for Microsoft-CLAP and 7 for LAION-CLAP; AudioCaps, 8 versus 9 and 0; ESC-50, 1 versus 2 and 3; FSD50K, 4 versus 5 and 6. The paper attributes these improvements to silence-aware chunking, attention pooling, and the hybrid loss’s reduced reliance on large negative sets.
Sensitivity to batch size is reported for Clotho with HTSAT-tiny and RoBERTa-large: batch size 4 gives audio-to-text and text-to-audio 7 of 8 and 9; batch size 8 gives 00 and 01; batch size 16 gives 02 and 03; batch size 32 gives 04 and 05; batch size 64 gives 06 and 07. The paper characterizes the model as relatively robust and states that the hybrid loss and pooling appear to mitigate the typical small-batch degradation of pure InfoNCE.
The limitations listed are specific. Performance depends on strong pretrained encoders, and smaller or weaker encoders may reduce gains. Extremely noisy, polyphonic scenes and overlapping events remain challenging because attention pooling may miss weak target events. Silence-based segmentation is characterized as a coarse heuristic, and difficult backgrounds may require more adaptive segmentation. For transfer to other multimodal retrieval tasks, the paper advises keeping the same 08 on inference-time embeddings, reserving cross-attention for training-only refinement, and increasing 09 or 10 modestly when batches are very small or labels are noisy while retaining 11 when moderate batch sizes are available.