{"id":8498,"library":"pymilvus-model","title":"PyMilvus Model Components","description":"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.","status":"active","version":"0.3.2","language":"python","source_language":"en","source_url":"https://github.com/milvus-io/pymilvus-model","tags":["vector-database","milvus","embedding","model","nlp","ai"],"install":[{"cmd":"pip install pymilvus-model","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for loading and using embedding models.","package":"sentence-transformers"},{"reason":"Underlying deep learning framework for model execution.","package":"torch"}],"imports":[{"wrong":"from pymilvus.model.dense import DenseEncoder","symbol":"DenseEncoder","correct":"from pymilvus.model.dense import DenseEncoder"}],"quickstart":{"code":"from pymilvus_model.dense.encoder import DenseEncoder\n\n# Initialize a DenseEncoder with a common embedding model\n# Ensure the model name is valid and accessible (e.g., from Hugging Face Model Hub)\nencoder = DenseEncoder(model_name='BAAI/bge-small-en-v1.5', device='cpu') # Change to 'cuda' if GPU available and configured\n\ntexts = [\n    'The quick brown fox jumps over the lazy dog.',\n    'Artificial intelligence is rapidly advancing.',\n    'Milvus is an open-source vector database.'\n]\n\n# Encode documents to get dense embeddings\nembeddings = encoder.encode_documents(texts)\n\nprint(f\"Encoded {len(texts)} texts.\")\nprint(f\"Shape of embeddings: {embeddings.shape}\")\nprint(f\"First embedding (truncated): {embeddings[0][:5]}...\")\n","lang":"python","description":"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."},"warnings":[{"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.","message":"Model 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.","severity":"gotcha","affected_versions":"All versions"},{"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).","message":"Using 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"The `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.","severity":"deprecated","affected_versions":"<1.0.0"}],"env_vars":null,"search_vec":"'0.3.2':55 'ai':83 'avail':68 'becom':67 'compon':3,13 'current':52 'databas':78 'deep':29 'dens':17 'develop':75 'embed':20,80 'face':34 'featur':63 'framework':31 'generat':16 'hug':33 'integr':66 'intend':21 'interfac':44 'learn':30 'leverag':27 'librari':9 'like':32 'milvus':25,79 'model':2,5,12,50,65,81 'new':62 'nlp':82 'offer':41 'often':69 'popular':28 'pre':48 'pre-train':47 'primarili':14 'provid':11 'pymilvus':1,4,73 'python':8 'releas':59 'sdk':74 'sentenc':38 'sentence-transform':37 'spars':19 'sync':71 'train':49 'transform':35,39 'typic':58 'unifi':43 'updat':60 'use':23 'various':46 'vector':77 'vector-databas':76 'version':53","created_at":"2026-04-16T17:02:30.734488+00:00","updated_at":"2026-04-16T17:02:30.734488+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmpooiyj8a_/venv/lib/python3.12/site-packages/pymilvus/model/__init__.py\", line 3, in <module>\n    from . import dense, hybrid, sparse, reranker, utils\n  File \"/tmp/tmpooiyj8a_/venv/lib/python3.12/site-packages/py"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.3.2","cli_name":"","cli_version":null,"type":"library","homepage":"https://milvus.io","github":"https://github.com/milvus-io/milvus-model","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pymilvus-model/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["vector-search","ai-ml","llm-agents","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}