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-modelVerified import paths — ran on the pinned version, not inferred.
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.
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.
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).
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.