Download README.md from ajay-narayanan/NaviSense-Spatial-Caption-Router-MobileCLIP-S0: direct link, hf CLI and curl.
- Browser
- Download file 5.41 kB
-
https://huggingface.co/ajay-narayanan/NaviSense-Spatial-Caption-Router-MobileCLIP-S0/resolve/main/README.md
- Command line
-
hf download hf://ajay-narayanan/NaviSense-Spatial-Caption-Router-MobileCLIP-S0/README.md
-
curl -L -o README.md https://huggingface.co/ajay-narayanan/NaviSense-Spatial-Caption-Router-MobileCLIP-S0/resolve/main/README.md
license: apple-amlr
library_name: pytorch
base_model: apple/MobileCLIP-S0
datasets:
- ajay-narayanan/NaviSense-Spatial-Caption-Router
language:
- en
tags:
- model-routing
- spatial-captioning
- accessibility
- mobileclip
- custom-code
NaviSense Spatial Caption Router · MobileCLIP-S0
Predicts the expected location-caption quality of LFM2.5-VL-450M and GPT-4o-mini from an image and requested object label, before either captioner runs. The router selects a backend; caption generation is performed separately.
This release is the selected original small spatial router, not the later larger blend or ranking-loss experiments.
Architecture and training
- Frozen MobileCLIP-S0 image/text encoders; one 256×256 image pass supplies a global vector and 64 local vectors, each 512-dimensional.
- Whole-image EXIF-upright RGB letterboxing, bilinear resize, padding value 127 and division by 255. It uses scene context rather than the detector router's center crop.
- Fixed object-conditioned pooling at temperature 5. Global/text/local interactions and nine spatial summaries form 2,569 features.
- One 2569 → 64 → 2 head with ReLU and training dropout 0.2: 164,610 learned parameters, plus four output-correction constants.
- Two sigmoid outputs after positive affine correction, ordered
[lfm_iphone, gpt4o_mini]. These are numeric expected judge scores/5, not success probabilities.
The head fits 8,000 training pairs with MSE, AdamW, learning rate 0.001, weight decay 0.05, batch size 256 and 35 epochs, seed 20261126. Of 2,000 validation pairs, 1,011 fit output correction and 989 support model selection. Test and reserve pairs receive no gradient fitting. The encoder checkpoint and code revisions are pinned in config.json.
Routing policy
Choose the backend maximizing:
predicted_score_over_5 − 0.125 × estimated_latency_seconds
Each backend starts at its 8k-training mean latency. Estimates combine its last eight selected calls with eight training-mean prior observations. Update only the chosen backend after its call. No current unchosen latency, generated caption, reference or judge record is a routing input.
Usage
Download the repository and install its requirements.txt. The bundle contains the frozen encoder weights, trained head, correction, configuration and standalone inference code; it does not contain either captioner.
import sys
from huggingface_hub import snapshot_download
from PIL import Image
folder = snapshot_download(
"ajay-narayanan/NaviSense-Spatial-Caption-Router-MobileCLIP-S0", token=True
)
sys.path.insert(0, folder)
from spatial_caption_router import SpatialCaptionRouter
router = SpatialCaptionRouter.from_pretrained(folder)
scores = router([Image.open("scene.jpg")], ["mug"])[0].tolist()
policy = router.new_policy() # retain this instance across requests
backend = policy.choose(scores)
print(router.config["backends"][backend])
# After calling that captioner: policy.observe(backend, measured_latency_ms)
Authenticate when accessing a private repository. encode_images and encode_queries expose reusable features; object-text embeddings can be cached.
Existing 5k-test benchmark
At λ = 0.125, using stored backend timings:
| Policy | Mean score/5 (%) | Mean backend ms | GPT calls | Utility |
|---|---|---|---|---|
| Always LFM | 73.404 | 464.8 | 0% | 0.675941 |
| Always GPT-4o-mini | 79.384 | 1261.4 | 100% | 0.636163 |
| Uniform random, 50/50 | 76.394 | 863.0 | 49.98% | 0.656066 |
| Training-average prior | 73.404 | 464.8 | 0% | 0.675941 |
| Object-label prior | 74.972 | 606.7 | 18.08% | 0.673883 |
| Cosine threshold | 79.992 | 992.0 | 65.80% | 0.675916 |
| NaviSense router | 77.392 | 702.6 | 30.26% | 0.686100 |
Random results average 1,000 independent fair-coin trials. The privileged hindsight upper bound is 0.818180 utility; it uses both true rewards and current costs and cannot be deployed. Quality is model-judge reward, not binary or human accuracy. Full metrics and provenance are in metadata/benchmark.json.
Verification, deployment and limits
The complete FP32 safetensors file is approximately 216 MB; the separate head is approximately 0.659 MB. Frozen encoders account for most storage. CoreML image and pooling/head exports are included separately; full Swift/text-encoder integration and actual iPhone latency remain unverified.
Reloaded weights reproduce all 5,000 cached-feature routing decisions and the benchmark above. Tensor-score error against stored predictions is at most 1.79e-7. Four image inputs give identical results before and after saving; freshly encoded CPU features differ numerically from the historical CUDA cache. Benchmark reproduction on cached features does not establish identical pixel-to-score behavior on every device.
Backend timings exclude router inference. Historical development/test inspection, reference errors and judge mistakes limit the evidence. No real-world blind-user retrieval success or end-to-end phone performance is established.
The bundled MobileCLIP weights and derivative are subject to the Apple Machine Learning Research Model License, included in LICENSE. This is a research release under those upstream terms; see the license before use.
