SentenceTransformer based on varin/embeddinggemma-thai-law

This is a sentence-transformers model finetuned from varin/embeddinggemma-thai-law on the json dataset. 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: varin/embeddinggemma-thai-law
  • Maximum Sequence Length: 256 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity
  • Training Dataset:
    • json

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 256, 'do_lower_case': False, 'architecture': 'Gemma3TextModel'})
  (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})
  (2): Dense({'in_features': 768, 'out_features': 3072, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
  (3): Dense({'in_features': 3072, 'out_features': 768, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
  (4): Normalize()
)

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("varin/embeddinggemma-thai-law")
# Run inference
queries = [
    "\u0e2b\u0e32\u0e01\u0e1c\u0e39\u0e49\u0e40\u0e1b\u0e47\u0e19\u0e2b\u0e38\u0e49\u0e19\u0e2a\u0e48\u0e27\u0e19\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14\u0e43\u0e2b\u0e49\u0e04\u0e27\u0e32\u0e21\u0e22\u0e34\u0e19\u0e22\u0e2d\u0e21 \u0e2b\u0e49\u0e32\u0e07\u0e2b\u0e38\u0e49\u0e19\u0e2a\u0e48\u0e27\u0e19\u0e08\u0e14\u0e17\u0e30\u0e40\u0e1a\u0e35\u0e22\u0e19\u0e2a\u0e2d\u0e07\u0e41\u0e2b\u0e48\u0e07\u0e08\u0e30\u0e04\u0e27\u0e1a\u0e23\u0e27\u0e21\u0e01\u0e31\u0e19\u0e44\u0e14\u0e49\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e21\u0e48?",
]
documents = [
    'ประมวลกฎหมายแพ่งและพาณิชย์ มาตรา 1073 ห้างหุ้นส่วนจดทะเบียนห้างหนึ่งจะควบเข้าเป็นอันเดียวกับห้างหุ้นส่วนจดทะเบียนอีกห้างหนึ่งก็ได้ โดยความยินยอมของผู้เป็นหุ้นส่วนทั้งหมด เว้นแต่จะได้ตกลงกันไว้เป็นอย่างอื่น',
    'การควบห้างหุ้นส่วนจดทะเบียนต้องกระทำโดยความยินยอมของหุ้นส่วนไม่น้อยกว่าสามในสี่ของจำนวนหุ้นส่วนทั้งหมดเท่านั้น',
    'ประมวลกฎหมายแพ่งและพาณิชย์ มาตรา 1061 เมื่อห้างหุ้นส่วนเลิกกันแล้วก็ให้จัดการชำระบัญชี เว้นแต่จะได้ตกลงกันให้จัดการทรัพย์สินโดยวิธีอื่นในระหว่างผู้เป็นหุ้นส่วนด้วยกัน หรือว่าห้างหุ้นส่วนนั้นศาลได้พิพากษาให้ล้มละลาย ถ้าการเลิกห้างหุ้นส่วนนั้นได้เป็นไปโดยที่เจ้าหนี้เฉพาะตัวของผู้เป็นหุ้นส่วนคนใดคนหนึ่งได้ให้คำบอกกล่าวก็ดี หรือโดยที่ผู้เป็นหุ้นส่วนคนใดคนหนึ่งล้มละลายก็ดี ท่านว่าจะงดการชำระบัญชีเสียได้ต่อเมื่อเจ้าหนี้คนนั้น หรือเจ้าพนักงานรักษาทรัพย์ยินยอมด้วย การชำระบัญชีนั้น ให้ผู้เป็นหุ้นส่วนทั้งหมดด้วยกันจัดทำหรือให้บุคคลอื่นซึ่งผู้เป็นหุ้นส่วนได้ตั้งแต่งขึ้นนั้นเป็นผู้จัดทำ การตั้งแต่งผู้ชำระบัญชี ให้วินิจฉัยชี้ขาดโดยคะแนนเสียงข้างมากของผู้เป็นหุ้นส่วน',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 768] [3, 768]

# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.7431, 0.0676, 0.1604]])

Training Details

Training Dataset

json

  • Dataset: json
  • Size: 20,750 training samples
  • Columns: anchor, positive, and negative
  • Approximate statistics based on the first 1000 samples:
    anchor positive negative
    type string string string
    details
    • min: 10 tokens
    • mean: 31.91 tokens
    • max: 58 tokens
    • min: 39 tokens
    • mean: 116.71 tokens
    • max: 256 tokens
    • min: 9 tokens
    • mean: 30.03 tokens
    • max: 54 tokens
  • Samples:
    anchor positive negative
    กฎหมายนี้มีชื่อเรียกว่าอะไร ประมวลกฎหมายแพ่งและพาณิชย์ มาตรา 1 กฎหมายนี้ให้เรียกว่า ประมวลกฎหมายแพ่งและพาณิชย์ พระราชบัญญัติว่าด้วยธุรกรรมทางอิเล็กทรอนิกส์
    ชื่อของประมวลกฎหมายนี้คืออะไร ประมวลกฎหมายแพ่งและพาณิชย์ มาตรา 1 กฎหมายนี้ให้เรียกว่า ประมวลกฎหมายแพ่งและพาณิชย์ ประมวลรัษฎากร
    กฎหมายที่กล่าวถึงในมาตรานี้เรียกว่าอะไร ประมวลกฎหมายแพ่งและพาณิชย์ มาตรา 1 กฎหมายนี้ให้เรียกว่า ประมวลกฎหมายแพ่งและพาณิชย์ พระราชบัญญัติล้มละลาย
  • Loss: CachedMultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim",
        "mini_batch_size": 8,
        "gather_across_devices": false
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 16
  • learning_rate: 2e-05
  • num_train_epochs: 1
  • warmup_ratio: 0.1
  • bf16: True
  • push_to_hub: True
  • hub_model_id: varin/embeddinggemma-thai-law
  • hub_strategy: end

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: no
  • prediction_loss_only: True
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 8
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 1
  • eval_accumulation_steps: None
  • torch_empty_cache_steps: None
  • learning_rate: 2e-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: 1
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.1
  • 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
  • bf16: True
  • fp16: False
  • 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: False
  • 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: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
  • parallelism_config: None
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch_fused
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • project: huggingface
  • trackio_space_id: trackio
  • 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: True
  • resume_from_checkpoint: None
  • hub_model_id: varin/embeddinggemma-thai-law
  • hub_strategy: end
  • hub_private_repo: None
  • hub_always_push: False
  • hub_revision: None
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • include_for_metrics: []
  • 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
  • include_tokens_per_second: False
  • include_num_input_tokens_seen: no
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • liger_kernel_config: None
  • eval_use_gather_object: False
  • average_tokens_across_devices: True
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Click to expand
Epoch Step Training Loss
0.0077 10 0.0347
0.0154 20 0.0056
0.0231 30 0.0127
0.0308 40 0.0101
0.0386 50 0.056
0.0463 60 0.003
0.0540 70 0.0061
0.0617 80 0.0134
0.0694 90 0.0114
0.0771 100 0.0013
0.0848 110 0.0107
0.0925 120 0.02
0.1002 130 0.002
0.1079 140 0.0016
0.1157 150 0.1214
0.1234 160 0.0062
0.1311 170 0.0322
0.1388 180 0.0354
0.1465 190 0.0267
0.1542 200 0.0176
0.1619 210 0.0139
0.1696 220 0.0469
0.1773 230 0.0268
0.1850 240 0.0361
0.1928 250 0.0369
0.2005 260 0.0902
0.2082 270 0.1318
0.2159 280 0.0116
0.2236 290 0.0204
0.2313 300 0.0166
0.2390 310 0.147
0.2467 320 0.0124
0.2544 330 0.0251
0.2621 340 0.0138
0.2699 350 0.043
0.2776 360 0.0814
0.2853 370 0.0181
0.2930 380 0.0328
0.3007 390 0.0273
0.3084 400 0.1388
0.3161 410 0.031
0.3238 420 0.0443
0.3315 430 0.0219
0.3392 440 0.0065
0.3470 450 0.0201
0.3547 460 0.043
0.3624 470 0.0411
0.3701 480 0.1481
0.3778 490 0.0352
0.3855 500 0.0208
0.3932 510 0.0159
0.4009 520 0.0161
0.4086 530 0.007
0.4163 540 0.0227
0.4241 550 0.0221
0.4318 560 0.0166
0.4395 570 0.007
0.4472 580 0.0291
0.4549 590 0.0152
0.4626 600 0.0158
0.4703 610 0.0344
0.4780 620 0.0184
0.4857 630 0.0126
0.4934 640 0.0091
0.5012 650 0.0154
0.5089 660 0.0155
0.5166 670 0.0096
0.5243 680 0.017
0.5320 690 0.0108
0.5397 700 0.0119
0.5474 710 0.007
0.5551 720 0.0273
0.5628 730 0.0232
0.5705 740 0.0186
0.5783 750 0.0246
0.5860 760 0.0118
0.5937 770 0.0035
0.6014 780 0.0133
0.6091 790 0.026
0.6168 800 0.0038
0.6245 810 0.044
0.6322 820 0.0076
0.6399 830 0.0334
0.6476 840 0.0173
0.6554 850 0.0111
0.6631 860 0.0385
0.6708 870 0.0082
0.6785 880 0.0114
0.6862 890 0.0071
0.6939 900 0.0414
0.7016 910 0.0038
0.7093 920 0.0065
0.7170 930 0.0049
0.7247 940 0.1457
0.7325 950 0.0117
0.7402 960 0.0146
0.7479 970 0.0162
0.7556 980 0.0132
0.7633 990 0.0035
0.7710 1000 0.0103
0.7787 1010 0.0409
0.7864 1020 0.0157
0.7941 1030 0.1586
0.8019 1040 0.0205
0.8096 1050 0.0915
0.8173 1060 0.015
0.8250 1070 0.0103
0.8327 1080 0.0016
0.8404 1090 0.0198
0.8481 1100 0.0393
0.8558 1110 0.0241
0.8635 1120 0.0043
0.8712 1130 0.0114
0.8790 1140 0.0215
0.8867 1150 0.0174
0.8944 1160 0.0286
0.9021 1170 0.006
0.9098 1180 0.0155
0.9175 1190 0.0292
0.9252 1200 0.0117
0.9329 1210 0.0153
0.9406 1220 0.0135
0.9483 1230 0.0203
0.9561 1240 0.0091
0.9638 1250 0.0282
0.9715 1260 0.0142
0.9792 1270 0.0983
0.9869 1280 0.0126
0.9946 1290 0.0159

Framework Versions

  • Python: 3.10.12
  • Sentence Transformers: 5.2.0
  • Transformers: 4.57.3
  • PyTorch: 2.9.1+cu128
  • Accelerate: 1.12.0
  • Datasets: 4.4.2
  • Tokenizers: 0.22.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",
}

CachedMultipleNegativesRankingLoss

@misc{gao2021scaling,
    title={Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup},
    author={Luyu Gao and Yunyi Zhang and Jiawei Han and Jamie Callan},
    year={2021},
    eprint={2101.06983},
    archivePrefix={arXiv},
    primaryClass={cs.LG}
}
Downloads last month
57
Safetensors
Model size
0.3B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for varin/embeddinggemma-thai-law

Unable to build the model tree, the base model loops to the model itself. Learn more.

Papers for varin/embeddinggemma-thai-law