Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
•
1908.10084
•
Published
•
9
This is a sentence-transformers model finetuned from GreenNode/GreenNode-Embedding-Large-VN-Mixed-V1. 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': 8192, 'do_lower_case': False, 'architecture': 'XLMRobertaModel'})
(1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, '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("ngocnamk3er/GreenNode-Embedding-Large-VN-Retrieval-fine-tuned-without-lotrinhhoc-18DEC")
# Run inference
sentences = [
'Làm thế nào để tìm kiếm sách trong kho sách đã được kích hoạt?',
'Chủ đề: 14. KÍCH HOẠT / TRA CỨU SÁCH\nNội dung:\n14. KÍCH HOẠT VÀ TRA CỨU SÁCH\n14.1. Kích hoạt sách\nBước 1: Truy cập trang web\nMở trình duyệt và truy cập vào website Tiếng Anh Cô Mai Phương\nĐăng nhập vào tài khoản để sử dụng đầy đủ các tính năng\nBước 2: Tìm mục Lịch sử đơn hàng\n[[img_link: https://imagedoan.s3.ap-southeast-2.amazonaws.com/docx_extracted/324f5bd0-0982-47f1-a8b9-317560ee0ef7.png]]\nTại giao diện trang chủ, người dùng nhấn vào avatar ở góc phải màn hình => chọn mục “Lịch sử đơn hàng”\nBước 3: Kích hoạt khoá sách\nTại giao diện Lịch sử đơn hàng, người dùng nhấn vào đơn hàng Sách => Nhấn nút “Kích hoạt”.\n14.2. Tra cứu sách\nBước 1: Tìm công cụ tra cứu Sách\n[[img_link: https://imagedoan.s3.ap-southeast-2.amazonaws.com/docx_extracted/b827d7c4-02c1-4b10-8d8f-5622a5afb777.png]]\nTại giao diện trang chủ, chọn mục Sách ở thanh menu bên trái => Nhấp vào để mở giao diện kho sách.\nBước 2: Tìm kiếm sách trong kho sách\n[[img_link: https://imagedoan.s3.ap-southeast-2.amazonaws.com/docx_extracted/8f66bfcd-d52b-4f0d-99e2-c225cad6a539.png]]\nNhập tên sách đã kích hoạt vào ô tìm kiếm hoặc nhấn trực tiếp vào 1 khoá sách bất kỳ đã kích hoạt.\nBước 3: Chọn topic sách\n[[img_link: https://imagedoan.s3.ap-southeast-2.amazonaws.com/docx_extracted/19adcfb6-9afe-461d-86d1-90d12f77d39e.png]]\nMàn hình hiển thị layout khoá sách => nhấn vào 1 topic mà bạn muốn tra cứu đáp án (Tên topic trên màn hình hiển thị trùng khớp với tên topic trong sách giấy)\nBước 4: Nhập ID câu hỏi cần tra đáp án\n[[img_link: https://imagedoan.s3.ap-southeast-2.amazonaws.com/docx_extracted/eae4a969-ad74-4d96-baea-9e5b0d0922ac.png]]\nNhập mã ID tương ứng với câu hỏi trong sách giấy => nhấn Enter\nHệ thống sẽ hiển thị đáp án câu hỏi tương ứng với mã ID đó.\n[[img_link: https://imagedoan.s3.ap-southeast-2.amazonaws.com/docx_extracted/70b6d904-2ebc-403a-9982-41494a1c7363.png]]\nTrong trường hợp muốn tra cứu các câu hỏi theo thứ tự lần lượt => người dùng nhấn nút “Next” để xem đáp án từng câu hoặc nhấn vào ô “Hide” để hiển thị danh sách các câu hỏi và tra cứu đáp án sách.',
'Câu hỏi: Làm thế nào để tải tài liệu?\nTrả lời: - Nếu em dùng laptop: Em tải file ở trên GG Chrome hoặc Cốc Cốc cho dễ em nhé. Em ấn vào mũi tên tải xuống màu đỏ thì file sẽ đc tải về máy của em, em hay kiểm tra phần nhật ký tải xuống gần đây trên trình duyệt google của em (nếu là cốc cốc, còn chrome thì nó ghi là "tệp đã tải xuống" đó em nhé. Hoặc em kiểm tra ở thư mục Download nhé.\n\n- Nếu em dùng điện thoại: Em vào web từ Zalo, Facebook hoặc search từ Google thường sẽ bị chặn tải nha em. Em mở bài giải trực tiếp trên app Google Chrome và tải về giúp chị nha. Trên Safari thì em vào cài đặt => Safari và tắt chế độ Chặn cửa sổ bật lên rồi tải tài liệu em nhé.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.7074, 0.1647],
# [0.7074, 1.0000, 0.3124],
# [0.1647, 0.3124, 1.0000]])
val_hit_at_kInformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.7101 |
| cosine_accuracy@5 | 0.9269 |
| cosine_accuracy@10 | 0.9707 |
| cosine_precision@1 | 0.7101 |
| cosine_precision@3 | 0.2979 |
| cosine_precision@5 | 0.1854 |
| cosine_precision@10 | 0.0971 |
| cosine_recall@1 | 0.7101 |
| cosine_recall@3 | 0.8936 |
| cosine_recall@5 | 0.9269 |
| cosine_recall@10 | 0.9707 |
| cosine_ndcg@10 | 0.8477 |
| cosine_mrr@10 | 0.8075 |
| cosine_map@100 | 0.8093 |
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
Có cách nào để đảm bảo rằng đáp án mặc định luôn chính xác và bao quát không ạ? |
Câu hỏi: HS làm đúng nhưng bị web đánh sai do đáp án khác với web nhưng vẫn đúng |
Em có thể giải quyết thắc mắc về điểm số một cách độc lập không? |
Câu hỏi: Sao em làm đúng mà hệ thống chấm sai? |
Chị có thể giới thiệu cho em chuyên đề tổng ôn trọng điểm từ vựng không ạ? |
Câu hỏi: Tính năng tập dịch ở khoá lớp 10 |
main.LoggingMultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false
}
eval_strategy: stepsper_device_train_batch_size: 4per_device_eval_batch_size: 4num_train_epochs: 1fp16: Truemulti_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 4per_device_eval_batch_size: 4per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_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: 1max_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: Falseeval_on_start: Falseeval_use_gather_object: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | val_hit_at_k_cosine_ndcg@10 |
|---|---|---|---|
| 0.1330 | 100 | - | 0.7748 |
| 0.2660 | 200 | - | 0.8199 |
| 0.3989 | 300 | - | 0.8323 |
| 0.5319 | 400 | - | 0.8401 |
| 0.6649 | 500 | 0.0732 | 0.8477 |
@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",
}
@misc{henderson2017efficient,
title={Efficient Natural Language Response Suggestion for Smart Reply},
author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
year={2017},
eprint={1705.00652},
archivePrefix={arXiv},
primaryClass={cs.CL}
}