Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 13
How to use ahmedosama2003/techforum-duplicate-detector with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("ahmedosama2003/techforum-duplicate-detector")
sentences = [
"Is there a common or well understood word for 'a group with no shared members'? I have two mathematical sets that have no common elements. In mathematical terms, these are called 'disjoint sets', and together they are called a 'partition'. What common or well understood word or phrase could I use to explain what these are, when speaking to someone who doesn't know what a disjoint set or partition is? Edit: I am looking for an alternative to the answer found in . I am looking for a reasonably common word/phrase to replace \"disjoint\". The other answer found in the linked question, \"orthogonal\", is much too obscure for my purpose.",
"Can we say that $\\left(a+b\\right)^{\\alpha}>a^{\\alpha}+b^{\\alpha}$ for all $a,b>0$ and $\\alpha>1$? For $\\alpha\\in\\mathbb{N}$ we can use the Binomial and get: $$\\left(a+b\\right)^{n}=\\sum_{k=0}^{n}{n \\choose k}a^{k}b^{n-k}=\\sum_{k=1}^{n-1}{n \\choose k}a^{k}b^{n-k}+a^{n}+b^{n}>a^{n}+b^{n} $$ But what about rational and irrational powers? Respectively, can we also say that $\\left(a+b\\right)^{\\alpha}<a^{\\alpha}+b^{\\alpha}$ for all $\\alpha<1$?",
"Word for two collections that do not have any elements in common I'm looking for a word for when you have a collection A and a collection B and they have no overlap. In mathematical terms: the relation between two sets where the intersection is empty. Like in this Venn diagram: The word that keeps popping up in my mind is disparate sets, but I don't feel that completely covers the meaning when I look at the definition, because that doesn't seem to preclude overlapping sets that are different: disparate 1. distinct in kind; essentially different; dissimilar: disparate ideas.",
"Resizing an iframe based on content I am working on an iGoogle-like application. Content from other applications (on other domains) is shown using iframes. How do I resize the iframes to fit the height of the iframes' content? I've tried to decipher the javascript Google uses but it's obfuscated, and searching the web has been fruitless so far. Update: Please note that content is loaded from other domains, so the applies."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from microsoft/codebert-base. It maps sentences & paragraphs to a 768-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, 'architecture': 'RobertaModel'})
(1): Pooling({'word_embedding_dimension': 768, '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})
)
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 = [
"How to adjust volume using batch files I want to know how to set volume with cmd but can't download software. I know it is possible because I had it but deleted it. opps",
"How can I control the master volume in Windows? Some keyboards have volume controls on them that can be pressed anytime to control the master volume. My keyboard does not have that. Is there a way that I can create a key macro that will work like the volume controls on those keyboards? It should always allow me to control the volume, even if I'm playing a game.",
"How many organisms have ever lived on Earth? I've looked for some information on this, but couldn't find anything useful. Has there been any noteworthy attempt to estimate the sum amount of individuals of all species that have ever lived on Earth?",
]
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, 0.3945, 0.0683],
# [ 0.3945, 1.0000, -0.0343],
# [ 0.0683, -0.0343, 1.0000]])
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
$f_n,f_n^{\prime}\rightarrow 0$ pointwise. But $(f_n^{\prime}) $ is not uniformly convergent. Find an example of such a sequence of functions. I was studying uniform convergence of sequence and series. I encounter this problem. Trying to find an example. Any help will be appreciated. The domain of the function can be any closed interval. For example, [0,1] will suffice. I am looking for an example to show that the conditions of the following theorems are necessary but not sufficient: Let $f_n\colon [a,b]\rightarrow \mathbb{R}$ be a sequence of differentiable functions on $[a,b]$, and let $f_n\rightarrow f$ pointwise on $[a,b]$. If $f_n^{\prime}\rightarrow g$ uniformly on $[a,b]$, then $f$ is differentiable on $[a,b]$ and $f^{\prime} = g$. |
Find sequence of differentiable functions $f_n$ on $\mathbb{R}$ that converge uniformly, but $f'_n$ converges only pointwise Question: Find a sequence of differentiable functions $f_n$ on $\mathbb{R}$ that converge uniformly to a differentiable function $f$, such that $f'_n$ converges pointwise but not uniformly to $f'$. Attempt: I have tried a number of possibilities, such as $f_n=x^n$ or $f_n=\frac{x^n}{n}$ but I don't know what the right approach is to construct the function. I am initially thinking that it's easiest to construct such a sequence of functions on the interval $[0,1]$ so that in the limit of $n$, part of the function goes to $0$ and the other part goes to $1$. However, this would make the resulting $f$ non-differentiable. |
Why is isNaN() is undefined? I'm new to this, so wondering if someone could please advise why isNaN() is undefined? package nan; public class nan { public static void main(String[] args) { { if (isNaN(1)) {System.out.println("true");} }; } } thanks |
What's the difference between JavaScript and Java? What's the difference between JavaScript and Java? |
How can I find data pattern matches in all fields/tables in an oracle database? Specifically, I am trying to find any credit card numbers that have been typed into text fields of any table in the database. This code below works for a single table where I know the primary key is "ID", but I cannot find a way to make this dynamic so that I can loop through many hundreds of table and rows. drop table tab1 purge; create table tab1(id number primary key, col1 varchar2(20), col2 varchar2(20), col3 varchar2(20)); Insert into TAB1 Values (1, 'No card here', 'Hello', 'nothing'); Insert into TAB1 Values (2, '1111222233334444', 'Visa', 'Hello'); Insert into TAB1 Values (3, 'Hello', 'MasterCard', '1111 2222 3333 4444'); Insert into TAB1 Values (4, 'Hello', '1111-2222-3333-4444', 'Visa'); Insert into TAB1 Values (5, 'Amex', 'Hello', '1111 222222 33333'); Insert into TAB1 Values (6, '111122222233333', 'Amex', 'Hello'); Insert into TAB1 Values (7, 'nothing', 'No card here', 'Hello'); COMMI... |
Search All Fields In All Tables For A Specific Value (Oracle) Is it possible to search every field of every table for a particular value in Oracle? There are hundreds of tables with thousands of rows in some tables so I know this could take a very long time to query. But the only thing I know is that a value for the field I would like to query against is 1/22/2008P09RR8. < I've tried using this statement below to find an appropriate column based on what I think it should be named but it returned no results. SELECT * from dba_objects WHERE object_name like '%DTN%' There is absolutely no documentation on this database and I have no idea where this field is being pulled from. Any thoughts? |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false
}
per_device_train_batch_size: 16per_device_eval_batch_size: 16num_train_epochs: 1multi_dataset_batch_sampler: round_robindo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 16gradient_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: 1max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_ratio: Nonewarmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Trueenable_jit_checkpoint: Falsesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseuse_cpu: Falseseed: 42data_seed: Nonebf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: -1ddp_backend: Nonedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonedisable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}accelerator_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: Nonegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Truepush_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_for_metrics: []eval_do_concat_batches: Trueauto_find_batch_size: Falsefull_determinism: Falseddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_num_input_tokens_seen: noneftune_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: Trueuse_cache: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.1067 | 500 | 1.3025 |
| 0.2133 | 1000 | 0.2615 |
| 0.3200 | 1500 | 0.1999 |
| 0.4266 | 2000 | 0.1671 |
| 0.5333 | 2500 | 0.1465 |
| 0.6399 | 3000 | 0.1371 |
| 0.7466 | 3500 | 0.1354 |
| 0.8532 | 4000 | 0.1277 |
| 0.9599 | 4500 | 0.1233 |
@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{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}
}
Base model
microsoft/codebert-base