tformal commited on
Commit
2f399fc
Β·
verified Β·
1 Parent(s): a8b4bc6

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +187 -0
README.md ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language: en
4
+ base_model: answerdotai/ModernBERT-base
5
+ pipeline_tag: feature-extraction
6
+ library_name: transformers
7
+ tags:
8
+ - splade
9
+ - sparse
10
+ - retrieval
11
+ - modernbert
12
+ ---
13
+
14
+ # SparseUp
15
+
16
+ > **TL;DR:** SparseUp is a strong and efficient sparse retriever trained on the same backbone family and fine-tuning data as DenseOn / LateOn (149M, ModernBERT). Strongest public vocabulary-based sparse encoder we know of under 150M on BEIR-13 (56.4 nDCG@10). Apache 2.0. Use it!
17
+
18
+ For the full story, see the **[blog post](TODO)**.
19
+
20
+ ## About
21
+
22
+ LightOn released open data plus **DenseOn** (single-vector) and **LateOn** (ColBERT). SparseUp fills the missing slot: a learned sparse bag over the 50*k* BPE vocab, so the three architectures can be compared with backbone and data held fixed. The model is initialized from `LateOn-unsupervised` with ModernBERT’s MLM `head` / `decoder.bias` grafted on (`decoder.weight` stays tied to LateOn embeddings). Fine-tuning is contrastive on LightOn’s mixture (7 hard negatives sampled from 50, plus in-batch). No cross-encoder distillation.
23
+
24
+ Three extra knobs *vs* vanilla SPLADE:
25
+ 1. **`logit_shift=15`** β€” `log(1 + ReLU(x βˆ’ 15))` so ReLU support starts sparse
26
+ 2. **`position_top_k=12`** β€” each token keeps 12 vocab dims max before pooling
27
+ 3. **`vocab_fold=case_space`** β€” fold case / `Δ ` surface forms onto one id after pooling
28
+
29
+ Prefixes `[Q] ` / `[D] ` are attended but not pooled. Scoring is **dot product**.
30
+
31
+ ## BEIR (nDCG@10)
32
+
33
+ *Same backbone / data. LateOn and DenseOn from [LightOn](TODO). SparseUp uses Seismic (approximate); their numbers are exact search.*
34
+ | Model | Avg | Avg (w/o MS MARCO) |
35
+ | --- | --- | --- |
36
+ | LateOn | **57.9** | **58.9** |
37
+ | DenseOn | 56.9 | 57.9 |
38
+ | **SparseUp** | 55.4 | 56.4 |
39
+
40
+ *Comparison against competitive sparse encoders. Best model at <150M parameters*
41
+ | Model | Avg (wo/ MS MARCO) |
42
+ | --- | --- |
43
+ | splade-v3 | 51.7 |
44
+ | granite-embedding-30m-sparse | 50.6 |
45
+ | ModernBERT-VT | 52.4 |
46
+ | opensearch-neural-sparse-encoding-v1 | 52.44 |
47
+ | opensearch-neural-sparse-encoding-doc-v3-gte | 54.6 |
48
+ | sparseup | 56.4 |
49
+ | LACONIC-1B** | 58.7 |
50
+
51
+ ## Model description
52
+
53
+ - **Type:** MLM β†’ `log1p(ReLU(x βˆ’ ΞΈ))` β†’ per-position top-k β†’ max-pool β†’ vocab fold
54
+ - **Base:** ModernBERT-base (149M), from LateOn-unsupervised + grafted MLM head
55
+ - **Language:** English
56
+ - **License:** Apache 2.0
57
+ - **Similarity:** dot
58
+ - **Query / doc prefixes:** `[Q] ` / `[D] `
59
+ - **Max lengths (eval):** query 128, document 512
60
+ - **Output:** sparse vector, vocab size ~50k (folded)
61
+ - **Training:** InfoNCE (`T=6`) + FLOPS, LightOn fine-tuning mixture
62
+
63
+ ## Usage
64
+
65
+ ### Transformers
66
+
67
+ ```python
68
+ from transformers import AutoModel
69
+ model = AutoModel.from_pretrained("Linkup-Platform/linkup-sparseup-embed-v1", trust_remote_code=True)
70
+ ```
71
+
72
+ #### basic encode
73
+ ```python
74
+ queries = ["England football player highest paid", "NYC capital which country?"]
75
+ model.encode_to_dict(text, kind="query", round_to=2, top_k=10)
76
+ [{'Δ England': 2.96,
77
+ 'Δ football': 2.68,
78
+ 'Δ paid': 2.65,
79
+ 'Δ player': 2.57,
80
+ 'Δ highest': 2.52,
81
+ 'Δ players': 2.19,
82
+ 'Δ pay': 2.04,
83
+ 'Δ english': 2.03,
84
+ 'Δ eng': 2.03,
85
+ 'Δ footballer': 1.97},
86
+ {'Δ capital': 3.25,
87
+ 'Δ NYC': 3.12,
88
+ 'Δ cap': 3.12,
89
+ 'Δ country': 3.12,
90
+ 'Δ ny': 3.09,
91
+ 'Δ York': 2.87,
92
+ 'Δ countries': 2.59,
93
+ 'Δ capit': 2.55,
94
+ 'Δ nation': 2.47,
95
+ 'Δ Capitol': 2.45}]
96
+ ```
97
+
98
+ #### scoring
99
+ ```python
100
+ documents = [
101
+ "Harry Kane is the England captain and among the highest-paid footballers.",
102
+ "New York City is in the United States, not a national capital.",
103
+ ]
104
+ q = model.encode(queries, kind="query")
105
+ d = model.encode(documents, kind="document")
106
+ print(model.score(q, d))
107
+ #tensor([[113.2993, 0.0000],
108
+ # [ 7.0030, 99.1290]])
109
+ ```
110
+
111
+ #### Diagnosis
112
+
113
+ We also provide utilities to better inspect the content of predictions.
114
+
115
+ * **prediction with attributions**: we associate every non-zero prediction to the input token that produced it (via max-pooling). We also show if a predicted token comes from the input or from expansion.
116
+
117
+ ```python
118
+ print(model.render(text, kind="query", top_k=10))
119
+ ```
120
+
121
+ ```
122
+ query Β· England football player highest paid
123
+ England β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.96 <- Β·England@2
124
+ football β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.68 <- football@3
125
+ paid β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.65 <- paid@6
126
+ player β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.57 <- player@4
127
+ highest β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.52 <- highest@5
128
+ players β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.19 <- player@4 <exp>
129
+ pay β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.04 <- paid@6 <exp>
130
+ english β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.03 <- Β·England@2 <exp>
131
+ eng β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.03 <- Β·England@2 <exp>
132
+ footballer β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 1.97 <- player@4 <exp>
133
+
134
+ query Β· NYC capital which country?
135
+ capital β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 3.25 <- capital@4
136
+ NYC β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 3.12 <- Β·C@3 <exp>
137
+ cap β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 3.12 <- capital@4 <exp>
138
+ country β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 3.12 <- country@6
139
+ ny β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 3.09 <- Β·NY@2
140
+ York β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.87 <- Β·NY@2 <exp>
141
+ countries β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.59 <- country@6 <exp>
142
+ capit β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.55 <- capital@4 <exp>
143
+ nation β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.47 <- country@6 <exp>
144
+ Capitol β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–’β–‘ 2.45 <- capital@4 <exp>
145
+ ```
146
+
147
+ * **visual attribution**: for the input text, we highlight every token that contributed to activate an output token. We represent the "importance" of this token as the max weight activation it produced.
148
+
149
+ ```python
150
+ document = ["The presence of communication amid scientific minds was equally important to the success of the Manhattan Project as scientific intellect was. The only cloud hanging over the impressive achievement of the atomic researchers and engineers is what their success truly meant; hundreds of thousands of innocent lives obliterated."]
151
+ print(model.highlight(text, kind="document", color=True))
152
+ # type: use color=True for a more visual rendering. ⟦ ⟧ / Β« Β» / β€Ή β€Ί represent strong / mid / weak attributions.
153
+ ```
154
+
155
+ ```
156
+ β€ΉTheβ€Ί ⟦presence⟧ Β«ofΒ» ⟦communication⟧ ⟦amid⟧ ⟦scientific⟧ ⟦minds⟧ Β«wasΒ» ⟦equally⟧ ⟦important⟧ Β«toΒ» the ⟦success⟧ Β«ofΒ» Β«theΒ» ⟦Manhattan⟧ ⟦Project⟧ Β«asΒ» β€Ήscientificβ€Ί ⟦intellect⟧ wasΒ«.Β» β€ΉTheβ€Ί Β«onlyΒ» ⟦cloud⟧ ⟦hanging⟧ Β«overΒ» the ⟦impressive⟧ ⟦achievement⟧ of the ⟦atomic⟧ ⟦researchers⟧ β€Ήandβ€Ί ⟦engineers⟧ β€Ήisβ€Ί what their Β«successΒ» Β«trulyΒ» ⟦meant;⟧ ⟦hundreds⟧ Β«ofΒ» ⟦thousands⟧ Β«ofΒ» ⟦innocent⟧ ⟦lives⟧ ⟦obliterated⟧.
157
+ ```
158
+
159
+ ### Sentence Transformers
160
+
161
+ ```python
162
+ from sentence_transformers import SparseEncoder
163
+ model = SparseEncoder("Linkup-Platform/linkup-sparseup-embed-v1")
164
+ queries = [
165
+ "England football player highest paid",
166
+ "NYC capital which country?",
167
+ ]
168
+ q = model.encode_query(queries)
169
+ print(model.decode(q, top_k=10))
170
+ # [[('Δ England', 2.96), ('Δ football', 2.68), ...],
171
+ # [('Δ capital', 3.25), ('Δ NYC', 3.12), ...]]
172
+ ```
173
+
174
+ ```python
175
+ documents = [
176
+ "Harry Kane is the England captain and among the highest-paid footballers.",
177
+ "New York City is in the United States, not a national capital.",
178
+ ]
179
+ d = model.encode_document(documents)
180
+ print(model.similarity(q, d))
181
+ # tensor([[113.29, 0.00],
182
+ # [ 7.00, 99.13]])
183
+ ```
184
+
185
+ ## Citation
186
+ ```TODO
187
+ ```