Spaces:
Running
Running
deploy: sync encoder from 26315a9
Browse files
README.md
CHANGED
|
@@ -10,12 +10,39 @@ pinned: false
|
|
| 10 |
|
| 11 |
# Reflections SigLIP text-query encoder
|
| 12 |
|
| 13 |
-
Embeds a natural-language query into a 768-d L2-normalized vector using the
|
| 14 |
-
SigLIP2 text tower (`onnx-community/siglip2-base-patch16-256-ONNX`)
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
- `POST /encode` β `{ "query": "..." }` β `{ "vector": [768 floats] }`. Requires
|
| 18 |
`Authorization: Bearer $SIGLIP_ENCODER_TOKEN`.
|
| 19 |
-
- `GET /health` β liveness for the keep-warm cron.
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Reflections SigLIP text-query encoder
|
| 12 |
|
| 13 |
+
Embeds a natural-language search query into a 768-d L2-normalized vector using the
|
| 14 |
+
SigLIP2 text tower (`onnx-community/siglip2-base-patch16-256-ONNX`) β the same
|
| 15 |
+
checkpoint the photo image embeddings use, so query and image vectors share one
|
| 16 |
+
cosine space. The model is baked into the Docker image at build time and stays
|
| 17 |
+
resident in RAM, so requests never pay a download or load cost.
|
| 18 |
+
|
| 19 |
+
## How it fits in
|
| 20 |
+
|
| 21 |
+
```
|
| 22 |
+
Browser ββ/gallery?q=β¦βββΆ Vercel web app
|
| 23 |
+
β POST /encode (Bearer $SIGLIP_ENCODER_TOKEN)
|
| 24 |
+
βΌ
|
| 25 |
+
this Space βββΆ {vector:[768]} (model resident in RAM)
|
| 26 |
+
β
|
| 27 |
+
Vercel cosine-ranks that vector against image embeddings in Neon (pgvector)
|
| 28 |
+
βΌ
|
| 29 |
+
ranked photos
|
| 30 |
+
|
| 31 |
+
Deploy: push to main (encoder/**) ββΆ GitHub Actions β(OIDC, no stored token)ββΆ hf upload ββΆ Space rebuilds
|
| 32 |
+
Warm: GitHub Actions cron βevery 6hββΆ GET /health (keeps the Space under HF's 48h sleep)
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
## API
|
| 36 |
|
| 37 |
- `POST /encode` β `{ "query": "..." }` β `{ "vector": [768 floats] }`. Requires
|
| 38 |
`Authorization: Bearer $SIGLIP_ENCODER_TOKEN`.
|
| 39 |
+
- `GET /health` β open liveness check for the keep-warm cron.
|
| 40 |
+
|
| 41 |
+
## Operating
|
| 42 |
|
| 43 |
+
- **Secret:** set `SIGLIP_ENCODER_TOKEN` on the Space; it must match the web app's
|
| 44 |
+
value (the web app sends it as the bearer token).
|
| 45 |
+
- **Deploy:** automatic on push to `main` touching `encoder/**`, via Trusted
|
| 46 |
+
Publishing (OIDC) β no HF token is stored anywhere.
|
| 47 |
+
- **Model:** downloaded once during the image build and baked in; container
|
| 48 |
+
starts (including post-sleep wakes) load it from local disk, never the network.
|