SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
(1): Pooling({'embedding_dimension': 384, 'pooling_mode': 'mean', 'include_prompt': True})
(2): Normalize({})
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("sentence_transformers_model_id")
5# Run inference
6queries = [
7 'query: 병과명',
8]
9documents = [
10 'passage: 한글명: 병과명\n영문약어명: BR_NM\n단어조합: 병과 + 명\n단어영문약어조합: BR + NM\n단어도메인분류조합: 명\n마지막단어: 명\n마지막단어도메인분류명: 명\n설명: 군사조직에서 군인이 능력에 따라 수행하는 주요 임무를 분류한 것의 이름',
11 'passage: 한글명: 변환파일명\n영문약어명: TRSF_FILE_NM\n단어조합: 변환 + 파일 + 명\n단어영문약어조합: TRSF + FILE + NM\n단어도메인분류조합: 명\n마지막단어: 명\n마지막단어도메인분류명: 명\n설명: 다르게 하여 바꾼 파일의 이름',
12 'passage: 한글명: 국가명\n영문약어명: NTN_NM\n단어조합: 국가 + 명\n단어영문약어조합: NTN + NM\n단어도메인분류조합: 명\n마지막단어: 명\n마지막단어도메인분류명: 명\n설명: 일정한 영토와 거기에 사는 사람들로 구성되고, 주권(主權)에 따른 하나의 통치 조직을 가지고 있는 사회 집단의 이름\n이음동의어: 나라명, 국가명칭, 국가이름, 나라명칭, 나라이름',
13]
14query_embeddings = model.encode_query(queries)
15document_embeddings = model.encode_document(documents)
16print(query_embeddings.shape, document_embeddings.shape)
17# [1, 384] [3, 384]
18
19# Get the similarity scores for the embeddings
20similarities = model.similarity(query_embeddings, document_embeddings)
21print(similarities)
22# tensor([[0.9488, 0.0378, 0.2989]])meta-assistant-termsInformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.9889 |
| cosine_accuracy@3 | 0.9997 |
| cosine_accuracy@5 | 0.9997 |
| cosine_precision@1 | 0.9889 |
| cosine_precision@3 | 0.3332 |
| cosine_precision@5 | 0.1999 |
| cosine_precision@10 | 0.1 |
| cosine_recall@1 | 0.9889 |
| cosine_recall@3 | 0.9997 |
| cosine_recall@5 | 0.9997 |
| cosine_recall@10 | 1.0 |
| cosine_ndcg@10 | 0.9955 |
| cosine_mrr@10 | 0.994 |
| cosine_map@100 | 0.994 |
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| modality | text | text | text |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
query: 고도 | passage: 한글명: 고도[object Object]영문약어명: ALTD[object Object]단어조합: 고도[object Object]단어영문약어조합: ALTD[object Object]단어도메인분류조합: 수[object Object]마지막단어: 고도[object Object]마지막단어도메인분류명: 수[object Object]설명: 평균 해수면 따위를 0으로 하여 측정한 대상 물체의 높이 | passage: 한글명: 해발고도[object Object]영문약어명: ELVT_ALTD[object Object]단어조합: 해발 + 고도[object Object]단어영문약어조합: ELVT + ALTD[object Object]단어도메인분류조합: 수[object Object]마지막단어: 고도[object Object]마지막단어도메인분류명: 수[object Object]설명: 평균 해수면을 기준으로 하여 잰 어떤 지점의 높이 |
query: 국비 | passage: 한글명: 국비[object Object]영문약어명: GVEXP[object Object]단어조합: 국비[object Object]단어영문약어조합: GVEXP[object Object]단어도메인분류조합: 비용[object Object]마지막단어: 국비[object Object]마지막단어도메인분류명: 비용[object Object]설명: 나라의 재정으로 부담하는 비용 | passage: 한글명: 국민주택기금금액[object Object]영문약어명: NHFND_AMT[object Object]단어조합: 국민주택기금 + 금액[object Object]단어영문약어조합: NHFND + AMT[object Object]단어도메인분류조합: 금액[object Object]마지막단어: 금액[object Object]마지막단어도메인분류명: 금액[object Object]설명: 한 세대당 85㎡ 이하로 규정된 국민 주택의 건설하는 것을 지원할 목적으로 마련한 기금에서 지원·융자 또는 보조하는 돈의 액수 |
query: 군번 | passage: 한글명: 군번[object Object]영문약어명: SRVNO[object Object]단어조합: 군번[object Object]단어영문약어조합: SRVNO[object Object]단어도메인분류조합: 번호[object Object]마지막단어: 군번[object Object]마지막단어도메인분류명: 번호[object Object]설명: 군인 개인마다 주어지는 고유 번호 | passage: 한글명: 군경력개월수[object Object]영문약어명: MLCR_MCNT[object Object]단어조합: 군경력 + 개월수[object Object]단어영문약어조합: MLCR + MCNT[object Object]단어도메인분류조합: 수[object Object]마지막단어: 개월수[object Object]마지막단어도메인분류명: 수[object Object]설명: 군에 복무한 경력에 대한 개월의 수 |
MultipleNegativesRankingLoss with these parameters:
1{
2 "scale": 20.0,
3 "similarity_fct": "cos_sim",
4 "gather_across_devices": false,
5 "directions": [
6 "query_to_doc"
7 ],
8 "partition_mode": "joint",
9 "hardness_mode": null,
10 "hardness_strength": 0.0
11}per_device_train_batch_size: 32num_train_epochs: 2learning_rate: 2e-05warmup_steps: 0.1fp16: Truedataloader_drop_last: Truebatch_sampler: no_duplicatesper_device_train_batch_size: 32num_train_epochs: 2max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.1optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Falsefp16: Truebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 8prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Truedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: Nonefsdp_config: Nonedeepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | meta-assistant-terms_cosine_ndcg@10 |
|---|---|---|---|
| -1 | -1 | - | 0.9082 |
| 0.0253 | 20 | 1.0291 | - |
| 0.0505 | 40 | 0.4264 | - |
| 0.0758 | 60 | 0.1148 | - |
| 0.1010 | 80 | 0.0439 | - |
| 0.1263 | 100 | 0.0415 | - |
| 0.1515 | 120 | 0.0254 | - |
| 0.1768 | 140 | 0.0248 | - |
| 0.2020 | 160 | 0.0183 | - |
| 0.2273 | 180 | 0.0152 | - |
| 0.2525 | 200 | 0.0155 | - |
| 0.2778 | 220 | 0.0180 | - |
| 0.3030 | 240 | 0.0240 | - |
| 0.3283 | 260 | 0.0119 | - |
| 0.3535 | 280 | 0.0235 | - |
| 0.3788 | 300 | 0.0164 | - |
| 0.4040 | 320 | 0.0094 | - |
| 0.4293 | 340 | 0.0075 | - |
| 0.4545 | 360 | 0.0067 | - |
| 0.4798 | 380 | 0.0072 | - |
| 0.5051 | 400 | 0.0081 | - |
| 0.5303 | 420 | 0.0071 | - |
| 0.5556 | 440 | 0.0078 | - |
| 0.5808 | 460 | 0.0077 | - |
| 0.6061 | 480 | 0.0093 | - |
| 0.6313 | 500 | 0.0109 | - |
| 0.6566 | 520 | 0.0075 | - |
| 0.6818 | 540 | 0.0036 | - |
| 0.7071 | 560 | 0.0046 | - |
| 0.7323 | 580 | 0.0056 | - |
| 0.7576 | 600 | 0.0061 | - |
| 0.7828 | 620 | 0.0052 | - |
| 0.8081 | 640 | 0.0056 | - |
| 0.8333 | 660 | 0.0081 | - |
| 0.8586 | 680 | 0.0065 | - |
| 0.8838 | 700 | 0.0043 | - |
| 0.9091 | 720 | 0.0067 | - |
| 0.9343 | 740 | 0.0049 | - |
| 0.9596 | 760 | 0.0038 | - |
| 0.9848 | 780 | 0.0054 | - |
| 1.0 | 792 | - | 0.9951 |
| 1.0101 | 800 | 0.0088 | - |
| 1.0354 | 820 | 0.0053 | - |
| 1.0606 | 840 | 0.0049 | - |
| 1.0859 | 860 | 0.0070 | - |
| 1.1111 | 880 | 0.0038 | - |
| 1.1364 | 900 | 0.0037 | - |
| 1.1616 | 920 | 0.0041 | - |
| 1.1869 | 940 | 0.0028 | - |
| 1.2121 | 960 | 0.0111 | - |
| 1.2374 | 980 | 0.0041 | - |
| 1.2626 | 1000 | 0.0040 | - |
| 1.2879 | 1020 | 0.0043 | - |
| 1.3131 | 1040 | 0.0034 | - |
| 1.3384 | 1060 | 0.0068 | - |
| 1.3636 | 1080 | 0.0040 | - |
| 1.3889 | 1100 | 0.0027 | - |
| 1.4141 | 1120 | 0.0036 | - |
| 1.4394 | 1140 | 0.0047 | - |
| 1.4646 | 1160 | 0.0051 | - |
| 1.4899 | 1180 | 0.0073 | - |
| 1.5152 | 1200 | 0.0052 | - |
| 1.5404 | 1220 | 0.0034 | - |
| 1.5657 | 1240 | 0.0056 | - |
| 1.5909 | 1260 | 0.0054 | - |
| 1.6162 | 1280 | 0.0100 | - |
| 1.6414 | 1300 | 0.0049 | - |
| 1.6667 | 1320 | 0.0034 | - |
| 1.6919 | 1340 | 0.0045 | - |
| 1.7172 | 1360 | 0.0027 | - |
| 1.7424 | 1380 | 0.0036 | - |
| 1.7677 | 1400 | 0.0024 | - |
| 1.7929 | 1420 | 0.0071 | - |
| 1.8182 | 1440 | 0.0050 | - |
| 1.8434 | 1460 | 0.0020 | - |
| 1.8687 | 1480 | 0.0028 | - |
| 1.8939 | 1500 | 0.0065 | - |
| 1.9192 | 1520 | 0.0028 | - |
| 1.9444 | 1540 | 0.0051 | - |
| 1.9697 | 1560 | 0.0075 | - |
| 1.9949 | 1580 | 0.0034 | - |
| 2.0 | 1584 | - | 0.9955 |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@misc{oord2019representationlearningcontrastivepredictive,
2 title={Representation Learning with Contrastive Predictive Coding},
3 author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
4 year={2019},
5 eprint={1807.03748},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG},
8 url={https://arxiv.org/abs/1807.03748},
9}