MichaelKarpe's picture
Update README.md
d96e8ca verified
|
raw
history blame
10 kB
metadata
library_name: sentence-transformers
pipeline_tag: sentence-similarity
tags:
  - sentence-transformers
  - feature-extraction
  - sentence-similarity
  - transformers
  - mteb
model-index:
  - name: mxbai-embed-large-v1-sts-matryoshka
    results:
      - task:
          type: STS
        dataset:
          type: mteb/biosses-sts
          name: MTEB BIOSSES
          config: default
          split: test
          revision: d3fb88f8f02e40887cd149695127462bbcf29b4a
        metrics:
          - type: cos_sim_pearson
            value: 89.74819706519132
          - type: cos_sim_spearman
            value: 89.16227258672195
          - type: euclidean_pearson
            value: 87.4894915970516
          - type: euclidean_spearman
            value: 88.82371065549121
          - type: manhattan_pearson
            value: 87.4550672002364
          - type: manhattan_spearman
            value: 88.74479319465274
      - task:
          type: STS
        dataset:
          type: mteb/sickr-sts
          name: MTEB SICK-R
          config: default
          split: test
          revision: a6ea5a8cab320b040a23452cc28066d9beae2cee
        metrics:
          - type: cos_sim_pearson
            value: 87.6165367318343
          - type: cos_sim_spearman
            value: 82.96648281765052
          - type: euclidean_pearson
            value: 85.15841275786363
          - type: euclidean_spearman
            value: 82.59932858741094
          - type: manhattan_pearson
            value: 85.13304536590803
          - type: manhattan_spearman
            value: 82.57423596486754
      - task:
          type: STS
        dataset:
          type: mteb/sts12-sts
          name: MTEB STS12
          config: default
          split: test
          revision: a0d554a64d88156834ff5ae9920b964011b16384
        metrics:
          - type: cos_sim_pearson
            value: 90.28534830444329
          - type: cos_sim_spearman
            value: 82.55267827529079
          - type: euclidean_pearson
            value: 88.25378069753911
          - type: euclidean_spearman
            value: 83.11525616002255
          - type: manhattan_pearson
            value: 88.22692740852892
          - type: manhattan_spearman
            value: 83.09760476508313
      - task:
          type: STS
        dataset:
          type: mteb/sts13-sts
          name: MTEB STS13
          config: default
          split: test
          revision: 7e90230a92c190f1bf69ae9002b8cea547a64cca
        metrics:
          - type: cos_sim_pearson
            value: 92.4873773117415
          - type: cos_sim_spearman
            value: 92.45311856572782
          - type: euclidean_pearson
            value: 91.3940762182452
          - type: euclidean_spearman
            value: 91.99304193285555
          - type: manhattan_pearson
            value: 91.36013458363827
          - type: manhattan_spearman
            value: 91.94059360016104
      - task:
          type: STS
        dataset:
          type: mteb/sts14-sts
          name: MTEB STS14
          config: default
          split: test
          revision: 6031580fec1f6af667f0bd2da0a551cf4f0b2375
        metrics:
          - type: cos_sim_pearson
            value: 92.86047241342555
          - type: cos_sim_spearman
            value: 91.7373997118018
          - type: euclidean_pearson
            value: 91.85151887796326
          - type: euclidean_spearman
            value: 91.84470114529888
          - type: manhattan_pearson
            value: 91.84546446666218
          - type: manhattan_spearman
            value: 91.83943192650281
      - task:
          type: STS
        dataset:
          type: mteb/sts15-sts
          name: MTEB STS15
          config: default
          split: test
          revision: ae752c7c21bf194d8b67fd573edf7ae58183cbe3
        metrics:
          - type: cos_sim_pearson
            value: 91.54334603049196
          - type: cos_sim_spearman
            value: 92.53856973601617
          - type: euclidean_pearson
            value: 91.78019629944465
          - type: euclidean_spearman
            value: 92.34058447365024
          - type: manhattan_pearson
            value: 91.77889261840363
          - type: manhattan_spearman
            value: 92.34415590718599
      - task:
          type: STS
        dataset:
          type: mteb/sts16-sts
          name: MTEB STS16
          config: default
          split: test
          revision: 4d8694f8f0e0100860b497b999b3dbed754a0513
        metrics:
          - type: cos_sim_pearson
            value: 86.44182676813374
          - type: cos_sim_spearman
            value: 88.13762635519763
          - type: euclidean_pearson
            value: 87.368150115143
          - type: euclidean_spearman
            value: 87.80086022782062
          - type: manhattan_pearson
            value: 87.36033717796437
          - type: manhattan_spearman
            value: 87.79278886160228
      - task:
          type: STS
        dataset:
          type: mteb/sts17-crosslingual-sts
          name: MTEB STS17 (en-en)
          config: en-en
          split: test
          revision: af5e6fb845001ecf41f4c1e033ce921939a2a68d
        metrics:
          - type: cos_sim_pearson
            value: 90.45736504439745
          - type: cos_sim_spearman
            value: 90.36467157990322
          - type: euclidean_pearson
            value: 90.19668998748772
          - type: euclidean_spearman
            value: 89.89620750310942
          - type: manhattan_pearson
            value: 90.28020856755623
          - type: manhattan_spearman
            value: 90.06372752006743
      - task:
          type: STS
        dataset:
          type: mteb/sts22-crosslingual-sts
          name: MTEB STS22 (en)
          config: en
          split: test
          revision: eea2b4fe26a775864c896887d910b76a8098ad3f
        metrics:
          - type: cos_sim_pearson
            value: 68.08713149697203
          - type: cos_sim_spearman
            value: 68.46457718572601
          - type: euclidean_pearson
            value: 69.25165385150007
          - type: euclidean_spearman
            value: 68.1342295049583
          - type: manhattan_pearson
            value: 69.30447292480429
          - type: manhattan_spearman
            value: 68.25582089078411
      - task:
          type: STS
        dataset:
          type: mteb/stsbenchmark-sts
          name: MTEB STSBenchmark
          config: default
          split: test
          revision: b0fddb56ed78048fa8b90373c8a3cfc37b684831
        metrics:
          - type: cos_sim_pearson
            value: 88.34259569356074
          - type: cos_sim_spearman
            value: 89.78243695761168
          - type: euclidean_pearson
            value: 89.12060338382234
          - type: euclidean_spearman
            value: 89.67729976099504
          - type: manhattan_pearson
            value: 89.12528974491349
          - type: manhattan_spearman
            value: 89.66532321334671

