开源项目Sphere使用教程

开源项目Sphere使用教程

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

1. 项目介绍

Sphere是一个开源项目,由Facebook Research团队开发。该项目旨在利用开放的网页语料库作为知识密集型自然语言处理(KI-NLP)任务的通用、未经过滤和结构化的知识源。Sphere项目通过结合强大的检索基线和一个开放的网页语料库,促进了透明和可重复的研究,并为进一步比较为人类优化的搜索引擎和为神经网络设计的检索解决方案铺平了道路。

2. 项目快速启动

以下步骤将帮助您快速启动Sphere项目:

首先,克隆项目仓库:

git clone git@github.com:facebookresearch/Sphere.git
cd Sphere

接着,创建一个Python虚拟环境并激活它:

conda create -n sphere -y python=3.7 && conda activate sphere

然后,安装项目:

pip install -e .

3. 应用案例和最佳实践

案例一:使用Sphere进行检索

Sphere提供了预构建的索引,可用于稀疏检索和密集检索。以下是如何下载和使用这些索引的示例:

稀疏检索
  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. 使用KILT工具评估检索性能,您需要先安装KILT:
pip install -e git+https://github.com/facebookresearch/KILT#egg=KILT
  1. 执行检索:
python src/kilt/scripts/execute_retrieval.py --model_name bm25 --model_configuration configs/bm25_sphere.json --test_config src/kilt/kilt/configs/dev_data.json --output_folder output/sparse/
密集检索
  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. 修改配置文件中的相关字段,如n_docs, model_file, rpc_retriever_cfg_file, 和rpc_index_id

  2. 启动分布式-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
  1. 执行检索:
python src/kilt/scripts/execute_retrieval.py --model_name dpr_distr --model_configuration configs/dpr_web_sphere.yaml --test_config src/kilt/kilt/configs/dev_data.json --output_folder output/dense/

4. 典型生态项目

Sphere项目可以与多个生态项目配合使用,例如:

  • Pyserini:用于评估检索系统的工具。
  • KILT:一个用于检索式问答任务的数据集和评估框架。
  • Distributed-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
发出的红包

打赏作者

吴年前Myrtle

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

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

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

打赏作者

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

抵扣说明:

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

余额充值