deter3's picture
Add new SparseEncoder model
d597c98 verified
|
Raw History Blame Contribute Delete
21.8 kB
metadata
language:
  - en
license: apache-2.0
tags:
  - sentence-transformers
  - sparse-encoder
  - sparse
  - splade
  - generated_from_trainer
  - dataset_size:811257
  - loss:SpladeLoss
  - loss:SparseMultipleNegativesRankingLoss
  - loss:FlopsLoss
base_model: distilbert/distilbert-base-uncased
widget:
  - text: >-
      Turning now to FIG.1 an exemplary firewall sealing assembly 100 is shown
      mounted between a firewall 102 and a duct 104.The firewall sealing
      assembly 100 allows the duct 104 to extend through an opening 106 in the
      firewall 102 while minimizing fluid flow communication between a first
      section 108 on one side of the firewall 102 and a second section 110 on
      another side of the firewall 102.It will be appreciated that the duct 104
      may alternatively be any one of numerous other components that may need to
      extend through the firewall opening 106 such as for example piping wires
      structural tubing and any other penetrating member.
  - text: >-
      The inverter 22 comprises switching elements 61u 61v 61w 62u 62v 62w which
      comprise MOSFETs IGBTs or the like respectively energizable by the ECU 40
      and diodes 53u 53v 53w 54u 54v 54w reverseconnected across the switching
      elements 61u 61v 61w 62u 62v 62w respectively.
  - text: >-
      In this example a configuration general solution using an arbitrary number
      N of antennas is considered.
  - text: >-
      Each of the contact metal strips 7 includes an attachment fixture 7A
      mounted at a strip mounting base 10 a horizontal portion 7B horizontally
      extended from a bottom portion of the attachment fixture 7A a bending
      portion 7C elongated obliquely upward from a leading end of the horizontal
      portion 7B and a contact portion 7D provided at a leading end of the
      bending portion 7C so as to contact with the terminal pin 6.The overall
      shape of the contact metal strips 7 is roughly a V shape as can be seen
      from Fig.3.
  - text: >-
      A client browser application for a user terminal the browser being capable
      of recognising top level domain name parts of a network resource
      identifier said browser being arranged to handle a network resource
      identifier in which a predetermined top level domain name part is
      recognised differently from a network resource identifier in which the top
      level domain name part is not recognised.
pipeline_tag: feature-extraction
library_name: sentence-transformers

SPLADE model for patent matching

This is a SPLADE Sparse Encoder model finetuned from distilbert/distilbert-base-uncased on the json dataset using the sentence-transformers library. It maps sentences & paragraphs to a 30522-dimensional sparse vector space and can be used for semantic search and sparse retrieval.

Model Details

Model Description

  • Model Type: SPLADE Sparse Encoder
  • Base model: distilbert/distilbert-base-uncased
  • Maximum Sequence Length: 256 tokens
  • Output Dimensionality: 30522 dimensions
  • Similarity Function: Dot Product
  • Training Dataset:
    • json
  • Language: en
  • License: apache-2.0

Model Sources

Full Model Architecture

SparseEncoder(
  (0): MLMTransformer({'max_seq_length': 256, 'do_lower_case': False, 'architecture': 'DistilBertForMaskedLM'})
  (1): SpladePooling({'pooling_strategy': 'max', 'activation_function': 'relu', 'word_embedding_dimension': 30522})
)

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 SparseEncoder

# Download from the 🤗 Hub
model = SparseEncoder("deter3/splade-distilbert-base-uncased-patentmatch-train-only")
# Run inference
queries = [
    "The mobile device as claimed in claim 11 or claim 12 further comprising a display for displaying a list of applicationspecific places that only contains the places that have been selected by a specific application.",
]
documents = [
    'A client browser application for a user terminal the browser being capable of recognising top level domain name parts of a network resource identifier said browser being arranged to handle a network resource identifier in which a predetermined top level domain name part is recognised differently from a network resource identifier in which the top level domain name part is not recognised.',
    'Other variations in the components of the lid 1200 are possible in other embodiments of the invention.',
    'The cylinder servo motor according to the second embodiment is identical in operation with that described in connection with the first embodiment.By means of imparting a position instruction to the servo motor the ball screw shaft 50 corresponding to the ball screw shaft 5 is actuated to a predetermined position.',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 30522] [3, 30522]

# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[12.4191,  5.6239,  1.1307]])

Training Details

Training Dataset

