Near Miss Search
Search by meaning that keeps what nearly matched. Clear matches sit in front; the near misses wait softly behind them.
Needs: Image embeddings and a text embedder in the same space (CLIP's two towers, or any multimodal embedding API). The preview runs quantised CLIP ViT-B/32 (downloaded once, in the browser) in a worker and caches the photos' embeddings locally.
Customize
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| items | { id: string; src: string; alt?: string; embedding?: ArrayLike<number> }[] | required | The photos. An item without an embedding yet shows under Recent but isn't searched. |
| embed | (text: string) => Promise<ArrayLike<number>> | required | Text to vector, in the same space as the photos. Called for the whole query and for each of its parts, and cached. Keep it stable: a new function searches again. |
| query | string | – | Controlled query. Leave it out and the component keeps its own. |
| onQueryChange | (query: string) => void | – | Called as the query is typed or cleared. |
| placeholder | string | "Search your photos" | In the empty field, and its accessible name. |
| columns | number | 4 | Tiles per row. |
| recent | number | 12 | How many photos to show before anything is typed. |
| floor | number | – | A cosine the best photo can reach to count as plain evidence even when the ranking slopes gently. Model-specific: about 0.27 for CLIP ViT-B/32. Leave it out to decide on the gap alone. |
| onOpen | (item: NearMissItem) => void | – | Called when a match or a recent photo is opened. |
| className | string | "" | Extra class on the root. |
| style | CSSProperties | – | Inline style on the root. Set --mlui-gap for the space between tiles. |