This is a BM25S index created with the
bm25s library (version
0.1.3), an ultra-fast implementation of BM25. It can be used for lexical retrieval tasks.
1pip install "bm25s==0.1.3"
2
3# Include extra dependencies like stemmer
4pip install "bm25s[full]==0.1.3"
5
6# For huggingface hub usage
7pip install huggingface_hub
You can use this index for information retrieval tasks. Here is an example:
1import bm25s
2from bm25s.hf import BM25HF
3
4# Load the index
5retriever = BM25HF.load_from_hub("orionweller/wikipedia-bm25s-model", revision="main")
6
7# You can retrieve now
8query = "a cat is a feline"
9results = retriever.retrieve(query, k=3)
1import bm25s
2from bm25s.hf import BM25HF
3
4# Create a BM25 index and add documents
5retriever = BM25HF()
6corpus = [
7 "a cat is a feline and likes to purr",
8 "a dog is the human's best friend and loves to play",
9 "a bird is a beautiful animal that can fly",
10 "a fish is a creature that lives in water and swims",
11]
12corpus_tokens = bm25s.tokenize(corpus)
13retriever.index(corpus_tokens)
14
15token = None # You can get a token from the Hugging Face website
16retriever.save_to_hub("orionweller/wikipedia-bm25s-model", token=token)