alt.freeweights.embed / voyage-4-nano
From: MongoDB <huggingface.co/MongoDB>Newsgroups: alt.freeweights.embedSubject:

voyage-4-nano

Date: 2026-11-15Commit: 5fb34e8Signed: 2DC28CC7B26A283B ✓

Feature extraction model with 346M parameters. Safetensors weights, 704 MB in all. Published by MongoDB under Apache-2.0.

346M params704MBvoyage-4-nanosafetensorspermissive
FactsParams346MSize704 MBFormatssafetensorsTaskfeature extractionLicenseApache-2.0From sourcepermissive
$ fw get MongoDB/voyage-4-nano
# manifest sha256 2aed0a0e39a0… · 704 MB · 16 files
$ fw verify ./voyage-4-nano MongoDB/voyage-4-nano
From sourceHosted (signed)MongoDB/voyage-4-nanoLast check: 2026-11-15 02:30 UTC

Get help: custom fine-tune or private deploy. We review your setup before we quote.

Works with

Evaluate with

Overview

Size
704 MB
Weights
693 MB (safetensors)
Parameters
346M
Formats
safetensors
Task
feature extraction
License
Apache-2.0 (permissive)
Files
16, each with a sha256
Publisher
MongoDB
Added
2026-11-15
Section
alt.freeweights.embed
Lineage

Original release from the publisher.

Where these bytes come from
Publisher at the pinned commit→You

Sources are tried in order. A file counts only when its size and sha256 match the manifest. Sources are checked when you ask for them, not on a timer.

Sources
BadgeHostLast checkResult
From sourcehuggingface.co2026-11-15 02:30 UTCpassed

Model card

From the publisher at commit 5fb34e8. Shown as plain text with links; images open at the publisher.

Image: MongoDB

voyage-4-nano#

Model Overview#

voyage-4-nano is a state-of-the-art text embedding model from the Voyage 4 series, designed for high-performance semantic search and retrieval tasks. This model features:

  • Developed by: Voyage AI
  • Supported Language(s): Multilingual
  • Context Length: 32000
  • Parameters: 180M [Non-embedding] + 160M [Embedding]
  • License: Apache 2.0

For detailed performance metrics and benchmarks, please refer to:

Key Features#

Shared Embedding Space with voyage-4 series#

The shared embedding space introduced in the Voyage 4 model series eliminates the need to re-index your data when switching between models in the series. Embeddings generated by different Voyage 4 models (voyage-4-large, voyage-4, voyage-4-lite, and voyage-4-nano) can be directly compared and used interchangeably. For example, use voyage-4-large for high-fidelity indexing, voyage-4-lite for high-throughput queries, and voyage-4-nano for local development.

Frontier Retrieval Quality at Low Cost#

Outperforms much larger existing embedding models, including voyage-3.5-lite.

Matryoshka Representation Learning (MRL)#

voyage-4-nano is trained with Matryoshka Representation Learning to enable flexible embedding dimensions with minimal loss of retreival quality. It supports 2048, 1024, 512, and 256 dimensional embeddings.

Quantization-Aware Training#

voyage-4-nano uses quantization-aware training to enable flexible output data types with minimal loss of retreival quality. It supports 32-bit floating point, signed and unsigned 8-bit integer, and binary precision outputs.

Usage#

Requires transformers>=4.56 (both 4.x and 5.x are supported).

Via Transformers#
import torch
from transformers import AutoModel, AutoTokenizer


def mean_pool(
    last_hidden_states: torch.Tensor, attention_mask: torch.Tensor
) -> torch.Tensor:
    input_mask_expanded = (
        attention_mask.unsqueeze(-1).expand(last_hidden_states.size()).float()
    )
    sum_embeddings = torch.sum(last_hidden_states * input_mask_expanded, 1)
    sum_mask = input_mask_expanded.sum(1)
    sum_mask = torch.clamp(sum_mask, min=1e-9)
    output_vectors = sum_embeddings / sum_mask
    return output_vectors


# If you have an Nvidia GPU, it's recommended to use exactly the same arguments for Nvidia GPUs. attn_implementation="eager" or "sdpa" also works, but some minor differences in embeddings are expected

device = "cuda"
model = AutoModel.from_pretrained(
    "voyageai/voyage-4-nano",
    trust_remote_code=True,
    attn_implementation="flash_attention_2",
    dtype=torch.bfloat16,
).to(device)
tokenizer = AutoTokenizer.from_pretrained("voyageai/voyage-4-nano")

# Embed queries with prompts
query = "What is the fastest route to 88 Kearny?"
prompt = "Represent the query for retrieving supporting documents: "
inputs = tokenizer(
    prompt + query, return_tensors="pt", padding=True, truncation=True, max_length=32768
)
inputs = {k: v.to(device) for k, v in inputs.items()}
with torch.no_grad():
    outputs = model.forward(**inputs)
