SentenceTransformer based on facebook/esm2_t6_8M_UR50D

This is a sentence-transformers model finetuned from facebook/esm2_t6_8M_UR50D. It maps sentences & paragraphs to a 320-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: facebook/esm2_t6_8M_UR50D
  • Maximum Sequence Length: 1026 tokens
  • Output Dimensionality: 320 dimensions
  • Similarity Function: Cosine Similarity

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 1026, 'do_lower_case': False, 'architecture': 'EsmModel'})
  (1): Pooling({'word_embedding_dimension': 320, '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})
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

pip install -U sentence-transformers

Then you can load this model and run inference.

from sentence_transformers import SentenceTransformer

# Download from the ๐Ÿค— Hub
model = SentenceTransformer("HassanCS/peptide_HLA_TCRa_TCRb__esm2_t6_8M_UR50D_up_to_epoch_8")
# Run inference
sentences = [
    'M E V T P S G T W L',
    'G Q A R V A Y Q V',
    'L L L A R A A S L S L',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 320]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.4961, 0.5182],
#         [0.4961, 1.0000, 0.8793],
#         [0.5182, 0.8793, 1.0000]])

Evaluation

Metrics

Semantic Similarity

Metric Value
pearson_cosine 0.9649
spearman_cosine 0.9629

Training Details

Training Dataset

Unnamed Dataset

  • Size: 101,745 training samples
  • Columns: sentence1, sentence2, and score
  • Approximate statistics based on the first 1000 samples:
    sentence1 sentence2 score
    type string string float
    details
    • min: 9 tokens
    • mean: 11.56 tokens
    • max: 26 tokens
    • min: 10 tokens
    • mean: 11.47 tokens
    • max: 26 tokens
    • min: 0.03
    • mean: 0.3
    • max: 1.0
  • Samples:
    sentence1 sentence2 score
    V Y G I R L E H F A L G W V F V P V 0.4487163971048506
    G R I A F F L K Y I P S I N V H H Y 0.2950890611282742
    I L A K F A H W L Q T N P V T L Q Y 0.24611965364324553
  • Loss: CoSENTLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "pairwise_cos_sim"
    }
    

Evaluation Dataset

