Feature Extraction
Transformers.js
ONNX
English
clip
text-encoder
quantized
int8
icon-search
browser
Instructions to use Cortiq-Labs/IconClip-ViT-L-14-text-encoder-ONNX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use Cortiq-Labs/IconClip-ViT-L-14-text-encoder-ONNX with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('feature-extraction', 'Cortiq-Labs/IconClip-ViT-L-14-text-encoder-ONNX');
Publish IconClip text encoder q8 (transformers.js layout + quantization linkage)
Browse files
README.md
CHANGED
|
@@ -276,15 +276,24 @@ import { AutoTokenizer, AutoModel } from "@huggingface/transformers";
|
|
| 276 |
|
| 277 |
const repo = "Cortiq-Labs/IconClip-ViT-L-14-text-encoder-ONNX";
|
| 278 |
const tokenizer = await AutoTokenizer.from_pretrained(repo);
|
| 279 |
-
const model = await AutoModel.from_pretrained(repo, {
|
|
|
|
|
|
|
|
|
|
| 280 |
|
| 281 |
-
|
|
|
|
|
|
|
|
|
|
| 282 |
padding: "max_length",
|
| 283 |
-
truncation: true,
|
| 284 |
max_length: 77,
|
|
|
|
| 285 |
});
|
| 286 |
-
const
|
| 287 |
-
//
|
|
|
|
|
|
|
|
|
|
| 288 |
```
|
| 289 |
|
| 290 |
For best results, enable cross-origin isolation (`COOP: same-origin` +
|
|
|
|
| 276 |
|
| 277 |
const repo = "Cortiq-Labs/IconClip-ViT-L-14-text-encoder-ONNX";
|
| 278 |
const tokenizer = await AutoTokenizer.from_pretrained(repo);
|
| 279 |
+
const model = await AutoModel.from_pretrained(repo, {
|
| 280 |
+
dtype: "q8",
|
| 281 |
+
device: "wasm", // or "webgpu" where supported
|
| 282 |
+
});
|
| 283 |
|
| 284 |
+
// CLIP text encoders use a fixed 77-token context window — pad every input
|
| 285 |
+
// to that length. This matches OpenAI CLIP, LAION CLIP, and every other
|
| 286 |
+
// CLIP-family ONNX export on HF.
|
| 287 |
+
const enc = await tokenizer(["shopping cart"], {
|
| 288 |
padding: "max_length",
|
|
|
|
| 289 |
max_length: 77,
|
| 290 |
+
truncation: true,
|
| 291 |
});
|
| 292 |
+
const out = await model(enc);
|
| 293 |
+
// The ONNX exposes the projected 768-d output under the `embeddings` key.
|
| 294 |
+
// transformers.js v4's EncoderOnly fallback uses this name when the
|
| 295 |
+
// CLIPTextModel config maps to the q8 quantized graph.
|
| 296 |
+
const vec = out.embeddings.data; // Float32Array(768), L2-normalised
|
| 297 |
```
|
| 298 |
|
| 299 |
For best results, enable cross-origin isolation (`COOP: same-origin` +
|