SentenceTransformer based on Qwen/Qwen3-Embedding-4B

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.

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Base model: Qwen/Qwen3-Embedding-4B
  • Maximum Sequence Length: 40960 tokens
  • Output Dimensionality: 2560 dimensions
  • Similarity Function: Cosine Similarity

Model Sources

Full Model Architecture

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()
)

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("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]])

Evaluation

Metrics

Semantic Similarity

Metric Value
pearson_cosine 0.6708
spearman_cosine 0.6666

Training Details

Training Dataset

Unnamed Dataset

  • Size: 16,676 training samples
  • Columns: anchor and positive
  • Approximate statistics based on the first 1000 samples:
    anchor positive
    type string string
    details
    • min: 56 tokens
    • mean: 84.52 tokens
    • max: 140 tokens
    • min: 54 tokens
    • mean: 87.07 tokens
    • max: 140 tokens
  • Samples:
    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.
  • Loss: MultipleNegativesSymmetricRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim",
        "gather_across_devices": false
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • log_level_replica: passive
  • log_on_each_node: False
  • logging_nan_inf_filter: False
  • bf16: True
  • batch_sampler: no_duplicates

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: no
  • prediction_loss_only: True
  • per_device_train_batch_size: 8
  • 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: 5e-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.0
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.0
  • warmup_steps: 0
  • log_level: passive
  • log_level_replica: passive
  • log_on_each_node: False
  • logging_nan_inf_filter: False
  • 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: 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
  • 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: 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: False
  • 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: False
  • prompts: None
  • batch_sampler: no_duplicates
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Click to expand
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

Framework Versions

  • Python: 3.10.18
  • Sentence Transformers: 5.1.1
  • Transformers: 4.56.2
  • PyTorch: 2.7.1+cu128
  • Accelerate: 1.10.1
  • Datasets: 4.1.1
  • 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",
}
Downloads last month
32
Safetensors
Model size
4B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for chantomkit/qwen3-4B-risk-mnr-law

Finetuned
(43)
this model

Paper for chantomkit/qwen3-4B-risk-mnr-law

Evaluation results