Alessio-Borgi/all-mpnet-base-v2-margin-based-triplet-loss-finetuned-culture-5-epochs-enhanced
SentenceTransformer based on sentence-transformers/all-mpnet-base-v2
This is a sentence-transformers model finetuned from sentence-transformers/all-mpnet-base-v2. 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: sentence-transformers/all-mpnet-base-v2 <!-- at revision 12e86a3c702fc3c50205a8db88f0ec7c0b6b94a0 -->
- Maximum Sequence Length: 384 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->
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': 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()
)Usage
Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
pip install -U sentence-transformersThen you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("Alessio-Borgi/all-mpnet-base-v2-margin-based-triplet-loss-finetuned-culture-5-epochs-enhanced")
# Run inference
sentences = [
'music of Japan overview of musical traditions in Japan In Japan, music includes a wide array of distinct genres, both traditional and modern. The word for "music" in Japanese is 音楽 (ongaku), combining the kanji 音 on (sound) with the kanji 楽 gaku (music, comfort). Japan is the world\'s largest market for music on physical media and the second-largest overall music market, with a retail value of US$2.7 billion in 2017. {\'aliases\': [\'music in Japan\', \'Japanese music\', \'Japan music\']} {\'instance of\': \'music genre\', \'country of origin\': \'United States\', \'described by source\': \'Brockhaus and Efron Encyclopedic Dictionary\', \'subclass of\': \'music genre\', \'on focus list of Wikimedia project\': \'WikiProject African diaspora\', \'inception\': \'{"time": "+1990-01-01T00:00:00Z", "timezone": 0, "before": 0, "after": 0, "precision": 9, "calendarmodel": "http://www.wikidata.org/entity/Q1985727"}\'}',
'CoMix Wave Films Japanese animation studio CoMix Wave Films, Inc. (Japanese: 株式会社コミックス・ウェーブ・フィルム, Hepburn: Kabushiki-gaisha Komikkusu Uēbu Firumu) is a Japanese animation film studio and distribution company based in Chiyoda, Tokyo, Japan. The studio is known for its anime feature films, short films, and television commercials, particularly those made by director Makoto Shinkai. It was founded in March 2007 when it split from CoMix Wave Inc., which was initially formed in 1998 from Itochu Corporation, ASATSU (now ADK), and other companies. On October 15, 2024, Toho announced that they\'d acquired 45 shares or 6.09% of CoMix Wave Films. {\'name\': \'CoMix Wave Films, Inc.\', \'native_name\': \'株式会社コミックス・ウェーブ・フィルム\', \'native_name_lang\': \'ja\', \'romanized_name\': \'Kabushiki-gaisha Komikkusu Uēbu Firumu\', \'logo\': \'CoMix Wave Films logo.svg\', \'logo_size\': \'150px\', \'image_caption\': \'Headquarters in Suginami, Tokyo\', \'type\': \'Kabushiki kaisha\', \'foundation\': \'{{start date and age|2007|03}}\', \'location\': \'Ogikubo\', \'location_city\': \'Suginami, Tokyo\', \'location_country\': \'Japan\', \'key_people\': \'Noritaka Kawaguchi (CEO)<br/>Kazuki Sunama (board member)<br/>Tomohiro Tokunaga (board member)\', \'industry\': \'Motion pictures (anime)<br>TV commercials\', \'predecessor\': \'CoMix Wave Inc.\', \'assets\': \'¥95.1 million (2017)\', \'owner\': \'Toho (6.09%)\', \'products\': "Animated feature films (\'\'anime\'\'), short films, commercials", \'homepage\': \'{{URL|http://www.cwfilms.jp/}}\', \'aliases\': [\'Comix Wave Films\', \'CoMix Wave Films Inc.\', \'CoMix Wave Films, Inc.\', \'Kabushiki-gaisha Komikkusu Uēbu Firumu\']} {\'instance of\': \'animation studio\', \'industry\': \'anime industry\', \'country\': \'Japan\', \'product or material produced\': \'anime\', \'legal form\': \'kabushiki gaisha\', \'headquarters location\': \'Suginami-ku\'}',
"white label record type of vinyl record labeling A white label record is a vinyl record with white labels attached. There are several variations each with a different purpose. Variations include test pressings, white label promos, and plain white labels. {'note': 'infobox not present in Wikipedia'} {'instance of': 'type of record label', 'subclass of': 'record label', 'country': 'Germany'}",
]
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]<!--
Direct Usage (Transformers)
<details><summary>Click to see the direct usage in Transformers</summary>
</details> -->
<!--
Downstream Usage (Sentence Transformers)
You can finetune this model on your own dataset.
<details><summary>Click to expand</summary>
</details> -->
<!--
Out-of-Scope Use
List how the model may foreseeably be misused and address what users ought not to do with the model. -->
<!--
Bias, Risks and Limitations
What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->
<!--
Recommendations
What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->
Training Details
Training Dataset
Unnamed Dataset
- Size: 6,551 training samples
- Columns: <code>sentence0</code>, <code>sentence1</code>, and <code>sentence_2</code>
- Approximate statistics based on the first 1000 samples: | | sentence0 | sentence1 | sentence_2 | |:--------|:-------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------| | type | string | string | string | | details | <ul><li>min: 46 tokens</li><li>mean: 302.15 tokens</li><li>max: 384 tokens</li></ul> | <ul><li>min: 59 tokens</li><li>mean: 296.32 tokens</li><li>max: 384 tokens</li></ul> | <ul><li>min: 59 tokens</li><li>mean: 299.25 tokens</li><li>max: 384 tokens</li></ul> |
- Samples: | sentence0 | sentence1 | sentence2 | |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Carolyn Carlson American dancer Carolyn Carlson (born 7 March 1943) is an American born French nationalized contemporary dance choreographer, performer, and poet. She is of Finnish descent. She is the director of the Centre Chorégraphique National in Roubaix and of the Atelier de Paris at La Cartoucherie de Vincennes in Paris. Carlson was awarded the title of Chevalier des Arts et des Lettres of the French Republic. {'birthdate': '{{birth date and age|1943|03|07}}', 'education': 'San Francisco School of Ballet; University of Utah'} {'instance of': 'human', 'occupation': 'choreographer', 'sex or gender': 'male', 'described by source': 'Obálky knih', 'country of citizenship': 'France', 'languages spoken, written or signed': 'English', 'genre': 'opera'}</code> | <code>Palace of Versailles palace in Versailles, France and location of the Museum of the History of France The Palace of Versailles ( vair-SY, vur-SY; French: château de Versailles [ʃɑto d(ə) vɛʁsɑj] ) is a former royal residence commissioned by King Louis XIV located in Versailles, about 18 kilometres (11 mi) west of Paris, in the Yvelines Department of Île-de-France region in France. The palace is owned by the government of France and since 1995 has been managed, under the direction of the French Ministry of Culture, by the Public Establishment of the Palace, Museum and National Estate of Versailles. About 15,000,000 people visit the palace, park, or gardens of Versailles every year, making it one of the most popular tourist attractions in the world. Louis XIII built a hunting lodge at Versailles in 1623. His successor, Louis XIV, expanded the château into a palace that went through several expansions in phases from 1661 to 1715. It was a favourite residence for both kings, and in 1682, L...</code> | <code>socks and sandals wearing socks and sandals together Wearing socks and sandals together is a controversial fashion combination and social phenomenon that is discussed in various countries and cultures. In some places it is considered a fashion faux pas. {'aliases': ['socks in sandals']} {}</code> | | <code>religious nationalism relationship between national identity and religion Religious nationalism can be understood in a number of ways, such as nationalism as a religion itself, a position articulated by Carlton Hayes in his text Nationalism: A Religion, or as the relationship of nationalism to a particular religious belief, dogma, ideology, or affiliation. This relationship can be broken down into two aspects: the politicisation of religion and the influence of religion on politics. In the former aspect, a shared religion can be seen to contribute to a sense of national unity, a common bond among the citizens of the nation. Another political aspect of religion is the support of a national identity, similar to a shared ethnicity, language, or culture. The influence of religion on politics is more ideological, where current interpretations of religious ideas inspire political activism and action; for example, laws are passed to foster stricter religious adherence. Ideologically-driven re...</code> | <code>Jugo species of plant Juglans regia, known by various common names including the common walnut, English walnut, or Persian walnut amongst other names, is a species of walnut. It is native to Eurasia in at least southwest and central Asia and southeast Europe, but its exact natural area is obscure due to its long history of cultivation. The species has numerous cultivars which produce the edible walnut consumed around the world and produced predominately in China. It is widely cultivated across temperate regions throughout the world including those of Eurasia, Australia, and the Americas. {'imagecaption': 'Mature walnut tree', 'status': 'LC', 'statussystem': 'IUCN3.1', 'genus': 'Juglans', 'parent': 'Juglans sect. Juglans', 'species': 'regia', 'authority': 'L.', 'rangemap': 'Juglans regia range.svg', 'rangemapcaption': 'Distribution map', 'synonymsref': '{{citation needed|reason|=|Always supply a suitable, single citation for synonym lists|date|=|November 2018}}', 'synonyms': "''J....</code> | <code>Mococa municipality in the state of São Paulo in Brazil Mococa Portuguese pronunciation: [moˈkɔkɐ] is a municipality in the state of São Paulo in Brazil. The population is 68,980 (2020 est.) in an area of 855 km². The elevation is 645 m. The local government is made up of a mayor (in Brazil, Prefeito) and a municipal council (in Brazil, Câmara Municipal.) The current mayor is Eduardo Ribeiro Barison, from the PSD, who was elected in the 2024 municipal elections. {'officialname': 'Mococa', 'imageskyline': 'Montagem fotográfica de Mococa.jpg', 'imagesize': '200px', 'imageflag': 'Flagmococa.jpg', 'imageseal': 'Brasaomococa.jpg', 'imagemap': 'SaoPaulo Municip Mococa.svg', 'mapsize': '200px', 'subdivisiontype': 'Country', 'subdivisiontype1': 'Region', 'subdivisiontype2': 'State', 'subdivisionname': 'Brazil', 'subdivisionname1': 'Southeast', 'subdivisionname2': 'São Paulo', 'areatotalkm2': '856.39', 'populationasof': '2013', 'populationtotal': '80,629', 'timezone': 'UTC-3', '...</code> | | <code>Hyundai N high-performance brand by Hyundai Hyundai N (Korean: 현대 N) is a sub-brand of high-performance cars, engines, and related technologies established in 2012 by Hyundai. Hyundai claims the "N" refers to two elements. First, the Namyang district in South Korea, home of Hyundai's Global Research & Development Center where the brand 'N' was founded; second, the over 20 km long Nordschleife northern loop of the Nürburgring racetrack in Germany, home to Hyundai's European Technical Center and where all the 'N' models are tested - and many other brands, too. The 'N' logo was inspired by the shape of chicanes in racing circuits. The first 'N'-branded vehicle produced was the i30 N, which debuted in 2016. {'name': 'Hyundai N', 'logo': 'Hyundai N Logo.png', 'producttype': '{{ubl |Performance engines and cars |Automotive sports accessories}}', 'currentowner': 'Hyundai Motor Group', 'producedby': 'Hyundai', 'introduced': '2016', 'markets': 'Worldwide', 'website': '[https://www.hyundai-n.com...</code> | <code>Anna Sui American fashion designer Anna Sui (Chinese: 蕭志美; pinyin: Xiāo Zhìměi; born August 4, 1964) is an American fashion designer. Her brand categories include several fashion lines, footwear, cosmetics, fragrances, eyewear, jewelry, accessories and home goods. Sui was named one of the "Top 5 Fashion Icons of the Decade", and in 2009 earned the Geoffrey Beene Lifetime Achievement Award from the Council of Fashion Designers of America (CFDA), joining the ranks of Yves Saint Laurent, Giorgio Armani, Ralph Lauren, and Diane von Furstenberg. {'caption': 'Sui in 2009', 'name': 'Anna Sui', 'birthdate': '{{Birth date and age|1964|8|4}}', 'birthplace': 'Detroit, Michigan, U.S.', 'education': 'Parsons School of Design', 'label_name': '{{plainlist|\n Anna Sui\n Dolly Girl by Anna Sui|ref| name="DollyGirl"|{{cite web |url=http://www.onward.co.jp/dollygirl/ |title=Dolly Girl by Anna Sui |date=2016 |website=onward.co.jp |publisher=Onward Kashiyama Co., Ltd. |access-date=October 6, 2016 |url-...</code> | <code>speechwriter person who writes speeches that will be delivered by another person A speechwriter is a person who is hired to prepare and write speeches to be delivered by another person. Speechwriters are employed by many senior-level elected officials and executives in the government and private sectors. They can also be employed to write for weddings and other social occasions. {'note': 'infobox not present in Wikipedia'} {'subclass of': 'writer', 'instance of': 'profession', 'ISCO-88 occupation class': '2451', 'ISCO-08 occupation class': '2641', 'different from': 'playwright'}</code> |
- Loss: <code>TripletLoss</code> with these parameters:
{
"distance_metric": "TripletDistanceMetric.EUCLIDEAN",
"triplet_margin": 0.5
}Training Hyperparameters
Non-Default Hyperparameters
num_train_epochs: 5fp16: Truemulti_dataset_batch_sampler: round_robin
All Hyperparameters
<details><summary>Click to expand</summary>
overwrite_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: 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: 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: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}tp_size: 0fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': 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
</details>
Training Logs
Framework Versions
- Python: 3.11.12
- Sentence Transformers: 3.4.1
- Transformers: 4.51.3
- PyTorch: 2.6.0+cu124
- Accelerate: 1.5.2
- Datasets: 3.5.0
- Tokenizers: 0.21.1
Citation
BibTeX
Sentence Transformers
@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",
}TripletLoss
@misc{hermans2017defense,
title={In Defense of the Triplet Loss for Person Re-Identification},
author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
year={2017},
eprint={1703.07737},
archivePrefix={arXiv},
primaryClass={cs.CV}
}<!--
Glossary
Clearly define terms in order to be accessible across audiences. -->
<!--
Model Card Authors
Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->
<!--
Model Card Contact
Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->
