Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 384, 'do_lower_case': False}) with Transformer model: MPNetModel
(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})
(2): Normalize()
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("Alessio-Borgi/all-mpnet-base-v2-margin-based-triplet-loss-finetuned-culture-1-epochs-enhanced_test")
5# Run inference
6sentences = [
7 "Gomal River river in Afghanistan and Pakistan The Gomal (Urdu: دریائے گومل, Pashto: ګومل سیند، ګومل دریاب) is a 400-kilometre-long (250 mi) river in Afghanistan and Pakistan. It rises in northern Afghanistan's Paktika Province and joins the Indus River 20 miles south of Dera Ismail Khan, in Pakistan's Khyber Pakhtunkhwa province. Gomal University in Dera Ismail Khan and Gomal District in Afghanistan's Paktika province are named after the river. {'name': 'Gomal', 'map': '{{maplink|frame|=|yes|frame-align|=|left|type|=|line|id|=|Q8501|text|=|Interactive Map}}', 'map_size': '250px', 'subdivision_type1': 'Countries', 'subdivision_name1': 'Afghanistan and Pakistan', 'subdivision_type2': 'Provinces', 'subdivision_name2': '{{hlist|Paktika|Balochistan|Khyber Pakhtunkhwa}}', 'length': '{{convert|400|km|mi|abbr|=|on}}', 'source1_location': 'Katawaz Region, Gomal District, Paktika Province, Afghanistan', 'source1_coordinates': '{{coord|32.502974|N|68.901294|E}}', 'mouth': 'Indus River', 'mouth_location': 'Dera Ismail Khan, Dera Ismail Khan District, Khyber Pakhtunkhwa, Pakistan', 'mouth_coordinates': '{{coord|31|36|53|N|70|50|46|E}}', 'tributaries_left': 'Wana Khwar', 'tributaries_right': 'Zhob River'} {'instance of': 'river', 'country': 'Spain', 'drainage basin': 'Tagus Basin', 'described by source': 'Brockhaus and Efron Encyclopedic Dictionary', 'mouth of the watercourse': 'Tagus River', 'located in the administrative territorial entity': 'Community of Madrid'}",
8 'National Union Party 1864–1868 Republican and Unionist political alliance The National Union Party, commonly the Union Party or Unionists, was a wartime coalition of Republicans, War Democrats, and border state Unconditional Unionists that supported the Lincoln Administration during the American Civil War. It held the 1864 National Union Convention that nominated Abraham Lincoln for president and Andrew Johnson for vice president in the 1864 United States presidential election. Following Lincoln\'s successful re-election and assassination, Johnson tried and failed to sustain the Union Party as a vehicle for his presidential ambitions. The coalition did not contest the 1868 elections, but the Republican Party continued to use the "Union Republican" label throughout the period of Reconstruction. Abraham Lincoln won the 1860 United States presidential election, receiving 180 electoral votes and 53% of the popular vote in the free states; opposition to Lincoln was divided, with most northern Democrats voting for Illinois Senator Stephen Douglas. Following the Republican victory, Douglas strongly condemned secession and publicly supported the federal government\'s efforts to preserve the Union. Pro-administration War Democrats in states like Ohio sought to cooperate with Republicans through the formation of Union parties in opposition to the anti-administration Peace faction. Elsewhere, the Union Party appeared as a coalition of conservative Republicans and Democrats opposed by the Radical Republicans. Besides allowing voters of diverse pre-war partisan allegiances to unite under a common banner, the Union label served a valuable propaganda purpose by implying the coalition\'s opponents were dis-unionists. The preeminent policy of the National Union Party was the preservation of the Union by the prosecution of the war to its ultimate conclusion. They rejected proposals for a negotiated peace as humiliating and ultimately ruinous to the authority of the national government. The party\'s 1864 platform called for the abolition of slavery by constitutional amendment, a "liberal and just" immigration policy, completion of the transcontinental railroad, and condemned the French intervention in Mexico as dangerous to republicanism. {\'colorcode\': \'{{party color|National Union Party (United States)}}\', \'name\': \'National Union Party\', \'logo\': \'Republican presidential ticket 1864b.jpg\', \'logo_size\': \'200px\', \'caption\': \'Campaign banner for the 1864 National Union ticket\', \'leader1_title\': \'Leaders\', \'leader1_name\': \'Abraham Lincoln<br>Andrew Johnson\', \'foundation\': \'{{start date and age|1861}}\', \'dissolution\': \'{{end date and age|1868}}\', \'merger\': \'Republican Party<br>War Democrats<br>Unconditional Union Party\', \'merged\': \'Republican Party<br>Democratic Party\', \'ideology\': \'American nationalism<br />Unionism<br>Abolitionism\', \'colors\': \'{{nowrap|color box|#CC0C2F|border|=|darkgray| Red |color box|#FFFFFF|border|=|darkgray| White |color box|#002C77|border|=|darkgray| Blue}} <br> {{color box|#CC0C2F|border|=|darkgray}} Red {{color box|#FFFFFF|border|=|darkgray}} White {{color box|#002C77|border|=|darkgray}} Blue {{small|(United States national colors)}}\', \'country\': \'the United States\', \'aliases\': [\'Union Party\']} {\'instance of\': \'political party\', \'number of seats in assembly\': \'{"amount": "+3", "unit": "1"}\', \'country\': \'Greece\', \'political alignment\': \'centre-left\', \'subclass of\': \'political party\', \'headquarters location\': \'Athens\'}',
9 'Thunnus genus of fishes Thunnus is a genus of ocean-dwelling, ray-finned bony fish from the mackerel family, Scombridae. More specifically, Thunnus is one of five genera which make up the tribe Thunnini – a tribe that is collectively known as the tunas. Also called the true tunas or real tunas, Thunnus consists of eight species of tuna (more than half of the overall tribe), divided into two subgenera. Their coloring, metallic blue on top and shimmering silver-white on the bottom, helps camouflage them from above and below. Atlantic bluefin tuna, the largest member of this genus, can grow to 15 feet (4.6 m) long and weigh up to 1,500 pounds (680 kg). All tunas are extremely strong, muscular swimmers, and the yellowfin tuna is known to reach speeds of up to 50 miles per hour (80 km/h) when pursuing prey. As with all tunas, members of this genus are warm-blooded, which is a rare trait among fish; this enables them to tolerate cold waters and to dive to deeper depths. Bluefin tunas, for example, are found in Newfoundland and Iceland, and also in the tropical waters of the Gulf of Mexico and the Mediterranean Sea, where some individuals go each year to spawn. Due to overfishing, the range of this genus has declined significantly, having been effectively extirpated from the Black Sea, for example. {\'name\': \'True tunas\', \'fossil_range\': \'{{Fossilrange|Tertiary|holocene}}\', \'image_caption\': \'Yellowfin tuna\', \'taxon\': \'Thunnus\', \'authority\': \'South, 1845\', \'type_species\': "\'\'Scomber thynnus\'\'", \'type_species_authority\': \'Linnaeus, 1758\', \'subdivision_ranks\': \'Subgenus\', \'subdivision\': "* \'\'T. (Thunnus)\'\' (bluefin group)\\n* \'\'T. (Neothunnus)\'\' (yellowfin group)", \'synonyms\': "*\'\'Albacora\'\' <small>Jordan, 1888</small>\\n*\'\'Germo\'\' <small>Jordan, 1888</small>\\n*\'\'Thynnus\'\' <small>Aguilera, 2020</small>\\n*\'\'Kishinoella\'\' <small>Jordan & Hubbs, 1925</small>\\n*\'\'Neothunnus\'\' <small>Kishinouye, 1923</small>\\n*\'\'Orcynus\'\' <small>Cuvier, 1816</small>\\n*\'\'Parathunnus\'\' <small>Kishinouye, 1923</small>\\n*\'\'Semathunnus\'\' <small>Fowler, 1933</small>", \'aliases\': [\'tuna\', \'tunafish\', \'tuna fish\', \'tunas\', \'tuna fishes\', \'tunafishes\', \'tunny\', \'tunnies\']} {\'subclass of\': \'fish\', \'instance of\': \'taxon\', \'taxon rank\': \'species\', \'described by source\': \'Encyclopædia Britannica 11th edition\', \'IUCN conservation status\': \'Least Concern\', \'maintained by WikiProject\': \'WikiProject Invasion Biology\', \'parent taxon\': \'Elasmobranchs\'}',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 768]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities.shape)
18# [3, 3]sentence_0, sentence_1, and sentence_2| sentence_0 | sentence_1 | sentence_2 | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| sentence_0 | sentence_1 | sentence_2 |
|---|---|---|
food presentation art of modifying, processing, arranging, or decorating food to enhance its aesthetic appeal Food presentation is the art of modifying, processing, arranging, or decorating food to enhance its aesthetic appeal. The visual presentation of foods is often considered by chefs at many different stages of food preparation, from the manner of tying or sewing meats, to the type of cut used in chopping and slicing meats or vegetables, to the style of mold used in a poured dish. The food itself may be decorated as in elaborately iced cakes, topped with ornamental sometimes sculptural consumables, drizzled with sauces, sprinkled with seeds, powders, or other toppings, or it may be accompanied by edible or inedible garnishes. Historically, the presentation of food has been used as a show of wealth and power. Such displays often emphasize the complexity of a dish's composition as opposed to its flavors. For instance, ancient sources recall the hosts of Roman banquets adding preciou... | golf course designer occupation; landscape architect specialized in designing golf courses A golf course is the grounds on which the sport of golf is played. It consists of a series of holes, each consisting of a tee box, a fairway, the rough and other hazards, and a green with a cylindrical hole in the ground, known as a "cup". The cup holds a flagstick, known as a "pin". A standard round of golf consists of 18 holes, and as such most courses contain 18 distinct holes; however, there are many 9-hole courses and some that have holes with shared fairways or greens. There are also courses with a non-standard number of holes, such as 12 or 14. The vast majority of golf courses have holes of varying length and difficulties that are assigned a standard score, known as par, that a proficient player should be able to achieve; this is usually three, four or five strokes. Par-3 courses consist of holes all of which have a par of three. Short courses have gained in popularity; these consist of m... | windmill machine that converts the energy of wind into rotational energy A windmill is a machine operated by the force of wind acting on vanes or sails to mill grain (gristmills). Windmills were used throughout the high medieval and early modern periods; the horizontal or panemone windmill first appeared in Persia during the 9th century, and the vertical windmill first appeared in northwestern Europe in the 12th century. Regarded as an icon of Dutch culture, there are approximately 1,000 windmills in the Netherlands today. {'aliases': ['wind mill']} {'instance of': 'geographic location', 'on focus list of Wikimedia project': 'Wikipedia:Vital articles/Level/4', 'occupant': 'World Trade Center'} |
brick block or a single unit of a ceramic material used in masonry construction A brick is a type of construction material used to build walls, pavements and other elements in masonry construction. Properly, the term brick denotes a unit primarily composed of clay, but is now also used informally to denote units made of other materials or other chemically cured construction blocks. Bricks can be joined using mortar, adhesives or by interlocking. Bricks are usually produced at brickworks in numerous classes, types, materials, and sizes which vary with region, and are produced in bulk quantities. Block is a similar term referring to a rectangular building unit composed of clay or concrete, but is usually larger than a brick. Lightweight bricks (also called lightweight blocks) are made from expanded clay aggregate. Fired bricks are one of the longest-lasting and strongest building materials, sometimes referred to as artificial stone, and have been used since c. 4000 BC. Air-dried bricks, ... | boomtown community that experiences sudden and rapid population and economic growth A boomtown is a community that undergoes sudden and rapid population and economic growth, or that is started from scratch. The growth is normally attributed to the nearby discovery of a precious resource such as gold, silver, or oil, although the term can also be applied to communities growing very rapidly for different reasons, such as a proximity to a major metropolitan area, large infrastructure projects, or an attractive climate. {'note': 'infobox not present in Wikipedia'} {'subclass of': 'city', 'part of': 'metropolitan area', 'country': 'Germany', 'instance of': 'concept'} | Crispy Crunch Canadian chocolate bar Crispy Crunch is a hard chocolate bar with a crispy peanut butter flake inside that is made by Cadbury in Canada. Harold Oswin, an employee of William Neilson, developed "Crispy Crunch" in 1930. {'name': 'Crispy Crunch', 'logo': 'Crispycrunch logo.png', 'logo_size': '200', 'producttype': 'Chocolate bar', 'currentowner': 'Cadbury', 'country': 'Canada', 'introduced': '{{start date and age |
Comics of the United Kingdom comic originating in the United Kingdom A British comic is a periodical published in the United Kingdom that contains comic strips. It is generally referred to as a comic or a comic magazine, and historically as a comic paper. As of 2014, the three longest-running comics of all time were all British. British comics are usually comics anthologies which are typically aimed at children, and are published weekly, although some are also published on a fortnightly or monthly schedule. The two most popular British comics, The Beano and The Dandy, were released by DC Thomson in the 1930s. By 1950 the weekly circulation of both reached two million. Explaining the enormous popularity of comics in British popular culture during this period, Anita O’Brien, director curator at London's Cartoon Museum, states: "When comics like The Beano and Dandy were invented back in the 1930s – and through really to the 1950s and 60s – these comics were almost the only entertainment a... | Romanesque architecture architectural style of Medieval Europe Romanesque architecture is an architectural style of medieval Europe that was predominant in the 11th and 12th centuries. The style eventually developed into the Gothic style with the shape of the arches providing a simple distinction: the Romanesque is characterized by semicircular arches, while the Gothic is marked by the pointed arches. The Romanesque emerged nearly simultaneously in multiple countries of Western Europe; its examples can be found across the continent, making it the first pan-European architectural style since Imperial Roman architecture. Similarly to Gothic, the name of the style was transferred onto the contemporary Romanesque art. Combining features of ancient Roman and Byzantine buildings and other local traditions, Romanesque architecture is known by its massive quality, thick walls, round arches, sturdy pillars, barrel vaults, large towers and decorative arcading. Each building has clearly defined f... | Castillo de Suel castle Sohail Castle (Spanish: Castillo Sohail) is a castle in Fuengirola, Spain. It is a historic fortress located in the coastal town of Fuengirola, situated along the Costa del Sol in the province of Málaga, Andalusia, Spain. The castle sits atop a hill overlooking the Mediterranean Sea, providing a strategic vantage point for controlling the surrounding area. Throughout its history, the castle has played a significant role in various historical events, and today it is a popular tourist attraction and cultural venue in the region. {'name': 'Sohail Castle', 'native_name': 'Castillo Sohail', 'caption': 'The Sohail Castle', 'location': 'Fuengirola, Spain', 'coordinates': '{{coord |
TripletLoss with these parameters:
1{
2 "distance_metric": "TripletDistanceMetric.EUCLIDEAN",
3 "triplet_margin": 0.5
4}num_train_epochs: 1fp16: Truemulti_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: noprediction_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: 1num_train_epochs: 1max_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: 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}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_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: round_robin| Epoch | Step | Training Loss |
|---|---|---|
| 0.6105 | 500 | 0.2649 |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@misc{hermans2017defense,
2 title={In Defense of the Triplet Loss for Person Re-Identification},
3 author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
4 year={2017},
5 eprint={1703.07737},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV}
8}