Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 15
How to use votanthanh32004/paraphrase-multilingual-mpnet-base-v2-experience with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("votanthanh32004/paraphrase-multilingual-mpnet-base-v2-experience")
sentences = [
"Yêu cầu 5+ năm kinh nghiệm chuyên sâu về audit Smart Contract, phát hiện các lỗ hổng bảo mật phức tạp như reentrancy, flash loan attacks cho các dự án DeFi có Total Value Locked (TVL) cao.",
"Managed the complete product lifecycle for an enterprise student information system over 9 years, prioritizing agile development sprints based on rigorous user research conducted directly with school district administrators.",
"Dẫn dắt thành công chiến lược Digital Transformation cho tập đoàn thực phẩm hàng đầu trong 11 năm, chuyển đổi toàn bộ mạng lưới phân phối sang mô hình Data-driven và triển khai hệ thống SAP ERP đồng bộ.",
"Chuyên viên kiểm toán hệ thống thông tin (IT Auditor) tại một ngân hàng truyền thống trong 6 năm, rà soát tuân thủ ISO 27001 cho các máy chủ vật lý, hoàn toàn không có kiến thức về Blockchain hay Solidity."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from sentence-transformers/paraphrase-multilingual-mpnet-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.
SentenceTransformer(
(0): Transformer({'max_seq_length': 128, 'do_lower_case': False, 'architecture': 'XLMRobertaModel'})
(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})
)
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("sentence_transformers_model_id")
# Run inference
sentences = [
'Yêu cầu 10+ năm kinh nghiệm, dẫn dắt mảng an toàn dược phẩm toàn cầu, am hiểu các quy định báo cáo biến cố bất lợi của FDA/EMA và dẫn dắt các buổi điều trần về an toàn thuốc.',
'Bác sĩ điều trị tại khoa Tim mạch trong 11 năm, am hiểu về tác dụng phụ của thuốc trên bệnh nhân thực tế, nhưng chưa từng làm việc trong môi trường công ty dược hay quản trị quy trình an toàn thuốc theo chuẩn quốc tế.',
'Developed specialized computer vision models for automated farming equipment over 5 years, expertly processing drone imagery to assess crop health indices and drastically reducing chemical waste through targeted spraying algorithms.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.4418, 0.1802],
# [0.4418, 1.0000, 0.0758],
# [0.1802, 0.0758, 1.0000]])
experience_valEmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.9441 |
| spearman_cosine | 0.9217 |
sentence_0, sentence_1, and label| sentence_0 | sentence_1 | label | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| sentence_0 | sentence_1 | label |
|---|---|---|
Requires 6+ years of experience acting as a formal people manager for a team of DevOps engineers, conducting 1-on-1s, managing career progression, and resolving personnel blockers. |
Designed robust OCR pipelines using Tesseract over 7 years, specifically writing algorithms to automatically deskew and preprocess degraded scanned documents to improve text extraction. |
0.15 |
Yêu cầu 10+ năm kinh nghiệm dẫn dắt các chiến dịch di trú hệ thống (Migration) từ On-premise lên Cloud (AWS/Azure), xử lý các bài toán kỹ thuật nợ và tái cấu trúc hệ thống Legacy. |
Giáo viên dạy môn Hóa học tại trường cấp 3 trong 11 năm, hướng dẫn học sinh thực hiện các phản ứng hóa học trong phòng thí nghiệm và ôn tập cho kỳ thi THPT quốc gia. |
0.15 |
Seeking a highly adaptable analyst with 3+ years of experience at a clean-tech startup, building financial models from scratch without existing templates, and pivoting quickly based on shifting venture capital priorities. |
Worked as a senior energy analyst at a massive legacy utility provider for 15 years, strictly utilizing rigid, decade-old proprietary software templates to forecast baseline coal consumption. |
0.4 |
CosineSimilarityLoss with these parameters:{
"loss_fct": "torch.nn.modules.loss.MSELoss"
}
eval_strategy: stepsper_device_train_batch_size: 16per_device_eval_batch_size: 16num_train_epochs: 4multi_dataset_batch_sampler: round_robindo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 16gradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1num_train_epochs: 4max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_ratio: Nonewarmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Trueenable_jit_checkpoint: Falsesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseuse_cpu: Falseseed: 42data_seed: Nonebf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: -1ddp_backend: Nonedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonedisable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}accelerator_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: Nonegroup_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: Truepush_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_for_metrics: []eval_do_concat_batches: Trueauto_find_batch_size: Falsefull_determinism: Falseddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_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: Trueuse_cache: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | experience_val_spearman_cosine |
|---|---|---|
| 1.0 | 85 | 0.9181 |
| 1.1765 | 100 | 0.9177 |
| 2.0 | 170 | 0.9217 |
@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",
}