Muennighoff commited on
Commit
dd40684
1 Parent(s): 3eade56

Update BM25S model

Browse files
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ corpus.jsonl filter=lfs diff=lfs merge=lfs -text
37
+ corpus.mmindex.json filter=lfs diff=lfs merge=lfs -text
38
+ vocab.index.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ library_name: bm25s
4
+ tags:
5
+ - bm25
6
+ - bm25s
7
+ - retrieval
8
+ - search
9
+ - lexical
10
+ ---
11
+
12
+ # BM25S Index
13
+
14
+ This is a BM25S index created with the [`bm25s` library](https://github.com/xhluca/bm25s) (version `0.1.7`), an ultra-fast implementation of BM25. It can be used for lexical retrieval tasks.
15
+
16
+ 💻[BM25S GitHub Repository](https://github.com/xhluca/bm25s)\
17
+ 🌐[BM25S Homepage](https://bm25s.github.io)
18
+
19
+ ## Installation
20
+
21
+ You can install the `bm25s` library with `pip`:
22
+
23
+ ```bash
24
+ pip install "bm25s==0.1.7"
25
+
26
+ # Include extra dependencies like stemmer
27
+ pip install "bm25s[full]==0.1.7"
28
+
29
+ # For huggingface hub usage
30
+ pip install huggingface_hub
31
+ ```
32
+
33
+ ## Loading a `bm25s` index
34
+
35
+ You can use this index for information retrieval tasks. Here is an example:
36
+
37
+ ```python
38
+ import bm25s
39
+ from bm25s.hf import BM25HF
40
+
41
+ # Load the index
42
+ retriever = BM25HF.load_from_hub("mteb/index_arxiv_bm25")
43
+
44
+ # You can retrieve now
45
+ query = "a cat is a feline"
46
+ results = retriever.retrieve(bm25s.tokenize(query), k=3)
47
+ ```
48
+
49
+ ## Saving a `bm25s` index
50
+
51
+ You can save a `bm25s` index to the Hugging Face Hub. Here is an example:
52
+
53
+ ```python
54
+ import bm25s
55
+ from bm25s.hf import BM25HF
56
+
57
+ corpus = [
58
+ "a cat is a feline and likes to purr",
59
+ "a dog is the human's best friend and loves to play",
60
+ "a bird is a beautiful animal that can fly",
61
+ "a fish is a creature that lives in water and swims",
62
+ ]
63
+
64
+ retriever = BM25HF(corpus=corpus)
65
+ retriever.index(bm25s.tokenize(corpus))
66
+
67
+ token = None # You can get a token from the Hugging Face website
68
+ retriever.save_to_hub("mteb/index_arxiv_bm25", token=token)
69
+ ```
70
+
71
+ ## Advanced usage
72
+
73
+ You can leverage more advanced features of the BM25S library during `load_from_hub`:
74
+
75
+ ```python
76
+ # Load corpus and index in memory-map (mmap=True) to reduce memory
77
+ retriever = BM25HF.load_from_hub("mteb/index_arxiv_bm25", load_corpus=True, mmap=True)
78
+
79
+ # Load a different branch/revision
80
+ retriever = BM25HF.load_from_hub("mteb/index_arxiv_bm25", revision="main")
81
+
82
+ # Change directory where the local files should be downloaded
83
+ retriever = BM25HF.load_from_hub("mteb/index_arxiv_bm25", local_dir="/path/to/dir")
84
+
85
+ # Load private repositories with a token:
86
+ retriever = BM25HF.load_from_hub("mteb/index_arxiv_bm25", token=token)
87
+ ```
88
+
89
+ ## Stats
90
+
91
+ This dataset was created using the following data:
92
+
93
+ | Statistic | Value |
94
+ | --- | --- |
95
+ | Number of documents | 2511805 |
96
+ | Number of tokens | 177111187 |
97
+ | Average tokens per document | 70.51 |
98
+
99
+ ## Parameters
100
+
101
+ The index was created with the following parameters:
102
+
103
+ | Parameter | Value |
104
+ | --- | --- |
105
+ | k1 | `1.5` |
106
+ | b | `0.75` |
107
+ | delta | `0.5` |
108
+ | method | `lucene` |
109
+ | idf method | `lucene` |
corpus.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e7820a396ea2153f123f25c68aff67080cc2ec6051de28ecd901760797d86c88
3
+ size 2690252471
corpus.mmindex.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29f064f3adc2758eb9ba57be96ce7f3adcafb559a6c1e0b9768f02b73769960a
3
+ size 26614791
data.csc.index.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d5167d877fa1219dc27898d9d02d7c0996ab606c045fd9b768c77651639cb59
3
+ size 708444876
indices.csc.index.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:95efdd76f20478a1d17f129131c927d9fb18353d823f336165a73876b2dd7ee0
3
+ size 708444876
indptr.csc.index.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7d4af7af6a8d6a5d4efa8b8fd729dceba9d9b78a4a5705152ab5dfa9c9cbe69d
3
+ size 2820904
params.index.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "k1": 1.5,
3
+ "b": 0.75,
4
+ "delta": 0.5,
5
+ "method": "lucene",
6
+ "idf_method": "lucene",
7
+ "dtype": "float32",
8
+ "int_dtype": "int32",
9
+ "num_docs": 2511805,
10
+ "version": "0.1.7"
11
+ }
vocab.index.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4ae9e9a3753f48774f1c4526bfd9ed9b44cb60ff365e73b58617f7d981ff25c5
3
+ size 11842206