What does the released Milvus Model library actually support?

Milvus Model (the pymilvus.model package) is a Python library that gives embedding and reranking models one shared interface, so you can turn text into vectors and re-score search results without writing a separate adapter for each provider. You install it with pip install "pymilvus[model]". It runs in your application process, not inside the Milvus server: the model you pick here decides which vectors you insert and which vectors you search with. The latest release, 0.3.4, exports twelve dense embedding functions, two sparse, two hybrid (dense plus sparse), and seven rerankers.

Every embedding function follows the same pattern: encode_documents() for the corpus, encode_queries() for search input, and a dim property that tells you how large to make the vector field. Every reranker is a callable that takes a query, a list of documents, and top_k. Swapping OpenAI for a local Sentence Transformers model is therefore a one-line change, as long as you re-embed the collection.

Three places to generate a representation. A wrapper export is not proof of executed inference or universal compatibility. Three places to generate a representation. A wrapper export is not proof of executed inference or universal compatibility.

How do you use a Milvus Model embedding function?

Install the extra and encode a few documents:

pip install "pymilvus[model]"
from pymilvus import model

ef = model.DefaultEmbeddingFunction()   # alias for OnnxEmbeddingFunction

docs = [
    "Artificial intelligence was founded as an academic discipline in 1956.",
    "Alan Turing was the first person to conduct substantial research in AI.",
]
doc_vectors = ef.encode_documents(docs)        # list of numpy arrays
query_vectors = ef.encode_queries(["Who started AI research?"])

print(ef.dim, doc_vectors[0].shape)            # use ef.dim for the FLOAT_VECTOR field

Read ef.dim before you create the collection and set the vector field’s dim to that value. The output vectors are ready for MilvusClient.insert() and MilvusClient.search(). Some wrappers treat queries and documents differently (Cohere, Voyage, and Jina pass a task or input type to the provider; BM25 and SPLADE weight them differently), so always use encode_queries at search time instead of reusing the document method.

Sparse functions return SciPy csr_array rows that go into a SPARSE_FLOAT_VECTOR field. Client-side BM25 needs corpus statistics before it can encode anything:

from pymilvus.model.sparse import BM25EmbeddingFunction
from pymilvus.model.sparse.bm25 import build_default_analyzer

bm25 = BM25EmbeddingFunction(build_default_analyzer(language="en"))
bm25.fit(docs)                 # compute IDF over your corpus
bm25.save("bm25_params.json")  # reload the same statistics at query time
sparse_docs = bm25.encode_documents(docs)

Hybrid functions such as BGEM3EmbeddingFunction return a dictionary with "dense" and "sparse" keys (and optional ColBERT vectors), and their dim is a dictionary too. Each output needs its own field in the schema, which pairs naturally with hybrid search.

Which embedding function should you use?

Start from where you want inference to run and what kind of retrieval you need:

If you want…UseNotes
A hosted API you already pay forOpenAIEmbeddingFunction, CohereEmbeddingFunction, VoyageEmbeddingFunction, JinaEmbeddingFunction, MistralAIEmbeddingFunction, GeminiEmbeddingFunction, NomicEmbeddingFunctionFastest path; pass an explicit model_name and API key
Local inference with an open modelSentenceTransformerEmbeddingFunctionCovers most Hugging Face sentence-embedding checkpoints
A small CPU-friendly baselineModel2VecEmbeddingFunction or DefaultEmbeddingFunctionGood for tests and prototypes, weaker on quality
Your own inference serverTEIEmbeddingFunctionPoints at a Hugging Face Text Embeddings Inference endpoint
Keyword-style sparse retrievalBM25EmbeddingFunction, SpladeEmbeddingFunctionBM25 needs fit(); SPLADE is a learned sparse model
Dense and sparse from one modelBGEM3EmbeddingFunction, MGTEEmbeddingFunctionOne encode call, two vector fields
Better ordering of a shortlistCohereRerankFunction, VoyageRerankFunction, JinaRerankFunction (hosted) or BGERerankFunction, CrossEncoderRerankFunction (local)Run after the initial vector search

Model quality matters more than the wrapper. Use MTEB and an evaluation set from your own data to pick the model, then pick the wrapper that runs it.

The full catalog in 0.3.4

The defaults below are what the wrapper uses if you pass no model_name. Several are older model generations, so pin the model you actually evaluated.

