CoolFace
Modelpublic

dragonkue/BGE-m3-ko

sourceHugging Faceapache-2.0updated 11mo agoView on Hugging Face
78likes61kdownloads
Model Card

<img src="https://cdn-uploads.huggingface.co/production/uploads/642b0c2fecec03b4464a1d9b/9uN5ypGY-GRGgakLs_s1o.png" width="600">

SentenceTransformer

This is a sentence-transformers model trained on the train_set dataset. 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.

Model Details

  • —Learning other languages ​​besides Chinese and English is insufficient, so additional learning is needed to optimize use of other languages.
  • —This model is additionally trained on the Korean dataset.

Model Description

  • —Model Type: Sentence Transformer Transformer Encoder
  • —Maximum Sequence Length: 8192 tokens
  • —Output Dimensionality: 1024 tokens
  • —Similarity Function: Cosine Similarity

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: 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()
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("dragonkue/bge-m3-ko")
# Run inference
sentences = [
    '수급권자 중 근로 능력이 없는 임산부는 몇 종에 해당하니?',
    '내년부터 저소득층 1세 미만 아동의 \n의료비 부담이 더 낮아진다!\n의료급여제도 개요\n□ (목적) 생활유지 능력이 없거나 생활이 어려운 국민들에게 발생하는 질병, 부상, 출산 등에 대해 국가가 의료서비스 제공\n□ (지원대상) 국민기초생활보장 수급권자, 타 법에 의한 수급권자 등\n\n| 구분 | 국민기초생활보장법에 의한 수급권자 | 국민기초생활보장법 이외의 타 법에 의한 수급권자 |\n| --- | --- | --- |\n| 1종 | ○ 국민기초생활보장 수급권자 중 근로능력이 없는 자만으로 구성된 가구 - 18세 미만, 65세 이상 - 4급 이내 장애인 - 임산부, 병역의무이행자 등 | ○ 이재민(재해구호법) ○ 의상자 및 의사자의 유족○ 국내 입양된 18세 미만 아동○ 국가유공자 및 그 유족․가족○ 국가무형문화재 보유자 및 그 가족○ 새터민(북한이탈주민)과 그 가족○ 5․18 민주화운동 관련자 및 그 유가족○ 노숙인 ※ 행려환자 (의료급여법 시행령) |\n| 2종 | ○ 국민기초생활보장 수급권자 중 근로능력이 있는 가구 | - |\n',
    '이어 이날 오후 1시30분부터 열릴 예정이던 스노보드 여자 슬로프스타일 예선 경기는 연기를 거듭하다 취소됐다. 조직위는 예선 없이 다음 날 결선에서 참가자 27명이 한번에 경기해 순위를 가리기로 했다.',
]
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]

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

Evaluation

Metrics

  • —ndcg, mrr, map metrics are metrics that consider ranking, while accuracy, precision, and recall are metrics that do not consider ranking. (Example: When considering ranking for retrieval top 10, different scores are given when the correct document is in 1st place and when it is in 10th place. However, accuracy, precision, and recall scores are the same if they are in the top 10.)
Information Retrieval
  • —Korean Embedding Benchmark is a benchmark with a relatively long 3/4 quantile of string length of 1024
Korean Embedding Benchmark with AutoRAG

