Fast CLIP text and image embedding toolkit for Node.js and browser using ONNX.
clipkit-embeddings is a TypeScript library and CLI that enables high-performance CLIP embeddings for both text and images, powered by onnxruntime-node. It allows you to use CLIP models offline for semantic search, similarity computation, or zero-shot classification — both programmatically and via the command line.
- 🔤 Embed text using
clip-text.onnx - 🖼️ Embed images using
clip-image.onnx - 🧠 Cosine similarity for comparing embeddings
- ⚡️ Fast inference with ONNXRuntime
- 🧰 CLI tool for quick use in scripts
- 🌐 Works in Node.js and browser (with bundler)
npm install clipkit-embeddingsnpm install -g clipkit-embeddingsimport { loadTextModel, embedText } from "clipkit-embeddings";
await loadTextModel("onnx/clip-text.onnx");
const embedding = await embedText("a photo of a dog");
console.log(embedding);import { loadImageModel, embedImage } from "clipkit-embeddings";
import { preprocessImage } from "clipkit-embeddings/utils";
await loadImageModel("onnx/clip-image.onnx");
const tensor = await preprocessImage("test/cat.jpg");
const embedding = await embedImage(tensor);
console.log(embedding);import { cosineSimilarity } from "clipkit-embeddings/utils";
const similarity = cosineSimilarity(imageEmbedding, textEmbedding);
console.log("Cosine similarity:", similarity.toFixed(4));Embed text:
clipkit text "a photo of a cat"Embed image:
clipkit image ./path/to/image.jpgclipkit-embeddings/
├── cli/ # CLI logic
├── src/ # Core logic (text/image/utils)
├── test/ # Sample test files and images
├── onnx/ # Model files (.onnx)
│ ├── clip-text.onnx
│ └── clip-image.onnx
├── package.json
├── tsconfig.json
├── README.md
└── LICENSEContributions, issues and feature requests are welcome!
Please open an issue to discuss any major changes beforehand.
This project is licensed under the MIT License.
See the LICENSE file for full text.