| name | cv-weighted-embedding-blending |
| description | Ensemble predictions from heterogeneous vision-language models by blending their output embeddings with fixed scalar weights in embedding space |
Weighted Embedding Blending
Overview
When multiple models produce embeddings for the same input (e.g., CLIP k-NN, BLIP interrogator, fine-tuned ViT), blending their output embeddings with scalar weights is a simple yet effective ensemble. Unlike logit averaging, embedding blending works in the target space directly — each model's contribution is weighted and summed before submission.
Quick Start
import numpy as np
emb_knn = predict_knn(images)
emb_blip = predict_blip(images)
emb_vit = predict_vit(images)
w_knn, w_blip, w_vit = 0.60, 0.15, 0.25
blended = w_knn * emb_knn + w_blip * emb_blip + w_vit * emb_vit
Workflow
- Generate embeddings from each model independently
- Ensure all embeddings share the same dimensionality and target space
- L2-normalize each model's output before blending (prevents scale dominance)
- Apply fixed scalar weights that sum to 1.0
- Optionally tune weights on a validation set using grid search or Nelder-Mead
Key Decisions
- Weight tuning: start with equal weights, then grid search in 0.05 increments on validation cosine similarity
- Normalization: L2-normalize each model's output before blending to equalize scales
- Number of models: 2-4 diverse models; beyond 4, diminishing returns and weight search becomes expensive
- Diversity matters: models should differ in architecture or approach (k-NN vs. generative captioning vs. fine-tuned regression)
- vs. stacking: embedding blending is simpler and avoids overfitting when validation data is small
References