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
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
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
- Dataset:
all-dev - Evaluated with
EmbeddingSimilarityEvaluator
| Metric | Value |
|---|---|
| pearson_cosine | 0.9649 |
| spearman_cosine | 0.9629 |
Training Details
Training Dataset
Unnamed Dataset
- Size: 101,745 training samples
- Columns:
sentence1,sentence2, andscore - 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 FA L G W V F V P V0.4487163971048506G R I A F F L K YI P S I N V H H Y0.2950890611282742I L A K F A H W LQ T N P V T L Q Y0.24611965364324553 - Loss:
CoSENTLosswith these parameters:{ "scale": 20.0, "similarity_fct": "pairwise_cos_sim" }
Evaluation Dataset
Unnamed Dataset
- Size: 11,305 evaluation samples
- Columns:
sentence1,sentence2, andscore - 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 FG A D G V G K S A L0.35084774335438396T P R V T G G G A ME I F D R Y G E E V0.21484461945678654S R I M L L A P KK I F G S L A F L0.14818627314226981 - Loss:
CoSENTLosswith these parameters:{ "scale": 20.0, "similarity_fct": "pairwise_cos_sim" }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy: epochper_device_train_batch_size: 128per_device_eval_batch_size: 128learning_rate: 0.001weight_decay: 0.0001num_train_epochs: 8fp16: Trueload_best_model_at_end: True
All Hyperparameters
Click to expand
overwrite_output_dir: Falsedo_predict: Falseeval_strategy: epochprediction_loss_only: Trueper_device_train_batch_size: 128per_device_eval_batch_size: 128per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 0.001weight_decay: 0.0001adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 8max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.0warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falsebf16: Falsefp16: Truefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Trueignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters:auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_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
Model tree for HassanCS/peptide_HLA_TCRa_TCRb__esm2_t6_8M_UR50D_up_to_epoch_8
Base model
facebook/esm2_t6_8M_UR50DEvaluation results
- Pearson Cosine on all devself-reported0.965
- Spearman Cosine on all devself-reported0.963