Registry / vector-search / pymilvus-model

pymilvus-model

JSON →
library0.3.2pypypiunverified

PyMilvus Model is a Python library that provides model components, primarily for generating dense and sparse embeddings, intended for use with Milvus. It leverages popular deep learning frameworks like Hugging Face Transformers and Sentence-Transformers to offer a unified interface for various pre-trained models. The current version is 0.3.2, and it typically releases updates as new features or model integrations become available, often in sync with PyMilvus SDK developments.

pip install pymilvus-model
INSTALL
IMPORT
SIG · PYMILVUS-MODEL
P
pymilvus-model
vector-searchpythonv0.3.2
Install
20.5s avg
Import
Disk
460MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 20.5s · import 0.000s · 482MB
460MB installed
● package 460MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DenseEncoder
from pymilvus.model.dense import DenseEncoder
from pymilvus.model.dense import DenseEncoder

This quickstart demonstrates how to initialize a `DenseEncoder` and use it to generate embeddings for a list of texts. It uses a popular sentence transformer model. Remember to specify `device='cuda'` if you have a GPU for faster encoding and have PyTorch installed with CUDA support.

from pymilvus_model.dense.encoder import DenseEncoder # Initialize a DenseEncoder with a common embedding model # Ensure the model name is valid and accessible (e.g., from Hugging Face Model Hub) encoder = DenseEncoder(model_name='BAAI/bge-small-en-v1.5', device='cpu') # Change to 'cuda' if GPU available and configured texts = [ 'The quick brown fox jumps over the lazy dog.', 'Artificial intelligence is rapidly advancing.', 'Milvus is an open-source vector database.' ] # Encode documents to get dense embeddings embeddings = encoder.encode_documents(texts) print(f"Encoded {len(texts)} texts.") print(f"Shape of embeddings: {embeddings.shape}") print(f"First embedding (truncated): {embeddings[0][:5]}...")
Debug
Known issues
gotchaModel names provided to `DenseEncoder` or `SparseEncoder` must correspond to models supported by the underlying `sentence-transformers` or `transformers` library, and be accessible on the Hugging Face Model Hub. Misspelled or unsupported model names will lead to loading errors.
fix
Always verify model names on the Hugging Face Model Hub (e.g., `huggingface.co/models`) and ensure they are compatible with `sentence-transformers` or `transformers`' auto-loading mechanisms.
affects: All versions
gotchaUsing large embedding models or encoding many texts can be computationally intensive. By default, `torch` might use the CPU, leading to slow performance. GPU acceleration (CUDA) is highly recommended for production use cases.
fix
Initialize encoders with `device='cuda'` if a compatible GPU is available (e.g., `DenseEncoder(model_name='...', device='cuda')`). Ensure `torch` is installed with CUDA support (`pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118` or similar for your CUDA version).
affects: All versions
deprecatedThe `pymilvus_model` library is relatively new (0.x.x) and its API might evolve in future minor versions. While no specific breaking changes are noted yet, expect potential adjustments in argument names or class structures as it matures towards a 1.0 release.
fix
Pin `pymilvus-model` to a specific version in `requirements.txt` to ensure stability. Review the official GitHub repository for release notes before upgrading to new minor versions.
affects: <1.0.0
Upgrade
Version history
0.3.2latest on PyPI · released Mar 31, 2025
Audit
Dependencies
sentence-transformersrequiredCore dependency for loading and using embedding models.
torchrequiredUnderlying deep learning framework for model execution.
Agent activity
39 hits · last 30 days
node
32
OpenAI (training)
1
Resources
pymilvus-model — pip install pymilvus-model · libregistry