Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': True}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, '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/BAAI_bge-base-en-v1.5_retrieval_finetuned_2025-03-29_23-29-50")
5# Run inference
6sentences = [
7 'Who is the leader of the Order of the Phoenix?',
8 "Book: 7, Chapter: 2\nPassage: The only things left out of place were today's Daily Prophet, still lying on the bed, and on top of it, the piece of broken mirror. Harry moved across the room, slid the mirror fragment off today's Prophet, and unfolded the newspaper. He had merely glanced at the headline when he had taken the rolled-up paper from the delivery owl early that morning and thrown it aside, after noting that it said nothing about Voldemort. Harry was sure that the Ministry was leaning on the Prophet to suppress news about Voldemort. It was only now, therefore, that he saw what he had missed. Across the bottom half of the front page a smaller headline was set over a picture of Dumbledore striding along looking harried:\nDUMBLEDORE - THE TRUTH AT LAST? Coming next week, the shocking story of the flawed genius considered by many to be the greatest wizard of his generation. Stripping away the popular image of serene, silver-bearded wisdom, Rita Skeeter reveals the disturbed childhood, the lawless youth, the lifelong feuds, and the guilty secrets that Dumbledore carried to his grave. WHY was the man tipped to be Minister of Magic content to remain a mere headmaster? WHAT was the real purpose of the secret organization known as the Order of the Phoenix? HOW did Dumbledore really meet his end? The answers to these and many more questions are explored in the explosive new biography, The Life and Lies of Albus Dumbledore, by Rita Skeeter, exclusively interviewed by Betty Braithwaite, page 13, inside.",
9 'Book: 6, Chapter: 8\nPassage: "Really?" said Harry, taking care not to catch Ron\'s eye; the last time he had met Hagrid\'s half-brother, a vicious giant with a talent for ripping up trees by the roots, his vocabulary had comprised five words, two of which he was unable to pronounce properly. "Oh yeah, he\'s really come on," said Hagrid proudly. "Yeh\'ll be amazed. I\'m thinkin\' o\' trainin\' him up as me assistant." Ron snorted loudly, but managed to pass it off as a violent sneeze.',
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.8571 |
sentence_0, sentence_1, and sentence_2| sentence_0 | sentence_1 | sentence_2 | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| sentence_0 | sentence_1 | sentence_2 |
|---|---|---|
How does receiving the Hogwarts acceptance letter change Harry's life and reveal his true heritage? | Book: 1, Chapter: 8[object Object]Passage: "Another Weasley, eh?" said Hagrid, glancing at Ron's freckles. "I spent half me life chasin' yer twin brothers away from the forest." The rock cakes were shapeless lumps with raisins that almost broke their teeth, but Harry and Ron pretended to be enjoying them as they told Hagrid all about their first lessons. Fang rested his head on Harry's knee and drooled all over his robes. Harry and Ron were delighted to hear Hagrid call Filch "that old git''[object Object]"An' as fer that cat, Mrs. Norris, I'd like ter introduce her to Fang sometime. D'yeh know, every time I go up ter the school, she follows me everywhere? Can't get rid of her - Filch puts her up to it." | Book: 1, Chapter: 17[object Object]Passage: "But Snape always seemed to hate me so much." "Oh, he does," said Quirrell casually, "heavens, yes. He was at Hogwarts with your father, didn't you know? They loathed each other. But he never wanted you dead." "But I heard you a few days ago, sobbing - I thought Snape was threatening you. For the first time, a spasm of fear flitted across Quirrell's face. |
Who is the supposed criminal believed to be after Harry? | Book: 3, Chapter: 5[object Object]Passage: "He looks like one good hex would finish him off, doesn't he? Anyway ..." He turned to Harry. "What were you going to tell us?" Harry explained all about Mr. and Mrs. Weasley's argument and the warning Mr. Weasley had just given him. When he'd finished, Ron looked thunderstruck, and Hermione had her hands over her mouth. She finally lowered them to say, "Sirius Black escaped to come after you? Oh, Harry ... you'll have to be really, really careful. Don't go looking for trouble, Harry -"[object Object]"I don't go looking for trouble," said Harry, nettled. "Trouble usually finds me." "How thick would Harry have to be, to go looking for a nutter who wants to kill him?" | Book: 2, Chapter: 6[object Object]Passage: He was about to follow Ron and Hermione inside when Lockhart's hand shot out. "Harry! I've been wanting a word - you don't mind if he's a couple of minutes late, do you, Professor Sprout?" Judging by Professor Sprout's scowl, she did mind, but Lockhart said, "That's the ticket," and closed the greenhouse door in her face. "Harry," said Lockhart, his large white teeth gleaming in the sunlight as he shook his head. |
What is the name of the potion that allows the drinker to assume the form of someone else? | Book: 2, Chapter: 9[object Object]Passage: "What we'd need to do is to get inside the Slytherin common room and ask Malfoy a few questions without him realizing it's us." "But that's impossible," Harry said as Ron laughed. "No, it's not," said Hermione. "All we'd need would be some Polyjuice Potion." "What's that?" said Ron and Harry together. "Snape mentioned it in class a few weeks ago -"[object Object]"D'you think we've got nothing better to do in Potions than listen to Snape?" muttered Ron. | Book: 5, Chapter: 4[object Object]Passage: And she hurried off downstairs again. Harry crossed the dingy landing, turned the bedroom doorknob, which was shaped like a serpent's head, and opened the door. He caught a brief glimpse of a gloomy high-ceilinged, twin-bedded room, then there was a loud twittering noise, followed by an even louder shriek, and his vision was completely obscured by a large quantity of very bushy hair - Hermione had thrown herself onto him in a hug that nearly knocked him flat, while Ron's tiny owl, Pigwidgeon, zoomed excitedly round and round their heads. "HARRY! Ron, he's here, Harry's here! We didn't hear you arrive! Oh, how are you? Are you all right? Have you been furious with us? I bet you have, I know our letters were useless - but we couldn't tell you anything, Dumbledore made us swear we wouldn't, oh, we've got so much to tell you, and you've got to tell us - the dementors! When we heard - and that Ministry hearing - it's just outrageous, I've looked it all up, they ... |
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.8143 |
| 0.2564 | 20 | 0.8286 |
| 0.3846 | 30 | 0.8357 |
| 0.5128 | 40 | 0.8500 |
| 0.6410 | 50 | 0.8429 |
| 0.7692 | 60 | 0.8500 |
| 0.8974 | 70 | 0.8571 |
| 1.0 | 78 | 0.8571 |
| -1 | -1 | 0.8571 |
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}