Unnamed Dataset

  • Size: 11,305 evaluation samples
  • Columns: sentence1, sentence2, and score
  • Approximate statistics based on the first 1000 samples:
    sentence1 sentence2 score
    type string string float
    details
    • min: 10 tokens
    • mean: 11.48 tokens
    • max: 26 tokens
    • min: 9 tokens
    • mean: 11.47 tokens
    • max: 26 tokens
    • min: 0.02
    • mean: 0.31
    • max: 1.0
  • Samples:
    sentence1 sentence2 score
    K S K R T P M G F G A D G V G K S A L 0.35084774335438396
    T P R V T G G G A M E I F D R Y G E E V 0.21484461945678654
    S R I M L L A P K K I F G S L A F L 0.14818627314226981
  • Loss: CoSENTLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "pairwise_cos_sim"
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: epoch
  • per_device_train_batch_size: 128
  • per_device_eval_batch_size: 128
  • learning_rate: 0.001
  • weight_decay: 0.0001
  • num_train_epochs: 8
  • fp16: True
  • load_best_model_at_end: True

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: epoch
  • prediction_loss_only: True
  • per_device_train_batch_size: 128
  • per_device_eval_batch_size: 128
  • 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: 0.001
  • weight_decay: 0.0001
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1.0
  • num_train_epochs: 8
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.0
  • 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
  • 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: True
  • ignore_data_skip: False
  • fsdp: []
  • fsdp_min_num_params: 0
  • fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
  • parallelism_config: None
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch_fused
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • project: huggingface
  • trackio_space_id: trackio
  • 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: no
  • 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: True
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Epoch Step Training Loss Validation Loss all-dev_spearman_cosine
0.1258 100 8.9433 - -
0.2516 200 8.7471 - -
0.3774 300 8.6225 - -
0.5031 400 8.5602 - -
0.6289 500 8.5013 - -
0.7547 600 8.4547 - -
0.8805 700 8.4103 - -
1.0 795 - 8.3649 0.8817
1.0063 800 8.3797 - -
1.1321 900 8.3271 - -
1.2579 1000 8.3076 - -
1.3836 1100 8.2519 - -
1.5094 1200 8.2203 - -
1.6352 1300 8.2108 - -
1.7610 1400 8.1601 - -
1.8868 1500 8.1745 - -
2.0 1590 - 8.1604 0.9278
2.0126 1600 8.1477 - -
2.1384 1700 8.192 - -
2.2642 1800 8.1813 - -
2.3899 1900 8.1643 - -
2.5157 2000 8.1401 - -
2.6415 2100 8.1043 - -
2.7673 2200 8.1092 - -
2.8931 2300 8.0935 - -
3.0 2385 - 8.0852 0.9385
3.0189 2400 8.0631 - -
3.1447 2500 8.031 - -
3.2704 2600 8.0052 - -
3.3962 2700 7.9924 - -
3.5220 2800 7.9701 - -
3.6478 2900 7.958 - -
3.7736 3000 7.9537 - -
3.8994 3100 7.9321 - -
4.0 3180 - 7.9955 0.9511
4.0252 3200 7.9196 - -
4.1509 3300 7.9891 - -
4.2767 3400 7.9788 - -
4.4025 3500 7.9793 - -
4.5283 3600 7.9699 - -
4.6541 3700 7.9371 - -
4.7799 3800 7.9548 - -
4.9057 3900 7.9349 - -
5.0 3975 - 7.9789 0.9520
5.0314 4000 7.9036 - -
5.1572 4100 7.874 - -
5.2830 4200 7.853 - -
5.4088 4300 7.8523 - -
5.5346 4400 7.8475 - -
5.6604 4500 7.8436 - -
5.7862 4600 7.8402 - -
5.9119 4700 7.8097 - -
6.0 4770 - 7.9175 0.9592
6.0377 4800 7.8271 - -
6.1635 4900 7.8704 - -
6.2893 5000 7.8793 - -
6.4151 5100 7.8644 - -
6.5409 5200 7.8611 - -
6.6667 5300 7.8571 - -
6.7925 5400 7.8439 - -
6.9182 5500 7.845 - -
7.0 5565 - 7.9248 0.9585
7.0440 5600 7.795 - -
7.1698 5700 7.7812 - -
7.2956 5800 7.7793 - -
7.4214 5900 7.7608 - -
7.5472 6000 7.7587 - -
7.6730 6100 7.7586 - -
7.7987 6200 7.7612 - -
7.9245 6300 7.7674 - -
8.0 6360 - 7.8833 0.9629
  • The bold row denotes the saved checkpoint.

Framework Versions

  • Python: 3.10.19
  • Sentence Transformers: 5.1.2
  • Transformers: 4.57.1
  • PyTorch: 2.9.1+cu128
  • Accelerate: 1.11.0
  • Datasets: 4.4.1
  • Tokenizers: 0.22.1

Citation

BibTeX

Sentence Transformers

@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",
}

CoSENTLoss

@article{10531646,
    author={Huang, Xiang and Peng, Hao and Zou, Dongcheng and Liu, Zhiwei and Li, Jianxin and Liu, Kay and Wu, Jia and Su, Jianlin and Yu, Philip S.},
    journal={IEEE/ACM Transactions on Audio, Speech, and Language Processing},
    title={CoSENT: Consistent Sentence Embedding via Similarity Ranking},
    year={2024},
    doi={10.1109/TASLP.2024.3402087}
}
Downloads last month
10
Safetensors
Model size
7.51M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for HassanCS/peptide_HLA_TCRa_TCRb__esm2_t6_8M_UR50D_up_to_epoch_8

Finetuned
(37)
this model

Evaluation results