开源项目Sphere安装与配置指南

开源项目Sphere安装与配置指南

Sphere Web-scale retrieval for knowledge-intensive NLP Sphere 项目地址: https://gitcode.com/gh_mirrors/sph/Sphere

1. 项目基础介绍

Sphere项目是Facebook Research团队开发的一个开源项目,旨在为知识密集型自然语言处理(NLP)任务提供一个基于互联网语料库的通用、未经过筛选且结构化的知识源。该项目的核心是一个名为CCNet的子集,包含了1.34亿份文档,被分割成了9.06亿个段落,作为互联网语料库。

主要编程语言:Python

2. 项目使用的关键技术和框架

  • Pyserini:一个用于检索的Python库,与Sphere项目的稀疏检索基线兼容。
  • Distributed Faiss:用于近似最近邻搜索的高效分布式库,Sphere项目的密集模型与其兼容。
  • DPR (Dense Passage Retrieval):一种用于检索任务的神经网络模型,Sphere项目中使用了DPR模型进行密集检索。

3. 项目安装和配置准备工作及详细步骤

准备工作

在开始安装之前,请确保您的系统中安装了以下依赖:

  • Python 3.7
  • Java 11(仅用于稀疏索引)
  • Git

安装步骤

克隆项目

首先,使用Git克隆Sphere项目:

git clone git@github.com:facebookresearch/Sphere.git
cd Sphere
创建虚拟环境并安装依赖

接着,创建一个名为sphere的虚拟环境并激活它,然后安装项目依赖:

conda create -n sphere -y python=3.7
conda activate sphere
pip install -e .
稀疏索引安装
  1. 下载并解压稀疏BM25索引:
mkdir -p faiss_index
wget -P faiss_index https://dl.fbaipublicfiles.com/sphere/sphere_sparse_index.tar.gz
tar -xzvf faiss_index/sphere_sparse_index.tar.gz -C faiss_index
  1. 安装Pyserini:
pip install jnius
pip install pyserini==0.9.4.0
  1. 下载稀疏索引配置文件:
mkdir -p configs
wget -P configs https://dl.fbaipublicfiles.com/sphere/bm25_sphere.json
  1. 更新bm25_sphere.json配置文件中的相关字段。
密集索引安装
  1. 下载DPR模型和配置文件:
mkdir -p checkpoints
wget -P checkpoints http://dl.fbaipublicfiles.com/sphere/dpr_web_biencoder.cp

mkdir -p configs
wget -P configs https://dl.fbaipublicfiles.com/sphere/dpr_web_sphere.yaml
  1. 更新dpr_web_sphere.yaml配置文件中的相关字段。

  2. 启动分布式Faiss服务器:

pip install -e git+https://github.com/facebookresearch/distributed-faiss#egg=distributed-faiss
python src/distributed-faiss/scripts/server_launcher.py \
--log-dir logs \
--discovery-config faiss_index/disovery_config.txt \
--num-servers 32 \
--num-servers-per-node 4 \
--timeout-min 4320 \
--save-dir faiss_index/ \
--mem-gb 500 \
--base-port 13034 \
--partition dev

注意事项

  • 请根据您的实际硬件情况调整分布式Faiss服务器配置参数。
  • 确保所有路径和配置正确无误。

按照以上步骤操作,您应该能够成功安装和配置Sphere项目。

Sphere Web-scale retrieval for knowledge-intensive NLP Sphere 项目地址: https://gitcode.com/gh_mirrors/sph/Sphere

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

羿靖炼Humphrey

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值