CategoryExportDefault modelWhat it does
denseOpenAIEmbeddingFunctiontext-embedding-ada-002Hosted OpenAI text embeddings
denseSentenceTransformerEmbeddingFunctionall-MiniLM-L6-v2Local Sentence Transformers models
denseVoyageEmbeddingFunctionvoyage-3-largeHosted Voyage embeddings; its dimension table predates Voyage 4
denseJinaEmbeddingFunctionjina-embeddings-v3Jina text API with task and dimension options
denseTEIEmbeddingFunctionset by the endpointCalls a Text Embeddings Inference server
denseOnnxEmbeddingFunctionGPTCache/paraphrase-albert-onnxBundled ONNX model; also exported as DefaultEmbeddingFunction. Not a general ONNX loader
denseCohereEmbeddingFunctionembed-english-light-v3.0Hosted Cohere embeddings with query/document input types
denseMistralAIEmbeddingFunctionmistral-embedHosted Mistral text embeddings
denseNomicEmbeddingFunctionnomic-embed-text-v1.5Nomic SDK text embeddings
denseInstructorEmbeddingFunctionhkunlp/instructor-xlInstruction-conditioned embeddings
denseModel2VecEmbeddingFunctionminishlab/potion-base-8MStatic, very fast Model2Vec embeddings
denseGeminiEmbeddingFunctiongemini-embedding-exp-03-07Gemini text embeddings; predates Gemini Embedding 2
sparseSpladeEmbeddingFunctionnaver/splade-cocondenser-ensembledistilLearned sparse (lexical) vectors
sparseBM25EmbeddingFunctionnone; fit on your corpusClient-side BM25 with an analyzer, k1=1.5, b=0.75
hybridBGEM3EmbeddingFunctionBAAI/bge-m3Dense, sparse, and optional ColBERT output
hybridMGTEEmbeddingFunctionAlibaba-NLP/gte-multilingual-baseMultilingual dense and sparse output
rerankerCohereRerankFunctionrerank-english-v3.0Hosted Cohere reranking
rerankerBGERerankFunctionBAAI/bge-reranker-v2-m3Local BGE reranker via FlagEmbedding
rerankerVoyageRerankFunctionrerank-2Hosted Voyage reranking (older default)
rerankerCrossEncoderRerankFunctionnone; pass model_nameLocal Sentence Transformers CrossEncoder
rerankerJinaRerankFunctionjina-reranker-v2-base-multilingualHosted Jina reranking
rerankerJevRerankFunctionjev-latestTypeSafe Jev evidence scoring with a scientific-claim template
rerankerTEIRerankFunctionset by the endpointReranking through a TEI server

What the library does not cover

The wrappers are text-first. They do not produce image, video, or audio embeddings, and they have no dedicated export for newer checkpoints such as WeMM, KaLM, or R3. For those, call the provider’s SDK or a multimodal model directly and insert the vectors yourself. A wrapper also does not guarantee that every model name you pass will work: Voyage 4 or Gemini Embedding 2 can be requested explicitly, but verify the returned dimension and normalization before encoding a full corpus.

The package name has history worth knowing. The current distribution is pymilvus.model on PyPI, which pymilvus[model] installs for you; the older milvus-model name has a separate release history, so don’t copy an import path from an old notebook without checking it.

Client-side model library or server-side Function?

Milvus can also generate embeddings itself. Since Milvus 2.6, you can declare a TEXTEMBEDDING Function in the collection schema (providers include OpenAI, Azure OpenAI, Cohere, Voyage AI, Gemini, AWS Bedrock, Vertex AI, and TEI), and a BM25 Function computes full-text sparse vectors on the server. Then you insert raw text and search with raw text.

Use pymilvus.model when you want to run open models locally, control batching and GPUs yourself, or reuse the same vectors outside Milvus. Use server-side Functions when you want the database to own the text-to-vector step so every client stays consistent. Note that client-side BM25EmbeddingFunction and the server BM25 Function keep different corpus statistics, so pick one per collection. The trade-offs are covered in client model wrappers vs. server Functions.

Related reading

To put an embedding function to work, follow the Milvus Quickstart and swap in the function you chose, or see the embedding overview for more examples.

Sources

Need a VectorDB for Your GenAI Apps?

Zilliz Cloud is a managed vector database built on Milvus perfect for building GenAI applications.

Try Free

Like the article? Spread the word