Matryoshka Representation Learning
Paper • 2205.13147 • Published • 30
How to use bnkc123/obscura-v1 with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("bnkc123/obscura-v1")
sentences = [
"What does Safeco define as 'permanently attached living quarters' for a motor home?",
"south dakota * rv program rules back to table of contents safeco insurance company of america 7 program rules this section details the types of vehicles permitted in the rv program and the rules for writing these vehicles. rv includes motor homes, travel trailers, sport travel trailers (includes horse trailers with living/sleeping quarters), fifth wheel trailers, folding camping trailers, truck mounted campers, and utility and horse trailers. rvs insured with safeco are intended for personal/ recreational use for up to 250 days per year. business and commercial activities are not permitted. motor homes we consider \"motor homes\" to be self-propelled mobile homes (including pickups or vans with permanently attached living quarters and used for recreational purposes) and provide temporary living quarters. \"permanently attached living quarters\" means: cooking, refrigerator, bathroom with plumbing, self contained heating and/or cooling, 110-125 electric supply and drinkable water supply. motor homes are not eligible for, and do not make other vehicles eligible for, account discount, distant student discount or good student discount. motor homes that carry liability coverage are not eligible for, but do extend, the multi-car discount to a private passenger auto. damage to your covered vehicle comprehensive and collision coverages are rated on the basis of actual cash value/current market value. travel trailers and camping trailers we consider \"trailers\" to be non-motorized vehicles that are intended to be towed and used for recreational purposes and are equipped with a living quarters, with the exception of horse and utility trailers. only physical damage coverage (comprehensive, collision or both) is available for trailers.",
"south dakota * rv rv types back to table of contents safeco insurance company of america 6 rv types permitted rv types the recreational vehicle types shown below are a general representation of the vehicles written in safeco's rv program. in addition to the vehicles shown below, utility trailers and horse trailers are also permitted in the rv program. see the program rules for vehicle type requirements. . class a - motor home class b - motor home class c - motor home truck mounted camper conventional trailer sport travel trailer fifth-wheel trailer folding camping trailer source: recreational vehicle industry association (rvia), 01/06",
"the surcharge will depend on the conviction or reason for filing. if a risk appears acceptable, submit on an unbound basis. include a copy of the official notice requesting a certificate. surcharges will be calculated by the home office. application of surcharge risks for whom we agree to issue a filing of financial responsibility will be surcharged under this rule as well as under the ddp, if applicable. the erie must certify that the driver is covered under every circumstance. there are some nonowned situations excluded by personal auto policy language. in these cases, the exclusions must be removed by endorsement and proper premiums applied. apply surcharges as shown below to the auto principally driven by the person for whom this filing is issued. in the case of named non- owner coverage, apply the surcharge to the premium obtained from rule 21, named non- owner coverage, in these rules pages. surcharge table apply only during the period of time that the certificate is required. certified risk surcharge table conviction surcharge driving while under the influence of drugs or alcohol. 50% failing to stop and report when involved in an accident. 50% assault or a felony involving a motor vehicle. 50% speeding that resulted in bi, pd or csl. 25% reckless driving that resulted in bi, pd or csl. 25% all other cases requiring financial responsibility filings. 5% private passenger auto va rules erie insurance exchange erie insurance company 5 effective 12/1/19"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from BAAI/bge-large-en-v1.5. It maps sentences & paragraphs to a 1024-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': 512, 'do_lower_case': True}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': True, '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': False, '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("bnkc123/obscura-v1")
# Run inference
sentences = [
'Which additional coverage table shows a $1,000 limit for identity theft on a standard policy but $10,000 for Platinum and GrandProtect?',
"farmers lloyd's insurance company of texas texas residential property manual updated: may, 2020 page 3 section i - additional coverages additional coverages ho-2 homeowners, homeowners, market value, mobile homeowners, renters, condominium and landlord's rental platinum and grandprotect products (includes homeowners, renters and condominium) loss of use additional living expense or fair rental value and loss of rental income increased limits available prohibited use refer to rule 2 yes up to 14 days refer to rule 2 yes for platinum up to 45 days debris removal 10% 10% reasonable repairs yes yes fire department charges $750 $1000 emergency removal of property 30 days 30 days emergency living expense $500 $500 refrigerated contents $1000 $1500 identity theft and credit protection (cov. 9) increased limits available $1000 yes $10,000 no data and records $1500 for personal none for business $2500 lock replacement yes yes reward coverage $5000 $5000 trees, shrubs and plants (coverage 12) increased limits available $500 per item/ 5% aggregate yes $500 per item/ 5% aggregate yes loss assessment (coverage 6) increased limits available $1000 yes $10,000 yes land $10,000 $10,000 volcanic action yes yes collapse yes yes inflation protection yes yes landlord's furnishings $2500 $2500 fungus and mold remediation $5000 $5000 backup of sewer, drain and sump pump (coverage 13) optional $10,000 increased limits available newly acquired watercraft n/a with grandprotect identity fraud n/a with grandprotect ordinance or law (coverage 15) optional grandprotect - blank property limit platinum - 50% of cov.",
"a increased limits available section ii - additional coverages additional coverages ho-2 homeowners, homeowners, market value, mobile homeowners, renters, condominium and landlord's rental platinum and grandprotect products (includes homeowners, renters and condominium) damage of property of others $500 $1500 claim expenses yes, including $200 for lost wages yes, including $250 for lost wages first aid expenses yes yes borrowed or rented watercraft n/a with grandprotect personal injury (coverage 25) optional included",
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
dim_1024InformationRetrievalEvaluator with these parameters:{
"truncate_dim": 1024
}
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.1471 |
| cosine_accuracy@3 | 0.3333 |
| cosine_accuracy@5 | 0.4118 |
| cosine_accuracy@10 | 0.5294 |
| cosine_precision@1 | 0.1471 |
| cosine_precision@3 | 0.1111 |
| cosine_precision@5 | 0.0824 |
| cosine_precision@10 | 0.0529 |
| cosine_recall@1 | 0.1471 |
| cosine_recall@3 | 0.3333 |
| cosine_recall@5 | 0.4118 |
| cosine_recall@10 | 0.5294 |
| cosine_ndcg@10 | 0.3255 |
| cosine_mrr@10 | 0.262 |
| cosine_map@100 | 0.2699 |
dim_512InformationRetrievalEvaluator with these parameters:{
"truncate_dim": 512
}
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.1471 |
| cosine_accuracy@3 | 0.3039 |
| cosine_accuracy@5 | 0.4118 |
| cosine_accuracy@10 | 0.5098 |
| cosine_precision@1 | 0.1471 |
| cosine_precision@3 | 0.1013 |
| cosine_precision@5 | 0.0824 |
| cosine_precision@10 | 0.051 |
| cosine_recall@1 | 0.1471 |
| cosine_recall@3 | 0.3039 |
| cosine_recall@5 | 0.4118 |
| cosine_recall@10 | 0.5098 |
| cosine_ndcg@10 | 0.3131 |
| cosine_mrr@10 | 0.2519 |
| cosine_map@100 | 0.2607 |
dim_256InformationRetrievalEvaluator with these parameters:{
"truncate_dim": 256
}
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.1275 |
| cosine_accuracy@3 | 0.3235 |
| cosine_accuracy@5 | 0.4118 |
| cosine_accuracy@10 | 0.4902 |
| cosine_precision@1 | 0.1275 |
| cosine_precision@3 | 0.1078 |
| cosine_precision@5 | 0.0824 |
| cosine_precision@10 | 0.049 |
| cosine_recall@1 | 0.1275 |
| cosine_recall@3 | 0.3235 |
| cosine_recall@5 | 0.4118 |
| cosine_recall@10 | 0.4902 |
| cosine_ndcg@10 | 0.3021 |
| cosine_mrr@10 | 0.2428 |
| cosine_map@100 | 0.2522 |
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
For a wood shake or shingle roof in good condition, what is the maximum age allowed for Replacement Cost coverage on a DP-3 policy? |
roofing systems in fair condition do not qualify for replacement cost coverage. roofing systems in poor condition will have coverage for the roofing system limited to fire and lightning only regardless of age. roofing system age / condition of the roof system excellent condition good condition asphalt / composition 1-22 1-15 slate 1-35 1-28 metal 1-56 1-34 flat/built-up/roll n/a n/a tile 1-35 1-28 wood shake / shingle 1-13 1-8 |
aegis california secondary residence insurance program 29 dp-man-ca (ed. 8) 16. roofs a. roof age the signed application will specifically disclose the age of the roof. the age of the roof is determined by subtracting the year the roof was installed from the year that the policy takes effect. the roof age will be updated manually at each policy renewal. if the roof age is updated or changed due to roof replacement, a copy of evidence (e.g. - copy of roof manufacturer's warranty indicating replacement date, copy of roof age disclosure statement from real estate transaction, receipt from roofing contractor) showing the date the roof was replaced must be submitted to the company. b. roof system type acceptable roof systems are as follows: 1. asphalt / composition - includes: (a) asphalt - shingle (fiberglass) (b) asphalt - shingle (architectural) (c) asphalt - shingle (architectural - hq) (d) composite - impact resistance shingle (e) composite - shake (f) composite - tile 2. slate - inclu... |
Which coverage form is used to insure the personal property of a tenant occupying a single-family dwelling or 1–4 family dwelling? |
american commerce insurance company ohio property program rules manual american commerce insurance company page 3 of 39 (04/20) form types ho3: special form- provides "open perils" coverage on the dwelling and other structures and "named perils" coverage on personal property. this policy may be written on an owner- occupied single-family, duplex, triplex, and fourplex dwelling used exclusively for private residential purposes with no more than 1 family per unit. at least one unit of the multi-family dwelling must be occupied by the insured. ho4: contents broad form - provides "named perils" coverage on the personal property of a tenant(s) occupying an apartment, townhouse, condominium, single-family dwelling or one unit in a 1-4 family dwelling used exclusively for private residential purposes with no more than 2 roomers or boarders. ho6: unit owners form - provides "named perils" coverage on building property and personal property for an insured who resides in an owner-occupied single... |
american commerce insurance company ohio property program rules manual american commerce insurance company page 4 of 39 (04/20) package policy requirements the following minimum limits apply to each form type. minimum package policy requirements ho3 ho4 ho6 cva base coverage -100% replacement cost n/a 10% of cvc cvb 10% of cva n/a n/a cvc 70% of cva base coverage base coverage cvd 20% of cva 40% of cvc 40% of cvc cvl $100,000 $100,000 $100,000 cvm $1,000 $1,000 $1,000 |
How does the manual define a seasonal dwelling? |
safeport insurance company homeowners program manual - south carolina (2020) general rules includes copyrighted material of insurance services office, inc. with its permission page 9 of 36 f. permitted business occupancies certain business occupancies are permitted, pro- vided: 1. the premises is occupied principally for private residential purposes, and 2. there is no other business occupancy on the premises. when the business is conducted on the residence premises, refer to rules 509. and 510. for section i coverage and rules 607. and 608. for section ii cov- erage. when it is conducted from an other resi- dence, only section ii coverage is available. refer to rules 607. and 608. g. farm property a homeowners policy shall not be issued to cover any property to which farm forms or rates apply under the rules of the company, except as noted in following paragraphs 1. and 2.: 1. section i - property - livestock collision coverage may be provided for loss due to colli- sion which results... |
safeport insurance company homeowners program manual - south carolina (2020) general rules includes copyrighted material of insurance services office, inc. with its permission page 10 of 36 3. fire resistive exterior walls and floors and roof constructed of masonry or other fire resistive materials. e. mixed (masonry/frame) a combination of both fr ame and masonry construc- tion shall be classed as frame when the exterior walls of frame construction (including gables) exceed 33 1/3% of the total exterior wall area; otherwise class as masonry. rule 108. seasonal dwelling definition a seasonal dwelling is a dwelling with continuous un-oc- cupancy of three or more consecutive months during any one-year period. rule 109. single and separate buildings definition a. single building all buildings or sections of buildings which are acces- sible through unprotected openings shall be consid- ered as a single building. b. separate building 1. buildings which are separated by space shall be consid... |
MatryoshkaLoss with these parameters:{
"loss": "TripletLoss",
"matryoshka_dims": [
1024,
512,
256
],
"matryoshka_weights": [
1,
1,
1
],
"n_dims_per_step": -1
}
eval_strategy: epochper_device_train_batch_size: 6per_device_eval_batch_size: 16gradient_accumulation_steps: 16num_train_epochs: 8lr_scheduler_type: cosinewarmup_ratio: 0.1bf16: Truetf32: Trueload_best_model_at_end: Trueoptim: adamw_torch_fusedpush_to_hub: Truehub_model_id: bnkc123/obscura-v1batch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: epochprediction_loss_only: Trueper_device_train_batch_size: 6per_device_eval_batch_size: 16per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 16eval_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: 8max_steps: -1lr_scheduler_type: cosinelr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_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: Truefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Truelocal_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: Trueignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}tp_size: 0fsdp_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}deepspeed: 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: Trueresume_from_checkpoint: Nonehub_model_id: bnkc123/obscura-v1hub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsegradient_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: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | dim_1024_cosine_ndcg@10 | dim_512_cosine_ndcg@10 | dim_256_cosine_ndcg@10 |
|---|---|---|---|---|---|
| 1.0 | 10 | 24.8465 | 0.5265 | 0.5079 | 0.5108 |
| 2.0 | 20 | 16.454 | 0.4701 | 0.4565 | 0.4235 |
| 3.0 | 30 | 9.4107 | 0.3821 | 0.3536 | 0.3599 |
| 4.0 | 40 | 4.786 | 0.3482 | 0.3464 | 0.3413 |
| 5.0 | 50 | 2.675 | 0.3266 | 0.3142 | 0.3150 |
| 6.0 | 60 | 1.542 | 0.3303 | 0.3161 | 0.3052 |
| 7.0 | 70 | 1.1167 | 0.3257 | 0.3131 | 0.3009 |
| 7.2105 | 72 | - | 0.3255 | 0.3131 | 0.3021 |
@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",
}
@misc{kusupati2024matryoshka,
title={Matryoshka Representation Learning},
author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
year={2024},
eprint={2205.13147},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
@misc{hermans2017defense,
title={In Defense of the Triplet Loss for Person Re-Identification},
author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
year={2017},
eprint={1703.07737},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
Base model
BAAI/bge-large-en-v1.5