SentenceTransformer based on allenai/longformer-base-4096
This is a sentence-transformers model finetuned from allenai/longformer-base-4096 on the all-nli-pair, all-nli-pair-class, all-nli-pair-score, all-nli-triplet, stsb, quora and natural-questions datasets. 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.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: allenai/longformer-base-4096
- Maximum Sequence Length: 4098 tokens
- Output Dimensionality: 768 tokens
- Similarity Function: Cosine Similarity
- Training Datasets:
- Language: en
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 4098, 'do_lower_case': False}) with Transformer model: LongformerModel
(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})
)
Usage
Direct Usage (Sentence Transformers)
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("Leo1212/longformer-base-4096-sentence-transformers-all-nli-stsb-quora-nq")
# Run inference
sentences = [
'How do I attract a girl?',
'How can I attract girls?',
"Why isn't my iPhone 5 charging?",
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
Training Details
Training Datasets
all-nli-pair
- Dataset: all-nli-pair at d482672
- Size: 10,000 training samples
- Columns:
anchor
andpositive
- Approximate statistics based on the first 1000 samples:
anchor positive type string string details - min: 5 tokens
- mean: 17.06 tokens
- max: 64 tokens
- min: 5 tokens
- mean: 9.64 tokens
- max: 31 tokens
- Samples:
anchor positive A person on a horse jumps over a broken down airplane.
A person is outdoors, on a horse.
Children smiling and waving at camera
There are children present
A boy is jumping on skateboard in the middle of a red bridge.
The boy does a skateboarding trick.
- Loss:
MultipleNegativesRankingLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
all-nli-pair-class
- Dataset: all-nli-pair-class at d482672
- Size: 10,000 training samples
- Columns:
premise
,hypothesis
, andlabel
- Approximate statistics based on the first 1000 samples:
premise hypothesis label type string string int details - min: 6 tokens
- mean: 17.4 tokens
- max: 50 tokens
- min: 5 tokens
- mean: 10.69 tokens
- max: 31 tokens
- 0: ~33.40%
- 1: ~33.30%
- 2: ~33.30%
- Samples:
premise hypothesis label A person on a horse jumps over a broken down airplane.
A person is training his horse for a competition.
1
A person on a horse jumps over a broken down airplane.
A person is at a diner, ordering an omelette.
2
A person on a horse jumps over a broken down airplane.
A person is outdoors, on a horse.
0
- Loss:
SoftmaxLoss
all-nli-pair-score
- Dataset: all-nli-pair-score at d482672
- Size: 10,000 training samples
- Columns:
sentence1
,sentence2
, andscore
- Approximate statistics based on the first 1000 samples:
sentence1 sentence2 score type string string float details - min: 6 tokens
- mean: 17.4 tokens
- max: 50 tokens
- min: 5 tokens
- mean: 10.69 tokens
- max: 31 tokens
- min: 0.0
- mean: 0.5
- max: 1.0
- Samples:
sentence1 sentence2 score A person on a horse jumps over a broken down airplane.
A person is training his horse for a competition.
0.5
A person on a horse jumps over a broken down airplane.
A person is at a diner, ordering an omelette.
0.0
A person on a horse jumps over a broken down airplane.
A person is outdoors, on a horse.
1.0
- Loss:
CoSENTLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "pairwise_cos_sim" }
all-nli-triplet
- Dataset: all-nli-triplet at d482672
- Size: 10,000 training samples
- Columns:
anchor
,positive
, andnegative
- Approximate statistics based on the first 1000 samples:
anchor positive negative type string string string details - min: 7 tokens
- mean: 10.38 tokens
- max: 45 tokens
- min: 6 tokens
- mean: 12.8 tokens
- max: 39 tokens
- min: 6 tokens
- mean: 13.4 tokens
- max: 50 tokens
- Samples:
anchor positive negative A person on a horse jumps over a broken down airplane.
A person is outdoors, on a horse.
A person is at a diner, ordering an omelette.
Children smiling and waving at camera
There are children present
The kids are frowning
A boy is jumping on skateboard in the middle of a red bridge.
The boy does a skateboarding trick.
The boy skates down the sidewalk.
- Loss:
MultipleNegativesRankingLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
stsb
- Dataset: stsb at ab7a5ac
- Size: 5,749 training samples
- Columns:
sentence1
,sentence2
, andscore
- Approximate statistics based on the first 1000 samples:
sentence1 sentence2 score type string string float details - min: 6 tokens
- mean: 10.02 tokens
- max: 28 tokens
- min: 6 tokens
- mean: 9.96 tokens
- max: 25 tokens
- min: 0.0
- mean: 0.54
- max: 1.0
- Samples:
sentence1 sentence2 score A plane is taking off.
An air plane is taking off.
1.0
A man is playing a large flute.
A man is playing a flute.
0.76
A man is spreading shreded cheese on a pizza.
A man is spreading shredded cheese on an uncooked pizza.
0.76
- Loss:
CoSENTLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "pairwise_cos_sim" }
quora
- Dataset: quora at 451a485
- Size: 10,000 training samples
- Columns:
anchor
andpositive
- Approximate statistics based on the first 1000 samples:
anchor positive type string string details - min: 6 tokens
- mean: 13.74 tokens
- max: 43 tokens
- min: 6 tokens
- mean: 13.91 tokens
- max: 44 tokens
- Samples:
anchor positive Astrology: I am a Capricorn Sun Cap moon and cap rising...what does that say about me?
I'm a triple Capricorn (Sun, Moon and ascendant in Capricorn) What does this say about me?
How can I be a good geologist?
What should I do to be a great geologist?
How do I read and find my YouTube comments?
How can I see all my Youtube comments?
- Loss:
MultipleNegativesRankingLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
natural-questions
- Dataset: natural-questions at f9e894e
- Size: 10,000 training samples
- Columns:
query
andanswer
- Approximate statistics based on the first 1000 samples:
query answer type string string details - min: 10 tokens
- mean: 12.43 tokens
- max: 23 tokens
- min: 18 tokens
- mean: 136.19 tokens
- max: 543 tokens
- Samples:
query answer when did richmond last play in a preliminary final
Richmond Football Club Richmond began 2017 with 5 straight wins, a feat it had not achieved since 1995. A series of close losses hampered the Tigers throughout the middle of the season, including a 5-point loss to the Western Bulldogs, 2-point loss to Fremantle, and a 3-point loss to the Giants. Richmond ended the season strongly with convincing victories over Fremantle and St Kilda in the final two rounds, elevating the club to 3rd on the ladder. Richmond's first final of the season against the Cats at the MCG attracted a record qualifying final crowd of 95,028; the Tigers won by 51 points. Having advanced to the first preliminary finals for the first time since 2001, Richmond defeated Greater Western Sydney by 36 points in front of a crowd of 94,258 to progress to the Grand Final against Adelaide, their first Grand Final appearance since 1982. The attendance was 100,021, the largest crowd to a grand final since 1986. The Crows led at quarter time and led by as many as 13, but the Tigers took over the game as it progressed and scored seven straight goals at one point. They eventually would win by 48 points – 16.12 (108) to Adelaide's 8.12 (60) – to end their 37-year flag drought.[22] Dustin Martin also became the first player to win a Premiership medal, the Brownlow Medal and the Norm Smith Medal in the same season, while Damien Hardwick was named AFL Coaches Association Coach of the Year. Richmond's jump from 13th to premiers also marked the biggest jump from one AFL season to the next.
who sang what in the world's come over you
Jack Scott (singer) At the beginning of 1960, Scott again changed record labels, this time to Top Rank Records.[1] He then recorded four Billboard Hot 100 hits – "What in the World's Come Over You" (#5), "Burning Bridges" (#3) b/w "Oh Little One" (#34), and "It Only Happened Yesterday" (#38).[1] "What in the World's Come Over You" was Scott's second gold disc winner.[6] Scott continued to record and perform during the 1960s and 1970s.[1] His song "You're Just Gettin' Better" reached the country charts in 1974.[1] In May 1977, Scott recorded a Peel session for BBC Radio 1 disc jockey, John Peel.
who produces the most wool in the world
Wool Global wool production is about 2 million tonnes per year, of which 60% goes into apparel. Wool comprises ca 3% of the global textile market, but its value is higher owing to dying and other modifications of the material.[1] Australia is a leading producer of wool which is mostly from Merino sheep but has been eclipsed by China in terms of total weight.[30] New Zealand (2016) is the third-largest producer of wool, and the largest producer of crossbred wool. Breeds such as Lincoln, Romney, Drysdale, and Elliotdale produce coarser fibers, and wool from these sheep is usually used for making carpets.
- Loss:
MultipleNegativesRankingLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
Evaluation Datasets
all-nli-triplet
- Dataset: all-nli-triplet at d482672
- Size: 6,584 evaluation samples
- Columns:
anchor
,positive
, andnegative
- Approximate statistics based on the first 1000 samples:
anchor positive negative type string string string details - min: 6 tokens
- mean: 18.02 tokens
- max: 66 tokens
- min: 5 tokens
- mean: 9.81 tokens
- max: 29 tokens
- min: 5 tokens
- mean: 10.37 tokens
- max: 29 tokens
- Samples:
anchor positive negative Two women are embracing while holding to go packages.
Two woman are holding packages.
The men are fighting outside a deli.
Two young children in blue jerseys, one with the number 9 and one with the number 2 are standing on wooden steps in a bathroom and washing their hands in a sink.
Two kids in numbered jerseys wash their hands.
Two kids in jackets walk to school.
A man selling donuts to a customer during a world exhibition event held in the city of Angeles
A man selling donuts to a customer.
A woman drinks her coffee in a small cafe.
- Loss:
MultipleNegativesRankingLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
stsb
- Dataset: stsb at ab7a5ac
- Size: 1,500 evaluation samples
- Columns:
sentence1
,sentence2
, andscore
- Approximate statistics based on the first 1000 samples:
sentence1 sentence2 score type string string float details - min: 5 tokens
- mean: 15.0 tokens
- max: 44 tokens
- min: 6 tokens
- mean: 14.99 tokens
- max: 61 tokens
- min: 0.0
- mean: 0.47
- max: 1.0
- Samples:
sentence1 sentence2 score A man with a hard hat is dancing.
A man wearing a hard hat is dancing.
1.0
A young child is riding a horse.
A child is riding a horse.
0.95
A man is feeding a mouse to a snake.
The man is feeding a mouse to the snake.
1.0
- Loss:
CoSENTLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "pairwise_cos_sim" }
quora
- Dataset: quora at 451a485
- Size: 1,000 evaluation samples
- Columns:
anchor
andpositive
- Approximate statistics based on the first 1000 samples:
anchor positive type string string details - min: 6 tokens
- mean: 13.86 tokens
- max: 63 tokens
- min: 6 tokens
- mean: 13.9 tokens
- max: 46 tokens
- Samples:
anchor positive What is your New Year resolution?
What can be my new year resolution for 2017?
Should I buy the IPhone 6s or Samsung Galaxy s7?
Which is better: the iPhone 6S Plus or the Samsung Galaxy S7 Edge?
What are the differences between transgression and regression?
What is the difference between transgression and regression?
- Loss:
MultipleNegativesRankingLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
natural-questions
- Dataset: natural-questions at f9e894e
- Size: 1,000 evaluation samples
- Columns:
query
andanswer
- Approximate statistics based on the first 1000 samples:
query answer type string string details - min: 9 tokens
- mean: 12.47 tokens
- max: 25 tokens
- min: 18 tokens
- mean: 139.05 tokens
- max: 572 tokens
- Samples:
query answer where does the waikato river begin and end
Waikato River The Waikato River is the longest river in New Zealand, running for 425 kilometres (264Â mi) through the North Island. It rises in the eastern slopes of Mount Ruapehu, joining the Tongariro River system and flowing through Lake Taupo, New Zealand's largest lake. It then drains Taupo at the lake's northeastern edge, creates the Huka Falls, and flows northwest through the Waikato Plains. It empties into the Tasman Sea south of Auckland, at Port Waikato. It gives its name to the Waikato Region that surrounds the Waikato Plains. The present course of the river was largely formed about 17,000 years ago. Contributing factors were climate warming, forest being reestablished in the river headwaters and the deepening, rather than widening, of the existing river channel. The channel was gradually eroded as far up river as Piarere, leaving the old Hinuera channel high and dry.[2] The remains of the old river path can be clearly seen at Hinuera where the cliffs mark the ancient river edges. The river's main tributary is the Waipa River, which has its confluence with the Waikato at Ngaruawahia.
what type of gas is produced during fermentation
Fermentation Fermentation reacts NADH with an endogenous, organic electron acceptor.[1] Usually this is pyruvate formed from sugar through glycolysis. The reaction produces NAD+ and an organic product, typical examples being ethanol, lactic acid, carbon dioxide, and hydrogen gas (H2). However, more exotic compounds can be produced by fermentation, such as butyric acid and acetone. Fermentation products contain chemical energy (they are not fully oxidized), but are considered waste products, since they cannot be metabolized further without the use of oxygen.
why was star wars episode iv released first
Star Wars (film) Star Wars (later retitled Star Wars: Episode IV – A New Hope) is a 1977 American epic space opera film written and directed by George Lucas. It is the first film in the original Star Wars trilogy and the beginning of the Star Wars franchise. Starring Mark Hamill, Harrison Ford, Carrie Fisher, Peter Cushing, Alec Guinness, David Prowse, James Earl Jones, Anthony Daniels, Kenny Baker, and Peter Mayhew, the film's plot focuses on the Rebel Alliance, led by Princess Leia (Fisher), and its attempt to destroy the Galactic Empire's space station, the Death Star. This conflict disrupts the isolated life of farmhand Luke Skywalker (Hamill), who inadvertently acquires two droids that possess stolen architectural plans for the Death Star. When the Empire begins a destructive search for the missing droids, Skywalker accompanies Jedi Master Obi-Wan Kenobi (Guinness) on a mission to return the plans to the Rebel Alliance and rescue Leia from her imprisonment by the Empire.
- Loss:
MultipleNegativesRankingLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
Training Hyperparameters
Non-Default Hyperparameters
overwrite_output_dir
: Trueeval_strategy
: stepsnum_train_epochs
: 5load_best_model_at_end
: True
All Hyperparameters
Click to expand
overwrite_output_dir
: Truedo_predict
: Falseeval_strategy
: stepsprediction_loss_only
: Trueper_device_train_batch_size
: 8per_device_eval_batch_size
: 8per_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
: 1.0num_train_epochs
: 5max_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
: 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}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
: Falsehub_always_push
: Falsegradient_checkpointing
: Falsegradient_checkpointing_kwargs
: Noneinclude_inputs_for_metrics
: Falseeval_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
: Nonedispatch_batches
: Nonesplit_batches
: 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
: Falsebatch_sampler
: batch_samplermulti_dataset_batch_sampler
: proportional
Training Logs
Epoch | Step | Training Loss | all-nli-triplet loss | stsb loss | natural-questions loss | quora loss |
---|---|---|---|---|---|---|
0.0487 | 200 | 2.0928 | - | - | - | - |
0.0973 | 400 | 2.2013 | - | - | - | - |
0.1460 | 600 | 1.7404 | - | - | - | - |
0.1946 | 800 | 1.9134 | - | - | - | - |
0.2433 | 1000 | 2.043 | 0.5161 | 6.2815 | 0.1172 | 0.0192 |
0.2920 | 1200 | 1.8817 | - | - | - | - |
0.3406 | 1400 | 1.7734 | - | - | - | - |
0.3893 | 1600 | 1.5935 | - | - | - | - |
0.4380 | 1800 | 1.6762 | - | - | - | - |
0.4866 | 2000 | 1.7031 | 0.4555 | 6.3907 | 0.0726 | 0.0198 |
0.5353 | 2200 | 1.8561 | - | - | - | - |
0.5839 | 2400 | 1.6742 | - | - | - | - |
0.6326 | 2600 | 1.456 | - | - | - | - |
0.6813 | 2800 | 1.6122 | - | - | - | - |
0.7299 | 3000 | 1.8851 | 0.4975 | 6.1758 | 0.0841 | 0.0208 |
0.7786 | 3200 | 1.5684 | - | - | - | - |
0.8273 | 3400 | 1.6535 | - | - | - | - |
0.8759 | 3600 | 1.5043 | - | - | - | - |
0.9246 | 3800 | 1.4768 | - | - | - | - |
0.9732 | 4000 | 1.686 | 0.4912 | 6.1600 | 0.0795 | 0.0170 |
- The bold row denotes the saved checkpoint.
Framework Versions
- Python: 3.11.9
- Sentence Transformers: 3.1.1
- Transformers: 4.45.2
- PyTorch: 2.3.1+cu121
- Accelerate: 1.0.0
- Datasets: 3.0.1
- Tokenizers: 0.20.0
Citation
BibTeX
Sentence Transformers and SoftmaxLoss
@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",
}
MultipleNegativesRankingLoss
@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}
}
CoSENTLoss
@online{kexuefm-8847,
title={CoSENT: A more efficient sentence vector scheme than Sentence-BERT},
author={Su Jianlin},
year={2022},
month={Jan},
url={https://kexue.fm/archives/8847},
}
- Downloads last month
- 23
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social
visibility and check back later, or deploy to Inference Endpoints (dedicated)
instead.
Model tree for Leo1212/longformer-base-4096-sentence-transformers-all-nli-stsb-quora-nq
Base model
allenai/longformer-base-4096