Replies: 1 comment 1 reply
|
I think we can actually instead of add documentation on how to enable this as well as a guide. We could have the configs on the same HMA folder, but wouldn't have it as part of the docker compose or hooked up to anything other than reference on a guide as that will also affect local development. From your own writeup adding CLIP increases the deployment needs given how heavy and slow CLIP calculations are, and the image is also way bigger. This helps adding visibility and guidance for anyone interested in exploring CLIP to know how to do it. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Related: UMass ROOST evaluation, UMass
tx-extension-clip(CLIPFloatSignal), Coop HMA docs (docs/integrations/hma.md)Summary
We propose enabling CLIP-based semantic image matching inside Coop’s existing HMA service, alongside today’s PDQ (photos) and VideoMD5 (videos). Inspiration and a working reference stack come from the UMass ROOST evaluation: CLIP embeddings are stored in HMA banks and used to match new content the same way PDQ banks work today.
This is not a new Coop microservice. HMA already hashes at ingest (
/h/hash), matches against banks (/m/lookup), and powersIMAGE_SIMILARITY_MATCH/IMAGE_SIMILARITY_DOES_NOT_MATCH. Coop’s server path is largely hash-type agnostic—new signal keys such asclip_floatflow through if HMA emits them. The main work is HMA packaging, product semantics (who uses CLIP, how rules treat it, thresholds, seeding), and ops cost (torch).Background
CLIP (via
CLIPFloatSignal/clip_float) embeds semantic similarity (cosine distance ~0.0–1.0 in the UMass extension). It complements PDQ; it does not replace verified hash-sharing programs.Decided: HMA packaging
We will extend the published Coop HMA image (
ghcr.io/facebook/threatexchange/hma:1.1.6today), install a pinned commit of the UMasstx-extension-clipfork, and registerCLIPFloatSignalnext toPdqSignalandVideoMD5Signalinhma/omm_config.py.Implications:
CLIP_DISABLE_HNSW_INDEX(exact flat search vs default HNSW)./m/lookup_threshold//m/lookup_topkpatches. Prefer Coop-side use of/m/lookupdistances unless those APIs prove necessary later.Proposed architecture (high level)
CLIP stays inside the existing HMA container. Coop continues to own bank metadata in Postgres (
hash_banks) and rule wiring.Strong lean (pending confirmation below): do not send
clip/clip_floatin NCMECoriginalFileHashpayloads. NCMEC paths should remain PDQ/MD5-style.Questions for the team
1. Who is CLIP for? (product scope)
Not every org may want or need semantic matching, and CLIP has real infra cost (larger HMA image, more RAM, slower hashing than PDQ).
PDQ answers “is this nearly the same bytes/pixels as something we already know?” CLIP answers “is this semantically like something in our bank?” (e.g. another photo from the same series, heavy crop/filter, different shot of the same subject). Many orgs may only need NCMEC/exchange PDQ banks and never build a semantic corpus.
Possible shapes:
Separately: once the HMA image includes CLIP, hashing may run centrally for everyone. Even then we may want product controls—on for every org, opt-in per org, or opt-in per bank—so orgs that only use NCMEC PDQ banks are not surprised by semantic matches or extra latency on ingest.
Please weigh in: who should get CLIP in MVP, and should it be opt-in?
2. How should rules behave when an image has both
pdqandclip_float?Once both signals are enabled, a photo hashed at ingest will typically carry both
pdqandclip_float. TodayIMAGE_SIMILARITY_MATCHiterates all hashes on the image and treats any bank hit as a match (OR across types).That is fine if operators understand “bank match = any algorithm.” It is risky if an existing “known hash” routing rule suddenly also fires on a loose CLIP hit against the same bank. Example: bank seeded with a few images for PDQ near-dupe; CLIP later matches a vaguely similar but unrelated image and enqueues to a high-severity queue.
Options:
IMAGE_SIMILARITY_*PDQ-oriented; add a semantic match signal)Please weigh in: OR vs picker vs separate signal?
3. Where should match distance thresholds live?
For CLIP, threshold is the product. Too loose → false positives; too tight → misses. PDQ is relatively forgiving to ship with HMA’s defaults; CLIP needs an explicit place for operators (or us) to set “how similar is similar enough?”
Lean for discussion: per hash bank (banks are often purpose-built: “strict PDQ / NCMEC-style bank” vs “semantic series bank”). Threshold lives with the bank you curated.
Alternatives:
HMA_DISTANCE_THRESHOLDS) — fast for a spike; one knob for the whole deployment; weak if orgs need different strictness.Extension default for
clip_floatdistance is on the order of 0.10 (UMass config); real threat corpora need calibration on Roost/customer data, not celebrity face demos.Please weigh in: per-bank vs per-rule vs env-only for MVP? (We lean per-bank.)
4. How should operators seed custom semantic banks?
A bank only matches after media (or hashes) are indexed into it. Coop can create banks today; adding media into a bank from Coop is not wired (server helper
addContentToBankexists; GraphQL/UI do not). Operators can use the HMA UI locally by findingCOOP_<ORGID>_…and uploading there.Without a seeding path, CLIP can be “on” in HMA but unused for custom semantic banks. Exchange sync fills NCMEC-style banks with PDQ hashes—it does not build your CLIP corpus.
Note: HMA must be able to fetch the URL (same constraint as ingest hashing—
localhostfrom inside Docker will fail).Please weigh in: required Coop ingest for MVP, or is HMA UI enough to start?
References
docs/integrations/hma.mdAll reactions