向量数据库Milvas

Milvus是在2019年创建的,其唯一目标是存储、索引和管理由深度神经网络和其他机器学习(ML)模型生成的大规模嵌入向量。

Milvus的概述 – Milvus向量库中文文档 (milvus-io.com)

Milvus 2.0 概述 - 《Milvus 帮助手册-教程 - V2 版本》 - 极客文档 (geekdaxue.co)

核心概念详见这里,其中常见的如下:

实体(Entity),代表现实世界对象的一组字段。在 Milvus 中,每个实体都由唯一的主键表示。同一集合中可以存在重复的主键。

集合(collection),用于存储和管理实体。相当于关系型数据库管理系统(RDBMS)中的表。

字段(field),是组成实体的单元。字段可以是结构化数据(例如数字、字符串)或向量。

Schema(模式),用于定义数据类型和数据属性的元信息。每个集合都有自己的集合 schema,定义集合的字段(field)、启用自动 ID(主键)分配,集合描述、字段名称、数据类型和其他属性的字段模式。简言之就是数据库的组织和结构。

嵌入向量(embedding vector)是对非结构化数据(如电子邮件、IoT 传感器数据、Instagram 照片、蛋白质结构等)的特征抽象。从数学上讲,嵌入向量是一组浮点数或二进制数的数组。

向量索引(vector index)是从原始数据派生出的重新组织的数据结构,可以大大加速向量相似度搜索的过程,如使用欧几里得距离(L2)作为相似度指标构建了一个1,024个簇的IVF_FLAT索引。如果没有在向量上构建索引,Milvus将默认执行暴力搜索。

向量相似度搜索(Vector similarity search)是比较一个向量与数据库中的向量,以找到与目标搜索向量最相似的向量的过程。用于计算向量之间的相似度(similarity)的算法通常采用近似最近邻(ANN)搜索。

检查集合信息
from pymilvus import Collection
collection = Collection("book")  # Get an existing collection.
 
collection.schema                # Return the schema.CollectionSchema of the collection.
collection.description           # Return the description of the collection.
collection.name                  # Return the name of the collection.
collection.is_empty              # Return the boolean value that indicates if the collection is empty.
collection.num_entities          # Return the number of entities in the collection.
collection.primary_field         # Return the schema.FieldSchema of the primary key field.
collection.partitions            # Return the list[Partition] object.
collection.indexes               # Return the list[Index] object.
collection.properties		# Return the expiration time of data in the collection.
 
使用方法
 以图搜图 - zwbsoft - 博客园 (cnblogs.com)

为AI而生的数据库:Milvus详解及实战_milvus怎么实现混合查询(向量和标量查询)-CSDN博客

可视化工具Attu

Milvus 图形化管理工具 Attu 来袭! - 知乎 (zhihu.com)

注意事项:
  • 搜索参数的设置详见这里,其中主要的参数如下
data 用于搜索的向量
anns_field 要搜索的字段名称
params 用于索引构建的指标类型特定的搜索参数。详情请见向量索引(Vector Index)
offset 返回结果中要跳过的结果数。设置过大导致距离小的结果无法返回。
limit 要返回的最相似结果的数量

参考文献:

  1. Milvus documentation

你可能感兴趣的:(人工智能)