Engineering4 min read
ReID embeddings and vector databases
Store, index and query normalized person-appearance embeddings without losing model compatibility, privacy boundaries or review context.
Run an unthresholded nearest-neighbour query against a non-empty candidate set and the index will return something—even when the correct person is absent. “Nearest” means closest among the vectors available to that search. It does not mean correct, authorised or safe to publish.
That is the central design problem for ReID embeddings and vector databases. You need the index, but you also need compatibility metadata, project isolation, a locally validated decision rule and enough context for a reviewer to reject the nearest result.
The current PolyReID embedding API contract documents 768 float32 values normalized to L2 norm 1. One raw vector therefore occupies 3,072 bytes before database metadata and index overhead.
Start with what “close” means
For vectors (x) and (y) with unit L2 norm, cosine similarity equals their inner product:
cosine(x, y) = (x · y) / (||x|| ||y||) = x · y
Higher similarity means the model places the crops closer in its learned appearance space. It is not a calibrated probability that the people are the same. If the correct person is missing from the gallery, the highest-scoring candidate is still only the least distant available candidate.
Metadata you must keep
Store at least:
modeland immutablemodel_revision;preprocess_version;- your project and source-object identifiers;
- creation and expiry timestamps;
- the lawful-purpose and access boundary needed by your application.
Never mix vectors from incompatible model or preprocessing revisions in one search space. Picture a gallery whose first half was embedded before a preprocessing change and second half after it: every ranking now confounds appearance with pipeline version. Isolate revisions, re-embed the authorised gallery and recalibrate before comparing them.
Choose the index only after measuring the gallery
Exact search compares the query with every vector. It is straightforward and often sufficient for small galleries. Approximate nearest-neighbour indexes usually trade some retrieval recall and additional tuning for lower query latency at larger scale. Memory depends on the index family and configuration: a graph index can use more than flat storage, while quantized indexes can use less.
Benchmark with realistic collection sizes and query patterns before choosing HNSW, IVF or another structure. Index parameters influence retrieval recall; they do not improve the underlying model. The FAISS project is one established library for dense-vector similarity search, while managed vector databases provide operational features around similar index families.
Keep the search inside the promised boundary
Use a separate logical collection or enforced tenant filter for each customer, project or event. If a participant searches one competition, the query must not silently expand into every vector the organisation has ever created.
Apply the same isolation to backups, analytics and deletion jobs. Store no source filename or image bytes in usage logs. If the application needs a preview, resolve it through the customer’s authorised object ID after retrieval.
Thresholds need local validation
An unthresholded nearest-neighbour search returns a top result whenever its candidate set is non-empty. That result can still be a bad match. Build a representative validation set, then choose review bands around the observed false-match and missed-match trade-off.
A useful interface exposes:
- the ranked candidate list, not only the first result;
- source context for a reviewer;
- an explicit reject action;
- a way to correct a merge or split;
- model and threshold versions for audit.
Revalidate after meaningful changes to cameras, crops, lighting, clothing or population. Domain drift can matter even when the API model has not changed.
For a repeatable validation method, continue with similarity-threshold calibration for Person ReID and the guide to evaluating domain shift.
Retention and deletion
Vector deletion must propagate to the primary index, replicas and any application cache. Treat expiry as an access-control rule first: deny access at the deadline, then let a retryable purge perform physical cleanup.
The API integration guide describes the currently documented idempotency cache and optional vector-retention mode. The complete Person ReID guide places the index inside the wider human-reviewed system.