Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 18
How to use Bea-Taylor/objection_fine_tuned_4 with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Bea-Taylor/objection_fine_tuned_4")
sentences = [
"The alternative scheme by SNB addresses the noise and overheating issues by using passive design strategies, including Passivhaus principles for orientation and proposing alternative building typologies in its design; the inclusion of maisonettes along the railway as suggested in the SNB proposal means that there would be no habitable rooms facing the tracks.",
"This would constitute over development of the residential site with loss of privacy for neighbours, a strain on Victorian infrastructure, local facilities and more congestion for Gordon Road.",
"The local traffic is appalling as it is and this is just going to add to the ongoing misery of the local area with the crumbling roads.",
"In the consultation in June, shown here, they said the play area was going to be communal, but that is not mentioned in the planning application at all."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from sentence-transformers/all-MiniLM-L6-v2. It maps sentences & paragraphs to a 384-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': 256, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, '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("Bea-Taylor/objection_fine_tuned_4")
# Run inference
sentences = [
'It will also reduce/limit/block east facing views of Canary Wharf for Swedish Quays residents next door. In turn, this will have a knock on effect on the value of our property because views of Canary Wharf are sought after by potential buyers.',
'I support the planning application for the proposed development of the roof space. This project is a vital step toward easing the financial burden on residents and addressing ongoing concerns effectively. Additionally, it brings the added benefit of a positive environmental impact, contributing to a more sustainable and responsible community.',
'My health has really suffered over the last two years during which, I have had 3 heart attacks and have recently been diagnosed with anaemia and emphysema as well as having stents surgically placed in my arteries. I am on twelve tablets a day for my health and this whole subject is creating all my health conditions to worsen. All I can do is emphasise my objections and hope that Barnet Council decline building permission.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
sts-devEmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.9829 |
| spearman_cosine | 0.9159 |
text1, text2, and label| text1 | text2 | label | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| text1 | text2 | label |
|---|---|---|
Loss of Daylight and Sunlight |
Fifthly, the increased height of the building with an additional storey will further reduce the available sunlight hours in my first floor flat leading to increased heating costs as well as a reduction in my quality of life. As the sun barely gets above the level of the existing building in the winter months it is likely I will spend much of the winter with the rear of my flat continually in shadow. |
0.75 |
The existing carpark has a maximum of 16 car parking spaces for the 37 flats, used on a first come first served basis. |
As the other comments on this application state, the building works appear to be complete and the application does not appear to demonstrate the scale of the work or the reality of the build. |
0.0 |
Are you proposing to connect to the existing drainage system? |
The design of the types of buildings being proposed is out of character with the area. I object to the removal of the existing footbridge... this is unacceptable and will cut the area of Victoria Park off from Cromer road - a currently safe route which pedestrians and school children use to access without having to cross road and the promise of new access or pedestrian routes will mean walking public pavements around New Barnet via Station Road. I am not convinced by the developers that an alternative safer route will be provided as they will say anything to obtain planning. |
0.0 |
CosineSimilarityLoss with these parameters:{
"loss_fct": "torch.nn.modules.loss.MSELoss"
}
text1, text2, and label| text1 | text2 | label | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| text1 | text2 | label |
|---|---|---|
1. Significant noise and disruption for local residents of rainbow quay and surrounding developments - Including over looking Princes Court and blocking already limited light. |
I object to the developer changing the goal posts in order to achieve more profit as it is not the families who need social housing who will benefit or the young people trying to get on the property ladder and can't but the developer who profits from those who can "afford" to pay the "high prices" of Barnet accommodation. |
0.0 |
Congestion on Camlet way and beach hill , roads which already have traffic issues! |
TRAFFIC AND PARKING - Granville Road has limited off road parking and is a busy & important thoroughfare from Ballards Lane, to High Road North Finchley & Summers Lane, linking Finchley & Friern Barnet. The addition of two further flats without parking provision would increase the pressure for parking spaces. |
0.75 |
It will also obstruct light to my property and garden. |
- Health and safety: concern for disruption building works will cause, damage to local infrastructure, increased traffic |
0.0 |
CosineSimilarityLoss with these parameters:{
"loss_fct": "torch.nn.modules.loss.MSELoss"
}
eval_strategy: stepsper_device_train_batch_size: 16per_device_eval_batch_size: 16learning_rate: 2e-05num_train_epochs: 1warmup_ratio: 0.1fp16: Trueoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_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: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_steps: -1lr_scheduler_type: linearlr_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: Falsefp16: Truefp16_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}deepspeed: 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: 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: batch_samplermulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | Validation Loss | sts-dev_spearman_cosine |
|---|---|---|---|---|
| -1 | -1 | - | - | 0.3501 |
| 0.0089 | 100 | 0.1082 | 0.1113 | 0.3928 |
| 0.0178 | 200 | 0.1088 | 0.1000 | 0.4880 |
| 0.0267 | 300 | 0.0931 | 0.0857 | 0.5950 |
| 0.0356 | 400 | 0.0765 | 0.0749 | 0.6603 |
| 0.0444 | 500 | 0.0725 | 0.0685 | 0.6929 |
| 0.0533 | 600 | 0.066 | 0.0622 | 0.7216 |
| 0.0622 | 700 | 0.0568 | 0.0558 | 0.7506 |
| 0.0711 | 800 | 0.0525 | 0.0498 | 0.7749 |
| 0.08 | 900 | 0.048 | 0.0453 | 0.7926 |
| 0.0889 | 1000 | 0.0438 | 0.0412 | 0.8091 |
| 0.0978 | 1100 | 0.0447 | 0.0375 | 0.8239 |
| 0.1067 | 1200 | 0.0391 | 0.0336 | 0.8357 |
| 0.1156 | 1300 | 0.0359 | 0.0305 | 0.8486 |
| 0.1244 | 1400 | 0.0307 | 0.0272 | 0.8565 |
| 0.1333 | 1500 | 0.0289 | 0.0251 | 0.8621 |
| 0.1422 | 1600 | 0.0256 | 0.0233 | 0.8667 |
| 0.1511 | 1700 | 0.0285 | 0.0221 | 0.8702 |
| 0.16 | 1800 | 0.0229 | 0.0206 | 0.8743 |
| 0.1689 | 1900 | 0.0228 | 0.0193 | 0.8781 |
| 0.1778 | 2000 | 0.022 | 0.0182 | 0.8814 |
| 0.1867 | 2100 | 0.0197 | 0.0173 | 0.8827 |
| 0.1956 | 2200 | 0.0185 | 0.0167 | 0.8837 |
| 0.2044 | 2300 | 0.0202 | 0.0162 | 0.8850 |
| 0.2133 | 2400 | 0.0178 | 0.0151 | 0.8883 |
| 0.2222 | 2500 | 0.0174 | 0.0147 | 0.8896 |
| 0.2311 | 2600 | 0.0171 | 0.0146 | 0.8891 |
| 0.24 | 2700 | 0.0163 | 0.0136 | 0.8921 |
| 0.2489 | 2800 | 0.0147 | 0.0131 | 0.8934 |
| 0.2578 | 2900 | 0.0149 | 0.0129 | 0.8953 |
| 0.2667 | 3000 | 0.0152 | 0.0122 | 0.8966 |
| 0.2756 | 3100 | 0.0138 | 0.0120 | 0.8969 |
| 0.2844 | 3200 | 0.0128 | 0.0114 | 0.8977 |
| 0.2933 | 3300 | 0.0128 | 0.0111 | 0.8991 |
| 0.3022 | 3400 | 0.0117 | 0.0106 | 0.9005 |
| 0.3111 | 3500 | 0.0126 | 0.0104 | 0.9009 |
| 0.32 | 3600 | 0.0118 | 0.0102 | 0.9020 |
| 0.3289 | 3700 | 0.0115 | 0.0100 | 0.9016 |
| 0.3378 | 3800 | 0.0115 | 0.0098 | 0.9019 |
| 0.3467 | 3900 | 0.0116 | 0.0092 | 0.9035 |
| 0.3556 | 4000 | 0.0113 | 0.0090 | 0.9042 |
| 0.3644 | 4100 | 0.0117 | 0.0090 | 0.9043 |
| 0.3733 | 4200 | 0.0097 | 0.0084 | 0.9054 |
| 0.3822 | 4300 | 0.0098 | 0.0087 | 0.9052 |
| 0.3911 | 4400 | 0.0098 | 0.0085 | 0.9054 |
| 0.4 | 4500 | 0.0097 | 0.0084 | 0.9056 |
| 0.4089 | 4600 | 0.0097 | 0.0082 | 0.9057 |
| 0.4178 | 4700 | 0.0102 | 0.0080 | 0.9066 |
| 0.4267 | 4800 | 0.0086 | 0.0079 | 0.9071 |
| 0.4356 | 4900 | 0.0085 | 0.0078 | 0.9070 |
| 0.4444 | 5000 | 0.009 | 0.0076 | 0.9080 |
| 0.4533 | 5100 | 0.0091 | 0.0073 | 0.9085 |
| 0.4622 | 5200 | 0.0084 | 0.0073 | 0.9085 |
| 0.4711 | 5300 | 0.0082 | 0.0071 | 0.9089 |
| 0.48 | 5400 | 0.0073 | 0.0070 | 0.9089 |
| 0.4889 | 5500 | 0.0096 | 0.0069 | 0.9098 |
| 0.4978 | 5600 | 0.007 | 0.0068 | 0.9097 |
| 0.5067 | 5700 | 0.0078 | 0.0070 | 0.9096 |
| 0.5156 | 5800 | 0.0079 | 0.0067 | 0.9102 |
| 0.5244 | 5900 | 0.0097 | 0.0067 | 0.9107 |
| 0.5333 | 6000 | 0.0077 | 0.0065 | 0.9110 |
| 0.5422 | 6100 | 0.0084 | 0.0065 | 0.9112 |
| 0.5511 | 6200 | 0.007 | 0.0063 | 0.9113 |
| 0.56 | 6300 | 0.0073 | 0.0062 | 0.9117 |
| 0.5689 | 6400 | 0.0078 | 0.0066 | 0.9107 |
| 0.5778 | 6500 | 0.0082 | 0.0062 | 0.9116 |
| 0.5867 | 6600 | 0.0066 | 0.0061 | 0.9119 |
| 0.5956 | 6700 | 0.0076 | 0.0060 | 0.9122 |
| 0.6044 | 6800 | 0.0076 | 0.0060 | 0.9120 |
| 0.6133 | 6900 | 0.0075 | 0.0059 | 0.9123 |
| 0.6222 | 7000 | 0.0071 | 0.0059 | 0.9126 |
| 0.6311 | 7100 | 0.0076 | 0.0057 | 0.9130 |
| 0.64 | 7200 | 0.0067 | 0.0056 | 0.9131 |
| 0.6489 | 7300 | 0.0069 | 0.0057 | 0.9130 |
| 0.6578 | 7400 | 0.0068 | 0.0055 | 0.9134 |
| 0.6667 | 7500 | 0.0073 | 0.0054 | 0.9136 |
| 0.6756 | 7600 | 0.0063 | 0.0056 | 0.9131 |
| 0.6844 | 7700 | 0.0068 | 0.0054 | 0.9134 |
| 0.6933 | 7800 | 0.0057 | 0.0054 | 0.9135 |
| 0.7022 | 7900 | 0.0073 | 0.0053 | 0.9137 |
| 0.7111 | 8000 | 0.0063 | 0.0053 | 0.9139 |
| 0.72 | 8100 | 0.0061 | 0.0052 | 0.9139 |
| 0.7289 | 8200 | 0.0062 | 0.0052 | 0.9141 |
| 0.7378 | 8300 | 0.0065 | 0.0051 | 0.9143 |
| 0.7467 | 8400 | 0.0061 | 0.0052 | 0.9141 |
| 0.7556 | 8500 | 0.0064 | 0.0050 | 0.9146 |
| 0.7644 | 8600 | 0.0056 | 0.0050 | 0.9146 |
| 0.7733 | 8700 | 0.006 | 0.0050 | 0.9146 |
| 0.7822 | 8800 | 0.0066 | 0.0049 | 0.9147 |
| 0.7911 | 8900 | 0.005 | 0.0048 | 0.9150 |
| 0.8 | 9000 | 0.0056 | 0.0048 | 0.9149 |
| 0.8089 | 9100 | 0.0061 | 0.0048 | 0.9149 |
| 0.8178 | 9200 | 0.0057 | 0.0047 | 0.9149 |
| 0.8267 | 9300 | 0.0075 | 0.0048 | 0.9150 |
| 0.8356 | 9400 | 0.0057 | 0.0047 | 0.9152 |
| 0.8444 | 9500 | 0.0055 | 0.0047 | 0.9151 |
| 0.8533 | 9600 | 0.0056 | 0.0047 | 0.9153 |
| 0.8622 | 9700 | 0.0049 | 0.0047 | 0.9153 |
| 0.8711 | 9800 | 0.0066 | 0.0047 | 0.9154 |
| 0.88 | 9900 | 0.0054 | 0.0046 | 0.9154 |
| 0.8889 | 10000 | 0.0055 | 0.0046 | 0.9154 |
| 0.8978 | 10100 | 0.0055 | 0.0046 | 0.9155 |
| 0.9067 | 10200 | 0.0048 | 0.0045 | 0.9155 |
| 0.9156 | 10300 | 0.0046 | 0.0045 | 0.9156 |
| 0.9244 | 10400 | 0.0063 | 0.0045 | 0.9157 |
| 0.9333 | 10500 | 0.0055 | 0.0045 | 0.9157 |
| 0.9422 | 10600 | 0.0059 | 0.0045 | 0.9158 |
| 0.9511 | 10700 | 0.0049 | 0.0045 | 0.9158 |
| 0.96 | 10800 | 0.0058 | 0.0045 | 0.9158 |
| 0.9689 | 10900 | 0.0052 | 0.0045 | 0.9158 |
| 0.9778 | 11000 | 0.0065 | 0.0044 | 0.9159 |
| 0.9867 | 11100 | 0.0053 | 0.0044 | 0.9159 |
| 0.9956 | 11200 | 0.0046 | 0.0044 | 0.9159 |
| -1 | -1 | - | - | 0.9159 |
@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",
}
Base model
nreimers/MiniLM-L6-H384-uncased