Views
No views yet
Note: This is an ONNX-only model. Ignore the auto-generated snippet above - use the code below withbackend="onnx".
| Variant | File | Size | Notes |
|---|---|---|---|
| FP32 | onnx/model.onnx + model.onnx.data | ~1.3GB | Highest accuracy, external data file |
| INT8 | onnx/model_qint8_avx512.onnx | 332MB | Recommended - 4x smaller, cosine sim ~0.96 vs FP32 |
input_ids, attention_mask (no position_ids required)1from sentence_transformers import SentenceTransformer
2
3# Load the ONNX model
4model = SentenceTransformer(
5 "thomasht86/voyage-4-nano-ONNX",
6 backend="onnx",
7 model_kwargs={"file_name": "onnx/model_qint8_avx512.onnx"},
8)
9
10# For documents (no prefix needed)
11docs = ["The quick brown fox jumps over the lazy dog."]
12doc_embeddings = model.encode(docs)
13
14# For queries (use the prompt name)
15queries = ["What animal jumps over the dog?"]
16query_embeddings = model.encode(queries, prompt_name="query")
17
18print(f"Embedding shape: {doc_embeddings.shape}") # (1, 2048)1import onnxruntime as ort
2import numpy as np
3from transformers import AutoTokenizer
4
5# Load tokenizer and model
6tokenizer = AutoTokenizer.from_pretrained("thomasht86/voyage-4-nano-ONNX")
7session = ort.InferenceSession("onnx/model_qint8_avx512.onnx")
8
9# Tokenize
10text = "The quick brown fox jumps over the lazy dog."
11inputs = tokenizer(text, return_tensors="np", padding=True, truncation=True)
12
13# Run inference (only input_ids and attention_mask needed)
14outputs = session.run(
15 None,
16 {
17 "input_ids": inputs["input_ids"],
18 "attention_mask": inputs["attention_mask"],
19 },
20)
21
22# outputs[0] is token embeddings, outputs[1] is sentence embedding (pooled + normalized)
23token_embeddings = outputs[0] # Shape: (batch, seq_len, 2048)
24sentence_embedding = outputs[1] # Shape: (batch, 2048)
25
26print(f"Sentence embedding shape: {sentence_embedding.shape}")1query_prefix = "Represent the query for retrieving supporting documents: "
2query = query_prefix + "What is the capital of France?"1<component id="voyage" type="hugging-face-embedder">
2 <transformer-model url="https://huggingface.co/thomasht86/voyage-4-nano-ONNX/resolve/main/onnx/model_qint8_avx512.onnx"/>
3 <tokenizer-model url="https://huggingface.co/thomasht86/voyage-4-nano-ONNX/raw/main/tokenizer.json"/>
4 <pooling-strategy>mean</pooling-strategy>
5 <normalize>true</normalize>
6 <prepend>
7 <query>Represent the query for retrieving supporting documents: </query>
8 </prepend>
9</component>schema doc {
document doc {
field text type string {
indexing: summary | index
}
}
field embedding type tensor<float>(x[2048]) {
indexing: input text | embed voyage | attribute | index
attribute {
distance-metric: angular
}
index {
hnsw {
max-links-per-node: 16
neighbors-to-explore-at-insert: 200
}
}
}
}| Text Type | Cosine Similarity |
|---|---|
| Short sentences | ~0.96 |
| Long paragraphs | ~0.96 |