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("CatkinChen/all-mpnet-base-v2_retrieval_finetuned_2025-03-29_23-37-00")
5# Run inference
6sentences = [
7 'Which Hogwarts house does Harry get sorted into?',
8 'Book: 1, Chapter: 7\nPassage: "Are you sure? You could be great, you know, its all here in your head, and Slytherin will help you on the way to greatness, no doubt about that - no? Well, if you\'re sure - better be GRYFFINDOR!" Harry heard the hat shout the last word to the whole hall. He took off the hat and walked shakily toward the Gryffindor table. He was so relieved to have been chosen and not put in Slytherin, he hardly noticed that he was getting the loudest cheer yet.',
9 'Book: 4, Chapter: 9\nPassage: "So," said Mr. Diggory with a kind of savage triumph, looking down upon Winky, who was still shaking convulsively. "I is not doing it!" she squealed, her eyes rolling in terror. "I is not, I is not, I is not knowing how! I is a good elf, I isn\'t using wands, I isn\'t knowing how!" "You\'ve been caught red-handed, elf!" Mr. Diggory roared.',
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]test-evalTripletEvaluator| Metric | Value |
|---|---|
| cosine_accuracy | 0.8286 |
sentence_0, sentence_1, and sentence_2| sentence_0 | sentence_1 | sentence_2 | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| sentence_0 | sentence_1 | sentence_2 |
|---|---|---|
What is the name of the spell that causes a person to be killed? | Book: 4, Chapter: 14[object Object]Passage: Hermione's hand shook slightly as, for the third time, she raised it into the air. "Yes?" said Moody, looking at her. "Avada Kedavra," Hermione whispered. Several people looked uneasily around at her, including Ron. "Ah," said Moody, another slight smile twisting his lopsided mouth. "Yes, the last and worst. Avada Kedavra ... the Killing Curse." He put his hand into the glass jar, and almost as though it knew what was coming, the third spider scuttled frantically around the bottom of the jar, trying to evade Moody's fingers, but he trapped it, and placed it upon the desktop. It started to scuttle frantically across the wooden surface. Moody raised his wand, and Harry felt a sudden thrill of foreboding. "Avada Kedavra!" Moody roared. There was a flash of blinding green light and a rushing sound, as though a vast, invisible something was soaring through the air - instantaneously the spider rolled over onto its back, unmarked, but unmistakably dead. Several o... | Book: 6, Chapter: 24[object Object]Passage: A roar of celebration erupted from the hole behind her. Harry gaped as people began to scream at the sight of him; several hands pulled him into the room. "We won!" yelled Ron, bounding into sight and brandishing the silver Cup at Harry. "We won! Four hundred and fifty to a hundred and forty! We won!" Harry looked around; there was Ginny running toward him; she had a hard, blazing look in her face as she threw her arms around him. |
Who is the first person Harry meets from the wizarding world? | Book: 1, Chapter: 4[object Object]Passage: Harry looked up at the giant. He meant to say thank you, but the words got lost on the way to his mouth, and what he said instead was, "Who are you?" The giant chuckled. "True, I haven't introduced meself. Rubeus Hagrid, Keeper of Keys and Grounds at Hogwarts." He held out an enormous hand and shook Harry's whole arm. "What about that tea then, eh?" he said, rubbing his hands together. "I'd not say no ter summat stronger if yeh've got it, mind." | Book: 2, Chapter: 17[object Object]Passage: He was standing at the end of a very long, dimly lit chamber. Towering stone pillars entwined with more carved serpents rose to support a ceiling lost in darkness, casting long, black shadows through the odd, greenish gloom that filled the place. His heart beating very fast, Harry stood listening to the chill silence. Could the basilisk be lurking in a shadowy corner, behind a pillar? And where was Ginny? He pulled out his wand and moved forward between the serpentine columns. Every careful footstep echoed loudly off the shadowy walls. He kept his eyes narrowed, ready to clamp them shut at the smallest sign of movement. The hollow eye sockets of the stone snakes seemed to be following him. More than once, with a jolt of the stomach, he thought he saw one stir. Then, as he drew level with the last pair of pillars, a statue high as the Chamber itself loomed into view, standing against the back wall. Harry had to crane his neck to look up into the giant face ... |
Who is the Half-Blood Prince? | Book: 6, Chapter: 28[object Object]Passage: Harry uttered an inarticulate yell of rage: In that instant, he cared not whether he lived or died. Pushing himself to his feet again, he staggered blindly toward Snape, the man he now hated as much as he hated Voldemort himself -[object Object]"Sectum - !" Snape flicked his wand and the curse was repelled yet again; but Harry was mere feet away now and he could see Snape's face clearly at last: He was no longer sneering or jeering; the blazing flames showed a face full of rage. Mustering all his powers of concentration, Harry thought, Levi -[object Object]"No, Potter!" screamed Snape. There was a loud BANG and Harry was soaring backward, hitting the ground hard again, and this time his wand flew out of his hand. He could hear Hagrid yelling and Fang howling as Snape closed in and looked down on him where he lay, wandless and defenseless as Dumbledore had been. Snape's pale face, illuminated by the flaming cabin, was suffused with hatred just as it had been before he had cursed Dumbl... | Book: 3, Chapter: 17[object Object]Passage: Lupin forced a laugh. "You're the cleverest witch of your age I've ever met, Hermione." "I'm not," Hermione whispered. "If I'd been a bit cleverer, I'd have told everyone what you are!" "But they already know," said Lupin. "At least, the staff do." "Dumbledore hired you when he knew you were a werewolf?" Ron gasped. "Is he mad?" "Some of the staff thought so," said Lupin. "He had to work very hard to convince certain teachers that I'm trustworthy -"[object Object]"AND HE WAS WRONG!" |
TripletLoss with these parameters:
1{
2 "distance_metric": "TripletDistanceMetric.COSINE",
3 "triplet_margin": 0.5
4}eval_strategy: stepsper_device_train_batch_size: 4per_device_eval_batch_size: 4num_train_epochs: 1multi_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 4per_device_eval_batch_size: 4per_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: Falsefp16_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: Nonedispatch_batches: Nonesplit_batches: 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 | test-eval_cosine_accuracy |
|---|---|---|
| 0.1282 | 10 | 0.8000 |
| 0.2564 | 20 | 0.8000 |
| 0.3846 | 30 | 0.8071 |
| 0.5128 | 40 | 0.8214 |
| 0.6410 | 50 | 0.8286 |
| 0.7692 | 60 | 0.8286 |
| 0.8974 | 70 | 0.8286 |
| 1.0 | 78 | 0.8286 |
| -1 | -1 | 0.8286 |
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}