CoolFace
Modelpublic

tranhuudan-fullstack-ai-engineer/stage1

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes75downloads
Model Card

SentenceTransformer based on vinai/phobert-base-v2

This is a sentence-transformers model finetuned from vinai/phobert-base-v2. It maps sentences & paragraphs to a 768-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: vinai/phobert-base-v2 <!-- at revision 2b51e367d92093c9688112098510e6a58bab67cd -->
  • Maximum Sequence Length: 512 tokens
  • Output Dimensionality: 768 tokens
  • Similarity Function: Cosine Similarity <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: RobertaModel 
  (1): Pooling({'word_embedding_dimension': 768, '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:

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("huudan123/stage1")
# Run inference
sentences = [
    'Báo đen đã editorialized chống lại những cuộc viếng_thăm của farrakhan với các nhà độc_tài châu phi .',
    'Báo đen đã viết về quá_khứ của farrakhan .',
    'Báo đen từ_chối yểm_trợ cho farrakhan .',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]

<!--

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
MetricValue
pearson_cosine0.4203
spearman_cosine0.5148
pearson_manhattan0.5605
spearman_manhattan0.5792
pearson_euclidean0.471
spearman_euclidean0.5087
pearson_dot0.3924
spearman_dot0.4338
pearson_max0.5605
spearman_max0.5792

<!--

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

Unnamed Dataset
  • Size: 102,178 training samples
  • Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
  • Approximate statistics based on the first 1000 samples: | | anchor | positive | negative | |:--------|:-----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------| | type | string | string | string | | details | <ul><li>min: 4 tokens</li><li>mean: 27.28 tokens</li><li>max: 147 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 14.99 tokens</li><li>max: 44 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 14.34 tokens</li><li>max: 34 tokens</li></ul> |
  • Samples: | anchor | positive | negative | |:--------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Tem đầy màusắc của madeira , cũng như tiền xu , ghichép ngânhàng , và các mặthàng khác như bưuthiếp là mối quantâm đến nhiều nhà sưutập .</code> | <code>Các nhà sưutập sẽ thích ghé thăm madeira bởivì những phânchia lớn của tem , ghichép ngânhàng , bưuthiếp , và nhiều mặthàng khác họ cóthể đọc được .</code> | <code>Mọi người quantâm đến việc bắtđầu bộ sưutập mới nên thoát madeira và đi dulịch phía bắc , nơi họ có khảnăng tìm thấy các cửahàng tốt .</code> | | <code>Cẩnthận đấy , ông inglethorp . Poirot bị bồnchồn .</code> | <code>Hãy chămsóc ông inglethorp .</code> | <code>Không cần phải cẩnthận với anh ta .</code> | | <code>Phải có mộtchút hoàinghi về trải nghiệm cánhân của sperling với tròchơi .</code> | <code>Hãy suynghĩ về những tácđộng khi nhìn vào kinhnghiệm của anh ấy .</code> | <code>Một người cóthể lấy trải nghiệm cánhân của sperling với giá_trị mặt .</code> |
  • Loss: <code>TripletLoss</code> with these parameters:
json
  {
      "distance_metric": "TripletDistanceMetric.EUCLIDEAN",
      "triplet_margin": 5
  }

Evaluation Dataset

Unnamed Dataset
  • Size: 12,772 evaluation samples
  • Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
  • Approximate statistics based on the first 1000 samples: | | anchor | positive | negative | |:--------|:-----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------| | type | string | string | string | | details | <ul><li>min: 4 tokens</li><li>mean: 27.81 tokens</li><li>max: 164 tokens</li></ul> | <ul><li>min: 3 tokens</li><li>mean: 14.94 tokens</li><li>max: 42 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 14.4 tokens</li><li>max: 39 tokens</li></ul> |
  • Samples: | anchor | positive | negative | |:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------| | <code>Tìnhyêu , anh có muốn em trởthành kassandra lubbock của anh không ?</code> | <code>Tôi cóthể là kassandra lubbock của anh .</code> | <code>Tôi từchối trởthành kassandra lubbock của anh .</code> | | <code>Vídụ , trong mùa thu năm 1997 , ủy ban điềutrị hạtnhân ( nrc ) vănphòng thanhtra tướng liệu nrc để có được quanđiểm của họ trên vănhóa antoàn của đạilý .</code> | <code>Nhânviên nrc đã được hỏi về quanđiểm của họ trên vănhóa antoàn của đạilý .</code> | <code>Các nhânviên không baogiờ quansát về quanđiểm của họ về vănhóa antoàn của đạilý trong mùa thu năm 1997 .</code> | | <code>Mỗi năm kem của trẻ nghệ và comedic tàinăng làm cho nó đường đến edinburgh , và fringe đã lớn lên trong việc huấnluyện lớn nhất trong khungcảnh lớn nhất cho các diễnviên pháttriển trên thếgiới .</code> | <code>Tàinăng mới đến edinburgh .</code> | <code>Tàinăng mới đến dublin .</code> |
  • Loss: <code>TripletLoss</code> with these parameters:
json
  {
      "distance_metric": "TripletDistanceMetric.EUCLIDEAN",
      "triplet_margin": 5
  }

Training Hyperparameters

Non-Default Hyperparameters
  • overwrite_output_dir: True
  • eval_strategy: epoch
  • per_device_train_batch_size: 128
  • per_device_eval_batch_size: 128
  • num_train_epochs: 20
  • lr_scheduler_type: cosine
  • warmup_ratio: 0.05
  • fp16: True
  • load_best_model_at_end: True
  • gradient_checkpointing: True
All Hyperparameters

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

  • overwrite_output_dir: True
  • 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
  • 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: 20
  • max_steps: -1
  • lr_scheduler_type: cosine
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.05
  • 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: True
  • 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}
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch
  • 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: False
  • hub_always_push: False
  • gradient_checkpointing: True
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • 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
  • dispatch_batches: None
  • split_batches: 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
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional

</details>

Training Logs

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

EpochStepTraining Losslosssts-dev_spearman_cosine
00--0.6643
0.0626504.6946--
0.12521004.031--
0.18771502.7654--
0.25032002.4176--
0.31292502.1111--
0.37553002.0263--
0.43803501.9296--
0.50064001.7793--
0.56324501.7903--
0.62585001.7638--
0.68845501.7042--
0.75096001.7038--
0.81356501.6221--
0.87617001.6172--
0.93877501.6227--
1.0799-1.52750.5219
1.00138001.6264--
1.06388501.364--
1.12649001.4447--
1.18909501.4161--
1.251610001.3575--
1.314110501.3554--
1.376711001.378--
1.439311501.3806--
1.501912001.3089--
1.564512501.4314--
1.627013001.3672--
1.689613501.3777--
1.752214001.3282--
1.814814501.3432--
1.877315001.3101--
1.939915501.2919--
2.01598-1.36430.5667
2.002516001.2969--
2.065116500.9629--
2.127717000.9878--
2.190217500.9437--
2.252818000.9832--
2.315418500.9584--
2.378019001.0689--
2.440619501.0579--
2.503120000.9888--
2.565720500.9452--
2.628321000.9378--
2.690921500.9553--
2.753422000.9337--
2.816022501.0184--
2.878623000.9663--
2.941223500.9686--
3.02397-1.34880.5442
3.003824000.9618--
3.066324500.6878--
3.128925000.6883--
3.191525500.6498--
3.254126000.6651--
3.316626500.6554--
3.379227000.7033--
3.441827500.6416--
3.504428000.7068--
3.567028500.6834--
3.629529000.7099--
3.692129500.7306--
3.754730000.7105--
3.817330500.7072--
3.879831000.7248--
3.942431500.7216--
4.03196-1.33580.5307
4.005032000.693--
4.067632500.4741--
4.130233000.4593--
4.192733500.449--
4.255334000.4326--
4.317934500.4488--
4.380535000.4762--
4.443135500.4723--
4.505636000.4713--
4.568236500.4612--
4.630837000.4537--
4.693437500.4928--
4.755938000.4568--
4.818538500.4771--
4.881139000.4688--
4.943739500.4549--
5.03995-1.40270.5360
5.006340000.5048--
5.068840500.2822--
5.131441000.3069--
5.194041500.2971--
5.256642000.3191--
5.319142500.3023--
5.381743000.3224--
5.444343500.3114--
5.506944000.3098--
5.569544500.3071--
5.632045000.3478--
5.694645500.3288--
5.757246000.3373--
5.819846500.3577--
5.882447000.331--
5.944947500.3132--
6.04794-1.40360.5148
  • The bold row denotes the saved checkpoint. </details>

Framework Versions

  • Python: 3.10.12
  • Sentence Transformers: 3.0.1
  • Transformers: 4.42.4
  • PyTorch: 2.3.1+cu121
  • Accelerate: 0.32.1
  • Datasets: 2.20.0
  • Tokenizers: 0.19.1

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",
}
TripletLoss
bibtex
@misc{hermans2017defense,
    title={In Defense of the Triplet Loss for Person Re-Identification}, 
    author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
    year={2017},
    eprint={1703.07737},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}

<!--

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. -->