improve_sentence_transformers_support
#1
by
arthurbresnu
- opened
{3_CSRSparsity → 3_SparseAutoEncoder}/config.json
RENAMED
|
File without changes
|
3_CSRSparsity/clearn_nfcorpus.pth → 3_SparseAutoEncoder/model.safetensors
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:466eedbe8a8e89291b73bf97fed504b2cc3938ce8731b801aaeb5d213b653173
|
| 3 |
+
size 268648800
|
{3_CSRSparsity → 3_SparseAutoEncoder}/pytorch_model.bin
RENAMED
|
File without changes
|
README.md
CHANGED
|
@@ -11,7 +11,9 @@ tags:
|
|
| 11 |
- text
|
| 12 |
- transformers
|
| 13 |
- text-embeddings-inference
|
| 14 |
-
-
|
|
|
|
|
|
|
| 15 |
model-index:
|
| 16 |
- name: NV-Embed-v2
|
| 17 |
results:
|
|
@@ -25,41 +27,43 @@ model-index:
|
|
| 25 |
- eng-Latn
|
| 26 |
metrics:
|
| 27 |
- type: ndcg@1
|
| 28 |
-
value: 0.
|
| 29 |
- type: ndcg@3
|
| 30 |
-
value: 0.
|
| 31 |
- type: ndcg@5
|
| 32 |
-
value: 0.
|
| 33 |
- type: ndcg@10
|
| 34 |
-
value: 0.
|
| 35 |
- type: ndcg@20
|
| 36 |
-
value: 0.
|
| 37 |
- type: ndcg@100
|
| 38 |
-
value: 0.
|
| 39 |
- type: ndcg@1000
|
| 40 |
-
value: 0.
|
| 41 |
- type: map@10
|
| 42 |
-
value: 0.
|
| 43 |
- type: map@100
|
| 44 |
-
value: 0.
|
| 45 |
- type: map@1000
|
| 46 |
-
value: 0.
|
| 47 |
- type: recall@10
|
| 48 |
-
value: 0.
|
| 49 |
- type: recall@100
|
| 50 |
-
value: 0.
|
| 51 |
- type: recall@1000
|
| 52 |
-
value: 0.
|
| 53 |
- type: precision@1
|
| 54 |
-
value: 0.
|
| 55 |
- type: precision@10
|
| 56 |
-
value: 0.
|
| 57 |
- type: mrr@10
|
| 58 |
-
value: 0.
|
| 59 |
- type: main_score
|
| 60 |
-
value: 0.
|
| 61 |
task:
|
| 62 |
type: Retrieval
|
|
|
|
|
|
|
| 63 |
---
|
| 64 |
|
| 65 |
|
|
@@ -75,25 +79,33 @@ We recommend using ``Transformers 4.47.0.``
|
|
| 75 |
You can evaluate this model loaded by Sentence Transformers with the following code snippet:
|
| 76 |
```python
|
| 77 |
import mteb
|
| 78 |
-
from sentence_transformers import
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
trust_remote_code=True
|
| 82 |
-
)
|
| 83 |
model.prompts = {
|
| 84 |
-
|
| 85 |
}
|
|
|
|
| 86 |
task = mteb.get_tasks(tasks=["NFCorpus"])
|
| 87 |
evaluation = mteb.MTEB(tasks=task)
|
| 88 |
-
evaluation.run(
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
```
|
| 91 |
|
| 92 |
## Citation
|
| 93 |
```bibtex
|
| 94 |
-
@
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
}
|
| 99 |
```
|
|
|
|
| 11 |
- text
|
| 12 |
- transformers
|
| 13 |
- text-embeddings-inference
|
| 14 |
+
- sparse-encoder
|
| 15 |
+
- sparse
|
| 16 |
+
- csr
|
| 17 |
model-index:
|
| 18 |
- name: NV-Embed-v2
|
| 19 |
results:
|
|
|
|
| 27 |
- eng-Latn
|
| 28 |
metrics:
|
| 29 |
- type: ndcg@1
|
| 30 |
+
value: 0.43189
|
| 31 |
- type: ndcg@3
|
| 32 |
+
value: 0.41132
|
| 33 |
- type: ndcg@5
|
| 34 |
+
value: 0.40406
|
| 35 |
- type: ndcg@10
|
| 36 |
+
value: 0.39624
|
| 37 |
- type: ndcg@20
|
| 38 |
+
value: 0.38517
|
| 39 |
- type: ndcg@100
|
| 40 |
+
value: 0.40068
|
| 41 |
- type: ndcg@1000
|
| 42 |
+
value: 0.49126
|
| 43 |
- type: map@10
|
| 44 |
+
value: 0.14342
|
| 45 |
- type: map@100
|
| 46 |
+
value: 0.21866
|
| 47 |
- type: map@1000
|
| 48 |
+
value: 0.2427
|
| 49 |
- type: recall@10
|
| 50 |
+
value: 0.1968
|
| 51 |
- type: recall@100
|
| 52 |
+
value: 0.45592
|
| 53 |
- type: recall@1000
|
| 54 |
+
value: 0.78216
|
| 55 |
- type: precision@1
|
| 56 |
+
value: 0.45511
|
| 57 |
- type: precision@10
|
| 58 |
+
value: 0.32353
|
| 59 |
- type: mrr@10
|
| 60 |
+
value: 0.537792
|
| 61 |
- type: main_score
|
| 62 |
+
value: 0.39624
|
| 63 |
task:
|
| 64 |
type: Retrieval
|
| 65 |
+
base_model:
|
| 66 |
+
- nvidia/NV-Embed-v2
|
| 67 |
---
|
| 68 |
|
| 69 |
|
|
|
|
| 79 |
You can evaluate this model loaded by Sentence Transformers with the following code snippet:
|
| 80 |
```python
|
| 81 |
import mteb
|
| 82 |
+
from sentence_transformers import SparseEncoder
|
| 83 |
+
|
| 84 |
+
model = SparseEncoder("Y-Research-Group/CSR-NV_Embed_v2-Retrieval-NFcorpus", trust_remote_code=True)
|
|
|
|
|
|
|
| 85 |
model.prompts = {
|
| 86 |
+
"NFCorpus-query": "Instruct: Given a question, retrieve relevant documents that answer the question\nQuery:"
|
| 87 |
}
|
| 88 |
+
|
| 89 |
task = mteb.get_tasks(tasks=["NFCorpus"])
|
| 90 |
evaluation = mteb.MTEB(tasks=task)
|
| 91 |
+
evaluation.run(
|
| 92 |
+
model,
|
| 93 |
+
eval_splits=["test"],
|
| 94 |
+
output_folder="./results/NFCorpus",
|
| 95 |
+
show_progress_bar=True,
|
| 96 |
+
encode_kwargs={"convert_to_sparse_tensor": False, "batch_size": 8},
|
| 97 |
+
) # MTEB don't support sparse tensors yet, so we need to convert to dense tensors
|
| 98 |
```
|
| 99 |
|
| 100 |
## Citation
|
| 101 |
```bibtex
|
| 102 |
+
@misc{wen2025matryoshkarevisitingsparsecoding,
|
| 103 |
+
title={Beyond Matryoshka: Revisiting Sparse Coding for Adaptive Representation},
|
| 104 |
+
author={Tiansheng Wen and Yifei Wang and Zequn Zeng and Zhong Peng and Yudi Su and Xinyang Liu and Bo Chen and Hongwei Liu and Stefanie Jegelka and Chenyu You},
|
| 105 |
+
year={2025},
|
| 106 |
+
eprint={2503.01776},
|
| 107 |
+
archivePrefix={arXiv},
|
| 108 |
+
primaryClass={cs.LG},
|
| 109 |
+
url={https://arxiv.org/abs/2503.01776},
|
| 110 |
}
|
| 111 |
```
|
config_sentence_transformers.json
CHANGED
|
@@ -1,27 +1,15 @@
|
|
| 1 |
{
|
| 2 |
"__version__": {
|
| 3 |
-
"sentence_transformers": "
|
| 4 |
"transformers": "4.47.0",
|
| 5 |
"pytorch": "2.5.1+cu12"
|
| 6 |
},
|
| 7 |
"prompts": {
|
| 8 |
-
"Banking77Classification": "Instruct: Given a question, please describe the intent of this question. \n Question: ",
|
| 9 |
-
"MTOPIntentClassification": "Instruct: Given a question, please describe the intent of this question. \n Question: ",
|
| 10 |
-
"TweetSentimentClassification": "Classify the sentiment of a given tweet as either positive, negative, or neutral.",
|
| 11 |
-
"BiorxivClusteringP2P.v2": "Identify the main category of Biorxiv papers based on the titles and abstracts",
|
| 12 |
-
"BiorxivClusteringS2S.v2": "Identify the main category of Biorxiv papers based on the titles",
|
| 13 |
-
"TwentyNewsgroupsClustering": "Identify the topic or theme of the given news articles",
|
| 14 |
-
"FiQA2018": {
|
| 15 |
-
"query": "Given a financial question, retrieve relevant passages that answer the query"
|
| 16 |
-
},
|
| 17 |
-
"SciFact": {
|
| 18 |
-
"query": "Given a scientific claim, retrieve documents that support or refute the claim"
|
| 19 |
-
},
|
| 20 |
"NFCorpus": {
|
| 21 |
-
"query": "Given a question, retrieve relevant documents that answer the question"
|
| 22 |
}
|
| 23 |
},
|
| 24 |
"default_prompt_name": null,
|
| 25 |
"model_type": "SparseEncoder",
|
| 26 |
-
"similarity_fn_name": "
|
| 27 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"__version__": {
|
| 3 |
+
"sentence_transformers": "5.0.0",
|
| 4 |
"transformers": "4.47.0",
|
| 5 |
"pytorch": "2.5.1+cu12"
|
| 6 |
},
|
| 7 |
"prompts": {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
"NFCorpus": {
|
| 9 |
+
"query": "Instruct: Given a question, retrieve relevant documents that answer the question. \n Question: "
|
| 10 |
}
|
| 11 |
},
|
| 12 |
"default_prompt_name": null,
|
| 13 |
"model_type": "SparseEncoder",
|
| 14 |
+
"similarity_fn_name": "cosine"
|
| 15 |
}
|
modules.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
| 20 |
{
|
| 21 |
"idx": 3,
|
| 22 |
"name": "3",
|
| 23 |
-
"path": "
|
| 24 |
-
"type": "sentence_transformers.sparse_encoder.models.
|
| 25 |
}
|
| 26 |
]
|
|
|
|
| 20 |
{
|
| 21 |
"idx": 3,
|
| 22 |
"name": "3",
|
| 23 |
+
"path": "3_SparseAutoEncoder",
|
| 24 |
+
"type": "sentence_transformers.sparse_encoder.models.SparseAutoEncoder"
|
| 25 |
}
|
| 26 |
]
|