Papers
Topics
Authors
Recent
Search
2000 character limit reached

Hybrid-NCE Loss for Audio-Text Retrieval

Updated 5 July 2026
  • 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, L1\mathcal{L}_1, 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 L1\mathcal{L}_1 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 NN matched audio–text pairs {(xia,xit)}i=1N\{(x_i^a, x_i^t)\}_{i=1}^N, with one shared-space audio embedding aia_i and one shared-space text embedding tit_i 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 L1\mathcal{L}_1 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 L1\mathcal{L}_1 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 2\ell_2-normalized:

a^i=aiai2,t^i=titi2.\hat{a}_i = \frac{a_i}{\|a_i\|_2}, \qquad \hat{t}_i = \frac{t_i}{\|t_i\|_2}.

The similarity function is cosine similarity:

L1\mathcal{L}_10

The contrastive component is symmetric InfoNCE with temperature L1\mathcal{L}_11:

L1\mathcal{L}_12

L1\mathcal{L}_13

L1\mathcal{L}_14

The cosine “directional” term is

L1\mathcal{L}_15

The L1\mathcal{L}_16 term is

L1\mathcal{L}_17

The total loss is a convex combination:

L1\mathcal{L}_18

The paper reports ablations on Clotho with HTSAT-tiny and RoBERTa-large, with frozen encoders, and identifies L1\mathcal{L}_19 as the best validation setting. A pure-contrastive baseline corresponds to NN0. The temperature NN1 is not specified in the paper; it is treated as a hyperparameter, with a suggested search range NN2 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 NN3, 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 NN4, dropout NN5, and residual connections:

NN6

The linear mapping into the shared space is

NN7

where NN8 and NN9.

During training, cross-modal attention is defined for shared-space sequences {(xia,xit)}i=1N\{(x_i^a, x_i^t)\}_{i=1}^N0 and {(xia,xit)}i=1N\{(x_i^a, x_i^t)\}_{i=1}^N1 by

{(xia,xit)}i=1N\{(x_i^a, x_i^t)\}_{i=1}^N2

{(xia,xit)}i=1N\{(x_i^a, x_i^t)\}_{i=1}^N3

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 {(xia,xit)}i=1N\{(x_i^a, x_i^t)\}_{i=1}^N4 and one text embedding {(xia,xit)}i=1N\{(x_i^a, x_i^t)\}_{i=1}^N5 per pair, both in {(xia,xit)}i=1N\{(x_i^a, x_i^t)\}_{i=1}^N6. 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 {(xia,xit)}i=1N\{(x_i^a, x_i^t)\}_{i=1}^N7, the directional term, and the {(xia,xit)}i=1N\{(x_i^a, x_i^t)\}_{i=1}^N8 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 {(xia,xit)}i=1N\{(x_i^a, x_i^t)\}_{i=1}^N9 pairs per batch, each anchor has only aia_i0 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 aia_i1 and small aia_i2, 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 aia_i3 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

aia_i4

the audio-to-text InfoNCE gradients satisfy

aia_i5

and, for aia_i6,

aia_i7

The paper further states that the directional term contributes

aia_i8

which yields a constant attractive force on positives after the chain rule through cosine similarity and aia_i9-normalization. The tit_i0 term adds an attractive subgradient on each embedding dimension by reducing tit_i1 and is described as less sensitive than tit_i2 to occasional large errors. Increasing tit_i3 smooths tit_i4 and reduces the magnitude of the InfoNCE gradients, but the paper states that tit_i5 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:

