Jasper Token Compression 600M ONNX INT4

Corrected ONNX export from Jasper Token Compression 600M at upstream revision e1373068c35fba2a37568da4eb4105377e17eae9. The corrected graph computes per-row lengths and adaptive pooling at runtime.

Input and output

Tensor Type Shape
input_ids INT64 batch ร— tokens
attention_mask INT64 batch ร— tokens
sentence_embedding FP32 batch ร— 2,048

Use a contiguous run of ones per text, with optional left or right padding marked by zeros. Keep at least one valid token per row. This export was tested from 1 through 1,024 tokens and uses the upstream default compression ratio of 0.5 above 80 valid tokens. The embedding is L2-normalized. The graph has no persistent KV cache.

Use ONNX Runtime and the bundled tokenizer. For retrieval queries, prepend the query instruction from the bundled config_sentence_transformers.json. Embed documents without that prefix. Keep tokenizer, prompt and export revision consistent across index and query inference. Rebuild any index created with the older ONNX graph.

import numpy as np
import onnxruntime as ort
from tokenizers import Tokenizer

tokenizer = Tokenizer.from_file("tokenizer.json")
tokenizer.enable_truncation(max_length=1024)
tokenizer.enable_padding(pad_id=151643, pad_token="<|endoftext|>", direction="left")
rows = tokenizer.encode_batch(["A short record.", "A longer example record."], add_special_tokens=False)
s = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
vectors = s.run(["sentence_embedding"], {
    "input_ids": np.asarray([r.ids for r in rows], dtype=np.int64),
    "attention_mask": np.asarray([r.attention_mask for r in rows], dtype=np.int64),
})[0]

This graph uses blockwise 4-bit weight quantization and ONNX Runtime quantized MatMul and Gather operators. Its long-input vectors diverged more from the reference than INT8. Evaluate retrieval fidelity on your corpus before adoption.

Downloads last month
23
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for magiccodingman/Jasper-Token-Compression-600M-ONNX-INT4

Quantized
(4)
this model