CoolFace
Modelpublic

Alessio-Borgi/all-mpnet-base-v2-margin-based-triplet-loss-finetuned-culture-15-epochs-enhanced

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes103downloads
Model Card

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

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:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("Alessio-Borgi/all-mpnet-base-v2-margin-based-triplet-loss-finetuned-culture-15-epochs-enhanced")
# Run inference
sentences = [
    "Intendant of Montevideo head of government of Montevideo The Intendant of Montevideo is head of the executive branch of the government of Montevideo. The Intendant serves a five-year term and is limited to two successive terms. According to the Constitution, the officeholder is elected in a direct election, which takes place on a date different from that of presidential elections. {'post': 'Intendant', 'body': 'Montevideo', 'insignia': 'Coat of arms of Montevideo Department.svg', 'insigniasize': '100px', 'native_name': '{{langx|es|Intendente de Montevideo}}', 'incumbent': 'Mauricio Zunino', 'incumbentsince': '8 July 2024', 'style': 'No courtesy, title or style', 'appointer': 'Direct election', 'termlength': '5 years (renewable)', 'formation': '19 January 1909', 'inaugural': 'Daniel Muñoz', 'website': '{{url|http://www.montevideo.gub.uy//}}', 'seat': 'City Hall of Montevideo'} {'instance of': 'human', 'sex or gender': 'male', 'occupation': 'politician', 'subclass of': 'politician', 'languages spoken, written or signed': 'English', 'different from': 'John Major', 'position held': 'member of the Chamber of Representatives of Belgium'}",
    "Bernard Archard British actor (1916-2008) Bernard Joseph Archard (20 August 1916 – 1 May 2008) was an English actor who made many film and television appearances. {'caption': 'Archard in 1962', 'name': 'Bernard Archard', 'birth_date': '{{Birth date|df|=|y|1916|08|20}}', 'birth_place': 'Fulham, London, England', 'death_date': '{{Death date and age|df|=|y|2008|5|1|1916|8|20}}', 'death_place': 'Witham Friary, Somerset, England', 'occupation': 'Actor', 'yearsactive': '1939–1994', 'domesticpartner': 'James Belchamber', 'aliases': ['Bernard Joseph Archard']} {'instance of': 'human', 'occupation': 'theatrical director', 'sex or gender': 'male', 'languages spoken, written or signed': 'Polish', 'country of citizenship': 'Poland'}",
    'department of corrections a type of government agency, found in many jurisdictions, responsible for managing prisons and parole/probation services In criminal justice, particularly in North America, correction, corrections, and correctional, are umbrella terms describing a variety of functions typically carried out by government agencies, and involving the punishment, treatment, and supervision of persons who have been convicted of crimes. These functions commonly include imprisonment, parole, and probation. A typical correctional institution is a prison. A correctional system, also known as a penal system, thus refers to a network of agencies that administer a jurisdiction\'s prisons, and community-based programs like parole, and probation boards. This system is part of the larger criminal justice system, which additionally includes police, prosecution and courts. Jurisdictions throughout Canada and the US have ministries or departments, respectively, of corrections, correctional services, or similarly-named agencies. "Corrections" is also the name of a field of academic study concerned with the theories, policies, and programs pertaining to the practice of corrections. Its object of study includes personnel training and management as well as the experiences of those on the other side of the fence — the unwilling subjects of the correctional process. Stohr and colleagues (2008) write that "Earlier scholars were more honest, calling what we now call corrections by the name penology, which means the study of punishment for crime." {\'aliases\': [\'correctional agency\', \'correctional service\']} {\'subclass of\': \'government agency\', \'described by source\': \'Small Brockhaus and Efron Encyclopedic Dictionary\', \'on focus list of Wikimedia project\': \'Wikipedia:Vital articles/Level/4\', \'different from\': \'Tribunal\'}',
]
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: 21 tokens</li><li>mean: 297.94 tokens</li><li>max: 384 tokens</li></ul> | <ul><li>min: 21 tokens</li><li>mean: 302.7 tokens</li><li>max: 384 tokens</li></ul> | <ul><li>min: 21 tokens</li><li>mean: 297.52 tokens</li><li>max: 384 tokens</li></ul> |
  • —Samples: | sentence0 | sentence1 | sentence2 | |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Hollywood Undead American rap rock band Hollywood Undead is an American rap rock band from Los Angeles, California, formed in 2005. All of the band members use pseudonyms and previously wore their own unique mask, most of which were based on the common hockey goaltender design. The band currently consists of five members: J-Dog, Funny Man, Johnny 3 Tears, Charlie Scene, and Danny. They released their debut album, Swan Songs, on September 2, 2008, and their live CD/DVD Desperate Measures, on November 10, 2009. Their second studio album, American Tragedy, was released April 5, 2011. Their third studio album, titled Notes from the Underground, was released on January 8, 2013. Their fourth studio album, Day of the Dead, was released on March 31, 2015. Hollywood Undead's fifth record is titled Five (or V), and was released on October 27, 2017. The first single from the album, called "California Dreaming", was made available July 24, 2017. Their sixth studio album, New Empire, Vol. 1, was re...</code> | <code>Oskar Fischinger German-American abstract animator, filmmaker, and painter (1900-1967) Oskar Wilhelm Fischinger (June 22, 1900 – January 31, 1967) was a German-American abstract animator, filmmaker, and painter, notable for creating abstract musical animation many decades before the appearance of computer graphics and music videos. He created special effects for Fritz Lang's 1929 Woman in the Moon, one of the first sci-fi rocket films, and influenced Disney's Fantasia. He made over 50 short films and painted around 800 canvases, many of which are in museums, galleries, and collections worldwide. Among his film works is Motion Painting No. 1 (1947), which is now listed on the National Film Registry of the U.S. Library of Congress. {'name': 'Oskar Fischinger', 'birthname': 'Oskar Wilhelm Fischinger', 'birthdate': '{{Birth date|1900|6|22|df|=|y}}', 'birthplace': 'Gelnhausen, German Empire', 'deathdate': '{{Death date and age|1967|1|31|1900|6|22|df|=|y}}', 'deathplace': 'Los Angeles, ...</code> | <code>sovereignty supreme authority within a territory, as well as external autonomy from other states Sovereignty can generally be defined as supreme authority. Sovereignty entails hierarchy within a state as well as external autonomy for states. In any state, sovereignty is assigned to the person, body or institution that has the ultimate authority over other people and to change existing laws. In political theory, sovereignty is a substantive term designating supreme legitimate authority over some polity. In international law, sovereignty is the exercise of power by a state. De jure sovereignty refers to the legal right to do so; de facto sovereignty refers to the factual ability to do so. This can become an issue of special concern upon the failure of the usual expectation that de jure and de facto sovereignty exist at the place and time of concern, and reside within the same organization. {'width': '30%'} {'subclass of': 'law', 'instance of': 'area of law', 'described by source': 'Encyc...</code> | | <code>social media and television Emerging platforms {} {'subclass of': 'television'}</code> | <code>public historian historian who fosters the general public's engagement with history Public history is a broad range of activities undertaken by people with some training in the discipline of history who are generally working outside of specialized academic settings. Public history practice is deeply rooted in the areas of historic preservation, archival science, oral history, museum curatorship, and other related fields. The field has become increasingly professionalized in the United States and Canada since the late 1970s. Some of the most common settings for the practice of public history are museums, historic homes and historic sites, parks, battlefields, archives, film and television companies, new media, and all levels of government. {'note': 'infobox not present in Wikipedia'} {'employer': 'University of Amsterdam', 'place of death': 'Luxembourg', 'instance of': 'profession', 'subclass of': 'historian'}</code> | <code>Yves Béhar Swiss designer, entrepreneur, and sustainability advocate Yves Béhar (IPA: [iv be.aʁ]; born 9 May 1967) is a Swiss-born American designer, entrepreneur, and educator. He is the founder and principal designer of Fuseproject, an industrial design and brand development firm. Béhar is also the co-founder and Chief Creative Officer of August Smart Lock, a smart lock company acquired by Assa Abloy in 2017; and co-founder of Canopy, a co-working space based in San Francisco. In 2011, the Conde Nast Innovation and Design Awards recognized Béhar as Designer of the Year. His clients have included Herman Miller, Movado, PUMA, Kodak, MINI, Western Digital, See Better to Learn Better, General Electric, Swarovski, Samsung, SNOO'S Happiest Baby Smart Bassinet, Jimmyjane, Prada and Cobalt Robotics. {'name': 'Yves Béhar', 'caption': 'Béhar in 2010', 'othernames': 'Yves Behar', 'birthdate': '{{birth date and age|1967|5|9|df|=|y}}', 'birthplace': 'Lausanne, Switzerland', 'education': 'B.S. ...</code> | | <code>Asterix and Cleopatra 1968 Belgian/French animated film Asterix and Cleopatra (French: Astérix et Cléopâtre) is a 1968 Belgian–French animated comedy film; it is the second Asterix adventure to be made into a feature film. Overseen by Asterix creators Goscinny and Uderzo (who had no involvement in the production of the first film, Asterix the Gaul and in their director debuts), the film is noticeably more well-produced than its predecessor, featuring far more detailed animation and a more polished soundtrack. Asterix and Cleopatra is practically a musical, featuring three individual song sequences and a more varied score than the earlier film. Elements of satire and surreal humour (such as Cleopatra's singing lion and the engraving of Santa Claus on the pyramid wall) are prominent throughout. {'name': 'Asterix and Cleopatra', 'nativename': 'Astérix et Cléopâtre', 'caption': 'Original release poster', 'director': 'René Goscinny<br />Albert Uderzo', 'producer': 'Raymond Leblanc', 'scree...</code> | <code>huevos rancheros Mexican breakfast dish Huevos rancheros (Spanish pronunciation: [ˈweβos ranˈtʃeɾos], 'ranch-style eggs') is a breakfast egg dish served in the style of the traditional large mid-morning fare on rural Mexican farms. {'name': 'Huevos rancheros', 'country': 'Mexico', 'course': 'Breakfast', 'main_ingredient': 'Tortillas, eggs, salsa, refried beans, avocado or guacamole'} {'instance of': 'dish', 'subclass of': 'dish', 'course': 'main course', 'has part(s)': 'meat', 'country of origin': 'Mexico', 'made from material': 'garlic'}</code> | <code>Project Hummerschere proposed project to expand Heligoland Project Hummerschere (English: Project Lobster Claw) was a construction project proposed by Nazi Germany's Kriegsmarine to expand the naval facilities on the island of Heligoland in the years leading up to World War II. Intended to create a large naval installation for operations in the North Sea, the plan involved expanding the island to its pre-1629 dimensions, restoring large areas which had been eroded by the sea. Construction was planned to more than double the usable area of both islands of Heligoland, allowing for the creation of a major naval base and Luftwaffe installation. Conceived by German Admiral Erich Raeder, the extensive project began in 1937. It was enthusiastically endorsed by Adolf Hitler, who personally inspected the construction in August 1938. After the onset of World War II the island became vulnerable to British air raids, and the project was abandoned as a result. == References == {'note': 'infobox not...</code> |
  • —Loss: <code>TripletLoss</code> with these parameters:
json
  {
      "distance_metric": "TripletDistanceMetric.EUCLIDEAN",
      "triplet_margin": 0.5
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —num_train_epochs: 15
  • —fp16: True
  • —multi_dataset_batch_sampler: round_robin
All Hyperparameters

<details><summary>Click to expand</summary>

  • —overwrite_output_dir: False
  • —do_predict: False
  • —eval_strategy: no
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 8
  • —per_device_eval_batch_size: 8
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 1
  • —eval_accumulation_steps: None
  • —torch_empty_cache_steps: None
  • —learning_rate: 5e-05
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —max_grad_norm: 1
  • —num_train_epochs: 15
  • —max_steps: -1
  • —lr_scheduler_type: linear
  • —lr_scheduler_kwargs: {}
  • —warmup_ratio: 0.0
  • —warmup_steps: 0
  • —log_level: passive
  • —log_level_replica: warning
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —save_safetensors: True
  • —save_on_each_node: False
  • —save_only_model: False
  • —restore_callback_states_from_checkpoint: False
  • —no_cuda: False
  • —use_cpu: False
  • —use_mps_device: False
  • —seed: 42
  • —data_seed: None
  • —jit_mode_eval: False
  • —use_ipex: False
  • —bf16: False
  • —fp16: True
  • —fp16_opt_level: O1
  • —half_precision_backend: auto
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: None
  • —local_rank: 0
  • —ddp_backend: None
  • —tpu_num_cores: None
  • —tpu_metrics_debug: False
  • —debug: []
  • —dataloader_drop_last: False
  • —dataloader_num_workers: 0
  • —dataloader_prefetch_factor: None
  • —past_index: -1
  • —disable_tqdm: False
  • —remove_unused_columns: True
  • —label_names: None
  • —load_best_model_at_end: False
  • —ignore_data_skip: False
  • —fsdp: []
  • —fsdp_min_num_params: 0
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —tp_size: 0
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —deepspeed: None
  • —label_smoothing_factor: 0.0
  • —optim: adamw_torch
  • —optim_args: None
  • —adafactor: False
  • —group_by_length: False
  • —length_column_name: length
  • —ddp_find_unused_parameters: None
  • —ddp_bucket_cap_mb: None
  • —ddp_broadcast_buffers: False
  • —dataloader_pin_memory: True
  • —dataloader_persistent_workers: False
  • —skip_memory_metrics: True
  • —use_legacy_prediction_loop: False
  • —push_to_hub: False
  • —resume_from_checkpoint: None
  • —hub_model_id: None
  • —hub_strategy: every_save
  • —hub_private_repo: None
  • —hub_always_push: False
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —include_inputs_for_metrics: False
  • —include_for_metrics: []
  • —eval_do_concat_batches: True
  • —fp16_backend: auto
  • —push_to_hub_model_id: None
  • —push_to_hub_organization: None
  • —mp_parameters:
  • —auto_find_batch_size: False
  • —full_determinism: False
  • —torchdynamo: None
  • —ray_scope: last
  • —ddp_timeout: 1800
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —include_tokens_per_second: False
  • —include_num_input_tokens_seen: False
  • —neftune_noise_alpha: None
  • —optim_target_modules: None
  • —batch_eval_metrics: False
  • —eval_on_start: False
  • —use_liger_kernel: False
  • —eval_use_gather_object: False
  • —average_tokens_across_devices: False
  • —prompts: None
  • —batch_sampler: batch_sampler
  • —multi_dataset_batch_sampler: round_robin

</details>

Training Logs

EpochStepTraining Loss
0.61055000.267
1.221010000.1538
1.831515000.0981
2.442020000.0675
3.052525000.0494
3.663030000.0302
4.273535000.0216
4.884040000.0141
5.494545000.0137
6.105050000.0112
6.715555000.0073
7.326060000.0059
7.936565000.0055
8.547070000.0041
9.157575000.0034
9.768080000.0015
10.378585000.002
10.989090000.0012
11.599595000.0008
12.2100100000.0008
12.8205105000.0004
13.4310110000.0002
14.0415115000.0002
14.6520120000.0001

Framework Versions

  • —Python: 3.11.12
  • —Sentence Transformers: 3.4.1
  • —Transformers: 4.51.3
  • —PyTorch: 2.6.0+cu124
  • —Accelerate: 1.6.0
  • —Datasets: 3.6.0
  • —Tokenizers: 0.21.1

Citation

BibTeX

Sentence Transformers
bibtex
@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
bibtex
@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. -->