Sliced Wasserstein嵌入结合HNSW实现画作色彩检索加速
Sliced Wasserstein embeddings + HNSW for color-scheme search over 48k paintings [P]
提供从距离度量到索引构建的完整可复现工程方案,参数与基准数据详实,适合做相似性搜索优化的开发者参考。
Palette Atlas (https://itzik123.github.io/PaletteAtlas/) searches public-domain paintings by color scheme. Each image is reduced to 128 colors of equal weight, so the natural distance is the Earth Mover's Distance, which is too slow for nearest-neighbor search over 48,695 items (about 6 ms per pair).
Palette Atlas (https://itzik123.github.io/PaletteAtlas/) 按配色方案搜索公有领域的绘画。每幅图像被缩减为等权重的 128 种颜色,因此自然距离是地球移动距离(Earth Mover's Distance),对于在 48,695 个项目中进行最近邻搜索来说太慢了(每对约 6 毫秒)。
The embedding: project the colors (OKLab) onto 8 directions on a Fibonacci hemisphere, sort, and average into 16 quantiles. L1 between two vectors is the 1D W1 averaged over the directions, a lower bound on the true W1.
嵌入:将颜色(OKLab)投影到斐波那契半球上的 8 个方向上,排序并平均为 16 个分位数。两个向量之间的 L1 距离是沿各方向平均的 1D W1,它是真实 W1 的下界。
Against the exact EMD on 240 queries (overlap with the exact top 10, and how much farther the top 10 lie):
针对 240 个查询的精确 EMD 结果(与精确前 10 名的重叠情况,以及前 10 名偏离的程度):
- sliced 8x16, L1: 78%, 1.8%
- sliced 8x16, L2: 69%, 3.4%
- soft color histogram, Hellinger: 45%, 13.5%
- mean color: 3%, 161%
The index is HNSW written from scratch (M=16, efConstruction=200): recall@10 of 1.000 at ef=32, 0.25 ms against 14 ms for brute force. The vectors' intrinsic dimension is about 11, so the hierarchy still helps (see Munyampirwa et al. 2025 on when it doesn't). One change from the paper: the top layer holds 8 k-means landmarks instead of randomly drawn nodes. The search cost is the same (2,558 vs 2,556 distance computations on average), and the top layer becomes one typical painting per color family.
索引是手写实现的 HNSW(M=16, efConstruction=200):在 ef=32 时 recall@10 为 1.000,耗时 0.25 毫秒,而暴力搜索需 14 毫秒。向量的内在维度约为 11,因此层级结构仍然有效(参见 Munyampirwa 等人 2025 年关于何时无效的研究)。与论文相比的一个改动是:顶层包含 8 个 k-means 地标,而不是随机抽取的节点。搜索成本相同(平均距离计算次数分别为 2,558 和 2,556),且顶层变为每个颜色家族对应一幅典型画作。
Write-up: https://github.com/itzik123/PaletteAtlas/blob/main/docs/searching-by-color.md
说明文档:https://github.com/itzik123/PaletteAtlas/blob/main/docs/searching-by-color.md
Code: https://github.com/itzik123/PaletteAtlas
代码:https://github.com/itzik123/PaletteAtlas
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力