Skip to main content

A lightweight version of Milvus wrapped with Python.

Project description

A lightweight version of Milvus

Introduction

Milvus Lite is the lightweight version of Milvus, a high-performance vector database that powers AI applications with vector similarity search. This repo contains the core components of Milvus Lite.

With Milvus Lite, you can start building an AI application with vector similarity search within minutes! Milvus Lite is good for running in the following environment:

  • Jupyter Notebook / Google Colab
  • Laptops
  • Edge Devices

Milvus Lite can be imported into your Python application, providing the core vector search functionality of Milvus. Milvus Lite is already included in the Python SDK of Milvus. To use it, you just need pip install pymilvus.

Milvus Lite uses the same API as Milvus Standalone and Distributed, providing a consistent experience across environments. Develop your GenAI applications once and run them anywhere: on a laptop or Jupyter Notebook with Milvus Lite, in a Docker container with Milvus Standalone, or on a K8s cluster with Milvus Distributed for large-scale production.

Milvus Lite is only suitable for small scale prototyping (usually less than a million vectors) or edge devices. For large scale production, we recommend using Milvus Standalone or Milvus Distributed. You can also consider the fully-managed Milvus on Zilliz Cloud.

Requirements

Milvus Lite currently supports the following environments:

  • Ubuntu >= 20.04 (x86_64 and arm64)
  • MacOS >= 11.0 (Apple Silicon M1/M2 and x86_64)

Note: Windows is not yet supported.

Installation

pip install -U pymilvus

We recommend using pymilvus. Since milvus-lite is included in pymilvus version 2.4.2 or above, you can pip install with -U to force update to the latest version and milvus-lite is automatically installed.

If you want to explicitly install milvus-lite package, or you have installed an older version of milvus-lite and would like to update it, you can do pip install -U milvus-lite.

Usage

In pymilvus, specify a local file name as uri parameter of MilvusClient will use Milvus Lite.

from pymilvus import MilvusClient
client = MilvusClient("./milvus_demo.db")

NOTE: Note that the same API also applies to Milvus Standalone, Milvus Distributed and Zilliz Cloud, the only difference is to replace local file name to remote server endpoint and credentials, e.g. client = MilvusClient(uri="http://localhost:19530", token="username:password") for self-hosted Milvus server.

Examples

Following is a simple demo showing how to use Milvus Lite for text search. There are more comprehensive examples for using Milvus Lite to build applications such as RAG, image search, and using Milvus Lite in popular RAG framework such as LangChain and LlamaIndex!

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)

Supported Features

Functionality

Milvus Lite shares the same API as Milvus Standalone, Milvus Distributed and Zilliz Cloud, offering core features including:

  • Insert/upsert operations
  • Vector data persistence and collection management
  • Dense, sparse, and hybrid vector search
  • Metadata filtering
  • Multi-vector support

Index Type

Milvus Lite has limited index type support compared to other Milvus deployments:

  • Prior to version 2.4.11:

    • Only supports the FLAT index type
    • Uses FLAT index regardless of the specified index type in collection creation
  • Version 2.4.11 and later:

    • Supports both FLAT and IVF_FLAT index types
    • For IVF_FLAT indexes:
      • Data size < 100,000: Automatically uses FLAT index internally for better performance
      • Data size ≥ 100,000: Constructs and uses IVF_FLAT index as specified

Known Limitations

Milvus Lite does not support partitions, users/roles/RBAC, alias. To use those features, please choose other Milvus deployment types such as Standalone, Distributed or Zilliz Cloud (fully-managed Milvus).

Migrating data from Milvus Lite

All data stored in Milvus Lite can be easily exported and loaded into other types of Milvus deployment, such as Milvus Standalone on Docker, Milvus Distributed on K8s, or fully-managed Milvus on Zilliz Cloud.

Milvus Lite provides a command line tool that can dump data into a json file, which can be imported into self-hosted Milvus or fully-managed Milvus on Zilliz Cloud.

pip install -U "pymilvus[bulk_writer]"
# The `milvus-lite` command line tool is already included in `milvus-lite` package which is part of "pymilvus", but it also needs some dependencies from `pymilvus[bulk_writer]` for dumping data.

milvus-lite dump -h

usage: milvus-lite dump [-h] [-d DB_FILE] [-c COLLECTION] [-p PATH]

optional arguments:
  -h, --help            show this help message and exit
  -d DB_FILE, --db-file DB_FILE
                        milvus lite db file
  -c COLLECTION, --collection COLLECTION
                        collection that need to be dumped
  -p PATH, --path PATH  dump file storage dir

The following example dumps all data from demo_collection collection that's stored in ./milvus_demo.db (a user specified local file that persists data for Milvus Lite)

To export data:

milvus-lite dump -d ./milvus_demo.db -c demo_collection -p ./data_dir
# ./milvus_demo.db: milvus lite db file
# demo_collection: collection that need to be dumped
#./data_dir : dump file storage dir

You can use the dump file as input to upload data to Zilliz Cloud via Data Import, or a self-hosted Milvus server via Bulk Insert.

Contributing

If you want to contribute to Milvus Lite, please read the Contributing Guide first.

Report a bug

For any bug or feature request, please report it by submitting an issue in milvus-lite repo.

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

milvus_lite-2.5.1-py3-none-manylinux2014_x86_64.whl (55.3 MB view details)

Uploaded Python 3

milvus_lite-2.5.1-py3-none-manylinux2014_aarch64.whl (45.3 MB view details)

Uploaded Python 3

milvus_lite-2.5.1-py3-none-macosx_11_0_arm64.whl (24.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

milvus_lite-2.5.1-py3-none-macosx_10_9_x86_64.whl (27.9 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file milvus_lite-2.5.1-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for milvus_lite-2.5.1-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 25ce13f4b8d46876dd2b7ac8563d7d8306da7ff3999bb0d14b116b30f71d706c
MD5 420c1a605db69041e762608dfc2fb1cf
BLAKE2b-256 d38241d9b80f09b82e066894d9b508af07b7b0fa325ce0322980674de49106a0

See more details on using hashes here.

File details

Details for the file milvus_lite-2.5.1-py3-none-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for milvus_lite-2.5.1-py3-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a13277e9bacc6933dea172e42231f7e6135bd3bdb073dd2688ee180418abd8d9
MD5 d815f3e1faac5d073772d8195d412612
BLAKE2b-256 2ecf3d1fee5c16c7661cf53977067a34820f7269ed8ba99fe9cf35efc1700866

See more details on using hashes here.

File details

Details for the file milvus_lite-2.5.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for milvus_lite-2.5.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a2e031088bf308afe5f8567850412d618cfb05a65238ed1a6117f60decccc95a
MD5 dc24877c0854697b8020960ef773bd5b
BLAKE2b-256 9b2e746f5bb1d6facd1e73eb4af6dd5efda11125b0f29d7908a097485ca6cad9

See more details on using hashes here.

File details

Details for the file milvus_lite-2.5.1-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for milvus_lite-2.5.1-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6b014453200ba977be37ba660cb2d021030375fa6a35bc53c2e1d92980a0c512
MD5 3aa765eb093e32ef783e465052d8b84e
BLAKE2b-256 a9b2acc5024c8e8b6a0b034670b8e8af306ebd633ede777dcbf557eac4785937

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page