TSDAE: Using Transformer-based Sequential Denoising Auto-Encoder for Unsupervised Sentence Embedding Learning
Paper • 2104.06979 • Published
How to use Komalverma/custom-bge-baai-base-cfr-cms with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Komalverma/custom-bge-baai-base-cfr-cms")
sentences = [
"the suppliers for shall use KK modifier. All suppliers, suppliers, shall submit claims competitive bid items using the aforementioned bidding The and KK are in Round of competitive bidding program and modifiers are for future program",
"<> To review and identify the policies and procedures that caused an HHA to furnish substandard care. <> To determine whether the HHA is in compliance with one or more or all additional conditions of participation not examined during the standard survey. An extended survey must be conducted not later than 14 calendar days after completion of a standard survey which found that a HHA was out of compliance with a condition of participation.",
"<> The individual plan of care under § 441.155 must be developed by an interdisciplinary team of physicians and other personnel who are employed by, or provide services to patients in, the facility. <> Based on education and experience, preferably including competence in child psychiatry, the team must be capable of— <> Assessing the beneficiary's immediate and long-range therapeutic needs, developmental priorities, and personal strengths and liabilities; <> A clinical psychologist who has a doctoral degree and a physician licensed to practice medicine or osteopathy; or",
"the KG modifier, whereas contract suppliers for the complex rehabilitative power wheelchair product category shall use the KK modifier. All suppliers, including grandfathered suppliers, shall submit claims for competitive bid items using the aforementioned competitive bidding modifiers. The KG and KK modifiers are used in Round I of the competitive bidding program and the KU and KW modifiers are reserved for future program use."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from BAAI/bge-base-en-v1.5. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for retrieval.
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
(1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True})
)
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("sentence_transformers_model_id")
# Run inference
sentences = [
'<> OTPs must provide counseling on preventing exposure to, and the transmission of, human immunodeficiency virus (HIV), viral hepatitis, and sexually transmitted infections (STIs) and either directly provide services and treatments or actively link to treatment each patient admitted or readmitted to treatment who has received positive test results for these conditions from initial and/or periodic medical examinations. <> OTPs must provide directly, or through referral to adequate and reasonably accessible community resources, vocational training, education, and employment services for patients who request such services or for whom these needs have been identified and mutually agreed-upon as beneficial by the patient and program staff.',
'<> OTPs must provide counseling on preventing exposure to, and the transmission of, human immunodeficiency virus (HIV), viral hepatitis, and sexually transmitted infections (STIs) and either directly provide services and treatments or actively link to treatment each patient admitted or readmitted to treatment who has received positive test results for these conditions from initial and/or periodic medical examinations. <> OTPs must provide directly, or through referral to adequate and reasonably accessible community resources, vocational training, education, and employment services for patients who request such services or for whom these needs have been identified and mutually agreed-upon as beneficial by the patient and program staff.',
'c. State Practice - The PECOS record should not be switched to "Approved" until the contractor receives the state\'s approval recommendation. However, if the contractor knows that the state in question generally does not review this type of transaction, the contractor need not send the transaction to the state and shall instead follow the instructions in section 10.6.1.2(B)',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 1.0000, 0.5026],
# [1.0000, 1.0000, 0.5026],
# [0.5026, 0.5026, 1.0000]])
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| modality | text | text |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
<> percent of the site the as determined under paragraph (c)(1) this section; and <> 50 percent the standard Federal prospective rate amount for discharge as determined § 412.523. (1) For section, the discharge payment is a ratio, expressed a percentage, of Medicare that the criteria exclusion site neutral payment rate as under paragraph (a)(2) of to total Medicare discharges under subpart during cost |
<> 50 percent of the site neutral payment rate amount for the discharge as determined under paragraph (c)(1) of this section; and <> 50 percent of the standard Federal prospective payment rate amount for the discharge as determined under § 412.523. (1) For purposes of this section, the discharge payment percentage is a ratio, expressed as a percentage, of Medicare discharges that meet the criteria for exclusion from the site neutral payment rate as described under paragraph (a)(2) of this section to total Medicare discharges paid under this subpart during the cost reporting period. |
Respirators shall equipped a durable bearing markings which applicant's name, the commercial designation of the and all appropriate approval |
Respirators shall be equipped with a substantial, durable container bearing markings which show the applicant's name, the type and commercial designation of the respirator it contains and all appropriate approval labels. |
This chapter specifies and procedures to MACs, Recovery Auditors, and the SMRC. The shall instructions to identify verify potential errors to produce the greatest to Medicare Contractors should use analytical methodologies to evaluate potential errors and take administrative unless determined is a priority to the They should archive the error |
This chapter specifies resources and procedures to the MACs, UPICs, Recovery Auditors, and the SMRC. The contractors shall use these instructions to identify and verify potential errors to produce the greatest protection to the Medicare program. Contractors should objectively use analytical methodologies to evaluate potential errors and not take administrative action unless they have verified the error and determined that the error is a high enough priority to justify the action. They should also archive the error including |
DenoisingAutoEncoderLoss with these parameters:{
"decoder_name_or_path": "BAAI/bge-base-en-v1.5",
"need_retokenization": false
}
per_device_train_batch_size: 16per_device_eval_batch_size: 16num_train_epochs: 8multi_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 16per_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: 1num_train_epochs: 8max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.0warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_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: Falsefp16: 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_torch_fusedoptim_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: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.1700 | 500 | 7.5851 |
| 0.3400 | 1000 | 6.3479 |
| 0.5100 | 1500 | 5.5558 |
| 0.6800 | 2000 | 4.7201 |
| 0.8501 | 2500 | 4.28 |
| 1.0201 | 3000 | 3.9788 |
| 1.1901 | 3500 | 3.728 |
| 1.3601 | 4000 | 3.568 |
| 1.5301 | 4500 | 3.4469 |
| 1.7001 | 5000 | 3.3317 |
| 1.8701 | 5500 | 3.2348 |
| 2.0401 | 6000 | 3.1438 |
| 2.2101 | 6500 | 3.0118 |
| 2.3801 | 7000 | 2.9728 |
| 2.5502 | 7500 | 2.9188 |
| 2.7202 | 8000 | 2.8691 |
| 2.8902 | 8500 | 2.8345 |
| 3.0602 | 9000 | 2.7537 |
| 3.2302 | 9500 | 2.6734 |
| 3.4002 | 10000 | 2.6435 |
| 3.5702 | 10500 | 2.6327 |
| 3.7402 | 11000 | 2.5934 |
| 3.9102 | 11500 | 2.5739 |
| 4.0802 | 12000 | 2.5119 |
| 4.2503 | 12500 | 2.4507 |
| 4.4203 | 13000 | 2.4414 |
| 4.5903 | 13500 | 2.4174 |
| 4.7603 | 14000 | 2.419 |
| 4.9303 | 14500 | 2.3955 |
| 5.1003 | 15000 | 2.3289 |
| 5.2703 | 15500 | 2.2981 |
| 5.4403 | 16000 | 2.2936 |
| 5.6103 | 16500 | 2.2902 |
| 5.7803 | 17000 | 2.2897 |
| 5.9504 | 17500 | 2.2659 |
| 6.1204 | 18000 | 2.2225 |
| 6.2904 | 18500 | 2.2028 |
| 6.4604 | 19000 | 2.1958 |
| 6.6304 | 19500 | 2.205 |
| 6.8004 | 20000 | 2.2054 |
| 6.9704 | 20500 | 2.2045 |
| 7.1404 | 21000 | 2.177 |
| 7.3104 | 21500 | 2.1662 |
| 7.4804 | 22000 | 2.1731 |
| 7.6505 | 22500 | 2.1592 |
| 7.8205 | 23000 | 2.1557 |
| 7.9905 | 23500 | 2.1608 |
@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",
}
@inproceedings{wang-2021-TSDAE,
title = "TSDAE: Using Transformer-based Sequential Denoising Auto-Encoderfor Unsupervised Sentence Embedding Learning",
author = "Wang, Kexin and Reimers, Nils and Gurevych, Iryna",
booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2021",
month = nov,
year = "2021",
address = "Punta Cana, Dominican Republic",
publisher = "Association for Computational Linguistics",
pages = "671--688",
url = "https://arxiv.org/abs/2104.06979",
}
Base model
BAAI/bge-base-en-v1.5