Spaces:
Running
Running
|
Download README.md from j4inam/reflections-encoder: direct link, hf CLI and curl.
- Browser
- Download file 2.63 kB
-
https://huggingface.co/spaces/j4inam/reflections-encoder/resolve/main/README.md
- Command line
-
hf download hf://spaces/j4inam/reflections-encoder/README.md
-
curl -L -o README.md https://huggingface.co/spaces/j4inam/reflections-encoder/resolve/main/README.md
2.63 kB
| title: Reflections SigLIP Encoder | |
| emoji: π | |
| colorFrom: indigo | |
| colorTo: blue | |
| sdk: docker | |
| app_port: 7860 | |
| pinned: false | |
| # Reflections SigLIP text-query encoder | |
| Embeds a natural-language search query into a 768-d L2-normalized vector using the | |
| SigLIP2 text tower (`onnx-community/siglip2-base-patch16-256-ONNX`) β the same | |
| checkpoint the photo image embeddings use, so query and image vectors share one | |
| cosine space. The model is baked into the Docker image at build time and stays | |
| resident in RAM, so requests never pay a download or load cost. | |
| ## How it fits in | |
| ``` | |
| Browser ββ/gallery?q=β¦βββΆ Vercel web app | |
| β POST /encode (Bearer $SIGLIP_ENCODER_TOKEN) | |
| βΌ | |
| this Space βββΆ {vector:[768]} (model resident in RAM) | |
| β | |
| Vercel cosine-ranks that vector against image embeddings in Neon (pgvector) | |
| βΌ | |
| ranked photos | |
| Deploy: push to main (encoder/**) ββΆ GitHub Actions β(OIDC, no stored token)ββΆ hf upload ββΆ Space rebuilds | |
| Warm: GitHub Actions cron βevery 6hββΆ GET /health (keeps the Space under HF's 48h sleep) | |
| ``` | |
| ## API | |
| - `POST /encode` β `{ "query": "..." }` β `{ "vector": [768 floats] }`. Requires | |
| `Authorization: Bearer $SIGLIP_ENCODER_TOKEN`. | |
| - `GET /health` β open liveness check for the keep-warm cron. | |
| ## Operating | |
| - **Secret:** set `SIGLIP_ENCODER_TOKEN` on the Space; it must match the web app's | |
| value (the web app sends it as the bearer token). | |
| - **Deploy:** automatic on push to `main` touching `encoder/**`, via Trusted | |
| Publishing (OIDC) β no HF token is stored anywhere. The tests run first and | |
| gate the upload; a pull request touching `encoder/**` runs them too. | |
| - **Model:** pinned to one Hub revision (`SIGLIP_MODEL_REVISION`, the same one | |
| `ingest/embedder.py` pins), so a re-export on the Hub can't move the text | |
| tower away from the image tower. Downloaded once during the image build and | |
| baked in; the image then | |
| sets `HF_HUB_OFFLINE=1`, so container starts (including post-sleep wakes) load | |
| it from local disk and never ask the Hub. Startup runs one real inference, so | |
| the first request after a wake is warm. | |
| - **Threads:** ONNX Runtime uses `ORT_INTRA_OP_THREADS` intra-op threads | |
| (default 2, the Space's vCPU count). | |
| - **Dependencies:** `requirements.txt` is what the image installs; | |
| `requirements-dev.txt` adds the test tools. Locally: | |
| `python -m venv .venv && .venv/bin/pip install -r requirements-dev.txt`, then | |
| `.venv/bin/pytest`. | |