找素材时,我经常记得画面,却不记得文件名。
比如一张海边日落的照片,或者一段从飞机上拍摄城市的视频。文件夹可以按时间和项目分类,但很难覆盖这些画面内容。
我想试着把找素材变成:输入一句描述,直接从本地照片和视频中检索相关内容。因此,我做了 ClipSeek Open,一款基于 EmbeddingGemma 2 的开源桌面应用,支持文字搜索和以图搜图。
这篇文章主要聊几个实际问题:模型能做什么、下载多大、跑起来要多少资源,以及借助 AI 开发时,怎样确认代码真的符合预期。
图 1:真实应用的素材库界面。演示素材包含 NASA 图像和生成的太空插图。
一、先认识一下 EmbeddingGemma 2
EmbeddingGemma 2 是 Google DeepMind 开源的多模态嵌入模型。它能把文字、图片、视频和音频映射到同一个向量空间,适合搜索、相似内容匹配和聚类。它的输出是一组表示内容特征的数字,应用可以据此比较不同输入的相关性。
根据模型说明,完整模型约有 7.4 亿参数,包括约 2.7 亿参数的文本模型、1.7 亿参数的视觉编码器和 3 亿参数的音频编码器。各模态编码器可以按需加载,支持 100 多种语言,原生输出 768 维向量,文本上下文为 8,192 tokens。
对照片和视频搜索来说,有用的是:一句话、一张图片和一段视频,可以编码成能够互相比较的向量。 ClipSeek Open 使用文本和视觉能力,目前没有提供音频检索功能。
接入时,我采用 ONNX Community 提供的 ONNX 模型文件。按项目固定下载清单计算,包含文本与视觉模型、分词器及配置文件,各精度所需下载量如下:
这里使用十进制 MB/GB,统计范围不包含音频模型、应用安装包和 CoreML 编译缓存。完整 7.4 亿参数模型的全部文件大小,与应用按需下载的大小是两回事。
模型越小,也不意味着在每种硬件和推理后端上都越快。后面 Q8 的 GPU 测试就遇到了这个问题。
二、搜索流程其实很直接
首次导入时,程序为素材计算向量并保存索引。用户搜索时,只需要编码查询,再检索相近的素材向量。
图 2:导入时编码素材,搜索时编码查询。两条路径使用一致的模型与精度。
例如,输入“海边的日落,天空是橙色的”,程序会将描述转成向量,与已有照片和视频的向量比较,再返回相近的结果。以图搜图沿用同一条检索路径,只是查询输入换成了参考图片。
底层使用 SQLite 保存路径、文件夹和标签,Qdrant Edge 保存向量索引;Tauri、Rust 和 React 负责桌面应用、导入队列与界面。素材采用引用模式,不额外复制原文件。
视频有一个需要说清楚的边界:当前应用为每个完整视频保存一个向量,返回完整视频,不定位到某一秒。 模型输入仍需按规范解码和采样画面,但没有建立持久化的逐帧搜索索引。
应用目前只接收时长已知、最长 32 秒的视频。这是当前实现明确执行并验证的导入限制,不能直接当作模型在所有使用方式下的统一上限。
图 3:使用自然语言搜索行星与星云相关画面。相似度用于结果排序,并不等于内容匹配的概率。
三、实际跑起来有多快,占多少内存?
先给出本地测试结果。测试机为 Apple M6、32 GiB 内存、macOS 27.0.1,使用 Q8 和应用的生产编码器;每种操作执行三次,排除首次请求,下面是后两次的热运行结果:
在这组输入上,CoreML 的照片编码约快 2.7 倍,视频编码约快 2.2 倍。它们是编码耗时,不是完整导入耗时,也不是搜索响应时间;文件读取、预处理、缩略图和索引写入仍有开销。
内存来自包含文字查询、照片和视频的混合编码测试:
RSS 是进程驻留内存指标,footprint 是另一套系统内存记账指标。两者都不能直接当作整台电脑的总内存需求,部分外部服务和设备缓存也不在进程指标里。因此,准确的结论是:这次 CoreML 测试更快、footprint 更低,但 RSS 略高。 不能简单宣传为“内存降低了几倍”。
这也解释了为什么约 542 MB 的 Q8 下载量,不代表运行时只占用 542 MB 内存:推理还需要中间张量、运行时和缓存。
实际使用建议预留 16 GB 内存、SSD 和 10 GB 可用空间,素材增多后还需要额外的缩略图与索引空间。16 GB 是当前推荐配置,上述性能测试使用的是 32 GiB 设备,低内存设备尚未充分验证。
当前 Apple Silicon 在 macOS 15+ 上优先使用 CoreML CPU/GPU,失败时保留 Metal/CPU 回退;Intel Mac 和 Windows 使用 CPU。这里没有宣称 ANE 加速,也没有将这组性能外推到 Intel 或 Windows。完整测试口径见项目推理说明。
四、一个实际的坑:启用 GPU,Q8 反而更慢
接入 GPU 时,我原本以为换个推理后端就能提速,实际测试却发现:同样的 Q8 模型和图片,在 Metal 上处理得比 CPU 更慢。
当时还不能确定是模型推理慢,还是应用里的其他步骤拖慢了速度。所以我先把视觉编码器单独拿出来,用同一张图片分别在 CPU 和 GPU 上运行。每次先运行一遍完成预热,再比较后续耗时,避免把模型加载和首次编译算进去。
结果仍然是 GPU 更慢。这样就能把排查范围缩小到模型执行这一段,不用继续在界面和导入队列里找原因。
接着,我对 Q8 模型中的矩阵计算做了单独实验。保留原本的量化权重数值,将相关计算改走浮点矩阵运算后,视觉编码明显变快了。这说明问题与当前运行时处理 Q8 量化矩阵的方式有关。Q8 文件更小,但在这条 GPU 路径上并没有获得速度优势;具体是哪一处底层实现造成的,还没有进一步确定。
之后我又测试了原生 CoreML。它在这台开发机上的照片和视频编码都更快,前一节列出的就是这次比较结果。不过,正式切换前,还需要确认它算出的向量与原来一致。
检查方法是:让两个后端处理相同输入,再比较输出向量。Q4、Q8、FP32 分别与各自精度的 CPU 结果比较,要求余弦相似度大于 0.9999,并补测长文本和完整的 32 秒动态视频。
这些检查通过后,应用才在符合条件的 Apple Silicon 设备上优先使用 CoreML,同时保留 Metal 和 CPU 回退。Q8 仍然是默认选项。
五、用 AI 开发,我觉得有用的几个习惯
AI 可以很快写出代码,但开发者仍然需要判断:实现是否符合需求,修改是否影响了原有功能。这个项目做下来,我觉得下面几个习惯比较有用。
1. 先写设计,再让 AI 写代码。
涉及多个模块的功能,先用一份简短文档讲清楚目标、实现思路、边界和验收方式。比如视频导入,要提前确定时长限制、索引单位,以及不支持的文件该如何处理。确认设计后再实现,能减少 AI 自行补充需求带来的返工。小改动用几句话说明即可,不必每次都写长文档。
2. 把代码规范变成自动检查。
在项目中写明目录职责、命名规则和模块边界,让 AI 沿用已有结构。同时配置格式化、Lint、类型检查和构建检查,在提交前执行。文档负责说明规则,工具负责检查能自动判断的部分;至于实现是否合理,仍要看代码。
3. 单元测试验证逻辑,E2E 验证完整流程。
单元测试适合检查明确的规则,例如“32 秒视频允许导入,33 秒拒绝”。E2E 则实际启动应用,验证“创建素材库 → 导入 → 搜索 → 重启后恢复”这样的用户操作。两者配合,才能同时检查局部逻辑和模块之间的连接。
测试也需要审查。尤其是让 AI 修复失败时,要确认它修改了实现,而不是删除断言、跳过测试,或放宽原本的验收标准。
4. 小步修改,验证后及时提交 Git。
一次尽量完成一个明确的改动,通过相关检查后就提交,并写清楚修改目的。继续下一步前,先保留一个可以回退的版本。这样出现问题时,更容易定位是哪次修改引入的,也方便比较 AI 修改前后的行为。
5. 提交前,自己看一遍 diff。
重点检查有没有超出任务范围的修改、重复实现、意外删除,以及密钥、个人路径和测试产物。涉及模型优化,还要与原始输出比较精度和耗时;涉及打包,就实际运行安装包。AI 的完成说明可以帮助梳理结果,但不能代替这些验证。
这些实践的作用,是让每次修改都有明确依据、可核对的结果和可恢复的版本。AI 负责加快实现,开发者负责确认方向和验收。
体验与源码
ClipSeek Open 提供 macOS Apple Silicon、Intel 和 Windows x64 安装包。首次使用需要联网下载模型,之后的素材处理在本地进行;macOS 需 14+。
欢迎大家来体验、star、和提交issue。
本文由 AI图鉴自动抓取并翻译,版权归原作者所有;如需查看原文请点下方链接。
When looking for media, I often remember the scene but not the filename.
Like a photo of a seaside sunset, or a video of a city taken from an airplane. Folders can be organized by date and project, but that doesn't cover the content of these scenes very well.
I wanted to try making media retrieval work like this: enter a description, and directly search locally stored photos and videos for relevant content. So I built ClipSeek Open, an open-source desktop app based on EmbeddingGemma 2, supporting text search and reverse image search.
This article mainly discusses several practical questions: what the model can do, how large the downloads are, how much resources are needed to run it, and how to verify that AI-generated code actually behaves as expected.
Figure 1: Material library UI in a real application. Demo content includes NASA images and generated space illustrations.
**1. Getting to Know EmbeddingGemma 2**
EmbeddingGemma 2 is an open-source multimodal embedding model from Google DeepMind. It maps text, images, video, and audio into the same vector space, suitable for search, similar-content matching, and clustering. Its output is a set of numbers representing content features, which applications can use to compare relevance across different inputs.
According to the model documentation, the full model has approximately 740M parameters, including a text encoder with ~270M parameters, a visual encoder with ~170M parameters, and an audio encoder with 300M parameters. Each modality encoder can be loaded on demand, supports 100+ languages, natively outputs 768-dimensional vectors, and has a text context window of 8,192 tokens.
For photo and video search, what matters is that a sentence, an image, and a video clip can all be encoded into comparable vectors. ClipSeek Open uses the text and vision capabilities; audio retrieval is not available yet.
For integration, I used ONNX model files provided by ONNX Community. Based on the project's fixed download manifest—which includes the text and vision models, tokenizer, and config files—the download size per precision level is as follows:
Here, decimal MB/GB is used. The scope excludes the audio model, the app installer, and CoreML compile cache. The total file size of the complete 740M-parameter model and the size downloaded on demand by the application are two different things.
A smaller model does not necessarily mean faster across all hardware and inference backends. I encountered this issue later with the Q8 GPU test.
**2. The Search Pipeline Is Actually Straightforward**
On first import, the app computes vectors for media assets and saves the index. When a user searches, it only needs to encode the query and retrieve the closest media vectors.
Figure 2: Encoding media on import, encoding queries on search. Both paths use the same model and precision.
For example, entering "sunset at the beach, orange sky" converts the description into a vector, compares it against existing photo and video vectors, and returns the closest matches. Reverse image search follows the same pipeline, with the query input replaced by a reference image.
Under the hood, SQLite stores paths, folders, and tags; Qdrant Edge stores the vector index; Tauri, Rust, and React handle the desktop app, import queue, and UI. Media is stored as references, without duplicating original files.
One boundary about video needs clarification: the current app stores one vector per complete video and returns the full video, without pinpointing to a specific second. The model input still decodes and samples frames according to specification, but no persistent per-frame search index is built.
The app currently only accepts videos with known duration, up to 32 seconds max. This is a clearly implemented and verified import restriction of the current build, and should not be generalized as a uniform upper bound across all possible usage patterns.
Figure 3: Searching for planet and nebula imagery using natural language. Similarity scores are used to rank results and do not equal the probability of content match.
**3. How Fast Does It Actually Run, and How Much Memory Does It Use?**
Starting with local test results. The test machine was Apple M6, 32 GiB RAM, macOS 27.0.1, using Q8 and the app's production encoder; each operation was run three times, excluding the first cold request. Below are the two warm-run results:
On this input set, CoreML photo encoding was roughly 2.7× faster, and video encoding roughly 2.2× faster. These are encoding times only, not full import times or search response latency; file reading, preprocessing, thumbnails, and index writes still incur overhead.
Memory came from a mixed encoding test including text queries, photos, and video:
RSS is a process resident memory metric, and footprint is another system-level memory accounting metric. Neither directly represents the total memory requirement of the entire machine, and some external services and device caches fall outside process-level metrics. Therefore, the accurate conclusion is: in this CoreML test, it ran faster with lower footprint, but RSS was slightly higher. You cannot simply market this as "memory reduced by several times."
This also explains why the ~542 MB Q8 download does not mean only 542 MB of RAM is occupied at runtime: inference also requires intermediate tensors, runtime overhead, and cache.
Practical recommendations suggest reserving at least 16 GB of memory, an SSD, and 10 GB of available disk space. As assets increase, additional space will be needed for thumbnails and indexes. 16 GB is the currently recommended configuration; the performance tests above were run on a device with 32 GiB of RAM, and lower-memory devices have not been thoroughly validated.
On Apple Silicon with macOS 15+, CoreML CPU/GPU is preferred, falling back to Metal/CPU on failure. Intel Macs and Windows use CPU only. There is no claim of ANE acceleration here, nor any extrapolation of these performance results to Intel or Windows. See the project's inference documentation for full testing methodology.
## Four, A Practical Pitfall: Enabling GPU Makes Q8 Slower
When integrating GPU support, I initially expected switching inference backends would speed things up. In practice, testing showed the same Q8 model and image processed slower on Metal than on CPU.
At the time, I couldn't determine whether the slowdown came from the model inference itself or from other steps in the app. So I isolated the vision encoder and ran the same image on both CPU and GPU separately. Each run was preceded by a warm-up pass, then subsequent timing was measured to exclude model loading and first-time compilation from the results.
The result remained: GPU was slower. This narrowed the scope down to model execution alone, rather than continuing to look for issues in the UI or import queue.
Next, I conducted a separate experiment on the matrix calculations within the Q8 model. Keeping the original quantized weights unchanged, I routed the relevant computations through floating-point matrix operations instead. The vision encoding became noticeably faster. This indicated the issue is related to how the current runtime handles Q8 quantized matrices. Q8 files are smaller, but on this GPU path they don't gain any speed advantage. The exact low-level implementation responsible hasn't been further pinpointed yet.
I then tested native CoreML. On this development machine, it encoded photos and videos faster across the board—those comparisons are what appear in the previous section. Before making an official switch, however, I still needed to confirm its output vectors match the originals.
The check was straightforward: have both backends process identical input, then compare their output vectors. For Q4, Q8, and FP32, I compared each against the respective precision CPU results, requiring a cosine similarity greater than 0.9999, supplemented with tests on long text and full 32-second dynamic video.
After passing all these checks, the app prioritizes CoreML on eligible Apple Silicon devices while retaining Metal and CPU rollback paths. Q8 remains the default.
## Five, Several Habits I've Found Useful When Developing with AI
AI can write code very quickly, but developers still need to judge whether an implementation meets requirements and whether changes affect existing functionality. Through this project, I found the following habits particularly useful.
### 1. Write the design first, then have AI write the code.
For features involving multiple modules, start with a brief document covering objectives, approach, boundaries, and acceptance criteria. With video import, for example, decide in advance the duration limits, indexing granularity, and how unsupported file types should be handled. Confirming the design before implementation reduces rework caused by AI filling in gaps with its own assumptions. Minor tweaks can be described in a few sentences—no need for a long document every time.
### 2. Turn coding standards into automated checks.
Document directory responsibilities, naming conventions, and module boundaries in the project so AI follows the existing structure. Also configure formatting, linting, type checking, and build verification to run before commit. Documentation states the rules; tools verify what can be automatically checked. Whether the implementation makes sense still requires human review.
### 3. Unit tests verify logic; E2E tests verify complete flows.
Unit tests suit clearly defined rules, such as "32-second videos are accepted, 33-second ones rejected." E2E tests launch the actual app and validate real user workflows like "create asset library → import → search → restore after restart." Together they cover both local logic and inter-module connections.
Tests also need review. Especially when asking AI to fix failures, confirm that it modified the implementation rather than deleting assertions, skipping tests, or relaxing the original acceptance criteria.
### 4. Make small changes, and commit to Git promptly after verification.
Strive to complete one clear change per iteration, submit once the relevant checks pass, and write a clear description of the purpose. Before moving to the next step, keep a snapshot you can roll back to if problems arise. This makes it easier to identify which change introduced an issue and to compare behavior before and after the AI's modifications.
### 5. Review the diff yourself before committing.
Pay special attention to out-of-scope changes, duplicate implementations, unexpected deletions, and any leaks of secrets, personal paths, or test artifacts. For model optimization work, compare accuracy and latency against the original output. For packaging, actually run the installed package. AI-generated completion notes can help organize results but cannot replace these validations.
The value of these practices lies in ensuring every change has a clear rationale, verifiable outcomes, and a restorable version. AI accelerates implementation; the developer confirms direction and acceptance.
Experience & Source Code
ClipSeek Open provides macOS Apple Silicon, Intel, and Windows x64 installers. The initial use requires an internet connection to download models, after which asset processing is performed locally; macOS 14+ is required.
We welcome you to try it, give us a star, and submit issues.
Auto-fetched and translated by AI Atlas. All rights belong to the original author.