feat: upgrade to SigLIP2 ViT-B/16 for semantic search

Replace OpenCLIP ViT-B/32 (512-d, ~78% recall) with SigLIP2 ViT-B/16
(768-d, ~84% recall) as the default embedding model for significantly
better image-text retrieval quality.

- New SigLIP2Embedder class with 384px input and SigLIP normalization
- ONNX export pipeline for SigLIP2 visual + textual encoders
- Migration 0010: resize embeddings.vector from 512 to 768 dimensions
- Config-driven model selection: "siglip2_vitb16" (default) or
  "openclip_vitb32" (legacy) — both models can coexist
- Content classifier follows the configured embedder family
- Existing embeddings cleared on migration; vision backfill regenerates

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-12 22:09:16 +02:00
parent c7dd03ade2
commit 94c07b1d0d
8 changed files with 222 additions and 27 deletions

View File

@@ -29,6 +29,8 @@ DOWNLOADS = []
EXPORTS = [
("embed/visual.onnx", "OpenCLIP ViT-B/32 visual encoder"),
("embed/textual.onnx", "OpenCLIP ViT-B/32 textual encoder"),
("embed_siglip2/visual.onnx", "SigLIP2 ViT-B/16 visual encoder"),
("embed_siglip2/textual.onnx", "SigLIP2 ViT-B/16 textual encoder"),
("detect/yolov8n.onnx", "YOLOv8n object detector"),
]
@@ -77,6 +79,7 @@ def bootstrap(models_dir: str | None = None):
from app.services.vision import export_models
export_models.export_openclip(base)
export_models.export_siglip2(base)
export_models.export_yolov8n(base)
except Exception as e:
logger.error(