A lightweight version of Milvus wrapped with Python.
Project description
Introduction
Milvus is an open-source vector database built to power embedding similarity search and AI applications. Milvus makes unstructured data search more accessible, and provides a consistent user experience regardless of the deployment environment. Milvus Lite is a lightweight version of Milvus that can be embedded into your Python application, integrating the core vector search functionality of Milvus. Please note that it is not suggested to use Milvus Lite in a production environment. Consider using Milvus clustered or the fully managed Milvus on Cloud.
Requirements
Milvus Lite is available in:
- Google Colab
- Jupyter Notebook
Here's also a list of verified OS types where Milvus Lite can successfully build and run:
- Ubuntu >= 20.04 (x86_64)
- MacOS >= 11.0 (Apple Silicon)
Installation
Note that milvus-lite is included in pymilvus since version 2.4.2.
pip install "pymilvus>=2.4.2"
Usage
In pymilvus
, specify a local file name as uri parameter of MilvusClient to use Milvus Lite.
from pymilvus import MilvusClient
client = MilvusClient("./milvus_demo.db")
Or with old connections.connect
API (not recommended):
from pymilvus import connections
connections.connect(uri="./milvus_demo.db")
Examples
from pymilvus import MilvusClient
import numpy as np
client = MilvusClient("./milvus_demo.db")
client.create_collection(
collection_name="demo_collection",
dimension=384 # The vectors we will use in this demo has 384 dimensions
)
# Text strings to search from.
docs = [
"Artificial intelligence was founded as an academic discipline in 1956.",
"Alan Turing was the first person to conduct substantial research in AI.",
"Born in Maida Vale, London, Turing was raised in southern England.",
]
# For illustration, here we use fake vectors with random numbers (384 dimension).
vectors = [[ np.random.uniform(-1, 1) for _ in range(384) ] for _ in range(len(docs)) ]
data = [ {"id": i, "vector": vectors[i], "text": docs[i], "subject": "history"} for i in range(len(vectors)) ]
res = client.insert(
collection_name="demo_collection",
data=data
)
# This will exclude any text in "history" subject despite close to the query vector.
res = client.search(
collection_name="demo_collection",
data=[vectors[0]],
filter="subject == 'history'",
limit=2,
output_fields=["text", "subject"],
)
print(res)
# a query that retrieves all entities matching filter expressions.
res = client.query(
collection_name="demo_collection",
filter="subject == 'history'",
output_fields=["text", "subject"],
)
print(res)
# delete
res = client.delete(
collection_name="demo_collection",
filter="subject == 'history'",
)
print(res)
Contributing
If you want to contribute to Milvus Lite, please read the Contributing Guide first.
Report a bug
When you use or develop milvus-lite, if you find any bug, please report it to us. You could submit an issue in milvus-lite or report you milvus repo if you think it is a Milvus issue.
License
Milvus Lite is under the Apache 2.0 license. See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for milvus_lite-2.4.3-py3-none-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bda7c6bd99434f3a7efa234e42f5455330c50cfead57d670576aafebe747335 |
|
MD5 | d582f1dde808118f1151899fef1bcaea |
|
BLAKE2b-256 | c6a8ef20b988bb3fb435cb2a5088909601897337e4fc0646f76349e8cc6dbc10 |
Hashes for milvus_lite-2.4.3-py3-none-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 522aee5c1baab770cacb8e061d40eb9c37d3250bec88ad3b4a2b3583335b5a55 |
|
MD5 | 1706e6472efd36c2396a4655056a9492 |
|
BLAKE2b-256 | daea235e2aa58835ae4c442d21243b4c9c4cc85a414ecb8110046659e2d556af |
Hashes for milvus_lite-2.4.3-py3-none-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9abc31eccb2bfef0171bb69850d2db8722978f182de1f276d1ee11f285218231 |
|
MD5 | 5886f2b4e0b09caee40120778e52817c |
|
BLAKE2b-256 | 3eaa905a9c15cc4a125b4ad016f785a3b20779cecf391a23fcc3e9d165dc04a5 |