embeddings = mean_pool(outputs.last_hidden_state, inputs["attention_mask"])
embeddings = torch.nn.functional.normalize(embeddings, p=2, dim=1)
Via Sentence Transformers#
from sentence_transformers import SentenceTransformer
import torch

# Standard loading, assuming no GPU access
model = SentenceTransformer(
    "voyageai/voyage-4-nano", 
    trust_remote_code=True, 
    truncate_dim=2048
)

# OPTIONAL: Loading for high-performance inference with GPUs
# Use 'flash_attention_2' and 'bfloat16' if your GPU supports it (e.g., A100, H100, RTX 30/40 series)
# model = SentenceTransformer(
#     "voyageai/voyage-4-nano", 
#     trust_remote_code=True, 
#     truncate_dim=2048, 
#     model_kwargs={
#         "attn_implementation": "flash_attention_2",
#         "dtype": torch.bfloat16
#     }
# )

query = "Which planet is known as the Red Planet?"
documents = [
	"Venus is often called Earth's twin because of its similar size and proximity.",
	"Mars, known for its reddish appearance, is often referred to as the Red Planet.",
	"Jupiter, the largest planet in our solar system, has a prominent red spot.",
	"Saturn, famous for its rings, is sometimes mistaken for the Red Planet."
]

# Encode via encode_query and encode_document to automatically use the right prompts
query_embedding = model.encode_query(query)
document_embeddings = model.encode_document(documents)

# Inspect the output shapes
print(f"Query Shape: {query_embedding.shape}")      # Expected: (2048,)
print(f"Document Shape: {document_embeddings.shape}") # Expected: (4, 2048)
  • The encode_query and encode_document methods automatically prepend the "Represent the query for retrieving supporting documents: " and "Represent the document for retrieval: " prompts as defined in config_sentence_transformers.json, respectively.
  • The default embedding dimension is 2048. To obtain lower-dimensional embeddings, you can use the truncate_dim argument in the encode_query and encode_document methods, or when initializing the model via the truncate_dim parameter. For example, model.encode_query(query, truncate_dim=512) will yield 512-dimensional embeddings. The model supports 2048, 1024, 512, and 256-dimensional embeddings.
  • You can post-process the embeddings to lower quantization levels using the precision argument in the encode_query and encode_document methods. For example, model.encode_query(query, precision='int8') will yield signed 8-bit integer embeddings. The supported precisions are 'float32', 'int8', 'uint8', 'binary', and 'ubinary'.
Via vllm#
"""
Example: Run voyage-4-nano on vLLM and compare output embeddings with HuggingFace.

Requires: pip install vllm==0.16.0 sentence-transformers
"""

import torch
import torch.nn.functional as F
import json

from vllm import LLM
from vllm.config import PoolerConfig

query = "Which planet is known as the Red Planet?"
documents = [
    "Venus is often called Earth's twin because of its similar size and proximity.",
    "Mars, known for its reddish appearance, is often referred to as the Red Planet.",
    "Jupiter, the largest planet in our solar system, has a prominent red spot.",
    "Saturn, famous for its rings, is sometimes mistaken for the Red Planet."
]


def get_hf_result(input):
    """Get embeddings from the HuggingFace SentenceTransformer pipeline as a reference."""
    from sentence_transformers import SentenceTransformer

    model = SentenceTransformer(
        "voyageai/voyage-4-nano", trust_remote_code=True, truncate_dim=2048
    )
    if isinstance(input, str):
        return model.encode_query(input).tolist()

    if isinstance(input, list):
        return model.encode_document(input).tolist()


def compare_embeddings(a, b):
    """Compare two embedding vectors and print detailed metrics."""
    a = torch.tensor(a, dtype=torch.float32)
    b = torch.tensor(b, dtype=torch.float32)

    norm_a = a.norm(p=2).item()
    norm_b = b.norm(p=2).item()

    an = F.normalize(a, p=2, dim=0)
    bn = F.normalize(b, p=2, dim=0)

    cosine = torch.dot(an, bn).item()
    l2 = (a - b).norm(p=2).item()
    l2_normed = (an - bn).norm(p=2).item()
    mae = (a - b).abs().mean().item()
    max_abs = (a - b).abs().max().item()

    ret = {
        "dim_a": a.numel(),
        "dim_b": b.numel(),
        "norm_a": norm_a,
        "norm_b": norm_b,
        "cosine_similarity": cosine,
        "l2_distance_raw": l2,
        "l2_distance_normalized": l2_normed,
        "mae": mae,
        "max_abs_diff": max_abs,
    }
    print("Compare the embeddings:", json.dumps(ret, indent=2))
    return ret


