CoolFace
Modelpublic

kushalc1/sarashina-embedding-v2-1b-jsts-matryoshka

sourceHugging Faceupdated 9mo agoView on Hugging Face
1likes112downloads
Model Card

SentenceTransformer based on sbintuitions/sarashina-embedding-v2-1b

This is a sentence-transformers model finetuned from sbintuitions/sarashina-embedding-v2-1b on the jsts dataset. It maps sentences & paragraphs to a 1792-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.

Model Details

Model Description

  • —Model Type: Sentence Transformer
  • —Base model: sbintuitions/sarashina-embedding-v2-1b <!-- at revision 1f3408afaa7b617e3445d891310a9c26dd0c68a5 -->
  • —Maximum Sequence Length: 8192 tokens
  • —Output Dimensionality: 1792 dimensions
  • —Similarity Function: Cosine Similarity
  • —Training Dataset:
  • —jsts
  • —Language: jpn <!-- - License: Unknown -->

Model Sources

Loss

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 8192, 'do_lower_case': False, 'architecture': 'LlamaModel'})
  (1): Pooling({'word_embedding_dimension': 1792, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': True, 'include_prompt': False})
)

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 SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("kushalc1/sarashina-embedding-v2-1b-jsts-matryoshka")
# Run inference
sentences = [
    '樹木に囲まれた芝生の上に三頭のキリンが立っています。',
    '芝生の上に数頭のキリンが歩いています。',
    '茶色のテーブルの上にピザと飲み物が置かれています。',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1792]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.9453, 0.4754],
#         [0.9453, 1.0000, 0.5004],
#         [0.4754, 0.5004, 1.0000]])

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

Evaluation

Metrics

Semantic Similarity
json
  {
      "truncate_dim": 1792
  }
Metricsts-dev-1792sts-test-1792
pearson_cosine0.80880.8088
spearman_cosine0.74350.7435
Semantic Similarity
json
  {
      "truncate_dim": 1280
  }
Metricsts-dev-1280sts-test-1280
pearson_cosine0.80780.8078
spearman_cosine0.74420.7442
Semantic Similarity
json
  {
      "truncate_dim": 768
  }
Metricsts-dev-768sts-test-768
pearson_cosine0.80490.8049
spearman_cosine0.74230.7423
Semantic Similarity
json
  {
      "truncate_dim": 256
  }
Metricsts-dev-256sts-test-256
pearson_cosine0.80220.8022
spearman_cosine0.74110.7411
Semantic Similarity
json
  {
      "truncate_dim": 64
  }
Metricsts-dev-64sts-test-64
pearson_cosine0.79720.7972
spearman_cosine0.73890.7389

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

jsts
  • —Dataset: jsts at b3d3097
  • —Size: 12,451 training samples
  • —Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
  • —Approximate statistics based on the first 1000 samples: | | sentence1 | sentence2 | score | |:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------| | type | string | string | float | | details | <ul><li>min: 5 tokens</li><li>mean: 10.64 tokens</li><li>max: 35 tokens</li></ul> | <ul><li>min: 3 tokens</li><li>mean: 10.53 tokens</li><li>max: 30 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 2.32</li><li>max: 5.0</li></ul> |
  • —Samples: | sentence1 | sentence2 | score | |:------------------------------------|:-----------------------------------|:-------------------------------| | <code>川べりでサーフボードを持った人たちがいます。</code> | <code>トイレの壁に黒いタオルがかけられています。</code> | <code>0.0</code> | | <code>二人の男性がジャンボジェット機を見ています。</code> | <code>2人の男性が、白い飛行機を眺めています。</code> | <code>3.799999952316284</code> | | <code>男性が子供を抱き上げて立っています。</code> | <code>坊主頭の男性が子供を抱いて立っています。</code> | <code>4.0</code> |
  • —Loss: <code>MatryoshkaLoss</code> with these parameters:
json
  {
      "loss": "MultipleNegativesRankingLoss",
      "matryoshka_dims": [
          1792,
          1280,
          768,
          256,
          64
      ],
      "matryoshka_weights": [
          1,
          1,
          1,
          1,
          1
      ],
      "n_dims_per_step": -1
  }

Evaluation Dataset

