Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
•
1908.10084
•
Published
•
9
This is a sentence-transformers model finetuned from intfloat/multilingual-e5-large. It maps sentences & paragraphs to a 1024-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': 512, 'do_lower_case': False}) with Transformer model: XLMRobertaModel
(1): Pooling({'word_embedding_dimension': 1024, '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})
(2): Normalize()
)
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("qminh369/tpbank-dense_embedding")
# Run inference
sentences = [
'Theo quy định của TPBank, làm thế nào để đề nghị tăng hạn mức thẻ tín dụng theo hình thức tín chấp hoặc có TSBĐ?',
'KH có thể đề nghị TPBank phê duyệt tăng hạn mức Thẻ tín dụng theo hình thức tín chấp (không có TSBĐ) hoặc có TSBĐ, việc tăng hạn mức Thẻ tín dụng dựa theo hồ sơ KH tương tự KH đề nghị xét cấp mới hạn mức Thẻ tín dụng tại Điều 8 và Điều 9 Sản phẩm này và thực hiện theo từng đối tượng KH cụ thể tại Phụ lục 01 – Quy định về cấp hạn mức Thẻ tín dụng đối với nhóm Khách hàng thông thường (PL01.SP31/CN/TD), Phụ lục 02 – Quy định cấp hạn mức Thẻ tín dụng đối với nhóm Khách hàng phê duyệt trước theo địa vị, chức vụ và thâm niên công tác (PL02.SP31/CN/TD), và Phụ lục 03 – Quy định cấp hạn mức Thẻ tín dụng đối với nhóm Khách hàng nội bộ TPBank và nhóm Khách hàng phê duyệt trước có chứng từ thay thế chứng từ chứng minh thu nhập (PL03.SP31/CN/TD) của Sản phẩm này.',
'1. Trung tâm Sản phẩm Tín dụng Bán lẻ - Khối Ngân hàng cá nhân có trách nhiệm hướng dẫn thi hành và tổ chức thực hiện Sản phẩm này. \n\n2. Các Ông (Bà) thành viên Ban Điều hành, Khối Ngân hàng cá nhân, Khối Tín dụng, Trung tâm Hỗ trợ tín dụng - Khối Vận hành, các Đơn vị kinh doanh và các Đơn vị, cá nhân liên quan trên toàn hệ thống TPBank chịu trách nhiệm thi hành Sản phẩm này./. \n\n\nNơi nhận: - Như Điều 29 (để thực hiện); - HĐQT, BKS (để báo cáo); - LC, RM, QA, IA (để biết); - Lưu VP. \n\nTỔNG GIÁM ĐỐC (Đã ký) NGUYỄN HƯNG',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
devBinaryClassificationEvaluator| Metric | Value |
|---|---|
| cosine_accuracy | 0.8646 |
| cosine_accuracy_threshold | 0.9988 |
| cosine_f1 | 0.6829 |
| cosine_f1_threshold | 0.9988 |
| cosine_precision | 0.8235 |
| cosine_recall | 0.5833 |
| cosine_ap | 0.6305 |
| dot_accuracy | 0.8646 |
| dot_accuracy_threshold | 0.9988 |
| dot_f1 | 0.6829 |
| dot_f1_threshold | 0.9988 |
| dot_precision | 0.8235 |
| dot_recall | 0.5833 |
| dot_ap | 0.6305 |
| manhattan_accuracy | 0.8646 |
| manhattan_accuracy_threshold | 1.2318 |
| manhattan_f1 | 0.6829 |
| manhattan_f1_threshold | 1.2318 |
| manhattan_precision | 0.8235 |
| manhattan_recall | 0.5833 |
| manhattan_ap | 0.6652 |
| euclidean_accuracy | 0.8646 |
| euclidean_accuracy_threshold | 0.0481 |
| euclidean_f1 | 0.6829 |
| euclidean_f1_threshold | 0.0481 |
| euclidean_precision | 0.8235 |
| euclidean_recall | 0.5833 |
| euclidean_ap | 0.6305 |
| max_accuracy | 0.8646 |
| max_accuracy_threshold | 1.2318 |
| max_f1 | 0.6829 |
| max_f1_threshold | 1.2318 |
| max_precision | 0.8235 |
| max_recall | 0.5833 |
| max_ap | 0.6652 |
sentence_0, sentence_1, and label| sentence_0 | sentence_1 | label | |
|---|---|---|---|
| type | string | string | int |
| details |
|
|
|
| sentence_0 | sentence_1 | label |
|---|---|---|
Câu hỏi có thể sinh ra từ đoạn văn trên là: "Quy định QD04/CN/TD và Quy trình QT09/CN/TD liên quan đến việc gì trong ngành ngân hàng?" |
|
0 |
Những biện pháp cụ thể nào mà CBBH cần thực hiện liên quan đến việc thanh toán Phí Bảo Hiểm Xe và việc mua Bảo Hiểm? |
Lưu ý: |
1 |
Theo thông tin được cung cấp, điều kiện nào cần phải đáp ứng để được vay vốn từ ngân hàng? |
|
0 |
OnlineContrastiveLosseval_strategy: stepsnum_train_epochs: 4fp16: Truemulti_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 8per_device_eval_batch_size: 8per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_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: {}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: Falseuse_ipex: 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: Falseignore_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}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_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: Falsehub_always_push: Falsegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseeval_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: Nonedispatch_batches: Nonesplit_batches: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falsebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robin| Epoch | Step | dev_max_ap |
|---|---|---|
| 0.9677 | 30 | 0.6413 |
| 1.0 | 31 | 0.6394 |
| 1.9355 | 60 | 0.6365 |
| 2.0 | 62 | 0.6373 |
| 2.9032 | 90 | 0.6551 |
| 3.0 | 93 | 0.6631 |
| 3.8710 | 120 | 0.6652 |
@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",
}
Base model
intfloat/multilingual-e5-large