Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 16
How to use sylviachangdou-prayer/stylematch-authorship-v1 with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("sylviachangdou-prayer/stylematch-authorship-v1")
sentences = [
"absolutely to exclude the disease. The progress of medical and sanitary science has been such, however, that if approved precautions are taken at once to put all of our cities and towns in the best sanitary condition, and provision is made for isolating any sporadic cases and for a thorough disinfection, an epidemic can, I am sure, be avoided. This work appertains to the local authorities, and the responsibility and the penalty will be appalling if it is neglected or unduly delayed. We are peculiarly subject in our great ports to the spread of infectious diseases by reason of the fact that unrestricted immigration brings to us out of European cities, in the overcrowded steerages of great steamships, a large number of persons whose surroundings make them the easy victims of the plague. This consideration, as well as those affecting the political, moral, and industrial interests of our country, leads",
"proposition in writing whereby they agree to remove one-half of their stock from the outlet on or before November 1 and the residue thereof and all their property and employees on or before December 1 next, and to abandon all claims in said outlet: Now, therefore, I, Benjamin Harrison, President of the United States, do give notice and proclaim that the time heretofore fixed for the removal of the live stock herded upon said outlet is extended to November 1 as to one-half thereof and to December 1 next as to the residue thereof and as to all property and employees. BENJ. HARRISON. BY THE PRESIDENT OF THE UNITED STATES OF AMERICA. A PROCLAMATION. Whereas it is provided in the act of Congress entitled \"An act to extend the northern boundary of the State of Nebraska,\" approved March 28, 1882-- That the northern boundary of the State of Nebraska shall",
"proper feeling her noble suitor had perhaps served her right; but after a while my curiosity as to just how her noble suitor _had_ served her got the better of that emotion, and I asked a question or two which led my companion again to apply to him the invidious term I have already quoted. What had happened was simply that Flora had at the eleventh hour broken down in the attempt to put him off with an uncandid account of her infirmity and that his lordship's interest in her had not been proof against the discovery of the way she had practised on him. Her dissimulation, he was obliged to perceive, had been infernally deep. The future in short assumed a new complexion for him when looked at through the grim glasses of a bride who, as he had said to some one, couldn't really, when you came to",
"experienced from external causes there is much room for congratulation on the prosperity and happiness flowing from our situation at home. The blessing of health has never been more universal. The fruits of the seasons, though in particular articles and districts short of their usual redundancy, are more than sufficient for our wants and our comforts. The face of our country ever presents evidence of laudable enterprise, of extensive capital, and of durable improvement. In a cultivation of the materials and the extension of useful manufactures, more especially in the general application to household fabrics, we behold a rapid diminution of our dependence on foreign supplies. Nor is it unworthy of reflection that this revolution in our pursuits and habits is in no slight degree a consequence of those impolitic and arbitrary edicts by which the contending nations, in endeavoring each of them to obstruct our trade with the other,"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from Blablablab/multilingual-style-representation. It maps sentences & paragraphs to a 1024-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': 'XLMRobertaModel'})
(1): Pooling({'embedding_dimension': 1024, '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 = [
'first time entering this dining-room, and naturally taking no special heed at what door he entered, will, upon rising to depart, commit the strangest blunders. Such, for instance, as opening the first door that comes handy, and finding himself stealing up-stairs by the back passage. Shutting that door, he will proceed to another, and be aghast at the cellar yawning at his feet. Trying a third, he surprises the housemaid at her work. In the end, no more relying on his own unaided efforts, he procures a trusty guide in some passing person, and in good time successfully emerges. Perhaps as curious a blunder as any, was that of a certain stylish young gentleman, a great exquisite, in whose judicious eyes my daughter Anna had found especial favor. He called upon the young lady one evening, and found her alone in the dining-room at her needlework. He stayed rather late;',
"might be placed over his grave. Though with the sentiment of the epitaph Plain Talk did not disagree, he himself being at times of a hypochondriac turn--at least, so many said--yet the language struck him as too much drawn out; so, after consultation with Old Prudence, he decided upon making use of the epitaph, yet not without verbal retrenchments. And though, when these were made, the thing still appeared wordy to him, nevertheless, thinking that, since a dead man was to be spoken about, it was but just to let him speak for himself, especially when he spoke sincerely, and when, by so doing, the more salutary lesson would be given, he had the retrenched inscription chiseled as follows upon the stone. 'HERE LIE THE REMAINS OF CHINA ASTER THE CANDLE-MAKER, WHOSE CAREER WAS AN EXAMPLE OF THE TRUTH OF SCRIPTURE, AS FOUND IN THE SOBER PHILOSOPHY OF SOLOMON THE",
'terrible mark upon her brow. Then the strong, soothing hand of the austere maid drew her head down on to the cushion, and the wild anger died away into passionate sobbing. At last she continued: “I will tell you about last night. You are aware, perhaps, that in this house all the servants sleep in the modern wing. This central block is made up of the dwelling-rooms, with the kitchen behind and our bedroom above. My maid, Theresa, sleeps above my room. There is no one else, and no sound could alarm those who are in the farther wing. This must have been well-known to the robbers, or they would not have acted as they did. “Sir Eustace retired about half-past ten. The servants had already gone to their quarters. Only my maid was up, and she had remained in her room at the top of the house until I',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8258, 0.8016],
# [0.8258, 1.0000, 0.6494],
# [0.8016, 0.6494, 1.0000]])
sentence_0, sentence_1, and sentence_2| sentence_0 | sentence_1 | sentence_2 | |
|---|---|---|---|
| type | string | string | string |
| modality | text | text | text |
| details |
|
|
|
| sentence_0 | sentence_1 | sentence_2 |
|---|---|---|
I went on: "As to life, that's another thing. And I don't know that one ought to blame you very much--though it seemed rather an excessive step. I wonder now if it isn't the ugliness rather than the pain of the struggle which . . . " She shuddered visibly: "But I do blame myself," she exclaimed with feeling. "I am ashamed." And, dropping her head, she looked in a moment the very picture of remorse and shame. "Well, you will be going away from all its horrors," I said. "And surely you are not afraid of the sea. You are a sailor's granddaughter, I understand." She sighed deeply. She remembered her grandfather only a little. He was a clean-shaven man with a ruddy complexion and long, perfectly white hair. He used to take her on his knee, and putting his face near hers, talk to her in loving whispers. |
be mighty careful then about what I said to anybody. Someone might have put it into his head to hang me at some yard-arm or other." "I envy your experience all the same," said Cosmo amiably. "I suppose your conscience was clear?" "I have always been most careful not to give my conscience any license to trouble me," retorted the other with a certain curtness of tone which was not offensive; "and I have lived now for some considerable time. I am really much older than I look," he concluded, giving Cosmo such a keen glance that the young man could not I help a smile. The other went on looking at him steadily for a while, then let his eyes wander to a door in a distant part of the long room as if impatient for the coming of the dinner. Then giving it up: "A man who has |
alarmed the young fellow, and he was going to make a noise; but I said: "Save your wind; if you open your mouth you are dead, sure. Tackle your instrument. Lively, now! Call Camelot." "This doth amaze me! How should such as you know aught of such matters as--" "Call Camelot! I am a desperate man. Call Camelot, or get away from the instrument and I will do it myself." "What--you?" "Yes--certainly. Stop gabbling. Call the palace." He made the call. "Now, then, call Clarence." "Clarence who?" "Never mind Clarence who. Say you want Clarence; you'll get an answer." He did so. We waited five nerve-straining minutes--ten minutes --how long it did seem!--and then came a click that was as familiar to me as a human voice; for Clarence had been my own pupil. "Now, my lad, vacate! They would have known my touch, maybe, and so your call was |
American exports, at stable prices and with more liberal government guarantees and financing--curbing tax and customs loopholes that encourage undue spending of private dollars abroad--and (through OECD, NATO and otherwise) sharing with our allies all efforts to provide for the common defense of the free world and the hopes for growth of the less developed lands. While the current deficit lasts, ways will be found to ease our dollar outlays abroad without placing the full burden on the families of men whom we have asked to serve our Flag overseas. In short, whatever is required will be done to back up all our efforts abroad, and to make certain that, in the future as in the past, the dollar is as "sound as a dollar." III. But more than our exchange of international payments is out of balance. The current Federal budget for fiscal 1961 is almost certain to show |
conquer the deserts, eradicate disease, tap the ocean depths, and encourage the arts and commerce. Let both sides unite to heed in all corners of the earth the command of Isaiah. . .to "undo the heavy burdens. . . let the oppressed go free." And if a beachhead of co-operation may push back the jungle of suspicion. . . let both sides join in creating not a new balance of power. . . but a new world of law. . .where the strong are just. . . and the weak secure. . .and the peace preserved. . . . All this will not be finished in the first one hundred days. Nor will it be finished in the first one thousand days. . . nor in the life of this administration, nor even perhaps in our lifetime on this planet. But let us begin. In your hands, my fellow citizens. |
Given the cooperation of the Federal Reserve System, which I so earnestly seek, I am confident that this movement can continue. I pledge the American people that I will do everything in a President's power to lower interest rates and to ease money in this country. The Federal Home Loan Bank Board tomorrow morning will announce that it will make immediately available to savings and loan associations an additional $1 billion, and will lower from 6 percent to 5 3/4 percent the interest rate charged on those loans. We shall continue on a sensible course of fiscal and budgetary policy that we believe will keep our economy growing without new inflationary spirals; that will finance responsibly the needs of our men in Vietnam and the progress of our people at home; that will support a significant improvement in our export surplus, and will press forward toward easier credit and toward |
because of the efforts of hundreds of volunteers and donations from people in all walks of life. Volunteers and financial support to provide volunteers with the assistance they need, is critical to reaching Project Gutenberg-tm’s goals and ensuring that the Project Gutenberg-tm collection will remain freely available for generations to come. In 2001, the Project Gutenberg Literary Archive Foundation was created to provide a secure and permanent future for Project Gutenberg-tm and future generations. To learn more about the Project Gutenberg Literary Archive Foundation and how your efforts and donations can help, see Sections 3 and 4 and the Foundation web page at http://www.pglaf.org. Section 3. Information about the Project Gutenberg Literary Archive Foundation The Project Gutenberg Literary Archive Foundation is a non profit 501(c)(3) educational corporation organized under the laws of the state of Mississippi and granted tax exempt status by the Internal Revenue Service. The Foundat... |
is for something more vital: imagination. Imagination is as the immortal God which should assume flesh for the redemption of mortal passion (Shelley). Imagination is our only guide into the world created by words. Whether those words are signed or unsigned becomes, as soon as the imagination redeems us, a matter of no importance, because we have approximated to the state in which they were written, and there are no names down there, no personality as we understand personality, no marrying or giving in marriage. What there is down there--ah, that is another enquiry, and may the clergymen and the scientists pursue it more successfully in the future than they have in the past. |
on again, with a patient tenderness that I was deeply grateful for. At first, as I lay quiet on the sofa, I found it painfully difficult, I might say impossible, to get rid of the impression of the glare of the flames, their hurry and noise, and the fierce burning smell. If I dozed for a minute, I was awakened by Miss Havisham’s cries, and by her running at me with all that height of fire above her head. This pain of the mind was much harder to strive against than any bodily pain I suffered; and Herbert, seeing that, did his utmost to hold my attention engaged. Neither of us spoke of the boat, but we both thought of it. That was made apparent by our avoidance of the subject, and by our agreeing—without agreement—to make my recovery of the use of my hands a question of so many |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
per_device_train_batch_size: 32num_train_epochs: 1per_device_eval_batch_size: 32batch_sampler: no_duplicatesmulti_dataset_batch_sampler: round_robinper_device_train_batch_size: 32num_train_epochs: 1max_steps: -1learning_rate: 5e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1label_smoothing_factor: 0.0bf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 32prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Falsedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: Nonefsdp_config: Nonedeepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.5931 | 500 | 3.1777 |
@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{oord2019representationlearningcontrastivepredictive,
title={Representation Learning with Contrastive Predictive Coding},
author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
year={2019},
eprint={1807.03748},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/1807.03748},
}
Base model
FacebookAI/xlm-roberta-large