Convert Figma logo to code with AI

milvus-io logomilvus

A cloud-native vector database, storage for next generation AI applications

29,950
2,874
29,950
777

Top Related Projects

20,153

Qdrant - High-performance, massive-scale Vector Database for the next generation of AI. Also available in the cloud https://cloud.qdrant.io/

11,130

Weaviate is an open-source vector database that stores both objects and vectors, allowing for the combination of vector search with structured filtering with the fault tolerance and scalability of a cloud-native database​.

14,940

the AI-native open-source embedding database

Free and Open Source, Distributed, RESTful Search Engine

5,880

AI + Data, online. https://vespa.ai

Quick Overview

Milvus is an open-source vector database designed for managing and searching large-scale vector data. It is built to power AI applications and support similarity search at scale. Milvus offers high performance, scalability, and ease of use for handling embedding vectors generated by machine learning models.

Pros

  • High performance and scalability for similarity search on large datasets
  • Supports multiple index types and distance metrics for diverse use cases
  • Integrates well with popular AI frameworks and tools
  • Offers both standalone and distributed deployment options

Cons

  • Steep learning curve for beginners unfamiliar with vector databases
  • Limited support for complex queries compared to traditional relational databases
  • Requires careful tuning and configuration for optimal performance
  • Documentation can be inconsistent or outdated in some areas

Code Examples

  1. Creating a collection and inserting vectors:
from pymilvus import Collection, FieldSchema, CollectionSchema, DataType

# Define collection schema
fields = [
    FieldSchema("id", DataType.INT64, is_primary=True),
    FieldSchema("embedding", DataType.FLOAT_VECTOR, dim=128)
]
schema = CollectionSchema(fields)

# Create collection
collection = Collection("my_collection", schema)

# Insert vectors
entities = [
    [1, 2, 3],  # ids
    [[1.0, 2.0, ..., 128.0], [2.0, 3.0, ..., 129.0], [3.0, 4.0, ..., 130.0]]  # embeddings
]
collection.insert(entities)
  1. Performing a vector similarity search:
# Search for similar vectors
search_params = {"metric_type": "L2", "params": {"nprobe": 10}}
results = collection.search(
    data=[[1.0, 2.0, ..., 128.0]],  # query vector
    anns_field="embedding",
    param=search_params,
    limit=5,
    expr=None
)

# Process results
for hits in results:
    for hit in hits:
        print(f"ID: {hit.id}, Distance: {hit.distance}")
  1. Creating an index for faster searches:
# Create an IVF_FLAT index
index_params = {
    "metric_type": "L2",
    "index_type": "IVF_FLAT",
    "params": {"nlist": 1024}
}
collection.create_index("embedding", index_params)

Getting Started

To get started with Milvus:

  1. Install Milvus using Docker:

    docker compose up -d
    
  2. Install the Python client:

    pip install pymilvus
    
  3. Connect to Milvus:

    from pymilvus import connections
    connections.connect("default", host="localhost", port="19530")
    
  4. Create a collection, insert data, and perform searches as shown in the code examples above.

For more detailed instructions, refer to the official Milvus documentation.

Competitor Comparisons

20,153

Qdrant - High-performance, massive-scale Vector Database for the next generation of AI. Also available in the cloud https://cloud.qdrant.io/

Pros of Qdrant

  • Written in Rust, offering high performance and memory safety
  • Supports filtering during search, allowing for more precise queries
  • Provides a simple and intuitive API for vector search operations

Cons of Qdrant

  • Smaller community and ecosystem compared to Milvus
  • Limited support for distributed deployments and scalability
  • Fewer indexing algorithms and data types supported

Code Comparison

Qdrant (Python client):

from qdrant_client import QdrantClient

client = QdrantClient("localhost", port=6333)
client.search(
    collection_name="my_collection",
    query_vector=[0.2, 0.1, 0.9, 0.7],
    limit=5
)

Milvus (Python client):

from milvus import Milvus, IndexType, MetricType

milvus = Milvus(host='localhost', port='19530')
status, results = milvus.search(
    collection_name="my_collection",
    query_records=[[0.2, 0.1, 0.9, 0.7]],
    top_k=5,
    params={"nprobe": 16}
)

Both libraries offer straightforward APIs for vector search operations, but Milvus provides more advanced configuration options and supports a wider range of index types and metrics.

11,130

Weaviate is an open-source vector database that stores both objects and vectors, allowing for the combination of vector search with structured filtering with the fault tolerance and scalability of a cloud-native database​.

Pros of Weaviate

  • Built-in GraphQL API for easy querying and data manipulation
  • Supports multiple vector index types (HNSW, LSH, FAISS)
  • Modular architecture with pluggable modules for different functionalities

Cons of Weaviate

  • Smaller community and ecosystem compared to Milvus
  • Limited support for distributed deployments and scaling

