首页
/ Voyager 项目下载及安装教程

Voyager 项目下载及安装教程

2024-12-09 05:43:55作者:瞿蔚英Wynne

1. 项目介绍

Voyager 是一个用于在内存中集合上执行快速近似最近邻搜索的库。它支持 Python 和 Java,并且在两种语言之间具有功能对等性和索引兼容性。Voyager 使用 HNSW 算法,基于开源的 hnswlib 包,并添加了许多功能以提高便利性和速度。该项目在 Spotify 的生产环境中广泛使用,每天查询数亿次,以支持众多面向用户的功能。

2. 项目下载位置

Voyager 项目托管在 GitHub 上,可以通过以下命令克隆项目仓库:

git clone https://github.com/spotify/voyager.git

3. 项目安装环境配置

3.1 系统要求

Voyager 支持多种操作系统和语言版本,具体兼容性如下:

操作系统 语言 版本 x86_64 (Intel) arm64 (ARM)
Linux Python 3.7
Linux Python 3.8
Linux Python 3.9
Linux Python 3.10
Linux Python 3.11
Linux Python 3.12
Linux Java 8-16+
macOS Python 3.7
macOS Python 3.8
macOS Python 3.9
macOS Python 3.10
macOS Python 3.11
macOS Python 3.12
macOS Java 8-16+
Windows Python 3.7
Windows Python 3.8
Windows Python 3.9
Windows Python 3.10
Windows Python 3.11
Windows Python 3.12
Windows Java 8-16+

3.2 环境配置示例

以下是配置 Python 和 Java 环境的示例:

Python 环境配置

# 安装 Python 3.8
sudo apt-get install python3.8

# 安装 pip
sudo apt-get install python3-pip

Java 环境配置

# 安装 OpenJDK 11
sudo apt-get install openjdk-11-jdk

4. 项目安装方式

4.1 Python 安装

# 进入项目目录
cd voyager

# 使用 pip 安装
pip install .

4.2 Java 安装

pom.xml 文件中添加以下依赖:

<dependency>
    <groupId>com.spotify</groupId>
    <artifactId>voyager</artifactId>
    <version>2.0.4</version>
</dependency>

5. 项目处理脚本

以下是一个简单的 Python 脚本示例,用于加载和查询 Voyager 索引:

from voyager import VoyagerIndex

# 创建索引
index = VoyagerIndex()

# 添加向量
index.add_items([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])

# 查询最近邻
results = index.query([1.0, 2.0, 3.0], k=1)

print(results)

通过以上步骤,您可以成功下载、安装并使用 Voyager 项目。

登录后查看全文
热门项目推荐
相关项目推荐