MichaelKarpe/mxbai-embed-large-v1-sts-matryoshka

This is a sentence-transformers model: It maps sentences & paragraphs to a 1024 dimensional dense vector space and can be used for tasks like clustering or semantic search.

Usage (Sentence-Transformers)

Using this model becomes easy when you have sentence-transformers installed:

pip install -U sentence-transformers

Then you can use the model like this:

from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]

model = SentenceTransformer('MichaelKarpe/mxbai-embed-large-v1-sts-matryoshka')
embeddings = model.encode(sentences)
print(embeddings)

Usage (HuggingFace Transformers)

Without sentence-transformers, you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.

from transformers import AutoTokenizer, AutoModel
import torch


#Mean Pooling - Take attention mask into account for correct averaging
def mean_pooling(model_output, attention_mask):
    token_embeddings = model_output[0] #First element of model_output contains all token embeddings
    input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
    return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)


# Sentences we want sentence embeddings for
sentences = ['This is an example sentence', 'Each sentence is converted']

# Load model from HuggingFace Hub
tokenizer = AutoTokenizer.from_pretrained('MichaelKarpe/mxbai-embed-large-v1-sts-matryoshka')
model = AutoModel.from_pretrained('MichaelKarpe/mxbai-embed-large-v1-sts-matryoshka')

# Tokenize sentences
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')

# Compute token embeddings
with torch.no_grad():
    model_output = model(**encoded_input)

# Perform pooling. In this case, mean pooling.
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])

print("Sentence embeddings:")
print(sentence_embeddings)

Evaluation Results

For an automated evaluation of this model, see the Sentence Embeddings Benchmark: https://seb.sbert.net

Training

The model was trained with the parameters:

DataLoader:

torch.utils.data.dataloader.DataLoader of length 360 with parameters:

{'batch_size': 16, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}

Loss:

sentence_transformers.losses.MatryoshkaLoss.MatryoshkaLoss with parameters:

{'loss': 'CoSENTLoss', 'matryoshka_dims': [1024, 768, 512, 256, 128, 64], 'matryoshka_weights': [1, 1, 1, 1, 1, 1], 'n_dims_per_step': -1}

Parameters of the fit()-Method:

{
    "epochs": 4,
    "evaluation_steps": 1000,
    "evaluator": "sentence_transformers.evaluation.EmbeddingSimilarityEvaluator.EmbeddingSimilarityEvaluator",
    "max_grad_norm": 1,
    "optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
    "optimizer_params": {
        "lr": 2e-05
    },
    "scheduler": "WarmupLinear",
    "steps_per_epoch": null,
    "warmup_steps": 144,
    "weight_decay": 0.01
}

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel 
  (1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)

Citing & Authors