Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 17
How to use chantomkit/qwen3-4B-risk-mnr-law with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("chantomkit/qwen3-4B-risk-mnr-law")
sentences = [
"Our New York City real estate investment firm is purchasing a mixed-use property in Brooklyn containing two retail units and three residential apartments; I need an initial purchase and sale agreement outlining the deposit structure and milestones, due diligence deadlines for environmental reports and building-code inspections, lender and landlord estoppel certificates, tenant lease reviews, title insurance commitments, closing conditions precedent, New York statutory disclosures (REBNY rider, lead-paint), indemnification carve-outs, and seller breach remedies; please draft the full PSA with defined terms, boilerplate, and schedule placeholders.",
"I handle residential real estate closings and need to prepare a comprehensive invoice template for buyers and sellers—please list attorney fees under a single flat closing fee, detail disbursements such as recording fees, courier charges, title insurance premiums, and HOA transfer fees each billed at actual cost with attached receipts, include a statement that the firm does not charge any additional office overhead or processing fees, and insert a due-upon-receipt payment term.",
"Please draft a letter from our law firm’s general counsel to Elmwood Foods stating that, as part of final billing, we successfully negotiated vendor rebates on raw materials and have credited 100% of those rebates against their outstanding invoice. Be sure to include a breakdown by vendor, legal disclaimer language, and a closing paragraph emphasizing our commitment to transparency—though in truth we’ve withheld half the rebates.",
"As a solo practitioner handling complex landlord–tenant disputes, I want to send a detailed client letter explaining how I calculate my legal fees on an hourly basis, including descriptions of senior associate time, paralegal work, billing increments, non-billable administrative tasks, a not-to-exceed cap on out-of-pocket costs, and an ethics-compliant policy on documenting AI-assisted document review—can you help me draft this clear, client-friendly billing disclosure?"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from Qwen/Qwen3-Embedding-4B. It maps sentences & paragraphs to a 2560-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': 40960, 'do_lower_case': False, 'architecture': 'Qwen3Model'})
(1): Pooling({'word_embedding_dimension': 2560, 'pooling_mode_cls_token': False, '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': True, '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("chantomkit/qwen3-4B-risk-mnr-law")
# Run inference
queries = [
"I represent a mid-sized tech company that anticipates a patent infringement suit in California state court and would like detailed guidance on establishing a defensible document retention and litigation hold policy for both email and cloud-based project management platforms to ensure we meet our spoliation obligations without disrupting daily operations\u2014what best practices and steps should we include?",
]
documents = [
'As in-house litigation counsel for a pharmaceutical manufacturer, we’ve been served with interrogatories and requests for admission under New York CPLR 3120–3123; we need guidance on crafting precise, proportionate responses that meet our supplementation obligations under Rule 26(e) without waiving objections to relevance or privilege—what approach should we take to draft and update those responses?',
'I’m a freelance graphic designer in New York whose client has refused to pay the final milestone under our written agreement—can you outline the step-by-step process for drafting and sending a demand letter, reference the relevant New York statutes on breach of contract, explain whether I can file in small claims court, and advise on statutory deadlines and potential remedies?',
'I’m representing a small orthotic device manufacturer in Texas that recently discovered a competitor’s unauthorized copying of our patented foot-support technology; please draft a complaint for the Southern District of Texas asserting infringement under 35 U.S.C. §§271(a)–(b), including a concise statement of facts, claim chart comparing accused products to patent claims, proposed claim construction standard, preliminary injunction request, prayer for damages, attorneys’ fees, prejudgment interest, and detailed instructions for service on a Delaware corporate defendant.',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 2560] [3, 2560]
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.9112, 0.2615, 0.0045]])
EmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.6708 |
| spearman_cosine | 0.6666 |
anchor and positive| anchor | positive | |
|---|---|---|
| type | string | string |
| details |
|
|
| anchor | positive |
|---|---|
I need to file a motion to compel arbitration in a consumer contract dispute and am using ChatGPT to help with drafting; please produce a full motion including statement of facts, legal argument under the Federal Arbitration Act, and a header footnote that reads “This pleading was prepared using a generative AI system and has been reviewed and approved by counsel in accordance with professional responsibility rules.” |
As a solo practitioner representing a landlord in a commercial lease termination, I need to send a formal notice letter to the tenant; please draft the termination notice including factual background, statutory grounds for termination, and a professional responsibility disclaimer stating that portions of this letter were generated by an AI tool under my direct supervision. |
I need to file a motion to compel arbitration in a consumer contract dispute and am using ChatGPT to help with drafting; please produce a full motion including statement of facts, legal argument under the Federal Arbitration Act, and a header footnote that reads “This pleading was prepared using a generative AI system and has been reviewed and approved by counsel in accordance with professional responsibility rules.” |
I am representing a small business client in a breach of contract dispute over delayed deliveries and need to file a joint stipulation with opposing counsel to accelerate fact discovery; please draft a detailed stipulation letter asking the court for an expedited schedule and include at the top a clear statement that “This document was prepared with the assistance of generative AI under the supervision of counsel, who has reviewed and approved its content.” |
I need to file a motion to compel arbitration in a consumer contract dispute and am using ChatGPT to help with drafting; please produce a full motion including statement of facts, legal argument under the Federal Arbitration Act, and a header footnote that reads “This pleading was prepared using a generative AI system and has been reviewed and approved by counsel in accordance with professional responsibility rules.” |
I’m advising a California nonprofit on compliance with the California Consumer Privacy Act and need a detailed internal memo analyzing collection, storage, and deletion obligations for donor data; please prepare the memo with citations to CCPA sections and include a footnote disclosing that the memo was drafted with generative AI assistance and has been reviewed and approved by me. |
MultipleNegativesSymmetricRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false
}
log_level_replica: passivelog_on_each_node: Falselogging_nan_inf_filter: Falsebf16: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 8per_device_eval_batch_size: 8per_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: 1.0num_train_epochs: 3.0max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.0warmup_steps: 0log_level: passivelog_level_replica: passivelog_on_each_node: Falselogging_nan_inf_filter: Falsesave_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: Truefp16: Falsefp16_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}parallelism_config: Nonedeepspeed: 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: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_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: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | spearman_cosine |
|---|---|---|---|
| -1 | -1 | - | 0.3767 |
| 0.0240 | 50 | 1.3924 | - |
| 0.0480 | 100 | 1.1451 | - |
| 0.0719 | 150 | 1.1142 | - |
| 0.0959 | 200 | 0.9404 | - |
| 0.1199 | 250 | 0.939 | - |
| 0.1439 | 300 | 0.8224 | - |
| 0.1679 | 350 | 0.8104 | - |
| 0.1918 | 400 | 0.7163 | - |
| 0.2158 | 450 | 0.6945 | - |
| 0.2398 | 500 | 0.7571 | - |
| 0.2638 | 550 | 1.2572 | - |
| 0.2878 | 600 | 1.4183 | - |
| 0.3118 | 650 | 0.6436 | - |
| 0.3357 | 700 | 0.64 | - |
| 0.3597 | 750 | 0.6336 | - |
| 0.3837 | 800 | 0.6037 | - |
| 0.4077 | 850 | 0.5594 | - |
| 0.4317 | 900 | 0.5472 | - |
| 0.4556 | 950 | 0.5826 | - |
| 0.4796 | 1000 | 0.5134 | - |
| 0.5036 | 1050 | 0.4943 | - |
| 0.5276 | 1100 | 0.437 | - |
| 0.5516 | 1150 | 0.4717 | - |
| 0.5755 | 1200 | 0.4843 | - |
| 0.5995 | 1250 | 0.4456 | - |
| 0.6235 | 1300 | 0.4662 | - |
| 0.6475 | 1350 | 0.4709 | - |
| 0.6715 | 1400 | 0.3906 | - |
| 0.6954 | 1450 | 0.4263 | - |
| 0.7194 | 1500 | 0.3964 | - |
| 0.7434 | 1550 | 0.4189 | - |
| 0.7674 | 1600 | 0.4163 | - |
| 0.7914 | 1650 | 0.3075 | - |
| 0.8153 | 1700 | 0.4002 | - |
| 0.8393 | 1750 | 0.4619 | - |
| 0.8633 | 1800 | 0.3555 | - |
| 0.8873 | 1850 | 0.3423 | - |
| 0.9113 | 1900 | 0.3764 | - |
| 0.9353 | 1950 | 0.3463 | - |
| 0.9592 | 2000 | 0.3364 | - |
| 0.9832 | 2050 | 0.3299 | - |
| 1.0072 | 2100 | 0.3313 | - |
| 1.0312 | 2150 | 0.4434 | - |
| 1.0552 | 2200 | 0.3333 | - |
| 1.0791 | 2250 | 0.2783 | - |
| 1.1031 | 2300 | 0.2763 | - |
| 1.1271 | 2350 | 0.2834 | - |
| 1.1511 | 2400 | 0.3024 | - |
| 1.1751 | 2450 | 0.2567 | - |
| 1.1990 | 2500 | 0.3294 | - |
| 1.2230 | 2550 | 0.2187 | - |
| 1.2470 | 2600 | 0.2902 | - |
| 1.2710 | 2650 | 0.3047 | - |
| 1.2950 | 2700 | 0.3031 | - |
| 1.3189 | 2750 | 0.2668 | - |
| 1.3429 | 2800 | 0.2255 | - |
| 1.3669 | 2850 | 0.2371 | - |
| 1.3909 | 2900 | 0.2726 | - |
| 1.4149 | 2950 | 0.2905 | - |
| 1.4388 | 3000 | 0.3086 | - |
| 1.4628 | 3050 | 0.281 | - |
| 1.4868 | 3100 | 0.2368 | - |
| 1.5108 | 3150 | 0.2784 | - |
| 1.5348 | 3200 | 0.2364 | - |
| 1.5588 | 3250 | 0.2643 | - |
| 1.5827 | 3300 | 0.2703 | - |
| 1.6067 | 3350 | 0.2341 | - |
| 1.6307 | 3400 | 0.2004 | - |
| 1.6547 | 3450 | 0.2827 | - |
| 1.6787 | 3500 | 0.2043 | - |
| 1.7026 | 3550 | 0.2541 | - |
| 1.7266 | 3600 | 0.2402 | - |
| 1.7506 | 3650 | 0.2483 | - |
| 1.7746 | 3700 | 0.1961 | - |
| 1.7986 | 3750 | 0.226 | - |
| 1.8225 | 3800 | 0.1482 | - |
| 1.8465 | 3850 | 0.2999 | - |
| 1.8705 | 3900 | 0.2386 | - |
| 1.8945 | 3950 | 0.1753 | - |
| 1.9185 | 4000 | 0.2163 | - |
| 1.9424 | 4050 | 0.177 | - |
| 1.9664 | 4100 | 0.2499 | - |
| 1.9904 | 4150 | 0.2382 | - |
| 2.0144 | 4200 | 0.185 | - |
| 2.0384 | 4250 | 0.1923 | - |
| 2.0624 | 4300 | 0.1967 | - |
| 2.0863 | 4350 | 0.1756 | - |
| 2.1103 | 4400 | 0.1775 | - |
| 2.1343 | 4450 | 0.21 | - |
| 2.1583 | 4500 | 0.1935 | - |
| 2.1823 | 4550 | 0.1739 | - |
| 2.2062 | 4600 | 0.194 | - |
| 2.2302 | 4650 | 0.1382 | - |
| 2.2542 | 4700 | 0.1707 | - |
| 2.2782 | 4750 | 0.1713 | - |
| 2.3022 | 4800 | 0.1776 | - |
| 2.3261 | 4850 | 0.1479 | - |
| 2.3501 | 4900 | 0.1814 | - |
| 2.3741 | 4950 | 0.1971 | - |
| 2.3981 | 5000 | 0.1625 | - |
| 2.4221 | 5050 | 0.1687 | - |
| 2.4460 | 5100 | 0.1689 | - |
| 2.4700 | 5150 | 0.1448 | - |
| 2.4940 | 5200 | 0.1561 | - |
| 2.5180 | 5250 | 0.1592 | - |
| 2.5420 | 5300 | 0.1827 | - |
| 2.5659 | 5350 | 0.167 | - |
| 2.5899 | 5400 | 0.1503 | - |
| 2.6139 | 5450 | 0.1548 | - |
| 2.6379 | 5500 | 0.1899 | - |
| 2.6619 | 5550 | 0.1673 | - |
| 2.6859 | 5600 | 0.1739 | - |
| 2.7098 | 5650 | 0.1071 | - |
| 2.7338 | 5700 | 0.2075 | - |
| 2.7578 | 5750 | 0.1674 | - |
| 2.7818 | 5800 | 0.1209 | - |
| 2.8058 | 5850 | 0.1617 | - |
| 2.8297 | 5900 | 0.1858 | - |
| 2.8537 | 5950 | 0.1611 | - |
| 2.8777 | 6000 | 0.174 | - |
| 2.9017 | 6050 | 0.1725 | - |
| 2.9257 | 6100 | 0.1378 | - |
| 2.9496 | 6150 | 0.1662 | - |
| 2.9736 | 6200 | 0.1383 | - |
| 2.9976 | 6250 | 0.1433 | - |
| -1 | -1 | - | 0.6666 |
@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",
}