Milvus Lite 简介:Milvus 的轻量级版本
重要说明
我们于 2024 年 6 月升级了 Milvus Lite,使人工智能开发人员能够更快地构建应用程序,同时确保在各种部署选项(包括 Kurbernetes 上的 Milvus、Docker 和托管云服务)中获得一致的体验。Milvus Lite 还集成了各种人工智能框架和技术,通过向量搜索功能简化了人工智能应用的开发。欲了解更多信息,请参阅以下参考资料:
Milvus Lite 发布博客:https://milvus.io/blog/introducing-milvus-lite.md
Milvus Lite 文档:https://milvus.io/docs/quickstart.md
Milvus Lite GitHub 存储库:https://github.com/milvus-io/milvus-lite
Milvus是一个开源向量数据库,专门用于索引、存储和查询由深度神经网络和其他机器学习(ML)模型生成的数十亿规模的 embedding 向量。它已成为许多必须在大规模数据集上执行相似性搜索的公司、研究人员和开发人员的首选。
不过,有些用户可能会觉得完整版 Milvus 太重或太复杂。为了解决这个问题,Milvus 社区最活跃的贡献者之一Bin Ji 创建了 MilvusLite,一个轻量级的 Milvus 版本。
Milvus Lite 是什么?
如前所述,Milvus Lite是 Milvus 的简化替代品,它具有如此多的优点和好处。
- 你可以将它集成到你的 Python 应用程序中,而不会增加额外的重量。
- 由于 Milvus Standalone 能够与嵌入式 Etcdings 和本地存储协同工作,因此它自成一体,不需要任何其他依赖项。
- 你可以将它作为 Python 库导入,也可以将它作为基于命令行界面(CLI)的独立服务器使用。
- 它能与 Google Colab 和 Jupyter Notebook 顺利配合。
- 你可以安全地将工作和编写的代码迁移到其他 Milvus 实例(单机版、集群版和完全托管版),而不会有任何丢失数据的风险。
什么时候应该使用 Milvus Lite?
具体来说,Milvus Lite 在以下情况下最有帮助:
- 当你喜欢在没有Milvus Operator、Helm 或Docker Compose 等容器技术和工具的情况下使用 Milvus 时。
- 使用 Milvus 时不需要虚拟机或容器。
- 希望在 Python 应用程序中加入 Milvus 功能时。
- 想在 Colab 或 Notebook 中启动 Milvus 实例进行快速实验时。
注意:如果你需要高性能、高可用性或高可扩展性,我们不建议在任何生产环境中使用 Milvus Lite。相反,请考虑在生产环境中使用Milvus 集群或Zilliz Cloud 上完全托管的 Milvus。
如何开始使用 Milvus Lite?
现在,让我们来看看如何安装、配置和使用 Milvus Lite。
先决条件
要使用 Milvus Lite,请确保已完成以下要求:
- 安装 Python 3.7 或更高版本。
- 使用下列经过验证的操作系统之一:
- Ubuntu >= 18.04 (x86_64)
- CentOS >= 7.0 (x86_64)
- MacOS >= 11.0 (Apple Silicon)
备注:
- Milvus Lite 使用
manylinux2014
作为基础镜像,使其与大多数 Linux 发行版兼容,适合 Linux 用户使用。 - 在 Windows 上运行 Milvus Lite 也是可能的,不过这还有待全面验证。
安装 Milvus Lite
Milvus Lite 在 PyPI 上提供,因此你可以通过pip
安装。
$ python3 -m pip install milvus
你也可以按如下方法用 PyMilvus 安装它:
$ python3 -m pip install milvus[client]
使用并启动 Milvus Lite
从我们项目库的示例文件夹下载示例笔记本。你有两个使用 Milvus Lite 的选择:要么将它作为 Python 库导入,要么使用 CLI 将它作为独立服务器在你的机器上运行。
- 要将 Milvus Lite 作为 Python 模块启动,请执行以下命令:
from milvus import default_server
from pymilvus import connections, utility
# Start your milvus server
default_server.start()
# Now you can connect with localhost and the given port
# Port is defined by default_server.listen_port
connections.connect(host='127.0.0.1', port=default_server.listen_port)
# Check if the server is ready.
print(utility.get_server_version())
# Stop your milvus server
default_server.stop()
- 要暂停或停止 Milvus Lite,使用
with
语句。
from milvus import default_server
with default_server:
# Milvus Lite has already started, use default_server here.
connections.connect(host='127.0.0.1', port=default_server.listen_port)
- 要将 Milvus Lite 作为基于 CLI 的独立服务器启动,请运行以下命令:
milvus-server
启动 Milvus Lite 后,你可以使用 PyMilvus 或其他你喜欢的工具连接到独立服务器。
以调试模式启动 Milvus Lite
- 要以 Python 模块的调试模式运行 Milvus Lite,请执行以下命令:
from milvus import debug_server, MilvusServer
debug_server.run()
# Or you can create a MilvusServer by yourself
# server = MilvusServer(debug=True)
- 要在调试模式下运行独立服务器,请执行以下命令:
milvus-server --debug
保存数据和日志
- 要为 Milvus Lite 创建一个包含所有相关数据和日志的本地目录,请执行以下命令:
from milvus import default_server
with default_server:
default_server.set_base_dir('milvus_data')
- 要在本地硬盘上保存独立服务器生成的所有数据和日志,请执行以下命令:
$ milvus-server --data milvus_data
配置 Milvus Lite
配置 Milvus Lite 与使用 Python API 或 CLI 设置 Milvus 实例类似。
- 要使用 Python API 配置 Milvus Lite,请使用
MilvusServer
实例的config.set
API 进行基本和额外设置:
from milvus import default_server
with default_server:
default_server.config.set('system_Log_level', 'info')
default_server.config.set('proxy_port', 19531)
default_server.config.set('dataCoord.segment.maxSize', 1024)
- 要使用 CLI 配置 Milvus Lite,运行以下命令进行基本设置:
$ milvus-server --system-log-level info
$ milvus-server --proxy-port 19531
- 或运行以下命令进行额外配置。
$ milvus-server --extra-config dataCoord.segment.maxSize=1024
所有可配置项目都在 Milvus 软件包随附的config.yaml
模板中。
有关如何安装和配置 Milvus Lite 的更多技术细节,请参阅我们的文档。
概述
Milvus Lite 是那些希望以简洁格式获得 Milvus 功能的用户的最佳选择。无论您是研究人员、开发人员还是数据科学家,都值得一试。
Milvus Lite 也是开源社区的一道亮丽风景线,展示了贡献者们的非凡工作。在季斌的努力下,Milvus 现在可以供更多用户使用了。我们迫不及待地想看到季斌和 Milvus 社区其他成员在未来带来的创新想法。
让我们保持联系!
如果您在安装或使用 Milvus Lite 时遇到问题,可以在这里提交问题,或通过Twitter或LinkedIn 联系我们。我们也欢迎你加入我们的Slack 频道,与我们的工程师和整个社区聊天,或者查看我们的周二办公时间!
Try Managed Milvus for Free
Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.
Get StartedLike the article? Spread the word