def example():
    # voyage-4-nano uses task-specific prompts for queries vs documents
    query_prompt = "Represent the query for retrieving supporting documents: "
    doc_prompt = "Represent the document for retrieval: "

    llm = LLM(
        model="voyageai/voyage-4-nano",
        runner="pooling",
        convert="embed",
        hf_overrides={
            # Use the bidirectional embedding architecture for voyage models
            "architectures": ["VoyageQwen3BidirectionalEmbedModel"],
        },
        trust_remote_code=True,
        dtype="bfloat16",
        max_model_len=32768,
        gpu_memory_utilization=0.5,
        enforce_eager=True,
        pooler_config=PoolerConfig(
            pooling_type="MEAN",
        ),
        enable_mfu_metrics=False,
        disable_log_stats=False,
    )

    # --- Query embedding ---
    query_emb = llm.embed([query_prompt + query])[0].outputs.embedding
    compare_embeddings(query_emb, get_hf_result(query))

    # --- Document embeddings (batched) ---
    embs = llm.embed([doc_prompt + doc for doc in documents])
    doc_embs = [e.outputs.embedding for e in embs]

    doc_embs_hf = get_hf_result(documents)
    for i in range(len(doc_embs)):
        compare_embeddings(doc_embs[i], doc_embs_hf[i])


if __name__ == "__main__":
    example()
Via Ollama and llama.cpp (GGUF)#

GGUF versions for Ollama (0.40.7 or newer) and llama.cpp are available at MongoDB/voyage-4-nano-GGUF. Their embeddings are in the same space as this model (the F16 file matches it to floating-point precision, Q8_0 to within 1e-3 cosine distance).

ollama pull hf.co/MongoDB/voyage-4-nano-GGUF:Q8_0

curl http://localhost:11434/api/embed -d '{
  "model": "hf.co/MongoDB/voyage-4-nano-GGUF:Q8_0",
  "input": ["Represent the query for retrieving supporting documents: Which planet is known as the Red Planet?"],
  "dimensions": 1024
}'

See the GGUF model card for llama.cpp usage, long inputs and memory settings.

Acknowledgments#

This model builds upon foundational work by the Qwen Team at Alibaba. We are grateful for their contributions to the open-source community, which have informed the development of this specialized embedding model for the Voyage 4 series.

We'd like to thank Tom Aarsen for adding sentence transformers suppport and improving transformers integration.

Files

16 files · 704 MBWeights 693 MB (safetensors). Sizes and sha256 from the signed manifest.
Hide all 16 files with their sha256
FileSizesha256
.gitattributes1.52 KB11ad7efa24975ee4b0c3c3a38ed18737f0658a5f75a0a96787b576a78a023361
1_Pooling/config.json313 B2bc529695125f68de57d1fd347e3d2920b993bc635c5f4f09a45e130c102a989
LICENSE.txt11.3 KB6128fb091df68c86035ebf80fde97956e9126c47ad90c19631f34cd98afbfe6c
NOTICE.txt797 Bf30cf8ced2476cbd4ddea495156f33deaf1c2245c5bed0ea46dab895c3aa59d5
README.md10.7 KBa9ef2951500fdbec6fa2486a28ddaeda8280ad99e9e13ddeec8918015e65a51e
config.json1.04 KBbcba1ed5644d9bc592aa6bf0e36e11c6642294b5aef0fe65fdc2d0c8cf098cae
config_sentence_transformers.json378 B4b0f3b9dea0ccb018b705084289d09ad1c4a02ddd277bf2e80bde9887539ef08
docs/MongoDB_Spring-Green.svg11.4 KB6441c0c4027760a21d8e6e8d87ff045694af433109f3c148f0319ae4e9537566
merges.txt1.67 MB599bab54075088774b1733fde865d5bd747cbcc7a547c5bc12610e874e26f5e3
model.safetensors693 MB3dae0c63c81dcab79ac213af331940a1bf2b8a53ec8646be878552890291ad30
modeling_qwen3_bidirectional.py3.49 KB425304da2571d17bf04add3b70fab46d4b7d4466abbe118ef553ccb6fe8fadfe
modules.json349 B84e40c8e006c9b1d6c122e02cba9b02458120b5fb0c87b746c41e0207cf642cf
sentence_bert_config.json59 Bae8658c7cf91db1a3ceee800af0f9bda2c7ad60a88b5c2b4d6d5cb0a4394c9c1
tokenizer.json7.03 MBc0382117ea329cdf097041132f6d735924b697924d6f6fc3945713e96ce87539
tokenizer_config.json7.23 KB58c4abbc36eeccd8b3c8453f262225e8f2803855c88790760b618f4cd9e43be9
vocab.json2.78 MBca10d7e9fb3ed18575dd1e277a2579c16d108e32f27439684afa0e10b1440910
VersionsEach time the pinned upstream commit or file list changed in this repo. Newest first.
Upstream commitDateContents
5fb34e870f pinned now2026-11-15 02:30 UTC16 files · 704 MB