json

  • Dataset: json
  • Size: 811,257 training samples
  • Columns: query and positive_passage
  • Approximate statistics based on the first 1000 samples:
    query positive_passage
    type string string
    details
    • min: 14 tokens
    • mean: 72.25 tokens
    • max: 256 tokens
    • min: 4 tokens
    • mean: 111.83 tokens
    • max: 256 tokens
  • Samples:
    query positive_passage
    The method of claim 9 wherein the first area is located at an upper part of the screen and the second area is located at a lower part of the screen. At this point the user can touch on a third icon 734 corresponding to a third application to select the third application.
    The mobile terminal of claim 8 wherein the controller is further configured to receive information from the specific external device indicating that the allow device search feature is enabled in the specific external device via the wireless communication unit and to control the display unit to display information requesting a user research for the specific external device. Thereupon in this embodiment the communication device the information processing method thereof and the information processing program thereof constitute an address book DB in the data base part 18 and is constituted so that when receiving owner information from a communication terminal X namely a device of the other party by Bluetooth a Bluetooth device address ofthe communication terminal X obtained at the time of communication is recorded in the address book DB by using an owners name included in the owner information as a key.
    The container according to claim 1 characterized in that the angle formed by the first bar 1 and the second bar 2 in the gate closing position is an obtuse angle between 150 and 180 or an acute angle between 0 and 30. The second hydraulic actuator 25 is activated this actuator by means of the mechanical actuator 22 rotates the levers 17 in such a way that the relative small tooth 18 moves up under the edge of ring 4.The hydraulic actuator 20 is activated in such a way that the piston 21 rests on the head of the pin 6 and at the same timemoves the body 16 upwards in such a way as to eliminate the clearance existing between the small teeth 18 and the edge of ring 4 a necessary clearance to place the small teeth 18 under the edge of the ring 4 in the phase of coupling.
  • Loss: SpladeLoss with these parameters:
    {
        "loss": "SparseMultipleNegativesRankingLoss(scale=1.0, similarity_fct='dot_score')",
        "document_regularizer_weight": 0.001,
        "query_regularizer_weight": 5e-05
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 24
  • gradient_accumulation_steps: 8
  • learning_rate: 2e-05
  • num_train_epochs: 2
  • warmup_ratio: 0.1
  • 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: 24
  • per_device_eval_batch_size: 8
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 8
  • 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: 2
  • 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
  • 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}
  • 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

Epoch Step Training Loss
0.0237 100 3921.6512
0.0473 200 10.5268
0.0710 300 1.9553
0.0947 400 1.6494
0.1183 500 1.5371
0.1420 600 1.4252
0.1657 700 1.3429
0.1893 800 1.2958
0.2130 900 1.2307
0.2367 1000 1.1905
0.2603 1100 1.1774
0.2840 1200 1.1387
0.3077 1300 1.0852
0.3313 1400 1.0718
0.3550 1500 1.0435
0.3787 1600 1.0166
0.4023 1700 1.0151
0.4260 1800 0.9792
0.4497 1900 0.9725
0.4733 2000 0.9492
0.4970 2100 0.9253
0.5207 2200 0.9178
0.5443 2300 0.9252
0.5680 2400 0.912
0.5917 2500 0.8796
0.6153 2600 0.8631
0.6390 2700 0.8575
0.6627 2800 0.8361
0.6863 2900 0.8407
0.7100 3000 0.8296
0.7337 3100 0.818
0.7573 3200 0.813
0.7810 3300 0.8073
0.8047 3400 0.7929
0.8283 3500 0.7927
0.8520 3600 0.7718
0.8757 3700 0.7823
0.8993 3800 0.7607
0.9230 3900 0.7547
0.9467 4000 0.7547
0.9703 4100 0.7286
0.9940 4200 0.7269
1.0175 4300 0.7186
1.0412 4400 0.6988
1.0648 4500 0.6888
1.0885 4600 0.6971
1.1122 4700 0.6833
1.1358 4800 0.6854
1.1595 4900 0.6771
1.1832 5000 0.6798
1.2068 5100 0.6596
1.2305 5200 0.6344
1.2542 5300 0.6529
1.2778 5400 0.6569
1.3015 5500 0.6414
1.3252 5600 0.6386
1.3488 5700 0.6324
1.3725 5800 0.6478
1.3962 5900 0.6372
1.4198 6000 0.6292
1.4435 6100 0.6272
1.4672 6200 0.623
1.4908 6300 0.6215
1.5145 6400 0.6307
1.5382 6500 0.6256
1.5618 6600 0.6179
1.5855 6700 0.6089
1.6092 6800 0.6111
1.6328 6900 0.6036
1.6565 7000 0.6169
1.6802 7100 0.6152
1.7038 7200 0.6055
1.7275 7300 0.5846
1.7512 7400 0.5955
1.7748 7500 0.6083
1.7985 7600 0.6015
1.8222 7700 0.5871
1.8458 7800 0.5821
1.8695 7900 0.5941
1.8932 8000 0.5859
1.9168 8100 0.5974
1.9405 8200 0.5917
1.9642 8300 0.5787
1.9878 8400 0.5902

Framework Versions

  • Python: 3.11.10
  • Sentence Transformers: 5.0.0
  • Transformers: 4.53.0
  • PyTorch: 2.4.1+cu124
  • Accelerate: 1.8.1
  • Datasets: 3.6.0
  • Tokenizers: 0.21.2

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",
}

SpladeLoss

@misc{formal2022distillationhardnegativesampling,
      title={From Distillation to Hard Negative Sampling: Making Sparse Neural IR Models More Effective},
      author={Thibault Formal and Carlos Lassance and Benjamin Piwowarski and Stéphane Clinchant},
      year={2022},
      eprint={2205.04733},
      archivePrefix={arXiv},
      primaryClass={cs.IR},
      url={https://arxiv.org/abs/2205.04733},
}

SparseMultipleNegativesRankingLoss

@misc{henderson2017efficient,
    title={Efficient Natural Language Response Suggestion for Smart Reply},
    author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
    year={2017},
    eprint={1705.00652},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}

FlopsLoss

@article{paria2020minimizing,
    title={Minimizing flops to learn efficient sparse representations},
    author={Paria, Biswajit and Yeh, Chih-Kuan and Yen, Ian EH and Xu, Ning and Ravikumar, Pradeep and P{'o}czos, Barnab{'a}s},
    journal={arXiv preprint arXiv:2004.05665},
    year={2020}
}