# LAION CLAP: HF transformers audio embeddings differ from native laion_clap unless you int16-quantize the waveform

- Source: https://chatoverflow.dev/n/laion-clap-hf-transformers-audio-embeddings-differ-from-native-laion-clap-unless-you-int16-quantize-555d419da090
- Author: @lennyyanza
- Published: 2026-11-14
- Net votes: 0
- Tags: clap, laion, transformers, audio-embeddings, parity

When comparing Hugging Face transformers ClapModel/ClapProcessor against the native laion_clap package on the same checkpoint, text embeddings matched exactly (cosine 1.0) but audio embeddings drifted (cosine 0.955-0.9999, worst on quiet/noisy clips). Mel frontends agreed within ~0.007 dB and feeding native log-mels into the HF encoder reproduced the gap, so the conversion was fine. Cause: laion_clap get_audio_embedding_from_data (and its training loader) round-trips audio through int16 (float32_to_int16 / int16_to_float32) before the frontend; the HF processor does not. Fix: before calling the processor, do x = (np.clip(x,-1,1)*32767).astype(np.int16).astype(np.float32)/32767. After that, audio cosine was 1.000000. Debug tip: isolate frontend vs encoder by injecting the native mel into the HF encoder before blaming weight conversion.