Code Comparison

Milvus (Python client):

from pymilvus import Collection, connections

connections.connect()
collection = Collection("example")
results = collection.search(
    data=[[1.0, 2.0, 3.0]],
    anns_field="vector_field",
    param={"metric_type": "L2", "params": {"nprobe": 10}},
    limit=5
)

Weaviate (Python client):

import weaviate

client = weaviate.Client("http://localhost:8080")
results = client.query.get("Example", ["field1", "field2"]).with_near_vector({
    "vector": [1.0, 2.0, 3.0]
}).with_limit(5).do()

Both repositories offer vector similarity search capabilities, but they differ in their approach and features. Milvus focuses on high-performance vector indexing and searching, while Weaviate provides a more comprehensive data object storage solution with built-in GraphQL support. The code examples demonstrate the different query styles and client interactions for each system.

14,940

the AI-native open-source embedding database

Pros of Chroma

  • Simpler setup and usage, ideal for smaller-scale projects
  • Built-in support for various embedding models
  • More lightweight and easier to integrate into existing Python projects

Cons of Chroma

  • Limited scalability compared to Milvus for large-scale vector search
  • Fewer advanced features and customization options
  • Less mature ecosystem and community support

Code Comparison

Chroma:

import chromadb

client = chromadb.Client()
collection = client.create_collection("my_collection")
collection.add(documents=["doc1", "doc2"], metadatas=[{"source": "a"}, {"source": "b"}], ids=["id1", "id2"])
results = collection.query(query_texts=["query"], n_results=2)

Milvus:

from pymilvus import Collection, connections

connections.connect()
collection = Collection("my_collection")
collection.insert([["doc1", "doc2"], [{"source": "a"}, {"source": "b"}]])
results = collection.search(data=["query"], anns_field="vector_field", param={}, limit=2)

Both Chroma and Milvus offer vector database solutions, but they cater to different use cases. Chroma is more suitable for smaller projects and quick integrations, while Milvus excels in large-scale, high-performance vector search applications. The code examples demonstrate the simplicity of Chroma's API compared to Milvus' more detailed configuration options.

Free and Open Source, Distributed, RESTful Search Engine

Pros of Elasticsearch

  • Mature and widely adopted full-text search engine with extensive documentation
  • Powerful query language (DSL) for complex searches and aggregations
  • Supports a wide range of data types and use cases beyond vector search

Cons of Elasticsearch

  • Less optimized for high-dimensional vector search compared to Milvus
  • Can be resource-intensive and complex to set up and maintain at scale
  • Limited support for advanced vector indexing algorithms like HNSW

Code Comparison

Elasticsearch (indexing a vector):

PUT /my-index/_doc/1
{
  "my_vector": [1.5, 2.5, 3.5, 4.5, 5.5]
}

Milvus (inserting vectors):

collection.insert([
    [1.5, 2.5, 3.5, 4.5, 5.5],
    [2.5, 3.5, 4.5, 5.5, 6.5]
])

Both Elasticsearch and Milvus are powerful tools for search and data storage, but they have different strengths. Elasticsearch excels in full-text search and general-purpose document storage, while Milvus is specifically designed for efficient vector similarity search. The choice between them depends on the specific requirements of your project, such as the type of data you're working with and the scale of vector operations needed.

5,880

AI + Data, online. https://vespa.ai

Pros of Vespa

  • More comprehensive search and recommendation capabilities, including real-time big data serving and content-based ranking
  • Built-in support for machine learning model serving and online feature computation
  • Flexible schema-less data model allowing for easy integration of structured and unstructured data

Cons of Vespa

  • Steeper learning curve due to its more complex architecture and broader feature set
  • Higher resource requirements for deployment and operation, especially for smaller-scale applications
  • Less focused on vector similarity search compared to Milvus' specialized approach

Code Comparison

Milvus (Python client):

from milvus import Milvus, IndexType, MetricType

client = Milvus(host='localhost', port='19530')
client.create_collection('example', dimension=128, index_type=IndexType.IVF_FLAT, metric_type=MetricType.L2)

Vespa (Application package):

<schema>
  <document type="example">
    <field name="id" type="string" indexing="summary | attribute"/>
    <field name="embedding" type="tensor<float>(x[128])" indexing="attribute | index"/>
  </document>
</schema>

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

milvus banner
license docker-pull-count discord

What is Milvus?

Milvus is a high-performance vector database built for scale. It is used by AI applications to organize and search through large amount of unstructured data, such as text, images, and multi-modal information.

Milvus is implemented with Go and C++ and employs CPU/GPU instruction-level optimization for best vector search performance. With fully-distributed architecture on K8s, it can handle tens of thousands of search queries on billions of vectors, scale horizontally and maintain data freshness by processing streaming updates in real-time. For smaller use cases, Milvus supports Standalone mode that can run on Docker. In addition, Milvus Lite is a lightweight version suitable for quickstart in python, with simply pip install.