This is a benchmark of Korean embedding models. (https://github.com/Marker-Inc-Korea/AutoRAG-example-korean-embedding-benchmark)

  • —Top-k 1
Model nameF1RecallPrecisionmAPmRRNDCG
paraphrase-multilingual-mpnet-base-v20.35960.35960.35960.35960.35960.3596
KoSimCSE-roberta0.42980.42980.42980.42980.42980.4298
Cohere embed-multilingual-v3.00.35960.35960.35960.35960.35960.3596
openai ada 0020.47370.47370.47370.47370.47370.4737
multilingual-e5-large-instruct0.46490.46490.46490.46490.46490.4649
Upstage Embedding0.65790.65790.65790.65790.65790.6579
paraphrase-multilingual-MiniLM-L12-v20.29820.29820.29820.29820.29820.2982
openaiembed3_small0.54390.54390.54390.54390.54390.5439
ko-sroberta-multitask0.42110.42110.42110.42110.42110.4211
openaiembed3_large0.60530.60530.60530.60530.60530.6053
KU-HIAI-ONTHEIT-large-v10.71050.71050.71050.71050.71050.7105
KU-HIAI-ONTHEIT-large-v1.10.71930.71930.71930.71930.71930.7193
kf-deberta-multitask0.45610.45610.45610.45610.45610.4561
gte-multilingual-base0.58770.58770.58770.58770.58770.5877
KoE50.70180.70180.70180.70180.70180.7018
BGE-m30.65780.65780.65780.65780.65780.6578
bge-m3-korean0.53510.53510.53510.53510.53510.5351
BGE-m3-ko0.74560.74560.74560.74560.74560.7456
  • —Top-k 3
Model nameF1RecallPrecisionmAPmRRNDCG
paraphrase-multilingual-mpnet-base-v20.23680.47370.15790.20320.20320.2712
KoSimCSE-roberta0.30260.60530.20180.26610.26610.3515
Cohere embed-multilingual-v3.00.28510.57020.19010.25150.25150.3321
openai ada 0020.35530.71050.23680.32020.32020.4186
multilingual-e5-large-instruct0.33330.66670.22220.29090.29090.3856
Upstage Embedding0.42110.84210.28070.35090.35090.4743
paraphrase-multilingual-MiniLM-L12-v20.20610.41230.13740.17400.17400.2340
openaiembed3_small0.36400.72810.24270.30260.30260.4097
ko-sroberta-multitask0.29390.58770.19590.25000.25000.3351
openaiembed3_large0.39470.78950.26320.33480.33480.4491
KU-HIAI-ONTHEIT-large-v10.43860.87720.29240.34210.34210.4766
KU-HIAI-ONTHEIT-large-v1.10.44300.88600.29530.34060.34060.4778
kf-deberta-multitask0.31580.63160.21050.27920.27920.3679
gte-multilingual-base0.40350.80700.26900.34500.34500.4614
KoE50.42540.85090.28360.31730.31730.4514
BGE-m30.42540.85080.28360.34210.34210.4701
bge-m3-korean0.36840.73680.24560.31430.31430.4207
BGE-m3-ko0.45170.90350.30110.34940.34940.4886
  • —Top-k 5
Model nameF1RecallPrecisionmAPmRRNDCG
paraphrase-multilingual-mpnet-base-v20.18130.54390.10880.15750.15750.2491
KoSimCSE-roberta0.21640.64910.12980.17510.17510.2873
Cohere embed-multilingual-v3.00.20760.62280.12460.16400.16400.2731
openai ada 0020.26020.78070.15610.21390.21390.3486
multilingual-e5-large-instruct0.25440.76320.15260.21940.21940.3487
Upstage Embedding0.29820.89470.17890.22370.22370.3822
paraphrase-multilingual-MiniLM-L12-v20.16370.49120.09820.14370.14370.2264
openaiembed3_small0.26900.80700.16140.21480.21480.3553
ko-sroberta-multitask0.21640.64910.12980.16970.16970.2835
openaiembed3_large0.28070.84210.16840.20880.20880.3586
KU-HIAI-ONTHEIT-large-v10.30410.91230.18250.21370.21370.3783
KU-HIAI-ONTHEIT-large-v1.10.30990.92980.18600.21480.21480.3834
kf-deberta-multitask0.22810.68420.13680.17240.17240.2939
gte-multilingual-base0.28650.85960.17190.20960.20960.3637
KoE50.29820.89470.17890.20540.20540.3678
BGE-m30.30410.91230.18250.21930.21930.3832
bge-m3-korean0.26610.79820.15960.21160.21160.3504
BGE-m3-ko0.30990.92980.18600.20980.20980.3793
  • —Top-k 10
Model nameF1RecallPrecisionmAPmRRNDCG
paraphrase-multilingual-mpnet-base-v20.12120.66670.06670.11970.11970.2382
KoSimCSE-roberta0.13240.72810.07280.10800.10800.2411
Cohere embed-multilingual-v3.00.13240.72810.07280.11500.11500.2473
openai ada 0020.15630.85960.08600.10510.10510.2673
multilingual-e5-large-instruct0.14830.81580.08160.09800.09800.2520
Upstage Embedding0.17070.93860.09390.10780.10780.2848
paraphrase-multilingual-MiniLM-L12-v20.10530.57890.05790.09610.09610.2006
openaiembed3_small0.15470.85090.08510.09840.09840.2593
ko-sroberta-multitask0.12760.70180.07020.09860.09860.2275
openaiembed3_large0.16430.90350.09040.11800.11800.2855
KU-HIAI-ONTHEIT-large-v10.17070.93860.09390.11050.11050.2860
KU-HIAI-ONTHEIT-large-v1.10.17220.94740.09470.10330.10330.2822
kf-deberta-multitask0.13880.76320.07630.10.10.2422
gte-multilingual-base0.16750.92110.09210.10660.10660.2805
KoE50.16750.92110.09210.10110.10110.2750
BGE-m30.17070.93860.09390.11300.11300.2884
bge-m3-korean0.15790.86840.08680.10930.10930.2721
BGE-m3-ko0.17700.97360.09740.10970.10970.2932
Information Retrieval
  • —Dataset: miracl-ko (https://github.com/project-miracl/miracl)
  • —miracl benchmark is a benchmark with a relatively short 3/4 quantile of string length of 220 on the Korean Wikidata set.
  • —Evaluated with <code>InformationRetrievalEvaluator</code>
MetricValue
cosine_accuracy@10.6103
cosine_accuracy@30.8169
cosine_accuracy@50.8732
cosine_accuracy@100.9202
cosine_precision@10.6103
cosine_precision@30.3787
cosine_precision@50.2761
cosine_precision@100.1728
cosine_recall@10.3847
cosine_recall@30.5902
cosine_recall@50.6794
cosine_recall@100.7695
cosine_ndcg@100.6833
cosine_mrr@100.7262
cosine_map@1000.6074
dot_accuracy@10.6103
dot_accuracy@30.8169
dot_accuracy@50.8732
dot_accuracy@100.9202
dot_precision@10.6103
dot_precision@30.3787
dot_precision@50.2761
dot_precision@100.1728
dot_recall@10.3847
dot_recall@30.5902
dot_recall@50.6794
dot_recall@100.7695
dot_ndcg@100.6723
dot_mrr@100.7262
dot_map@1000.6074

Bias, Risks and Limitations

  • —Since the evaluation results are different for each domain, it is necessary to compare and evaluate the model in your own domain. In the Miracl benchmark, the evaluation was conducted using the Korean Wikipedia as a corpus, and in this case, the cosine_ndcg@10 score dropped by 0.02 points after learning. However, in the Auto-RAG benchmark, which is a financial domain, the ndcg score increased by 0.09 when it was top 1. This model may be advantageous for use in a specific domain.
  • —Also, since the miracl benchmark consists of a corpus of relatively short strings, while the Korean Embedding Benchmark consists of a corpus of longer strings, this model may be more advantageous if the length of the corpus you want to use is long.

Training Hyperparameters

Non-Default Hyperparameters

The batch size was referenced from the following paper: Text Embeddings by Weakly-Supervised Contrastive Pre-training (https://arxiv.org/pdf/2212.03533)

  • —eval_strategy: steps
  • —per_device_train_batch_size: 32768
  • —per_device_eval_batch_size: 32768
  • —learning_rate: 3e-05
  • —warmup_ratio: 0.03333333333333333
  • —fp16: True
  • —batch_sampler: no_duplicates
All Hyperparameters

<details><summary>Click to expand</summary>

  • —overwrite_output_dir: False
  • —do_predict: False
  • —eval_strategy: steps
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 32768
  • —per_device_eval_batch_size: 32768
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 1
  • —eval_accumulation_steps: None
  • —learning_rate: 3e-05
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —max_grad_norm: 1.0
  • —num_train_epochs: 3
  • —max_steps: -1
  • —lr_scheduler_type: linear
  • —lr_scheduler_kwargs: {}
  • —warmup_ratio: 0.03333333333333333
  • —warmup_steps: 0
  • —log_level: passive
  • —log_level_replica: warning
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —save_safetensors: True
  • —save_on_each_node: False
  • —save_only_model: False
  • —restore_callback_states_from_checkpoint: False
  • —no_cuda: False
  • —use_cpu: False
  • —use_mps_device: False
  • —seed: 42
  • —data_seed: None
  • —jit_mode_eval: False
  • —use_ipex: False
  • —bf16: False
  • —fp16: True
  • —fp16_opt_level: O1
  • —half_precision_backend: auto
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: None
  • —local_rank: 0
  • —ddp_backend: None
  • —tpu_num_cores: None
  • —tpu_metrics_debug: False
  • —debug: []
  • —dataloader_drop_last: True
  • —dataloader_num_workers: 0
  • —dataloader_prefetch_factor: None
  • —past_index: -1
  • —disable_tqdm: False
  • —remove_unused_columns: True
  • —label_names: None
  • —load_best_model_at_end: False
  • —ignore_data_skip: False
  • —fsdp: []
  • —fsdp_min_num_params: 0
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —deepspeed: None
  • —label_smoothing_factor: 0.0
  • —optim: adamw_torch
  • —optim_args: None
  • —adafactor: False
  • —group_by_length: False
  • —length_column_name: length
  • —ddp_find_unused_parameters: None
  • —ddp_bucket_cap_mb: None
  • —ddp_broadcast_buffers: False
  • —dataloader_pin_memory: True
  • —dataloader_persistent_workers: False
  • —skip_memory_metrics: True
  • —use_legacy_prediction_loop: False
  • —push_to_hub: False
  • —resume_from_checkpoint: None
  • —hub_model_id: None
  • —hub_strategy: every_save
  • —hub_private_repo: False
  • —hub_always_push: False
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —include_inputs_for_metrics: False
  • —eval_do_concat_batches: True
  • —fp16_backend: auto
  • —push_to_hub_model_id: None
  • —push_to_hub_organization: None
  • —mp_parameters:
  • —auto_find_batch_size: False
  • —full_determinism: False
  • —torchdynamo: None
  • —ray_scope: last
  • —ddp_timeout: 1800
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —dispatch_batches: None
  • —split_batches: None
  • —include_tokens_per_second: False
  • —include_num_input_tokens_seen: False
  • —neftune_noise_alpha: None
  • —optim_target_modules: None
  • —batch_eval_metrics: False
  • —batch_sampler: no_duplicates
  • —multi_dataset_batch_sampler: proportional

</details>

Citation

BibTeX

Sentence Transformers
bibtex
@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",
}
bibtex
@misc{bge-m3,
      title={BGE M3-Embedding: Multi-Lingual, Multi-Functionality, Multi-Granularity Text Embeddings Through Self-Knowledge Distillation}, 
      author={Jianlv Chen and Shitao Xiao and Peitian Zhang and Kun Luo and Defu Lian and Zheng Liu},
      year={2024},
      eprint={2402.03216},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
bibtex
@article{wang2022text,
  title={Text Embeddings by Weakly-Supervised Contrastive Pre-training},
  author={Wang, Liang and Yang, Nan and Huang, Xiaolong and Jiao, Binxing and Yang, Linjun and Jiang, Daxin and Majumder, Rangan and Wei, Furu},
  journal={arXiv preprint arXiv:2212.03533},
  year={2022}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->