This is a BM25S index created with the bm25s library (version 0.2.0), an ultra-fast implementation of BM25. It can be used for lexical retrieval tasks.
1pip install"bm25s==0.2.0"23# For huggingface hub usage4pip install huggingface_hub
Loading a bm25s index
You can use this index for information retrieval tasks. Here is an example:
python
1import bm25s
2from bm25s.hf import BM25HF
34# Load the index5retriever = BM25HF.load_from_hub("dadashzadeh/2023_10_en_keywords_Cryptocurrency")67# You can retrieve now8query ="a cat is a feline"9results = retriever.retrieve(bm25s.tokenize(query), k=3)
Saving a bm25s index
You can save a bm25s index to the Hugging Face Hub. Here is an example:
python
1import bm25s
2from bm25s.hf import BM25HF
34corpus =[5"northwest bank",6"misfits market",7"merrick bank login",8"marketing",9"market place",10"jetblue customer service",11"internal revenue service",12"how to make money online",13"gordon food service",14"futures market",15"frontier airlines customer service",16"food banks near me",17"first convenience bank",18"eastern bank",19"dollar bank",20]2122retriever = BM25HF(corpus=corpus)23retriever.index(bm25s.tokenize(corpus))2425token =None# You can get a token from the Hugging Face website26retriever.save_to_hub("dadashzadeh/2023_10_en_keywords_Cryptocurrency", token=token)
Advanced usage
You can leverage more advanced features of the BM25S library during load_from_hub:
python
1# Load corpus and index in memory-map (mmap=True) to reduce memory2retriever = BM25HF.load_from_hub("dadashzadeh/2023_10_en_keywords_Cryptocurrency", load_corpus=True, mmap=True)34# Load a different branch/revision5retriever = BM25HF.load_from_hub("dadashzadeh/2023_10_en_keywords_Cryptocurrency", revision="main")67# Change directory where the local files should be downloaded8retriever = BM25HF.load_from_hub("dadashzadeh/2023_10_en_keywords_Cryptocurrency", local_dir="/path/to/dir")910# Load private repositories with a token:11retriever = BM25HF.load_from_hub("dadashzadeh/2023_10_en_keywords_Cryptocurrency", token=token)
Stats
This dataset was created using the following data: 497 keywords Cryptocurrency (semrush)
Statistic
Value
Number of documents
602959
Number of tokens
2414020
Average tokens per document
4.0
Parameters
The index was created with the following parameters:
Parameter
Value
k1
1.5
b
0.75
delta
0.5
method
lucene
idf method
lucene
Citation
To cite bm25s, please use the following bibtex:
@misc{lu_2024_bm25s,
title={BM25S: Orders of magnitude faster lexical search via eager sparse scoring},
author={Xing Han Lù},
year={2024},
eprint={2407.03618},
archivePrefix={arXiv},
primaryClass={cs.IR},
url={https://arxiv.org/abs/2407.03618},
}