Downloads · 30 days
6
4% of all-time downloads
tonnnnnnnnnnnnn/triplet-loss-v1
triplet-loss-v1 is a sentence similarity model from tonnnnnnnnnnnnn. Use it when you need a score for how close two texts are. It is set up for sentence-transformers.
This is a sentence-transformers model finetuned from sentence-transformers/all-MiniLM-L6-v2 on the samplepreptriplet dataset. It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for…
Downloads · 30 days
6
4% of all-time downloads
All-time downloads
137
Public
Parameters
22.7M
90.9 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors90.9 MB · 99%
From the Hugging Face model README
This is a sentence-transformers model finetuned from sentence-transformers/all-MiniLM-L6-v2 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.
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()
)
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-v1")
# Run inference
sentences = [
'A spin-off about Juda and Daato raising their kids. The trickster twins take the center stage.',
'What is the name of the manga with the description "During the early years of the hottest MMORPG called Arena, the world’s top ranker Meleegod vanished after setting every possible record in the virtual world. In the real world, this deathly melee damage dealer was the happy-go-lucky Kang Hyeonu, who simply deleted his character and quit his hobby to finish mandatory military service and inherit his father’s company. This rosy future dissolves within two years when a business rival makes his father go bankrupt. Hyeonu struggles to make ends meet with a string of part-time jobs, but his best friend has a better idea. He urges Hyeonu to conquer the Arena once again and earn a cushy living as a gaming celebrity. Vowing to strike it rich and avenge his father, the former Meleegod returns to the Arena as a newbie. Only this time, he’s out for blood!"?',
'What manga is about Juda and Daato raising their kids?',
]
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.5077, 0.9839],
# [-0.5077, 1.0000, -0.5727],
# [ 0.9839, -0.5727, 1.0000]])
<!--
### 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.*
-->
manga-dev, wikipedia-sections-test, wikipedia-sections-test, wikipedia-sections-test and wikipedia-sections-test| Metric | manga-dev | wikipedia-sections-test |
|---|---|---|
| cosine_accuracy | 0.0133 | 0.0133 |
| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details | <ul><li>min: 7 tokens</li><li>mean: 100.77 tokens</li><li>max: 246 tokens</li></ul> | <ul><li>min: 7 tokens</li><li>mean: 35.69 tokens</li><li>max: 242 tokens</li></ul> | <ul><li>min: 7 tokens</li><li>mean: 44.12 tokens</li><li>max: 242 tokens</li></ul> |
| anchor | positive | negative |
|---|---|---|
| <code>Spunky mercenary mage Priscilla Mortia sets out on her final mission: to reclaim the last 15 years of her tragic life. Using a mana stone called the Dragon Heart, she travels back in time to when her family ruled over the land. While Priscilla’s goal is to reawaken her magical powers by obtaining the Dragon Heart in the past, she must survive the sinister plots of her wicked stepmother and her elderly fiance. To aid in her quest she seeks out Kian Lustin, a renowned swordsman who once captured her heart. But why does their fateful first meeting seem strangely familiar? Can Priscilla finally gain Kian's allegiance and claim her rightful seat as the heir to House Mortia?</code> | <code>What is the name of a manga about a group of boys who encounter a mysterious village full of youkai?</code> | <code>What is the name of the manga with the description "Spunky mercenary mage Priscilla Mortia sets out on her final mission: to reclaim the last 15 years of her tragic life. Using a mana stone called the Dragon Heart, she travels back in time to when her family ruled over the land. While Priscilla’s goal is to reawaken her magical powers by obtaining the Dragon Heart in the past, she must survive the sinister plots of her wicked stepmother and her elderly fiance. To aid in her quest she seeks out Kian Lustin, a renowned swordsman who once captured her heart. But why does their fateful first meeting seem strangely familiar? Can Priscilla finally gain Kian's allegiance and claim her rightful seat as the heir to House Mortia?"</code> |
| <code>Rayne woke up with no memories of the apocalypse. Samael is just... a delinquent, who happened to find Rayne at a rooftop. They both ended up making a deal in order to survive in a world where cannibalistic monsters roam.</code> | <code>What is the legendary road of immortality?</code> | <code>What manga has a protagonist named Rayne who wakes up with no memories of the apocalypse and a delinquent named Samael?</code> |
| <code>A flawless love story of the flawed. Stuttering lady Maximilian is forced into a marriage with Sir Riftan, but he leaves on a campaign after their wedding night. 3 years later, he triumphantly returns, ready to cherish her. As life with her husband finally begins, she only has one question — does she deserve this love and happiness?</code> | <code>What is the name of a manga about a 24-year-old woman who has a one-night stand with her landlady and develops a relationship with her?</code> | <code>What manga is about longing for love and marriage?</code> |
{
"distance_metric": "TripletDistanceMetric.EUCLIDEAN",
"triplet_margin": 5
}
| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details | <ul><li>min: 7 tokens</li><li>mean: 99.81 tokens</li><li>max: 256 tokens</li></ul> | <ul><li>min: 7 tokens</li><li>mean: 35.44 tokens</li><li>max: 234 tokens</li></ul> | <ul><li>min: 7 tokens</li><li>mean: 43.91 tokens</li><li>max: 228 tokens</li></ul> |
| anchor | positive | negative |
|---|---|---|
| <code>So-Mang Park wants to have a relationship at least once in her teens. But true love leading to a dreamy romantic marriage is just a crazy delusion that'll never happen. In reality, So-mang Park and the word "date" just don't belong together. Then one day a ray of hope shines upon her. Is this what flirting is? This is a story of a cheerful yet delusional girl's quest for romance.</code> | <code>What is the name of the manga set in a war-ravaged island with ex-yakuza Kazuki Taizou?</code> | <code>What is a romantic story about a young couple's first love?</code> |
| <code>As the most popular member of super idol group FLY, Yusen was soaring high until a joke goes horribly awry. Every day he’s now top of the news for some new social media disaster. Yelling at flight attendants, beating children, cursing on live TV, he tries his best but haters gonna hate and the news gonna fake. Even as the news misinterprets his every move, he refuses to quit for those fans who stand by him no matter what. Top Headline: Super Idol Yusen is off his rocker or is the pop star just misunderstood? </code> | <code>What is the name of the manga with the following description?</code> | <code>What is the latest news about Yusen from FLY?</code> |
| <code>I reincarnated as the Villainess In a novel I had read, Jubellian Eloy Floyen. I was doomed to die, but no! With the memories of my previous life, I will avoid my death flag! “I will not marry a man who has no honor, no family, no property, and no Power!” As I declared my will to live a glorious and glamorous life, my Dad decided to make the crown prince my fiancé?! Is he Mad?! I’ll just treat the engagement contract as a last measure. “Why are you avoiding your engagement with the Crown Prince?” “Because it scares me! He kills people who don’t obey him right away!” A few days later the Crown Prince sent me a letter. “Don’t worry, I won’t kill you.” Oh no….did I already do something worth dying for?</code> | <code>What is the name of a manga about an alien from Chlorodium #2 who gets used to eating human food?</code> | <code>What is the name of the manga with the description "I reincarnated as the Villainess In a novel I had read, Jubellian Eloy Floyen. I was doomed to die, but no! With the memories of my previous life, I will avoid my death flag! “I will not marry a man who has no honor, no family, no property, and no Power!” As I declared my will to live a glorious and glamorous life, my Dad decided to make the crown prince my fiancé?! Is he Mad?! I’ll just treat the engagement contract as a last measure. “Why are you avoiding your engagement with the Crown Prince?” “Because it scares me! He kills people who don’t obey him right away!” A few days later the Crown Prince sent me a letter. “Don’t worry, I won’t kill you.” Oh no….did I already do something worth dying for?"</code> |
{
"distance_metric": "TripletDistanceMetric.EUCLIDEAN",
"triplet_margin": 5
}
eval_strategy: stepsper_device_train_batch_size: 64per_device_eval_batch_size: 64num_train_epochs: 4warmup_ratio: 0.1fp16: Trueoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 64per_device_eval_batch_size: 64per_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: 4max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_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: 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}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}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_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: Falsehub_revision: Nonegradient_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: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss | manga-dev_cosine_accuracy | wikipedia-sections-test_cosine_accuracy |
|---|---|---|---|---|---|
| 0.7874 | 100 | 4.3192 | 4.0202 | 0.0178 | - |
| 1.5748 | 200 | 4.0382 | 3.9409 | 0.0211 | - |
| 2.3622 | 300 | 3.9501 | 3.9073 | 0.0178 | - |
| 3.1496 | 400 | 3.9062 | 3.8886 | 0.0144 | - |
| 3.9370 | 500 | 3.881 | 3.8774 | 0.0133 | - |
| -1 | -1 | - | - | - | 0.0133 |
@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",
}
@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.*
-->