Use it

$ fw get MongoDB/voyage-4-nano
# manifest sha256 2aed0a0e39a0… · 704 MB · 16 files
$ fw verify ./voyage-4-nano MongoDB/voyage-4-nano
fw.pyChecks the signature and every sha256, tries each source in order, resumes.
$ python3 fw.py get https://freeweights.allternit.com/manifests/MongoDB/voyage-4-nano.json --dir ./voyage-4-nano $ python3 fw.py verify ./voyage-4-nano ./MongoDB__voyage-4-nano.json
hfThe Hugging Face CLI with one setting. Same repo id.
$ HF_ENDPOINT=https://freeweights.allternit.com hf download MongoDB/voyage-4-nano --revision 5fb34e870f49f19e79c94d5e118f5ee730133279 --local-dir ./voyage-4-nano
transformersLoad the weights in Python.
import os os.environ["HF_ENDPOINT"] = "https://freeweights.allternit.com" from transformers import AutoModel, AutoTokenizer tok = AutoTokenizer.from_pretrained("MongoDB/voyage-4-nano", revision="5fb34e870f49f19e79c94d5e118f5ee730133279") model = AutoModel.from_pretrained("MongoDB/voyage-4-nano", revision="5fb34e870f49f19e79c94d5e118f5ee730133279", device_map="auto")
sentence-transformersEmbed text with sentence-transformers.
import os os.environ["HF_ENDPOINT"] = "https://freeweights.allternit.com" from sentence_transformers import SentenceTransformer model = SentenceTransformer("MongoDB/voyage-4-nano", revision="5fb34e870f49f19e79c94d5e118f5ee730133279") vectors = model.encode(["Hello"])

License

Name
Apache License 2.0
Id
Apache-2.0
Class
Permissive
Redistribution
yes
Listing
Hosted (signed)
Decided
License as declared by the publisher. No person read it. 2026-11-15
Text in
LICENSE.txt
Text sha256
6128fb091df68c86035ebf80fde97956e9126c47ad90c19631f34cd98afbfe6c
Terms gate
No extra terms beyond the license.

Read the license text

Licenses are checked against the license table. A custom license passes only after a person reads it.

Provenance

From: MongoDB <huggingface.co/MongoDB>Newsgroups: alt.freeweights.embedSubject: voyage-4-nanoDate: 2026-11-15Commit: 5fb34e8Signed: 2DC28CC7B26A283B ✓
Upstream
MongoDB/voyage-4-nano
Pinned commit
5fb34e870f49f19e79c94d5e118f5ee730133279
Manifest
voyage-4-nano.json · .minisig
Manifest sha256
2aed0a0e39a0b8195e0a7d403d828762e3eaf67f89c16ae1f289fd774eb7da28
Signature
minisign, Ed25519, key 2DC28CC7B26A283B
Created
2026-11-15 02:30 UTC
Generator
freeweights-manifest/0.1.0
Takedowns
None.

How to verify

$ curl -O https://freeweights.allternit.com/manifests/MongoDB/voyage-4-nano.json $ curl -O https://freeweights.allternit.com/manifests/MongoDB/voyage-4-nano.json.minisig $ minisign -Vm voyage-4-nano.json -P RWQ7KGqyx4zCLXtUFOqvfv8L3g+8fpKJ1FsuxPyOYMF+4KufbUxKq1Oq $ shasum -a 256 <file> # compare with the Files tab

A manifest whose signature fails must be rejected. A file whose size or sha256 does not match must be discarded. Verify a download

Model tree

1 model in the catalog name this one as their parent.

Quantizations
1
Quantizations 1
Get it
Download
$ HF_ENDPOINT=https://freeweights.allternit.com hf download MongoDB/voyage-4-nano
Open in Freeweights Studio

Pull, verify and run it in the Allternit app on Desktop, web or phone.

Signed manifest
minisign, key 2DC28CC7B26A283B. voyage-4-nano.json. Provenance. Takedown history: none.

Variants

1 quantized or adapter build of voyage-4-nano. Each has its own license check and page.

From: sentence-transformers <huggingface.co/sentence-transformers>Subject: all-MiniLM-L6-v1
From: unsloth <huggingface.co/unsloth>Subject: all-MiniLM-L6-v2
From: mlx-community <huggingface.co/mlx-community>Subject: all-MiniLM-L6-v2-4bit
From: sentence-transformers <huggingface.co/sentence-transformers>Subject: all-mpnet-base-v1
From: sentence-transformers <huggingface.co/sentence-transformers>Subject: allenai-specter
From: sentence-transformers <huggingface.co/sentence-transformers>Subject: bert-base-nli-max-tokens