jsts
  • —Dataset: jsts at b3d3097
  • —Size: 1,457 evaluation samples
  • —Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
  • —Approximate statistics based on the first 1000 samples: | | sentence1 | sentence2 | score | |:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------| | type | string | string | float | | details | <ul><li>min: 5 tokens</li><li>mean: 10.78 tokens</li><li>max: 34 tokens</li></ul> | <ul><li>min: 3 tokens</li><li>mean: 10.63 tokens</li><li>max: 37 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 2.22</li><li>max: 5.0</li></ul> |
  • —Samples: | sentence1 | sentence2 | score | |:-----------------------------------------|:------------------------------------|:--------------------------------| | <code>レンガの建物の前を、乳母車を押した女性が歩いています。</code> | <code>厩舎で馬と女性とが寄り添っています。</code> | <code>0.0</code> | | <code>山の上に顔の白い牛が2頭います。</code> | <code>曇り空の山肌で、牛が2匹草を食んでいます。</code> | <code>2.4000000953674316</code> | | <code>バナナを持った人が道路を通行しています。</code> | <code>道の上をバナナを背負った男性が歩いています。</code> | <code>3.5999999046325684</code> |
  • —Loss: <code>MatryoshkaLoss</code> with these parameters:
json
  {
      "loss": "MultipleNegativesRankingLoss",
      "matryoshka_dims": [
          1792,
          1280,
          768,
          256,
          64
      ],
      "matryoshka_weights": [
          1,
          1,
          1,
          1,
          1
      ],
      "n_dims_per_step": -1
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —eval_strategy: steps
  • —per_device_train_batch_size: 16
  • —per_device_eval_batch_size: 16
  • —num_train_epochs: 4
  • —warmup_ratio: 0.1
  • —fp16: True
All Hyperparameters

<details><summary>Click to expand</summary>

  • —overwrite_output_dir: False
  • —do_predict: False
  • —eval_strategy: steps
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 16
  • —per_device_eval_batch_size: 16
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 1
  • —eval_accumulation_steps: None
  • —torch_empty_cache_steps: None
  • —learning_rate: 5e-05
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —max_grad_norm: 1.0
  • —num_train_epochs: 4
  • —max_steps: -1
  • —lr_scheduler_type: linear
  • —lr_scheduler_kwargs: {}
  • —warmup_ratio: 0.1
  • —warmup_steps: 0
  • —log_level: passive
  • —log_level_replica: warning
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —save_safetensors: True
  • —save_on_each_node: False
  • —save_only_model: False
  • —restore_callback_states_from_checkpoint: False
  • —no_cuda: False
  • —use_cpu: False
  • —use_mps_device: False
  • —seed: 42
  • —data_seed: None
  • —jit_mode_eval: False
  • —use_ipex: False
  • —bf16: False
  • —fp16: True
  • —fp16_opt_level: O1
  • —half_precision_backend: auto
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: None
  • —local_rank: 0
  • —ddp_backend: None
  • —tpu_num_cores: None
  • —tpu_metrics_debug: False
  • —debug: []
  • —dataloader_drop_last: False
  • —dataloader_num_workers: 0
  • —dataloader_prefetch_factor: None
  • —past_index: -1
  • —disable_tqdm: False
  • —remove_unused_columns: True
  • —label_names: None
  • —load_best_model_at_end: False
  • —ignore_data_skip: False
  • —fsdp: []
  • —fsdp_min_num_params: 0
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —parallelism_config: None
  • —deepspeed: None
  • —label_smoothing_factor: 0.0
  • —optim: adamwtorchfused
  • —optim_args: None
  • —adafactor: False
  • —group_by_length: False
  • —length_column_name: length
  • —ddp_find_unused_parameters: None
  • —ddp_bucket_cap_mb: None
  • —ddp_broadcast_buffers: False
  • —dataloader_pin_memory: True
  • —dataloader_persistent_workers: False
  • —skip_memory_metrics: True
  • —use_legacy_prediction_loop: False
  • —push_to_hub: False
  • —resume_from_checkpoint: None
  • —hub_model_id: None
  • —hub_strategy: every_save
  • —hub_private_repo: None
  • —hub_always_push: False
  • —hub_revision: None
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —include_inputs_for_metrics: False
  • —include_for_metrics: []
  • —eval_do_concat_batches: True
  • —fp16_backend: auto
  • —push_to_hub_model_id: None
  • —push_to_hub_organization: None
  • —mp_parameters:
  • —auto_find_batch_size: False
  • —full_determinism: False
  • —torchdynamo: None
  • —ray_scope: last
  • —ddp_timeout: 1800
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —include_tokens_per_second: False
  • —include_num_input_tokens_seen: False
  • —neftune_noise_alpha: None
  • —optim_target_modules: None
  • —batch_eval_metrics: False
  • —eval_on_start: False
  • —use_liger_kernel: False
  • —liger_kernel_config: None
  • —eval_use_gather_object: False
  • —average_tokens_across_devices: False
  • —prompts: None
  • —batch_sampler: batch_sampler
  • —multi_dataset_batch_sampler: proportional
  • —router_mapping: {}
  • —learning_rate_mapping: {}

</details>

Training Logs

EpochStepTraining LossValidation Losssts-dev-1792_spearman_cosinests-dev-1280_spearman_cosinests-dev-768_spearman_cosinests-dev-256_spearman_cosinests-dev-64_spearman_cosinests-test-1792_spearman_cosinests-test-1280_spearman_cosinests-test-768_spearman_cosinests-test-256_spearman_cosinests-test-64_spearman_cosine
0.12841004.9116.23730.75730.75720.75170.73500.7114-----
0.25672005.86647.98130.67390.66920.66360.65000.6146-----
0.38513007.2597.98290.68310.68150.67970.66980.6529-----
0.51354007.12347.58100.68780.68870.68810.68190.6679-----
0.64185007.2336.93840.66280.66940.66580.66620.6583-----
0.77026007.02287.01020.63520.63640.63460.63100.6246-----
0.89867006.5396.76710.64110.64150.64030.63940.6346-----
1.02708006.28637.58460.61200.63420.63140.62660.6189-----
1.15539005.76086.74800.67730.67900.67580.67480.6691-----
1.283710005.6726.64810.68460.68360.68170.68340.6794-----
1.412111005.73716.68430.69450.69530.69660.69390.6891-----
1.540412005.88276.68630.69030.69400.69220.68830.6834-----
1.668813005.62426.65170.68560.68570.68470.68090.6762-----
1.797214005.52116.14280.71340.71230.71170.70650.7022-----
1.925515005.48826.04390.72270.72270.72140.71920.7134-----
2.053916005.44366.03610.71990.72030.71910.72010.7143-----
2.182317004.3666.14470.72860.72900.72740.72830.7231-----
2.310718004.66076.16920.73650.73560.73440.73030.7263-----
2.439019004.36516.21090.71780.71690.71490.71340.7125-----
2.567420004.46926.14210.72370.72330.72140.71920.7150-----
2.695821004.4345.94620.72750.72670.72600.72530.7203-----
2.824122004.26346.00550.72180.72160.72050.71960.7177-----
2.952523004.25245.88340.72970.73080.73020.72820.7245-----
3.080924003.51466.26350.74300.74250.74160.74020.7357-----
3.209225003.01376.13960.74550.74410.74300.74100.7377-----
3.337626002.99566.27790.74260.74270.74070.74020.7371-----
3.466027003.01256.24150.74590.74570.74350.74250.7378-----
3.594428003.26836.22140.74070.74070.73850.73780.7342-----
3.722729002.78186.28540.74440.74420.74220.74110.7390-----
3.851130002.72166.27600.74250.74290.74110.74010.7378-----
3.979531002.89016.23060.74350.74420.74230.74110.7389-----
-1-1-------0.74350.74420.74230.74110.7389

Framework Versions

  • —Python: 3.12.6
  • —Sentence Transformers: 5.2.0
  • —Transformers: 4.56.0
  • —PyTorch: 2.8.0+cu129
  • —Accelerate: 1.10.1
  • —Datasets: 4.4.2
  • —Tokenizers: 0.22.0

Citation

BibTeX

Sentence Transformers
bibtex
@inproceedings{reimers-2019-sentence-bert,
    title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
    author = "Reimers, Nils and Gurevych, Iryna",
    booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
    month = "11",
    year = "2019",
    publisher = "Association for Computational Linguistics",
    url = "https://arxiv.org/abs/1908.10084",
}
MatryoshkaLoss
bibtex
@misc{kusupati2024matryoshka,
    title={Matryoshka Representation Learning},
    author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
    year={2024},
    eprint={2205.13147},
    archivePrefix={arXiv},
    primaryClass={cs.LG}
}
MultipleNegativesRankingLoss
bibtex
@misc{henderson2017efficient,
    title={Efficient Natural Language Response Suggestion for Smart Reply},
    author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
    year={2017},
    eprint={1705.00652},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->