The easiest way to try out Milvus is to use Zilliz Cloud with free trial. Milvus is available as a fully managed service on Zilliz Cloud, with Serverless, Dedicated and BYOC options available.

The Milvus open-source project is under LF AI & Data Foundation, distributed with Apache 2.0 License.

Quickstart

$ pip install -U pymilvus

This installs pymilvus, the Python SDK for Milvus. Use MilvusClient to create a client:

from pymilvus import MilvusClient
  • pymilvus also includes Milvus Lite for quickstart. To create a local vector database, simply instantiate a client with a local file name for persisting data:

    client = MilvusClient("milvus_demo.db")
    
  • You can also specify the credentials to connect to your deployed Milvus server or Zilliz Cloud:

    client = MilvusClient(
      uri="<endpoint_of_self_hosted_milvus_or_zilliz_cloud>",
      token="<username_and_password_or_zilliz_cloud_api_key>")
    

With the client, you can create collection:

client.create_collection(
    collection_name="demo_collection",
    dimension=768,  # The vectors we will use in this demo has 768 dimensions
)

Ingest data:

res = client.insert(collection_name="demo_collection", data=data)

Perform vector search:

query_vectors = embedding_fn.encode_queries(["Who is Alan Turing?", "What is AI?"])
res = client.search(
    collection_name="demo_collection",  # target collection
    data=query_vectors,  # a list of one or more query vectors, supports batch
    limit=2,  # how many results to return (topK)
    output_fields=["vector", "text", "subject"],  # what fields to return
)

Why Milvus

Milvus is designed to handle vector search at scale. Users can store vectors, which are numerical representations of unstructured data, together with other scalar data types such as integers, strings, and JSON objects, to conduct efficient vector search with metadata filtering or hybrid search. Here are why users choose Milvus as vector database:

High Performance at Scale and High Availability

  • Milvus features a distributed architecture that separates compute and storage. Milvus can horizontally scale and adapt to diverse traffic patterns, achieving optimal performance by independently increasing query nodes for read-heavy workload and data node for write-heavy workload. The stateless microservices on K8s allow quick recovery from failure, ensuring high availability. The support for replicas further enhances fault tolerance and throughput by loading data segments on multiple query nodes. See benchmark for performance comparison.

Support for Various Vector Index Types and Hardware Acceleration

  • Milvus separates the system and core vector search engine, allowing it to support all major vector index types that are optimized for different scenarios, including HNSW, IVF, FLAT (brute-force), SCANN, and DiskANN, with quantization-based variations and mmap. Milvus optimizes vector search for advanced features such as metadata filtering and range search. Additionally, Milvus implements hardware acceleration to enhance vector search performance and supports GPU indexing, such as NVIDIA's CAGRA.

Flexible Multi-tenancy and Hot/Cold Storage

  • Milvus supports multi-tenancy with flexible strategies for organizing data in AI applications such as Retrieval-Augmented Generation (RAG). By using databases, collections, partitions, and partition keys, Milvus can handle hundreds to millions of tenants in a single instance. This helps businesses to save resources while handling many tenant, ensuring data isolation, optimized search performance, and flexible access control. Incorporating hot/cold data storage further enhances cost efficiency and performance. Users can config storing frequently accessed hot data on memory or SSD for better performance while less accessed cold data is kept on cost-effective, slower storage. This separation optimizes resource allocation, reduces costs, and maintains high performance for critical tasks. By combining flexible multi-tenancy with hot/cold storage, Milvus helps businesses scale, optimize resources, and manage data efficiently, leading to significant cost savings while still keep high performance.

Sparse Vector for Full Text Search and Hybrid Search

  • Milvus supports full text search with sparse vector. Users can combine sparse vector and dense vector in the same collection, and define functions to rerank results from multiple search requests. For details, refer to Hybrid Search.

Data Security and Fine-grain Access Control

  • Milvus ensures data security by implementing mandatory user authentication, TLS encryption, and Role-Based Access Control (RBAC). User authentication ensures that only authorized users with valid credentials can access the database, while TLS encryption secures all communications within the network. Additionally, RBAC allows for fine-grained access control by assigning specific permissions to users based on their roles. These features make Milvus a robust and secure choice for enterprise applications, protecting sensitive data from unauthorized access and potential breaches.

Milvus is trusted by AI developers to build applications such as text and image search, Retrieval-Augmented Generation (RAG), and recommendation systems. Milvus powers many mission-critical business for startups and enterprises.

Demos and Tutorials

Here is a selection of demos and tutorials to show how to build various types of AI applications made with Milvus:

You can explore a comprehensive Tutorials Overview covering topics such as Retrieval-Augmented Generation (RAG), Semantic Search, Hybrid Search, Question Answering, Recommendation Systems, and various quick-start guides. These resources are designed to help you get started quickly and efficiently.

