SentenceTransformer based on tonnnnnnnnnnnnn/semantic_text_sim-v1

This is a sentence-transformers model finetuned from tonnnnnnnnnnnnn/semantic_text_sim-v1 on the sample_prep_triplet dataset. It maps sentences & paragraphs to a 384-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 Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 256, 'do_lower_case': False, 'architecture': 'BertModel'})
  (1): Pooling({'word_embedding_dimension': 384, '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-transformers

Then you can load this model and run inference.

from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("tonnnnnnnnnnnnn/triplet-loss-v2")
# Run inference
sentences = [
    'Earth is under constant threat from Neighbors, invincible monsters from another dimension that destroy our way of life. At least we have the elite warriors of Border, who co-opt alien technology to fight back! Our hero Osamu Mikumo may not be the best agent, but he’ll do whatever it takes to defend life on Earth as we know it. When Osamu meets a feisty humanoid Neighbor named Yuma, everything that he thinks is right is turned on its head. Can the two natural enemies ever become friends?',
    'What is the name of a manga with a protagonist named Killing and a description about him being a monster?',
    'What is the name of the manga with the description "Earth is under constant threat from Neighbors, invincible monsters from another dimension that destroy our way of life. At least we have the elite warriors of Border, who co-opt alien technology to fight back! Our hero Osamu Mikumo may not be the best agent, but he’ll do whatever it takes to defend life on Earth as we know it. When Osamu meets a feisty humanoid Neighbor named Yuma, everything that he thinks is right is turned on its head. Can the two natural enemies ever become friends?"',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.7718, 0.9976],
#         [0.7718, 1.0000, 0.8020],
#         [0.9976, 0.8020, 1.0000]])

Evaluation

Metrics

Triplet

  • Datasets: manga-dev and wikipedia-sections-test
  • Evaluated with TripletEvaluator
Metric manga-dev wikipedia-sections-test
cosine_accuracy 0.0078 0.0078

Training Details

Training Dataset

sample_prep_triplet

  • Dataset: sample_prep_triplet at 5bea00c
  • Size: 8,100 training samples
  • Columns: anchor, positive, and negative
  • Approximate statistics based on the first 1000 samples:
    anchor positive negative
    type string string string
    details
    • min: 7 tokens
    • mean: 98.92 tokens
    • max: 241 tokens
    • min: 8 tokens
    • mean: 36.73 tokens
    • max: 234 tokens
    • min: 7 tokens
    • mean: 42.38 tokens
    • max: 234 tokens
  • Samples:
    anchor positive negative
    Special chapters for Keeper of the Pearl. What manga is based on Daily Lives of Highschool Boys? What manga has special chapters for Keeper of the Pearl?
    “I’ll wait for you,” whispers a mysterious, red-haired woman. So goes the recurring dream Jaesin Yang has had every night since the tragic massacre at the orphanage when he was a child. When he moves to the notoriously haunted Orchid Road to delve into the meaning behind his dreams, he is nearly killed by a vengeful demon on the first night. However, he is rescued by a beautiful woman named Socheon who looks just like the woman in his dreams. Together, they join forces to help innocent demons and fight against the demonic designs of Geumgwan, the lord of all demons. What is the name of the manga with the description "Yoshida Yuko was living a perfectly normal (if poverty-stricken) life, but at the age of fifteen, she suddenly sprouts demon horns and a tail! Her mother explains that she's actually a demon named Shadow Mistress Yuko, once sealed away and cursed so that her family would remain poor for generations. Now Yuko can break that very curse if she defeats Chiyoda Momo, a magical girl who goes to her school…but Momo is stronger than she is, knows how to manage magical powers, and is so freaking nice that she's actually helping Yuko out of scrapes. Yuko's too weak and uncoordinated to straight-up kill Momo, even if she wanted to, but she can't just be buddies with this generous magical girl, either–she has to break the curse on her family somehow. What's a demon girl to do?" Who is the mysterious red-haired woman in Jaesin's dream?
    Makoto Kowata is a 15 year-old witch-in-training who moves out of her parents' home in Yokohama to live with relatives in rural Aomori. She has a lot to learn about magic and living in the countryside, and she's enthusiastic to begin these new adventures. Balancing her days with both the otherworldly and the mundane, Makoto learns to cast magic spells one day and grow her own vegetables the next. With her feline familiar Chito, her nomadic sister Akane, and her cousins, Kei and Chinatsu, Makoto makes the most out of each day - whether she's making enchanted snacks, accidentally summoning a giant flock of crows or exploring ancient ruins on the back of a flying whale! What is the name of the manga with the description "Across the world, malevolent beings known as il inhabit enchanting objects to entice curious humans toward them, and in doing so they devour the heart and freely use their victims’ bodies as puppets. To combat the threat that the il pose, hunters called Syste Behards roam the land fighting their prey to keep innocent civilians safe. One such hunter is March, who has an incredible ability capable of subduing, exorcising, and defeating ils. But with a dark power sleeping inside that threatens to overwhelm the young Syste Berhard at the first sign of falling in love, can March continue to fight the il and still remain human?" What is a manga about a 15 year-old witch-in-training who moves out of her parents' home in Yokohama to live with relatives in rural Aomori?
  • Loss: TripletLoss with these parameters:
    {
        "distance_metric": "TripletDistanceMetric.EUCLIDEAN",
        "triplet_margin": 5
    }
    

Evaluation Dataset

sample_prep_triplet

  • Dataset: sample_prep_triplet at 5bea00c
  • Size: 900 evaluation samples
  • Columns: anchor, positive, and negative
  • Approximate statistics based on the first 900 samples:
    anchor positive negative
    type string string string
    details
    • min: 7 tokens
    • mean: 98.37 tokens
    • max: 256 tokens
    • min: 7 tokens
    • mean: 38.07 tokens
    • max: 231 tokens
    • min: 7 tokens
    • mean: 43.13 tokens
    • max: 231 tokens
  • Samples:
    anchor positive negative
    February 2000: Every personnel of Babylon Labs vanished within a single night. Overseer Otto of Schicksal dispatched a special task force to investigate the incident. No one realized that this mysterious event would quickly escalate to global proportions. What is the name of the manga where the protagonists go on a relaxing trip to a waterpark? What happened at Babylon Labs in February 2000?
    Before Teru’s brother died, he gave her a special cellphone connected to "Daisy", a boy who would be there to look out for her whenever she needs someone. One year later and Teru continues to send mails to the mysterious Daisy, but she still has no idea who he actually is. One day, after accidentally breaking a window at school, Teru meets the rude school janitor, Tasuku Kurosaki, who insists she work off the cost of repairing the damage. But there’s more to this grouchy caretaker than meets the eye as in reality he is the Daisy who has been watching over Teru for all this time! With no intention of letting the lonely girl know his true identity, Tasuku must attempt to help Teru without being discovered, but can he really keep up the act, and just why is he taking care of her in the first place? What is the story of Neo Venezia? What is the name of a manga about a boy who attempts to capture his mother's last days on his phone after her death?
    The story follows Giorno Giovana, the son Dio Brando had while possessing Jonathan Joestar's body, as he rises to the top of organized crime. Giorno wants to become a Gang Star in order to help make the world a better place. His mob group must first be won over to accept him and his ideals as they take on missions with their Stand abilities. The later half of the story boils down to a showdown between their group and the Boss as the Boss tries to erase anyone who knows about him. What is a manga about a high school boy who loves to cross-dress and read BL comics? What is the name of the manga that follows Giorno Giovana as he rises to the top of organized crime?
  • Loss: TripletLoss with these parameters:
    {
        "distance_metric": "TripletDistanceMetric.EUCLIDEAN",
        "triplet_margin": 5
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 64
  • per_device_eval_batch_size: 64
  • num_train_epochs: 4
  • warmup_ratio: 0.1
  • fp16: True

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 64
  • per_device_eval_batch_size: 64
  • 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.0
  • num_train_epochs: 4
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.1
  • 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
  • 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: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
  • parallelism_config: None
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • project: huggingface
  • trackio_space_id: trackio
  • 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
  • hub_revision: None
  • 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: no
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • liger_kernel_config: None
  • eval_use_gather_object: False
  • average_tokens_across_devices: True
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Epoch Step Training Loss Validation Loss manga-dev_cosine_accuracy wikipedia-sections-test_cosine_accuracy
0.7874 100 4.2272 3.9894 0.0111 -
1.5748 200 4.0211 3.9017 0.0122 -
2.3622 300 3.9273 3.8652 0.0111 -
3.1496 400 3.8888 3.8424 0.0078 -
3.9370 500 3.8619 3.8322 0.0078 -
-1 -1 - - - 0.0078

Framework Versions

  • Python: 3.10.0
  • Sentence Transformers: 5.1.2
  • Transformers: 4.57.1
  • PyTorch: 2.5.1+cu121
  • Accelerate: 1.11.0
  • Datasets: 4.4.1
  • Tokenizers: 0.22.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}
}
Downloads last month
1
Safetensors
Model size
22.7M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for tonnnnnnnnnnnnn/triplet-loss-v2

Dataset used to train tonnnnnnnnnnnnn/triplet-loss-v2

Papers for tonnnnnnnnnnnnn/triplet-loss-v2

Evaluation results