Instructions to use magiccodingman/Jasper-Token-Compression-600M-ONNX-INT4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use magiccodingman/Jasper-Token-Compression-600M-ONNX-INT4 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("magiccodingman/Jasper-Token-Compression-600M-ONNX-INT4", trust_remote_code=True) sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
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
Model tree for magiccodingman/Jasper-Token-Compression-600M-ONNX-INT4
Base model
Qwen/Qwen3-0.6B-Base