初始化项目,由ModelHub XC社区提供模型
Model: naver/splade-cocondenser-ensembledistil Source: Original Platform
This commit is contained in:
27
.gitattributes
vendored
Normal file
27
.gitattributes
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.model filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||||
5
1_SpladePooling/config.json
Normal file
5
1_SpladePooling/config.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"pooling_strategy": "max",
|
||||||
|
"activation_function": "relu",
|
||||||
|
"word_embedding_dimension": null
|
||||||
|
}
|
||||||
100
README.md
Normal file
100
README.md
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
---
|
||||||
|
license: cc-by-nc-sa-4.0
|
||||||
|
language: "en"
|
||||||
|
tags:
|
||||||
|
- splade
|
||||||
|
- query-expansion
|
||||||
|
- document-expansion
|
||||||
|
- bag-of-words
|
||||||
|
- passage-retrieval
|
||||||
|
- knowledge-distillation
|
||||||
|
- sentence-transformers
|
||||||
|
- sparse-encoder
|
||||||
|
- sparse
|
||||||
|
pipeline_tag: feature-extraction
|
||||||
|
library_name: sentence-transformers
|
||||||
|
datasets:
|
||||||
|
- ms_marco
|
||||||
|
---
|
||||||
|
|
||||||
|
## SPLADE CoCondenser EnsembleDistil
|
||||||
|
|
||||||
|
SPLADE model for passage retrieval. For additional details, please visit:
|
||||||
|
* paper: https://arxiv.org/abs/2205.04733
|
||||||
|
* code: https://github.com/naver/splade
|
||||||
|
|
||||||
|
| | MRR@10 (MS MARCO dev) | R@1000 (MS MARCO dev) |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `splade-cocondenser-ensembledistil` | 38.3 | 98.3 |
|
||||||
|
|
||||||
|
## Model Details
|
||||||
|
|
||||||
|
This is a [SPLADE Sparse Encoder](https://www.sbert.net/docs/sparse_encoder/usage/usage.html) model. It maps sentences & paragraphs to a 30522-dimensional sparse vector space and can be used for semantic search and sparse retrieval.
|
||||||
|
|
||||||
|
### Model Description
|
||||||
|
- **Model Type:** SPLADE Sparse Encoder
|
||||||
|
- **Base model:** [Luyu/co-condenser-marco](https://huggingface.co/Luyu/co-condenser-marco)
|
||||||
|
- **Maximum Sequence Length:** 512 tokens (256 for evaluation reproduction)
|
||||||
|
- **Output Dimensionality:** 30522 dimensions
|
||||||
|
- **Similarity Function:** Dot Product
|
||||||
|
|
||||||
|
### Full Model Architecture
|
||||||
|
|
||||||
|
```
|
||||||
|
SparseEncoder(
|
||||||
|
(0): MLMTransformer({'max_seq_length': 512, 'do_lower_case': False}) with MLMTransformer model: BertForMaskedLM
|
||||||
|
(1): SpladePooling({'pooling_strategy': 'max', 'activation_function': 'relu', 'word_embedding_dimension': 30522})
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Direct Usage (Sentence Transformers)
|
||||||
|
|
||||||
|
First install the Sentence Transformers library:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -U sentence-transformers
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can load this model and run inference.
|
||||||
|
```python
|
||||||
|
from sentence_transformers import SparseEncoder
|
||||||
|
|
||||||
|
# Download from the 🤗 Hub
|
||||||
|
model = SparseEncoder("naver/splade-cocondenser-ensembledistil")
|
||||||
|
# Run inference
|
||||||
|
queries = ["what causes aging fast"]
|
||||||
|
documents = [
|
||||||
|
"UV-A light, specifically, is what mainly causes tanning, skin aging, and cataracts, UV-B causes sunburn, skin aging and skin cancer, and UV-C is the strongest, and therefore most effective at killing microorganisms. Again â\x80\x93 single words and multiple bullets.",
|
||||||
|
"Answers from Ronald Petersen, M.D. Yes, Alzheimer's disease usually worsens slowly. But its speed of progression varies, depending on a person's genetic makeup, environmental factors, age at diagnosis and other medical conditions. Still, anyone diagnosed with Alzheimer's whose symptoms seem to be progressing quickly â\x80\x94 or who experiences a sudden decline â\x80\x94 should see his or her doctor.",
|
||||||
|
"Bell's palsy and Extreme tiredness and Extreme fatigue (2 causes) Bell's palsy and Extreme tiredness and Hepatitis (2 causes) Bell's palsy and Extreme tiredness and Liver pain (2 causes) Bell's palsy and Extreme tiredness and Lymph node swelling in children (2 causes)",
|
||||||
|
]
|
||||||
|
query_embeddings = model.encode_query(queries)
|
||||||
|
document_embeddings = model.encode_document(documents)
|
||||||
|
print(query_embeddings.shape, document_embeddings.shape)
|
||||||
|
# [1, 30522] [3, 30522]
|
||||||
|
|
||||||
|
# Get the similarity scores for the embeddings
|
||||||
|
similarities = model.similarity(query_embeddings, document_embeddings)
|
||||||
|
print(similarities)
|
||||||
|
# tensor([[ 9.9933, 10.8691, 3.4265]])
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Citation
|
||||||
|
|
||||||
|
If you use our checkpoint, please cite our work:
|
||||||
|
|
||||||
|
```
|
||||||
|
@misc{https://doi.org/10.48550/arxiv.2205.04733,
|
||||||
|
doi = {10.48550/ARXIV.2205.04733},
|
||||||
|
url = {https://arxiv.org/abs/2205.04733},
|
||||||
|
author = {Formal, Thibault and Lassance, Carlos and Piwowarski, Benjamin and Clinchant, Stéphane},
|
||||||
|
keywords = {Information Retrieval (cs.IR), Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
|
||||||
|
title = {From Distillation to Hard Negative Sampling: Making Sparse Neural IR Models More Effective},
|
||||||
|
publisher = {arXiv},
|
||||||
|
year = {2022},
|
||||||
|
copyright = {Creative Commons Attribution Non Commercial Share Alike 4.0 International}
|
||||||
|
}
|
||||||
|
```
|
||||||
26
config.json
Normal file
26
config.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"_name_or_path": "Luyu/co-condenser-marco",
|
||||||
|
"architectures": [
|
||||||
|
"BertForMaskedLM"
|
||||||
|
],
|
||||||
|
"attention_probs_dropout_prob": 0.1,
|
||||||
|
"classifier_dropout": null,
|
||||||
|
"gradient_checkpointing": false,
|
||||||
|
"hidden_act": "gelu",
|
||||||
|
"hidden_dropout_prob": 0.1,
|
||||||
|
"hidden_size": 768,
|
||||||
|
"initializer_range": 0.02,
|
||||||
|
"intermediate_size": 3072,
|
||||||
|
"layer_norm_eps": 1e-12,
|
||||||
|
"max_position_embeddings": 512,
|
||||||
|
"model_type": "bert",
|
||||||
|
"num_attention_heads": 12,
|
||||||
|
"num_hidden_layers": 12,
|
||||||
|
"pad_token_id": 0,
|
||||||
|
"position_embedding_type": "absolute",
|
||||||
|
"torch_dtype": "float32",
|
||||||
|
"transformers_version": "4.11.3",
|
||||||
|
"type_vocab_size": 2,
|
||||||
|
"use_cache": true,
|
||||||
|
"vocab_size": 30522
|
||||||
|
}
|
||||||
14
config_sentence_transformers.json
Normal file
14
config_sentence_transformers.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"model_type": "SparseEncoder",
|
||||||
|
"__version__": {
|
||||||
|
"sentence_transformers": "5.0.0",
|
||||||
|
"transformers": "4.50.3",
|
||||||
|
"pytorch": "2.6.0+cu124"
|
||||||
|
},
|
||||||
|
"prompts": {
|
||||||
|
"query": "",
|
||||||
|
"document": ""
|
||||||
|
},
|
||||||
|
"default_prompt_name": null,
|
||||||
|
"similarity_fn_name": "dot"
|
||||||
|
}
|
||||||
14
modules.json
Normal file
14
modules.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"idx": 0,
|
||||||
|
"name": "0",
|
||||||
|
"path": "",
|
||||||
|
"type": "sentence_transformers.sparse_encoder.models.MLMTransformer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 1,
|
||||||
|
"name": "1",
|
||||||
|
"path": "1_SpladePooling",
|
||||||
|
"type": "sentence_transformers.sparse_encoder.models.SpladePooling"
|
||||||
|
}
|
||||||
|
]
|
||||||
3
pytorch_model.bin
Normal file
3
pytorch_model.bin
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:c16fced81589f81555499208ff7626ee28870c6dc7d4d053c552ff20f3363b0c
|
||||||
|
size 438141995
|
||||||
4
sentence_bert_config.json
Normal file
4
sentence_bert_config.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"max_seq_length": 512,
|
||||||
|
"do_lower_case": false
|
||||||
|
}
|
||||||
1
special_tokens_map.json
Normal file
1
special_tokens_map.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
||||||
1
tokenizer.json
Normal file
1
tokenizer.json
Normal file
File diff suppressed because one or more lines are too long
1
tokenizer_config.json
Normal file
1
tokenizer_config.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"do_lower_case": true, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "do_basic_tokenize": true, "never_split": null, "model_max_length": 512, "name_or_path": "Luyu/co-condenser-marco", "special_tokens_map_file": "/bos/tmp0/luyug/outputs/condenser/models/l2-s6-km-L128-e8-lr1e-4-b256/special_tokens_map.json", "tokenizer_class": "BertTokenizer"}
|
||||||
Reference in New Issue
Block a user