tit_i6

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 tit_i7 replaces tit_i8 to allow precomputation of audio embeddings. An additional training trick is reported: with probability tit_i9, the text-conditioned query is replaced by the learned L1\mathcal{L}_10 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, L1\mathcal{L}_11 and L1\mathcal{L}_12; Clotho, L1\mathcal{L}_13 and L1\mathcal{L}_14; ESC-50, L1\mathcal{L}_15 and L1\mathcal{L}_16; FSD50K, L1\mathcal{L}_17 and L1\mathcal{L}_18. For text-to-audio retrieval, the reported results are: AudioCaps, L1\mathcal{L}_19 and L1\mathcal{L}_10; Clotho, L1\mathcal{L}_11 and L1\mathcal{L}_12. The paper also reports paired Wilcoxon signed-rank tests on per-audio L1\mathcal{L}_13, with L1\mathcal{L}_14 for audio-to-text and L1\mathcal{L}_15 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 L1\mathcal{L}_16 yields L1\mathcal{L}_17 for audio-to-text and L1\mathcal{L}_18 for text-to-audio, whereas the hybrid setting L1\mathcal{L}_19 yields 2\ell_20 and 2\ell_21, corresponding to gains of 2\ell_22 and 2\ell_23. 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 2\ell_24, the reported comparisons are: Clotho, 2\ell_25 versus 2\ell_26 for Microsoft-CLAP and 2\ell_27 for LAION-CLAP; AudioCaps, 2\ell_28 versus 2\ell_29 and a^i=aiai2,t^i=titi2.\hat{a}_i = \frac{a_i}{\|a_i\|_2}, \qquad \hat{t}_i = \frac{t_i}{\|t_i\|_2}.0; ESC-50, a^i=aiai2,t^i=titi2.\hat{a}_i = \frac{a_i}{\|a_i\|_2}, \qquad \hat{t}_i = \frac{t_i}{\|t_i\|_2}.1 versus a^i=aiai2,t^i=titi2.\hat{a}_i = \frac{a_i}{\|a_i\|_2}, \qquad \hat{t}_i = \frac{t_i}{\|t_i\|_2}.2 and a^i=aiai2,t^i=titi2.\hat{a}_i = \frac{a_i}{\|a_i\|_2}, \qquad \hat{t}_i = \frac{t_i}{\|t_i\|_2}.3; FSD50K, a^i=aiai2,t^i=titi2.\hat{a}_i = \frac{a_i}{\|a_i\|_2}, \qquad \hat{t}_i = \frac{t_i}{\|t_i\|_2}.4 versus a^i=aiai2,t^i=titi2.\hat{a}_i = \frac{a_i}{\|a_i\|_2}, \qquad \hat{t}_i = \frac{t_i}{\|t_i\|_2}.5 and a^i=aiai2,t^i=titi2.\hat{a}_i = \frac{a_i}{\|a_i\|_2}, \qquad \hat{t}_i = \frac{t_i}{\|t_i\|_2}.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 a^i=aiai2,t^i=titi2.\hat{a}_i = \frac{a_i}{\|a_i\|_2}, \qquad \hat{t}_i = \frac{t_i}{\|t_i\|_2}.7 of a^i=aiai2,t^i=titi2.\hat{a}_i = \frac{a_i}{\|a_i\|_2}, \qquad \hat{t}_i = \frac{t_i}{\|t_i\|_2}.8 and a^i=aiai2,t^i=titi2.\hat{a}_i = \frac{a_i}{\|a_i\|_2}, \qquad \hat{t}_i = \frac{t_i}{\|t_i\|_2}.9; batch size 8 gives L1\mathcal{L}_100 and L1\mathcal{L}_101; batch size 16 gives L1\mathcal{L}_102 and L1\mathcal{L}_103; batch size 32 gives L1\mathcal{L}_104 and L1\mathcal{L}_105; batch size 64 gives L1\mathcal{L}_106 and L1\mathcal{L}_107. 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 L1\mathcal{L}_108 on inference-time embeddings, reserving cross-attention for training-only refinement, and increasing L1\mathcal{L}_109 or L1\mathcal{L}_110 modestly when batches are very small or labels are noisy while retaining L1\mathcal{L}_111 when moderate batch sizes are available.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Hybrid-NCE Loss.