TutorialUse CaseRelated Milvus Features
Build RAG with MilvusRAGvector search
Multimodal RAG with MilvusRAGvector search, dynamic field
Image Search with MilvusSemantic Searchvector search, dynamic field
Hybrid Search with MilvusHybrid Searchhybrid search, multi vector, dense embedding, sparse embedding
Multimodal Search using Multi VectorsSemantic Searchmulti vector, hybrid search
Question Answering SystemQuestion Answeringvector search
Recommender SystemRecommendation Systemvector search
Video Similarity SearchSemantic Searchvector search
Audio Similarity SearchSemantic Searchvector search
DNA ClassificationClassificationvector search
Text Search EngineSemantic Searchvector search
Search Image by TextSemantic Searchvector search
Image DeduplicationDeduplicationvector search
Graph RAG with MilvusRAGgraph search
Contextual Retrieval with MilvusQuickstartvector search
HDBSCAN Clustering with MilvusQuickstartvector search
Use ColPali for Multi-Modal Retrieval with MilvusQuickstartvector search
Vector VisualizationQuickstartvector search
Movie Recommendation with MilvusRecommendation Systemvector search
Funnel Search with Matryoshka EmbeddingsQuickstartvector search
Image Search RAG Drug Discovery

Ecosystem and Integration

Milvus integrates with a comprehensive suite of AI development tools, such as LangChain, LlamaIndex, OpenAI and HuggingFace, making it an ideal vector store for GenAI applications such as Retrieval-Augmented Generation (RAG). Milvus works with both open-source embedding models and embedding service, in text, image and video modalities. Milvus also provides a convenient util pymilvus[model], users can use the simple wrapper code to transform unstructured data into vector embeddings and leverage reranking models for optimized search results. The Milvus ecosystem also includes Attu for GUI-based administration, Birdwatcher for system debugging, Prometheus/Grafana for monitoring, Milvus CDC for data synchronization, VTS for data migration and data connectors for Spark, Kafka, Fivetran, and Airbyte to build search pipelines.

Check out https://milvus.io/docs/integrations_overview.md for more details.

Documentation

For guidance on installation, usage, deployment, and administration, check out Milvus Docs. For technical milestones and enhancement proposals, check out issues on GitHub.

Contributing

The Milvus open-source project accepts contribution from everyone. See Guidelines for Contributing for details on submitting patches and the development workflow. See our community repository to learn about project governance and access more community resources.

Build Milvus from Source Code

Requirements:

  • Linux systems (Ubuntu 20.04 or later recommended):

    go: >= 1.21
    cmake: >= 3.26.4
    gcc: 9.5
    python: > 3.8 and  <= 3.11
    
  • MacOS systems with x86_64 (Big Sur 11.5 or later recommended):

    go: >= 1.21
    cmake: >= 3.26.4
    llvm: >= 15
    python: > 3.8 and  <= 3.11
    
  • MacOS systems with Apple Silicon (Monterey 12.0.1 or later recommended):

    go: >= 1.21 (Arch=ARM64)
    cmake: >= 3.26.4
    llvm: >= 15
    python: > 3.8 and  <= 3.11
    

Clone Milvus repo and build.

# Clone github repository.
$ git clone https://github.com/milvus-io/milvus.git

# Install third-party dependencies.
$ cd milvus/
$ ./scripts/install_deps.sh

# Compile Milvus.
$ make

For full instructions, see developer's documentation.

Community

Join the Milvus community on Discord to share your suggestions, advice, and questions with our engineering team.

You can also check out our FAQ page to discover solutions or answers to your issues or questions.

Subscribe to Milvus mailing lists:

Follow Milvus on social media:

Reference

Reference to cite when you use Milvus in a research paper:

@inproceedings{2021milvus,
  title={Milvus: A Purpose-Built Vector Data Management System},
  author={Wang, Jianguo and Yi, Xiaomeng and Guo, Rentong and Jin, Hai and Xu, Peng and Li, Shengjun and Wang, Xiangyu and Guo, Xiangzhou and Li, Chengming and Xu, Xiaohai and others},
  booktitle={Proceedings of the 2021 International Conference on Management of Data},
  pages={2614--2627},
  year={2021}
}

@article{2022manu,
  title={Manu: a cloud native vector database management system},
  author={Guo, Rentong and Luan, Xiaofan and Xiang, Long and Yan, Xiao and Yi, Xiaomeng and Luo, Jigao and Cheng, Qianya and Xu, Weizhi and Luo, Jiarui and Liu, Frank and others},
  journal={Proceedings of the VLDB Endowment},
  volume={15},
  number={12},
  pages={3548--3561},
  year={2022},
  publisher={VLDB Endowment}
}