696c17fe29
Direct port of ImageRepo's siglip.py. Lazy torch/transformers import so the web container can import the module (for enqueue logic) without the torch cost. EMBED_DIM=1152 asserted against the schema's Vector(1152) columns. Real inference runs in the local integration suite. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
31 lines
801 B
Python
31 lines
801 B
Python
"""Embedder unit tests. The SigLIP model is a multi-GB download not present
|
|
in CI, so these test only the import-safety contract and the singleton.
|
|
Real embedding runs in the local integration suite.
|
|
"""
|
|
|
|
from backend.app.services.ml.embedder import (
|
|
EMBED_DIM,
|
|
MODEL_VERSION,
|
|
Embedder,
|
|
get_embedder,
|
|
)
|
|
|
|
|
|
def test_embed_dim_matches_schema():
|
|
# image_record.siglip_embedding and tag_reference_embedding.embedding
|
|
# are both Vector(1152). This must stay in sync.
|
|
assert EMBED_DIM == 1152
|
|
|
|
|
|
def test_model_version_default():
|
|
assert MODEL_VERSION == "siglip-so400m-patch14-384"
|
|
|
|
|
|
def test_get_embedder_singleton():
|
|
assert get_embedder() is get_embedder()
|
|
|
|
|
|
def test_not_loaded_until_called():
|
|
e = Embedder()
|
|
assert e._model is None # not loaded until .load()
|