vietnamese-bi-encoder-fine-tuning-for-law-chatbot
This is a sentence-transformers model finetuned from bkai-foundation-models/vietnamese-bi-encoder. 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: bkai-foundation-models/vietnamese-bi-encoder
- Maximum Sequence Length: 256 tokens
- Output Dimensionality: 768 tokens
- Similarity Function: Cosine Similarity
- Language: vn
- License: apache-2.0
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': 256, '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:
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("maiduchuy321/vietnamese-bi-encoder-fine-tuning-for-law-chatbot")
# Run inference
sentences = [
'Thời gian giải quyết thủ tục hành chính đối với 01 bộ hồ sơ quảng cáo thực phẩm?',
'Theo quy định tại khoản 5 Điều 27 Nghị định 15/2018/NĐ-CP: Trong thời hạn 10 ngày làm việc, kể từ ngày nhận đủ hồ sơ hợp lệ, cơ quan tiếp nhận hồ sơ có trách nhiệm xem xét hồ sơ và trả kết quả theo Mẫu số 11 Phụ lục I ban hành kèm theo Nghị định 15/2018/NĐ-CP. Thời hạn này được tính từ ngày đóng dấu đến của cơ quan tiếp nhận hồ sơ nếu hồ sơ được gửi qua đường bưu điện hoặc ngày hồ sơ hoàn chỉnh được tiếp nhận trên hệ thống dịch vụ công trực tuyến.Trong trường hợp không đồng ý với nội dung quảng cáo của tổ chức, cá nhân hoặc yêu cầu sửa đổi, bổ sung, cơ quan tiếp nhận hồ sơ phải có văn bản nêu rõ lý do và căn cứ pháp lý của việc yêu cầu. Trong thời hạn 10 ngày làm việc kể từ khi nhận hồ sơ sửa đổi, bổ sung, cơ quan tiếp nhận hồ sơ thẩm định hồ sơ và có văn bản trả lời. Sau 90 ngày làm việc kể từ khi có công văn yêu cầu sửa đổi, bổ sung nếu tổ chức, cá nhân không sửa đổi, bổ sung thì hồ sơ không còn giá trị.',
'Ngoài các hồ sơ, tài liệu gửi 1 lần và gửi hàng năm theo chế độ quy định, chủ đầu tư gửi KBNN các hồ sơ, tài liệu có liên quan theo quy định tại tiết 1.5.1, mục 1.5, và 1.5.1, mục 1.6, điểm 1, phần II, Thông tư số 113/2008/TT-BTC ngày 27/11/2008 của BTC cụ thể: Hồ sơ cam kết chi thường xuyên:- Hợp đồng mua bán hàng hoá, dịch vụ có giá trị từ 100 triệu đồng trở lên (gửi lần đầu hoặc khi có điều chỉnh hợp đồng);- Đề nghị cam kết chi hoặc đề nghị điều chỉnh cam kết chi.Hồ sơ cam kết chi đầu tư: - Hợp đồng có giá trị từ 500 triệu đồng trở lên (gửi lần đầu khi đề nghị cam kết chi hoặc gửi khi có điều chỉnh hợp đồng);- Đề nghị cam kết chi hoặc đề nghị điều chỉnh cam kết chi.',
]
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]
Evaluation
Metrics
Information Retrieval
- Dataset:
dim_768
- Evaluated with
InformationRetrievalEvaluator
Metric | Value |
---|---|
cosine_accuracy@1 | 0.5192 |
cosine_accuracy@3 | 0.7035 |
cosine_accuracy@5 | 0.7704 |
cosine_accuracy@10 | 0.8433 |
cosine_precision@1 | 0.5192 |
cosine_precision@3 | 0.2345 |
cosine_precision@5 | 0.1541 |
cosine_precision@10 | 0.0843 |
cosine_recall@1 | 0.5192 |
cosine_recall@3 | 0.7035 |
cosine_recall@5 | 0.7704 |
cosine_recall@10 | 0.8433 |
cosine_ndcg@10 | 0.6785 |
cosine_mrr@10 | 0.6261 |
cosine_map@100 | 0.6315 |
Information Retrieval
- Dataset:
dim_512
- Evaluated with
InformationRetrievalEvaluator
Metric | Value |
---|---|
cosine_accuracy@1 | 0.51 |
cosine_accuracy@3 | 0.7058 |
cosine_accuracy@5 | 0.7642 |
cosine_accuracy@10 | 0.8402 |
cosine_precision@1 | 0.51 |
cosine_precision@3 | 0.2353 |
cosine_precision@5 | 0.1528 |
cosine_precision@10 | 0.084 |
cosine_recall@1 | 0.51 |
cosine_recall@3 | 0.7058 |
cosine_recall@5 | 0.7642 |
cosine_recall@10 | 0.8402 |
cosine_ndcg@10 | 0.673 |
cosine_mrr@10 | 0.6197 |
cosine_map@100 | 0.6252 |
Information Retrieval
- Dataset:
dim_256
- Evaluated with
InformationRetrievalEvaluator
Metric | Value |
---|---|
cosine_accuracy@1 | 0.5023 |
cosine_accuracy@3 | 0.6951 |
cosine_accuracy@5 | 0.7634 |
cosine_accuracy@10 | 0.8349 |
cosine_precision@1 | 0.5023 |
cosine_precision@3 | 0.2317 |
cosine_precision@5 | 0.1527 |
cosine_precision@10 | 0.0835 |
cosine_recall@1 | 0.5023 |
cosine_recall@3 | 0.6951 |
cosine_recall@5 | 0.7634 |
cosine_recall@10 | 0.8349 |
cosine_ndcg@10 | 0.6663 |
cosine_mrr@10 | 0.6125 |
cosine_map@100 | 0.6182 |
Information Retrieval
- Dataset:
dim_128
- Evaluated with
InformationRetrievalEvaluator
Metric | Value |
---|---|
cosine_accuracy@1 | 0.4839 |
cosine_accuracy@3 | 0.6674 |
cosine_accuracy@5 | 0.7481 |
cosine_accuracy@10 | 0.821 |
cosine_precision@1 | 0.4839 |
cosine_precision@3 | 0.2225 |
cosine_precision@5 | 0.1496 |
cosine_precision@10 | 0.0821 |
cosine_recall@1 | 0.4839 |
cosine_recall@3 | 0.6674 |
cosine_recall@5 | 0.7481 |
cosine_recall@10 | 0.821 |
cosine_ndcg@10 | 0.6487 |
cosine_mrr@10 | 0.5939 |
cosine_map@100 | 0.6001 |
Information Retrieval
- Dataset:
dim_64
- Evaluated with
InformationRetrievalEvaluator
Metric | Value |
---|---|
cosine_accuracy@1 | 0.4462 |
cosine_accuracy@3 | 0.6382 |
cosine_accuracy@5 | 0.7158 |
cosine_accuracy@10 | 0.7988 |
cosine_precision@1 | 0.4462 |
cosine_precision@3 | 0.2127 |
cosine_precision@5 | 0.1432 |
cosine_precision@10 | 0.0799 |
cosine_recall@1 | 0.4462 |
cosine_recall@3 | 0.6382 |
cosine_recall@5 | 0.7158 |
cosine_recall@10 | 0.7988 |
cosine_ndcg@10 | 0.6178 |
cosine_mrr@10 | 0.5604 |
cosine_map@100 | 0.5667 |
Training Details
Training Dataset
Unnamed Dataset
- Size: 11,711 training samples
- Columns:
Câu hỏi
andCâu trả lời
- Approximate statistics based on the first 1000 samples:
Câu hỏi Câu trả lời type string string details - min: 6 tokens
- mean: 38.26 tokens
- max: 256 tokens
- min: 4 tokens
- mean: 143.99 tokens
- max: 256 tokens
- Samples:
Câu hỏi Câu trả lời Phòng thử nghiệm của tổ chức, doanh nghiệp chỉ thực hiện hoạt động thử nghiệm phục vụ kiểm soát chất lượng sản phẩm do chính tổ chức, doanh nghiệp sản xuất ra thì có phải thực hiện đăng ký hoạt động thử nghiệm theo Nghị định số 107/2016/NĐ-CP không?
Tại khoản 1 Điều 2 Nghị định số 107/2016/NĐ-CP quy định Nghị định này áp dụng đối với các tổ chức, doanh nghiệp có hoạt động kinh doanh dịch vụ đánh giá sự phù hợp (thử nghiệm, chứng nhận, giám định, kiểm định) trên lãnh thổ Việt Nam. Do đó, trong trường hợp này, tổ chức, doanh nghiệp không phải thực hiện đăng ký hoạt động thử nghiệm theo quy định tại Nghị định số 107/2016/NĐ-CP. Trường hợp, tổ chức, doanh nghiệp có nhu cầu cung cấp dịch vụ thử nghiệm thì phải thực hiện đăng ký hoạt động thử nghiệm theo quy định tại Nghị định số 107/2016/NĐ-CP.
Sửa đổi, bổ sung Giấy chứng nhận đủ điều kiện hoạt động điểm cung cấp dịch vụ trò chơi điện tử công cộng trong trường hợp nào?; cách thức thực hiện như thế nào; thời gian thực thực hiện trong bao lâu?
Sửa đổi, bổ sung trong thời hạn hiệu lực của Giấy chứng nhận đủ điều kiện hoạt động điểm cung cấp dịch vụ trò chơi điện tử công cộng, chủ điểm cung cấp dịch vụ trò chơi điện tử công cộng phải làm thủ tục sửa đổi, bổ sung giấy chứng nhận đủ điều kiện hoạt động điểm cung cấp dịch vụ trò chơi điện tử công cộng đã được cấp thuộc một trong các trường hợp sau đây: Thay đổi tên điểm cung cấp dịch vụ trò chơi điện tử công cộng; Thay đổi chủ điểm cung cấp dịch vụ trò chơi điện tử công cộng đối với trường hợp chủ điểm là cá nhân hoặc thay đổi người quản lý trực tiếp điểm cung cấp dịch vụ trò chơi điện tử công cộng đối với trường hợp chủ điểm là tổ chức, doanh nghiệp; Cách thức thực hiện: cá nhân có thể gửi hồ sơ trực tiếp hoặc gửi trực tuyến qua cổng dịch vụ công tỉnh Hà Giang; Thời gian thực hiện trong 05 ngày làm việc, kể từ ngày nhận đủ hồ sơ hợp lệ.
Đối với trường hợp đại lý đã được cấp trước đây có được phép hoạt động đến hết thời hạn trong Giấy chứng nhận đủ điều kiện kinh doanh dược không? Hay hướng dẫn các đại lý chuyển đổi qua quầy thuốc ngay khi Nghị định 54/2017/NĐ-CP ngày 08/5/2017 của Chính phủ có hiệu lực? Theo quy định của Luật Dược 2016 không còn loại hình bán lẻ thuốc là đại lý thuốc.
Khoản 1 Điều 115 Luật dược quy định về điều khoản chuyển tiếp, theo đó:“Cơ sở kinh doanh dược đã được cấp Giấy chứng nhận đủ điều kiện kinh doanh dượctheo quy định của Luật dược 34/2005/QH11 được tiếp tục kinh doanh thuốc cho đếnhết thời hạn hiệu lực của Giấy chứng nhận đủ điều kiện kinh doanh dược”. Nhưvậy, các đại lý bán lẻ thuốc đã được cấp Giấy chứng nhận đủ điều kiện kinhdoanh dược được phép hoạt động đến hết thời hạn ghi trên Giấy chứng nhận đủđiều kiện kinh doanh dược. Việc các đại lý muốn chuyển đổi thành quầy thuốc thìphải đáp ứng các quy định về điều kiện và địa bàn hoạt động đối với quầy thuốc
- Loss:
MatryoshkaLoss
with these parameters:{ "loss": "MultipleNegativesRankingLoss", "matryoshka_dims": [ 768, 512, 256, 128, 64 ], "matryoshka_weights": [ 1, 1, 1, 1, 1 ], "n_dims_per_step": -1 }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy
: epochper_device_train_batch_size
: 32per_device_eval_batch_size
: 16gradient_accumulation_steps
: 32learning_rate
: 2e-05num_train_epochs
: 15lr_scheduler_type
: cosinewarmup_ratio
: 0.1fp16
: Truetf32
: Falseload_best_model_at_end
: Trueoptim
: adamw_torch_fusedbatch_sampler
: no_duplicates
All Hyperparameters
Click to expand
overwrite_output_dir
: Falsedo_predict
: Falseeval_strategy
: epochprediction_loss_only
: Trueper_device_train_batch_size
: 32per_device_eval_batch_size
: 16per_gpu_train_batch_size
: Noneper_gpu_eval_batch_size
: Nonegradient_accumulation_steps
: 32eval_accumulation_steps
: Nonelearning_rate
: 2e-05weight_decay
: 0.0adam_beta1
: 0.9adam_beta2
: 0.999adam_epsilon
: 1e-08max_grad_norm
: 1.0num_train_epochs
: 15max_steps
: -1lr_scheduler_type
: cosinelr_scheduler_kwargs
: {}warmup_ratio
: 0.1warmup_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
: Falselocal_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}deepspeed
: Nonelabel_smoothing_factor
: 0.0optim
: adamw_torch_fusedoptim_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
: no_duplicatesmulti_dataset_batch_sampler
: proportional
Training Logs
Epoch | Step | Training Loss | dim_128_cosine_map@100 | dim_256_cosine_map@100 | dim_512_cosine_map@100 | dim_64_cosine_map@100 | dim_768_cosine_map@100 |
---|---|---|---|---|---|---|---|
0.8743 | 10 | 3.9132 | - | - | - | - | - |
0.9617 | 11 | - | 0.4759 | 0.5066 | 0.5205 | 0.4333 | 0.5227 |
1.7486 | 20 | 2.3057 | - | - | - | - | - |
1.9235 | 22 | - | 0.5345 | 0.5541 | 0.5686 | 0.4968 | 0.5756 |
2.6230 | 30 | 1.3986 | - | - | - | - | - |
2.9727 | 34 | - | 0.5586 | 0.5826 | 0.5958 | 0.5223 | 0.5979 |
3.4973 | 40 | 0.954 | - | - | - | - | - |
3.9344 | 45 | - | 0.5739 | 0.5948 | 0.6079 | 0.5370 | 0.6066 |
4.3716 | 50 | 0.6417 | - | - | - | - | - |
4.9836 | 57 | - | 0.5865 | 0.6066 | 0.6135 | 0.5488 | 0.6152 |
5.2459 | 60 | 0.4711 | - | - | - | - | - |
5.9454 | 68 | - | 0.5898 | 0.6140 | 0.6170 | 0.5572 | 0.6196 |
6.1202 | 70 | 0.3451 | - | - | - | - | - |
6.9945 | 80 | 0.2679 | 0.5957 | 0.6118 | 0.6212 | 0.5627 | 0.6210 |
7.8689 | 90 | 0.2066 | - | - | - | - | - |
7.9563 | 91 | - | 0.5973 | 0.6140 | 0.6253 | 0.5643 | 0.6268 |
8.7432 | 100 | 0.1844 | - | - | - | - | - |
8.9180 | 102 | - | 0.5971 | 0.6189 | 0.6271 | 0.5621 | 0.6281 |
9.6175 | 110 | 0.1604 | - | - | - | - | - |
9.9672 | 114 | - | 0.5993 | 0.6190 | 0.6273 | 0.5646 | 0.6307 |
10.4918 | 120 | 0.1507 | - | - | - | - | - |
10.9290 | 125 | - | 0.5976 | 0.6181 | 0.6258 | 0.5668 | 0.6305 |
11.3661 | 130 | 0.1307 | - | - | - | - | - |
11.9781 | 137 | - | 0.5990 | 0.6166 | 0.6251 | 0.5671 | 0.6318 |
12.2404 | 140 | 0.1275 | - | - | - | - | - |
12.9399 | 148 | - | 0.6002 | 0.6174 | 0.6259 | 0.5665 | 0.6314 |
13.1148 | 150 | 0.1204 | - | - | - | - | - |
13.9891 | 160 | 0.1227 | 0.6004 | 0.6176 | 0.6253 | 0.5668 | 0.6316 |
14.4262 | 165 | - | 0.6001 | 0.6182 | 0.6252 | 0.5667 | 0.6315 |
- The bold row denotes the saved checkpoint.
Framework Versions
- Python: 3.10.13
- Sentence Transformers: 3.0.1
- Transformers: 4.41.2
- PyTorch: 2.1.2
- Accelerate: 0.30.1
- Datasets: 2.19.1
- Tokenizers: 0.19.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",
}
MatryoshkaLoss
@misc{kusupati2024matryoshka,
title={Matryoshka Representation Learning},
author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
year={2024},
eprint={2205.13147},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
MultipleNegativesRankingLoss
@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}
}
- Downloads last month
- 7
Inference Providers
NEW
This model is not currently available via any of the supported third-party Inference Providers, and
the model is not deployed on the HF Inference API.
Model tree for maiduchuy321/vietnamese-bi-encoder-fine-tuning-for-law-chatbot
Base model
bkai-foundation-models/vietnamese-bi-encoderEvaluation results
- Cosine Accuracy@1 on dim 768self-reported0.519
- Cosine Accuracy@3 on dim 768self-reported0.704
- Cosine Accuracy@5 on dim 768self-reported0.770
- Cosine Accuracy@10 on dim 768self-reported0.843
- Cosine Precision@1 on dim 768self-reported0.519
- Cosine Precision@3 on dim 768self-reported0.235
- Cosine Precision@5 on dim 768self-reported0.154
- Cosine Precision@10 on dim 768self-reported0.084
- Cosine Recall@1 on dim 768self-reported0.519
- Cosine Recall@3 on dim 768self-reported0.704