[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-monatis--clip.cpp":3,"tool-monatis--clip.cpp":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",147882,2,"2026-04-09T11:32:47",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108111,"2026-04-08T11:23:26",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[35,15,13,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":77,"owner_email":78,"owner_twitter":79,"owner_website":80,"owner_url":81,"languages":82,"stars":103,"forks":104,"last_commit_at":105,"license":106,"difficulty_score":107,"env_os":108,"env_gpu":109,"env_ram":110,"env_deps":111,"category_tags":118,"github_topics":121,"view_count":32,"oss_zip_url":79,"oss_zip_packed_at":79,"status":17,"created_at":128,"updated_at":129,"faqs":130,"releases":160},5850,"monatis\u002Fclip.cpp","clip.cpp","CLIP inference in plain C\u002FC++ with no extra dependencies","clip.cpp 是一个用纯 C\u002FC++ 编写的开源项目，旨在无需任何额外依赖即可高效运行 CLIP 模型。它让开发者能够在资源受限的设备上轻松实现图像语义搜索、零样本图像标注等功能，也是构建大型多模态应用的轻量级基石。\n\n传统深度学习框架往往体积庞大且启动缓慢，难以在边缘设备或无服务器环境中部署。clip.cpp 通过引入 GGML 库，完美解决了这一痛点。它不仅将量化后的模型体积压缩至约 85MB，还具备极快的冷启动速度，非常适合对内存和计算能力有严格限制的场景。\n\n该项目主要面向嵌入式开发者、后端工程师以及希望优化模型部署的研究人员。其核心技术亮点包括支持 4 位、5 位及 8 位多种量化精度，灵活适配文本、视觉或双塔模型架构。更值得一提的是，它提供了仅依赖 Python 标准库的绑定接口，彻底摆脱了 NumPy、PyTorch 等重型框架的束缚，同时兼容 C 语言调用，为多语言生态集成提供了极大便利。如果你需要在低成本硬件上快速落地多模态 AI 应用，clip.cpp 是一个值得尝试的高效方案。","# clip.cpp\n\nCLIP inference in plain C\u002FC++ with no extra dependencies\n\n## Description\n\nThis is a dependency free implementation of well known [CLIP](https:\u002F\u002Fgithub.com\u002Fopenai\u002Fclip) by OpenAI,\nthanks to the great work in [GGML](https:\u002F\u002Fgithub.com\u002Fggerganov\u002Fggml).\nYou can use it to work with CLIP models from both OpenAI and LAION\nin Transformers format.\n\n## Motivation\n\nCLIP is deployed for several task from semantic image search to zero-shot image labeling.\nIt's also a part of Stable Diffusion and and the recently emerging field of large multimodal models (LMM).\nThis repo is aimed at powering useful applications based on such models on computation- or memory-constraint devices.\n4-bit quantized CLIP is only 85.6 MB!\n\n## Features\n\n- Dependency-free and lightweight inference thanks to [ggml](https:\u002F\u002Fgithub.com\u002Fggerganov\u002Fggml.gi).\n- 4-bit, 5-bit and 8-bit quantization support.\n- Support inference with `text-only`, `vision-only` and `two-tower` model variants. It might be relevant to use a single modality in certain cases, as in encoders for large multimodal models, or building and\u002For searching for semantic image search.\n- Dependency free Python binding without relying any large third-party packages. No need for Numpy, TensorFlow, PyTorch, ONNX etc. In fact, nothing more than the standard Python library.\n\nclip.cpp also has a short startup time compared to large ML frameworks, which makes it suitable for serverless deployments where the cold start is an issue.\n\n## Hot topics\n\n-   01\u002F27\u002F2024: Clojure bindings available, [clip.clj](https:\u002F\u002Fgithub.com\u002Fphronmophobic\u002Fclip.clj).\n-   09\u002F27\u002F2023: clip.cpp now uses a new model file structure in GGUF format. This is a breaking change. See bwlow for more information.\n-   09\u002F14\u002F2023: All functions are C-compatible now. `zsl` example is updated to match Huggingface's zero-shot behavior in the zero-shot pipeline.\n-   09\u002F11\u002F2023: Introduce Python bindings.\n-   07\u002F12\u002F2023: Batch inference support for image encoding.\n-   07\u002F11\u002F2023: Semantic image search [example](examples\u002Fimage-search\u002FREADME.md) directly in C++.\n\n## BREAKING CHANGE\n\n### As of 09\u002F27\u002F2023, clip.cpp uses a new model file structure in GGUF format. The latest commit that is compatible with older .bin files is [05f2efd8081b8695e8174dea7a82116ece2fdf63](https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp\u002Fcommit\u002F05f2efd8081b8695e8174dea7a82116ece2fdf63). There will be no back compatibility support for older models, and you are recommended to update to the new code and model files. The new structure allows text-only and vision-only model files as well as 32-bit floating point precision, 5-bit and 8-bit quantization support in addition to the existing 16-bit floating point precision and 4-bit quantization.\n\n## Note about image preprocessing\n\nPIL uses a two-pass convolutions-based bicubic interpolation in resizing with antialiasing applied. In Pytorch, antialiasing is optional. It needs some extra attention to implement this preprocessing logic that matches their results numerically. However, I found that linear interpolation is also good enough for both comparison of different embeddings from this implementation and also comparison of an embedding from this implementation and another one from Transformers. So let's use it until we craft a proper bicubic interpolation.\n\n## Preconverted Models\n\nPreconverted Models can be found in [HuggingFace Repositories tagged with `clip-cpp-gguf`](https:\u002F\u002Fhuggingface.co\u002Fmodels?other=clip-cpp-gguf).\nIf you want to do conversion yourself for some reason, see below for how.\nOtherwise, download a model of your choice from the link above and then feel free to jump to the building section.\n\n## Model conversion\n\nYou can convert CLIP models from OpenAI and LAION in Transformers format. Apparently, LAION's models outperform OpenAI models in several benchmarks, so they are recommended.\n\n1. Clone the model repo from HF Hub:\n\n```shell\ngit lfs init\n\ngit clone https:\u002F\u002Fhuggingface.co\u002Flaion\u002FCLIP-ViT-B-32-laion2B-s34B-b79K\n```\n\n2. Clone this repository:\n\n```shell\ngit clone --recurse-submodules https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp.git\n\ncd clip.cpp\u002Fmodels\n```\n\n3. You need to install pytorch and transformers packages if you haven't already. Otherwise, you can skip this step:\n\n```shell\npip install -r requirements.txt\n```\n\n4. Use `models\u002Fconvert_hf_to_gguf.py` to convert it to GGUF format:\n\n```shell\npython convert_hf_to_gguf.py -m ..\u002F..\u002FCLIP-ViT-B-32-laion2B-s34B-b79K\n```\n\nThe output `CLIP-ViT-B-32-laion2B-s34B-b79K_ggml-model-f16.bin` file is in the model directory specified in the command above.\n\nTo see other options that you can use with the conversion script, run:\n\n```shell\npython convert_hf_to_gguf.py --help\n```\n\n## Building\n\n```shell\ngit clone --recurse-submodules https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp.git\n\ncd clip.cpp\n\nmkdir build\n\ncd build\n\ncmake -DCLIP_NATIVE=ON ..\n\nmake\n```\n\nAnd the binaries are in the `.\u002Fbin` directory.\n\n**Note**: Some Mac devices report `x86_64` instead of `arm64` architecture. If this is the case see [here](https:\u002F\u002Fgithub.com\u002Fggerganov\u002Fwhisper.cpp\u002Fissues\u002F66#issuecomment) for a discussion.\nI couldn't reproduce it on my Macbook M2 pro so cannot help further. If you know a solution that I can include in `CMakeLists.txt` please ping me [here](https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp\u002Fissues\u002F24).\n\n## Quantization\n\n`clip.cpp` supports q4_0, q4_1, q5_0, q5_1 and q8_0 quantization types.\nYou can quantize a model in f32 (recommended) or f16 to one of these types by using the `.\u002Fbin\u002Fquantize` binary. \n\n\n```\nusage: .\u002Fbin\u002Fquantize \u002Fpath\u002Fto\u002Fggml-model-f32.gguf \u002Fpath\u002Fto\u002Fggml-model-quantized.gguf type                              \n  type = 2 - q4_0                                                                                                       \n  type = 3 - q4_1                                                                                                       \n  type = 6 - q5_0                                                                                                       \n  type = 7 - q5_1                                                                                                       \n  type = 8 - q8_0                                                                                                       \n```\n\nFor example, you can run the following to convert the model to q5_1:\n\n```shell\n.\u002Fbin\u002Fquantize .\u002FCLIP-ViT-B-32-laion2B-s34B-b79K\u002Fggml-model-f32.gguf .\u002FCLIP-ViT-B-32-laion2B-s34B-b79K\u002Fggml-model-q5_1.gguf 7\n```\n\nNow you can use `ggml-model-q5_1.gguf` just like the model in F16.\n\n## Usage\n\nCurrently we have 4 examples: `main`, `zsl` and `image-search`.\n\n1. `main` is just for demonstrating the usage of API and optionally print out some verbose timings. It simply calculates the similarity between one image and one text passed as CLI args.\n\n```\nUsage: .\u002Fbin\u002Fmain [options]\n\nOptions:  -h, --help: Show this message and exit\n  -m \u003Cpath>, --model \u003Cpath>: path to model. Default: models\u002Fggml-model-f16.gguf\n  -t N, --threads N: Number of threads to use for inference. Default: 4\n  --text \u003Ctext>: Text to encode. At least one text should be specified\n  --image \u003Cpath>: Path to an image file. At least one image path should be specified\n  -v \u003Clevel>, --verbose \u003Clevel>: Control the level of verbosity. 0 = minimum, 2 = maximum. Default: 1\n```\n\n2. `zsl` is a zero-shot image labeling example. It labels an image with one of the labels.\n   The CLI args are the same as in `main`,\n   but you must specify multiple `--text` arguments to specify the labels.\n\n3. `image-search` is an example for semantic image search with [USearch](https:\u002F\u002Fgithub.com\u002Funum-cloud\u002Fusearch\u002F).\n   You must enable `CLIP_BUILD_IMAGE_SEARCH` option to compile it, and the dependency will be automatically fetched by cmake:\n\n```shell\nmkdir build\n\ncd build\n\ncmake -DCLIP_BUILD_IMAGE_SEARCH=ON ..\n\nmake\n```\n\nSee [examples\u002Fimage-search\u002FREADME.md](examples\u002Fimage-search\u002FREADME.md) for more info and usage.\n\n4. `extract` is a tool to extract vectors to `*.npy` files in Numpy format. It is again dependency-free, i.e., no need for Numpy.\n\nCLI arguments are the same as in `main` and `zsl`, but you can pass one or multiple `--text` and\u002For `--image` arguments. Either of them or a combination of both allowed.\n\n**Note**: Support for processing `*.txt` files and image directories is on the way.\n\n## Python bindings\n\nYou can use clip.cpp in Python with no third-party libraries (no dependencies other than standard Python libraries).\nIt uses `ctypes` to load a dynamically linked library (DLL) to interface the implementation in C\u002FC++.\n\nIf you are on an X64 Linux distribution, you can simply Pip-install it with AVX2 support:\n\n```shell\npip install clip_cpp\n```\n\n> Colab Notebook available for quick experiment :\n>\n> \u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FYossef-Dawoad\u002Fclip.cpp\u002Fblob\u002Fadd_colab_notebook_example\u002Fexamples\u002Fpython_bindings\u002Fnotebooks\u002Fclipcpp_demo.ipynb\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\" alt=\"Open In Colab\"\u002F>\u003C\u002Fa>\n\nIf you are on another operating system or architecture,\nor if you want to make use of support for instruction sets other than AVX2 (e.g., AVX512),\nyou can build it from source.\n\nAll you need is to compile with `-DBUILD_SHARED_LIBS=ON` option to get the required DLL.\n\n```shell\nmkdir build\n\ncd build\n\ncmake -DBUILD_SHARED_LIBS=ON ..\n\nmake\n```\n\nAnd find the `libclip.so` binary in the `build` directory.\nSee [examples\u002Fpython_bindings\u002FREADME.md](examples\u002Fpython_bindings\u002FREADME.md) for more info and usage.\n\n## Benchmarking\n\nYou can use the benchmarking utility to compare the performances of different checkpoints and quantization types.\n\n```\nusage: .\u002Fbin\u002Fbenchmark \u003Cmodel_path> \u003Cimages_dir> \u003Cnum_images_per_dir> [output_file]\n\nmodel_path: path to CLIP model in GGML format\nimages_dir: path to a directory of images where images are organized into subdirectories named classes\nnum_images_per_dir: maximum number of images to read from each one of subdirectories. if 0, read all files\noutput_file: optional. if specified, dump the output to this file instead of stdout\n```\n\nSee [tests\u002FREADME.md](tests\u002FREADME.md) for more info about benchmarking.\n\n## Future Work\n-   [ ] Integrate up to the latest GGML and support multiple backends.\n\n-   [ ] \n","# clip.cpp\n\n纯 C\u002FC++ 实现的 CLIP 推理，无额外依赖\n\n## 说明\n\n这是由 OpenAI 开发的知名 CLIP 模型的无依赖实现，得益于 [GGML](https:\u002F\u002Fgithub.com\u002Fggerganov\u002Fggml) 的出色工作。你可以使用它来处理来自 OpenAI 和 LAION 的 Transformers 格式 CLIP 模型。\n\n## 动机\n\nCLIP 被广泛应用于语义图像搜索、零样本图像分类等多种任务。它也是 Stable Diffusion 以及新兴的大规模多模态模型（LMM）领域的一部分。本仓库旨在为基于此类模型的应用程序提供支持，特别是在计算或内存受限的设备上运行。经过 4 位量化后的 CLIP 模型仅需 85.6 MB！\n\n## 特性\n\n- 借助 [ggml](https:\u002F\u002Fgithub.com\u002Fggerganov\u002Fggml)，实现无依赖、轻量级的推理。\n- 支持 4 位、5 位和 8 位量化。\n- 支持 `仅文本`、`仅视觉` 以及 `双塔` 模型变体的推理。在某些情况下，例如用于大型多模态模型的编码器，或者构建和搜索语义图像数据库时，单独使用某一模态可能更为合适。\n- 无依赖的 Python 绑定，无需任何大型第三方库。不需要 NumPy、TensorFlow、PyTorch、ONNX 等，实际上仅需标准 Python 库即可。\n\n与大型机器学习框架相比，clip.cpp 的启动时间更短，因此非常适合冷启动问题较为突出的无服务器部署场景。\n\n## 最新动态\n\n- 2024年1月27日：Clojure 绑定可用，详见 [clip.clj](https:\u002F\u002Fgithub.com\u002Fphronmophobic\u002Fclip.clj)。\n- 2023年9月27日：clip.cpp 现在采用 GGUF 格式的全新模型文件结构。这是一个破坏性变更，请参阅下方了解更多信息。\n- 2023年9月14日：所有函数现已兼容 C 语言。`zsl` 示例已更新，以匹配 Hugging Face 零样本管道中的行为。\n- 2023年9月11日：引入 Python 绑定。\n- 2023年7月12日：支持批量图像编码推理。\n- 2023年7月11日：直接在 C++ 中实现语义图像搜索示例，详情见 [examples\u002Fimage-search\u002FREADME.md]。\n\n## 破坏性变更\n\n### 自 2023年9月27日起，clip.cpp 使用 GGUF 格式的全新模型文件结构。与旧版 .bin 文件兼容的最新提交是 [05f2efd8081b8695e8174dea7a82116ece2fdf63](https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp\u002Fcommit\u002F05f2efd8081b8695e8174dea7a82116ece2fdf63)。我们将不再提供对旧模型的向后兼容支持，建议您更新至新代码及模型文件。新结构不仅支持现有的 16 位浮点精度和 4 位量化，还新增了 32 位浮点精度、5 位和 8 位量化，并且可以分别存储仅文本和仅视觉的模型文件。\n\n## 关于图像预处理的说明\n\nPIL 在进行带抗锯齿的双通道卷积双三次插值缩放时，会应用抗锯齿处理。而在 PyTorch 中，抗锯齿是可选的。要实现与它们结果数值一致的预处理逻辑，需要特别注意。不过，我发现线性插值对于比较本实现与其他 Transformers 实现的嵌入向量，以及比较本实现与其它实现的嵌入向量来说，已经足够好。因此，在我们开发出合适的双三次插值之前，暂时就使用线性插值吧。\n\n## 预转换模型\n\n预转换模型可在 [Hugging Face 上标记为 `clip-cpp-gguf` 的仓库](https:\u002F\u002Fhuggingface.co\u002Fmodels?other=clip-cpp-gguf)中找到。如果您出于某种原因希望自行进行转换，请参阅下文。否则，您可以从上述链接下载所需的模型，然后直接跳转到编译部分。\n\n## 模型转换\n\n您可以将 OpenAI 和 LAION 提供的 Transformers 格式 CLIP 模型进行转换。据称，LAION 的模型在多项基准测试中表现优于 OpenAI 的模型，因此推荐使用 LAION 的模型。\n\n1. 从 Hugging Face Hub 克隆模型仓库：\n\n```shell\ngit lfs init\n\ngit clone https:\u002F\u002Fhuggingface.co\u002Flaion\u002FCLIP-ViT-B-32-laion2B-s34B-b79K\n```\n\n2. 克隆本仓库：\n\n```shell\ngit clone --recurse-submodules https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp.git\n\ncd clip.cpp\u002Fmodels\n```\n\n3. 如果尚未安装 PyTorch 和 Transformers 库，请先安装；否则可跳过此步骤：\n\n```shell\npip install -r requirements.txt\n```\n\n4. 使用 `models\u002Fconvert_hf_to_gguf.py` 将其转换为 GGUF 格式：\n\n```shell\npython convert_hf_to_gguf.py -m ..\u002F..\u002FCLIP-ViT-B-32-laion2B-s34B-b79K\n```\n\n输出的 `CLIP-ViT-B-32-laion2B-s34B-b79K_ggml-model-f16.bin` 文件位于上述命令中指定的模型目录中。\n\n如需查看转换脚本的其他选项，请运行：\n\n```shell\npython convert_hf_to_gguf.py --help\n```\n\n## 编译\n\n```shell\ngit clone --recurse-submodules https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp.git\n\ncd clip.cpp\n\nmkdir build\n\ncd build\n\ncmake -DCLIP_NATIVE=ON ..\n\nmake\n```\n\n编译生成的二进制文件位于 `.\u002Fbin` 目录中。\n\n**注意**：部分 Mac 设备报告的架构为 `x86_64` 而不是 `arm64`。如果遇到这种情况，请参阅 [此处](https:\u002F\u002Fgithub.com\u002Fggerganov\u002Fwhisper.cpp\u002Fissues\u002F66#issuecomment) 的讨论。我在自己的 MacBook M2 Pro 上未能复现该问题，因此无法提供更多帮助。如果您知道可以在 `CMakeLists.txt` 中加入的解决方案，请在此处联系我：[issues\u002F24](https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp\u002Fissues\u002F24)。\n\n## 量化\n\n`clip.cpp` 支持 q4_0、q4_1、q5_0、q5_1 和 q8_0 五种量化类型。您可以使用 `.\u002Fbin\u002Fquantize` 二进制工具，将 f32（推荐）或 f16 格式的模型量化为其中任意一种类型。\n\n\n```\n用法：.\u002Fbin\u002Fquantize \u002Fpath\u002Fto\u002Fggml-model-f32.gguf \u002Fpath\u002Fto\u002Fggml-model-quantized.gguf type                              \n  type = 2 - q4_0                                                                                                       \n  type = 3 - q4_1                                                                                                       \n  type = 6 - q5_0                                                                                                       \n  type = 7 - q5_1                                                                                                       \n  type = 8 - q8_0                                                                                                       \n```\n\n例如，您可以运行以下命令将模型量化为 q5_1：\n\n```shell\n.\u002Fbin\u002Fquantize .\u002FCLIP-ViT-B-32-laion2B-s34B-b79K\u002Fggml-model-f32.gguf .\u002FCLIP-ViT-B-32-laion2B-s34B-b79K\u002Fggml-model-q5_1.gguf 7\n```\n\n现在您可以像使用 f16 格式的模型一样使用 `ggml-model-q5_1.gguf`。\n\n## 使用方法\n\n目前我们有4个示例：`main`、`zsl` 和 `image-search`。\n\n1. `main` 仅用于演示 API 的使用，并可选择性地输出详细的计时信息。它简单地计算通过命令行参数传入的一张图片与一段文本之间的相似度。\n\n```\n用法：.\u002Fbin\u002Fmain [选项]\n\n选项：  -h, --help：显示此消息并退出\n  -m \u003C路径>, --model \u003C路径>：模型路径。默认值：models\u002Fggml-model-f16.gguf\n  -t N, --threads N：用于推理的线程数。默认值：4\n  --text \u003C文本>：要编码的文本。至少需要指定一个文本。\n  --image \u003C路径>：图像文件的路径。至少需要指定一个图像路径。\n  -v \u003C级别>, --verbose \u003C级别>：控制详细程度。0 = 最低，2 = 最高。默认值：1\n```\n\n2. `zsl` 是一个零样本图像标注示例。它会根据提供的标签对一张图像进行标注。\n   命令行参数与 `main` 相同，\n   但必须指定多个 `--text` 参数来定义标签。\n\n3. `image-search` 是一个基于 [USearch](https:\u002F\u002Fgithub.com\u002Funum-cloud\u002Fusearch\u002F) 的语义图像搜索示例。\n   编译时需启用 `CLIP_BUILD_IMAGE_SEARCH` 选项，依赖项将由 CMake 自动下载：\n\n```shell\nmkdir build\n\ncd build\n\ncmake -DCLIP_BUILD_IMAGE_SEARCH=ON ..\n\nmake\n```\n\n更多信息和使用方法请参阅 [examples\u002Fimage-search\u002FREADME.md](examples\u002Fimage-search\u002FREADME.md)。\n\n4. `extract` 是一个工具，用于将向量提取为 NumPy 格式的 `*.npy` 文件。它同样无需任何依赖，即不需要安装 NumPy。\n   命令行参数与 `main` 和 `zsl` 相同，但可以传递一个或多个 `--text` 和\u002F或 `--image` 参数。两者均可单独使用，也可组合使用。\n\n**注意**：支持处理 `*.txt` 文件和图像目录的功能正在开发中。\n\n## Python 绑定\n\n您可以在 Python 中使用 clip.cpp，而无需任何第三方库（除了标准 Python 库之外没有其他依赖）。\n它使用 `ctypes` 加载动态链接库 (DLL)，以实现与 C\u002FC++ 实现的接口。\n\n如果您使用的是 X64 架构的 Linux 发行版，可以直接通过 Pip 安装并获得 AVX2 支持：\n\n```shell\npip install clip_cpp\n```\n\n> 提供 Colab 笔记本以便快速实验：\n>\n> \u003Ca href=\"https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FYossef-Dawoad\u002Fclip.cpp\u002Fblob\u002Fadd_colab_notebook_example\u002Fexamples\u002Fpython_bindings\u002Fnotebooks\u002Fclipcpp_demo.ipynb\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg\" alt=\"在 Colab 中打开\"\u002F>\u003C\u002Fa>\n\n如果您使用的是其他操作系统或架构，\n或者希望利用 AVX2 以外的指令集支持（例如 AVX512），\n您可以从源代码编译。\n\n您只需使用 `-DBUILD_SHARED_LIBS=ON` 选项进行编译，即可生成所需的 DLL。\n\n```shell\nmkdir build\n\ncd build\n\ncmake -DBUILD_SHARED_LIBS=ON ..\n\nmake\n```\n\n编译完成后，您将在 `build` 目录中找到 `libclip.so` 二进制文件。\n更多信息和使用方法请参阅 [examples\u002Fpython_bindings\u002FREADME.md](examples\u002Fpython_bindings\u002FREADME.md)。\n\n## 基准测试\n\n您可以使用基准测试工具比较不同检查点和量化类型的表现。\n\n```\n用法：.\u002Fbin\u002Fbenchmark \u003C模型路径> \u003C图像目录> \u003C每个子目录的图像数量> [输出文件]\n\n模型路径：GGML 格式的 CLIP 模型路径\n图像目录：包含按类别命名的子目录的图像目录\n每个子目录的图像数量：从每个子目录中最多读取的图像数量。如果为 0，则读取所有文件\n输出文件：可选。如果指定，则将输出转储到该文件，而不是标准输出\n```\n\n有关基准测试的更多信息，请参阅 [tests\u002FREADME.md](tests\u002FREADME.md)。\n\n## 未来工作\n-   [ ] 集成最新版本的 GGML，并支持多种后端。\n\n-   [ ]","# clip.cpp 快速上手指南\n\n`clip.cpp` 是一个无依赖、轻量级的 CLIP 模型推理工具，基于 C\u002FC++ 和 GGML 库实现。它支持 4-bit\u002F5-bit\u002F8-bit 量化，模型文件极小（4-bit 版本仅约 85.6 MB），非常适合在计算或内存受限的设备上运行，也适用于对冷启动敏感的 Serverless 部署。\n\n## 环境准备\n\n*   **操作系统**: Linux, macOS, Windows (需构建环境)\n*   **编译器**: 支持 C++11 的编译器 (如 `gcc`, `clang`, `msvc`)\n*   **构建工具**: `cmake`, `make` (Windows 下可用 `nmake` 或 `mingw32-make`)\n*   **模型转换依赖 (可选)**: 若需自行转换模型，需安装 Python 及 `torch`, `transformers` 库。\n    ```bash\n    pip install torch transformers\n    ```\n*   **Git LFS**: 下载大模型文件时需要。\n\n## 安装步骤\n\n### 1. 克隆项目\n```bash\ngit clone --recurse-submodules https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp.git\ncd clip.cpp\n```\n\n### 2. 编译构建\n创建构建目录并编译：\n```bash\nmkdir build\ncd build\ncmake -DCLIP_NATIVE=ON ..\nmake\n```\n编译完成后，可执行文件位于 `.\u002Fbin` 目录中。\n\n> **注意**: 若在 macOS M1\u002FM2 等设备上遇到架构识别问题，请参考项目 Issue 讨论调整 CMake 配置。\n\n### 3. 获取模型\n你可以直接从 HuggingFace 下载已转换好的 **GGUF** 格式模型（推荐），或自行转换。\n\n*   **下载预转换模型**:\n    访问 [HuggingFace Models](https:\u002F\u002Fhuggingface.co\u002Fmodels?other=clip-cpp-gguf) 搜索带有 `clip-cpp-gguf` 标签的模型并下载 `.gguf` 文件。\n\n*   **自行转换模型 (可选)**:\n    若需使用特定模型，可先将 HuggingFace 上的 Transformers 格式模型转换为 GGUF 格式：\n    ```bash\n    # 假设已克隆目标模型仓库到 ..\u002F..\u002FCLIP-ViT-B-32-laion2B-s34B-b79K\n    python models\u002Fconvert_hf_to_gguf.py -m ..\u002F..\u002FCLIP-ViT-B-32-laion2B-s34B-b79K\n    ```\n\n### 4. 模型量化 (可选)\n为了进一步减小体积和提升速度，可将模型量化为 4-bit\u002F5-bit\u002F8-bit：\n```bash\n# 用法：.\u002Fbin\u002Fquantize \u003C输入模型> \u003C输出模型> \u003C类型>\n# 类型代码：2=q4_0, 3=q4_1, 6=q5_0, 7=q5_1, 8=q8_0\n.\u002Fbin\u002Fquantize .\u002Fggml-model-f32.gguf .\u002Fggml-model-q5_1.gguf 7\n```\n\n## 基本使用\n\n编译后的 `bin` 目录包含多个示例工具，最常用的是 `main`（计算图文相似度）和 `zsl`（零样本图像分类）。\n\n### 示例 1：计算图像与文本的相似度 (`main`)\n计算一张图片与一段文本的匹配程度：\n\n```bash\n.\u002Fbin\u002Fmain \\\n  -m ..\u002Fmodels\u002Fggml-model-f16.gguf \\\n  --text \"a photo of a dog\" \\\n  --image ..\u002Fimages\u002Fdog.jpg\n```\n\n**参数说明**:\n*   `-m`: 模型路径 (默认 `models\u002Fggml-model-f16.gguf`)\n*   `--text`: 需要编码的文本\n*   `--image`: 图片文件路径\n*   `-t`: 线程数 (默认 4)\n*   `-v`: 详细程度 (0-2)\n\n### 示例 2：零样本图像分类 (`zsl`)\n从多个标签中选择最符合图片内容的标签：\n\n```bash\n.\u002Fbin\u002Fzsl \\\n  -m ..\u002Fmodels\u002Fggml-model-f16.gguf \\\n  --text \"cat\" \\\n  --text \"dog\" \\\n  --text \"bird\" \\\n  --image ..\u002Fimages\u002Fanimal.jpg\n```\n*注意：必须提供多个 `--text` 参数作为候选标签。*\n\n### 示例 3：提取向量 (`extract`)\n将图像或文本编码为向量并保存为 NumPy 格式 (`.npy`)，无需安装 NumPy：\n\n```bash\n.\u002Fbin\u002Fextract \\\n  -m ..\u002Fmodels\u002Fggml-model-f16.gguf \\\n  --text \"hello world\" \\\n  --image ..\u002Fimages\u002Ftest.png\n```\n生成的向量文件可用于后续的语义搜索或其他任务。\n\n### Python 绑定 (可选)\n`clip.cpp` 提供无第三方依赖的 Python 绑定。\n*   **直接安装 (Linux x64)**:\n    ```bash\n    pip install clip_cpp\n    ```\n*   **源码编译启用共享库**:\n    若需自定义指令集或在其他平台使用，编译时需开启共享库选项：\n    ```bash\n    cmake -DBUILD_SHARED_LIBS=ON ..\n    make\n    ```\n    随后通过 `ctypes` 加载生成的 `libclip.so` (或对应平台的动态库) 即可在 Python 中调用。具体用法参见 `examples\u002Fpython_bindings\u002F`。","一家初创公司正在开发一款运行在边缘设备（如 Raspberry Pi）上的离线智能相册应用，需要实时根据用户输入的自然语言描述检索本地图片。\n\n### 没有 clip.cpp 时\n- **部署体积过大**：传统 PyTorch 或 TensorFlow 环境连同依赖库动辄数百兆甚至数 GB，远超边缘设备的存储限制。\n- **启动延迟严重**：加载庞大的深度学习框架导致应用冷启动时间过长，用户点击搜索后需等待数秒才能响应。\n- **依赖管理复杂**：在资源受限的 Linux 环境中配置 Python 虚拟环境、安装 NumPy 等科学计算库极易出错且维护困难。\n- **内存占用过高**：全精度模型运行时内存消耗巨大，容易导致低配设备内存溢出或系统卡顿。\n\n### 使用 clip.cpp 后\n- **极致轻量部署**：借助 4-bit 量化技术，模型文件仅约 85.6 MB，且无需任何第三方依赖，轻松嵌入嵌入式系统。\n- **毫秒级快速响应**：摒弃了重型框架的加载开销，clip.cpp 启动极快，实现了近乎实时的图像语义检索体验。\n- **纯净运行环境**：仅依赖标准 C\u002FC++ 库或原生 Python 绑定，彻底消除了复杂的环境配置难题，提升了系统稳定性。\n- **低内存高效运行**：量化模型大幅降低内存占用，使老旧硬件也能流畅运行多模态推理任务而不影响其他进程。\n\nclip.cpp 通过将高性能 CLIP 推理带入无依赖的轻量级环境，成功让复杂的语义图像搜索在资源受限的边缘设备上变得触手可及。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmonatis_clip.cpp_d9fb0596.png","monatis","M. Yusuf Sarıgöz","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fmonatis_3ac2835a.jpg","Co-founder @altaidevorg, Sr. AI Research engineer and Google Developer Expert on Machine Learning - Making LLM customization uncool again.","@altaidevorg","Turkey","yusufsarigoz@gmail.com",null,"https:\u002F\u002Faltai.dev","https:\u002F\u002Fgithub.com\u002Fmonatis",[83,87,91,95,99],{"name":84,"color":85,"percentage":86},"C++","#f34b7d",92.8,{"name":88,"color":89,"percentage":90},"Python","#3572A5",3.2,{"name":92,"color":93,"percentage":94},"CMake","#DA3434",2.2,{"name":96,"color":97,"percentage":98},"Shell","#89e051",0.9,{"name":100,"color":101,"percentage":102},"C","#555555",0.8,557,53,"2026-04-08T17:09:35","MIT",4,"Linux, macOS","不需要 GPU，纯 CPU 运行（基于 GGML）","最低约 85.6 MB (4-bit 量化模型)，推荐视具体模型大小而定",{"notes":112,"python":113,"dependencies":114},"1. 核心推理无需任何第三方依赖，支持 4\u002F5\u002F8-bit 量化以大幅降低内存占用。2. 模型需转换为 GGUF 格式才能使用（旧版 .bin 文件已不再支持）。3. Python 绑定通过 ctypes 调用动态库，无需安装 NumPy 或 PyTorch 即可运行。4. Mac M 系列芯片需注意架构识别问题。5. 若需自行转换模型，需临时安装 PyTorch 和 Transformers。","标准库即可 (构建转换脚本需安装 PyTorch 和 Transformers)",[115,116,117],"无运行时依赖 (C\u002FC++ 核心)","PyTorch (仅用于模型转换)","Transformers (仅用于模型转换)",[35,119,120,16,14,15,13,52],"其他","音频",[122,123,124,125,126,127],"c","clip","cpp","ggml","image-search","multimodal","2026-03-27T02:49:30.150509","2026-04-09T20:50:48.751004",[131,136,141,146,151,156],{"id":132,"question_zh":133,"answer_zh":134,"source_url":135},26528,"在 Apple M1\u002FM2 (ARM64) Mac 上编译时遇到架构警告或构建错误怎么办？","如果在编译时遇到架构警告（如提示 x86_64 但实际是 ARM64）或类似 'a space is required between consecutive right angle brackets' 的错误，通常是因为编译器标准设置过低。请确保使用 C++11 或更高版本（推荐 C++20）。\n\n解决方法是在 `examples\u002FCMakeLists.txt` 中添加以下配置以强制指定 C++ 标准：\n```cmake\ntarget_compile_features(common-clip PUBLIC cxx_std_20)\n```\n此外，确认你使用的是较新版本的 Clang（如 Apple clang version 14+），并使用 Ninja 或 Make 进行构建。","https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp\u002Fissues\u002F24",{"id":137,"question_zh":138,"answer_zh":139,"source_url":140},26529,"加载大型 CLIP 模型（如 ViT-H-14）时出现内存不足或断言失败错误如何解决？","加载大型模型时出现的 `ggml_new_tensor_impl: not enough space` 或 `Assertion '!isnan(sp[i])' failed` 错误，通常是由于上下文内存池大小不足或计算过程中的数值问题导致的。\n\n该问题已在后续的修复分支或主分支中解决（参考 PR #11 及相关 ggml 更新）。建议拉取最新的代码并重新编译。如果问题依旧，可能需要手动调整上下文内存分配倍数（曾有人尝试乘以 100ul 临时缓解，但根本解决需等待官方修复合并）。","https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp\u002Fissues\u002F9",{"id":142,"question_zh":143,"answer_zh":144,"source_url":145},26530,"使用 4bit 量化模型运行 image-search-build 处理多张图片时发生段错误（Segmentation Fault）怎么办？","这是一个已知问题，当使用 4bit 量化模型（.q4_1.bin）并在文件夹中包含多张图片进行批量推理时，由于内存需求增加会导致段错误。F16 模型通常不受此影响。\n\n该问题已在主分支（master）中修复。请务必更新到最新代码并重新编译。维护者指出这是针对多图像批量推理内存需求增加而进行的补丁。","https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp\u002Fissues\u002F45",{"id":147,"question_zh":148,"answer_zh":149,"source_url":150},26531,"为什么零样本分类（ZSL）的结果与 Hugging Face 演示不一致，或者对某些类别（如性别）有严重偏差？","如果发现 `zsl` 命令输出的概率分布与 Hugging Face 在线演示差异巨大（例如演示中为 1.0\u002F0.0，本地为 0.53\u002F0.47），或者对特定类别（如 'man'\u002F'woman'）存在预测偏差，这通常是由于分数归一化或计算逻辑的差异造成的。\n\n维护者已针对此类准确性问题和偏差进行了修复。请确保你使用的是最新版本的代码库。如果更新后问题仍然存在，可能是模型本身的特性或特定输入导致的，建议尝试不同的模型变体（如 OpenAI 原始权重）进行对比测试。","https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp\u002Fissues\u002F44",{"id":152,"question_zh":153,"answer_zh":154,"source_url":155},26532,"该项目是否支持 BLIP 或 Stable Diffusion 等多模态模型？","目前 `clip.cpp` 主要专注于 CLIP 特征提取器。虽然它可以作为基础组件用于构建更复杂的多模态模型（如 BLIP = CLIP + 桥接机制 + 语言模型），但这些完整模型（如 BLIP-base, BLIP2, Stable Diffusion）属于独立的项目范畴。\n\n大型 OpenAI 和 Open CLIP 变体（如 ViT-bigG-14, ViT-L-14）已在该项目中得到支持。对于完整的图文生成或高级描述任务，需要结合其他项目或使用专门的实现。","https:\u002F\u002Fgithub.com\u002Fmonatis\u002Fclip.cpp\u002Fissues\u002F4",{"id":157,"question_zh":158,"answer_zh":159,"source_url":135},26533,"如何正确编译项目以避免 C++ 标准相关的语法错误？","遇到类似 'error: a space is required between consecutive right angle brackets' 的编译错误，表明编译器正在使用过旧的 C++ 标准（如 C++98）。\n\n解决方案是显式指定 C++ 标准。在构建配置中（如 CMake），确保为目标添加编译特性：\n```cmake\ntarget_compile_features(common-clip PUBLIC cxx_std_20)\n```\n或者在运行 cmake 时确保环境默认支持 C++11 及以上版本。推荐使用 C++20 以获得最佳兼容性。",[]]