CoolFace
Modelpublic

CatkinChen/BAAI_bge-base-en-v1.5_retrieval_finetuned_2025-03-31_20-43-41

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

SentenceTransformer based on BAAI/bge-base-en-v1.5

This is a sentence-transformers model finetuned from BAAI/bge-base-en-v1.5. 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: BAAI/bge-base-en-v1.5 <!-- at revision a5beb1e3e68b9ab74eb54cfd186867f64f240e1a -->
  • —Maximum Sequence Length: 512 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': 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()
)

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("CatkinChen/BAAI_bge-base-en-v1.5_retrieval_finetuned_2025-03-31_20-43-41")
# Run inference
sentences = [
    'What is the name of the spell that creates a mark in the sky?',
    'Book: 4, Chapter: 9\nPassage: They waited, listening to the sounds of the uneven steps behind the dark trees. But the footsteps came to a sudden halt. "Hello?" called Harry. There was silence. Harry got to his feet and peered around the tree. It was too dark to see very far, but he could sense somebody standing just beyond the range of his vision. "Who\'s there?" he said. And then, without warning, the silence was rent by a voice unlike any they had heard in the wood; and it uttered, not a panicked shout, but what sounded like a spell. "MORSMORDRE!" And something vast, green, and glittering erupted from the patch of darkness Harry\'s eyes had been struggling to penetrate; it flew up over the treetops and into the sky. "What the - ?" gasped Ron as he sprang to his feet again, staring up at the thing that had appeared.',
    'Book: 4, Chapter: 9\nPassage: The Dark Mark\'s a wizard\'s sign. It requires a wand." "Yeah," said Mr. Diggory, "and she had a wand." "What?" said Mr. Weasley.',
]
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. -->

Evaluation

Metrics

Information Retrieval
MetricValue
cosine_accuracy@10.1235
cosine_accuracy@30.1852
cosine_accuracy@50.2099
cosine_accuracy@100.3086
cosine_precision@10.1235
cosine_precision@30.0658
cosine_precision@50.0444
cosine_precision@100.0321
cosine_recall@10.1111
cosine_recall@30.1564
cosine_recall@50.1749
cosine_recall@100.2613
cosine_ndcg@100.1786
cosine_mrr@100.1661
cosine_map@1000.1552

<!--

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: 309 training samples
  • —Columns: <code>sentence0</code>, <code>sentence1</code>, and <code>sentence_2</code>
  • —Approximate statistics based on the first 309 samples: | | sentence0 | sentence1 | sentence_2 | |:--------|:----------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------| | type | string | string | string | | details | <ul><li>min: 9 tokens</li><li>mean: 17.76 tokens</li><li>max: 51 tokens</li></ul> | <ul><li>min: 46 tokens</li><li>mean: 215.37 tokens</li><li>max: 512 tokens</li></ul> | <ul><li>min: 40 tokens</li><li>mean: 207.31 tokens</li><li>max: 512 tokens</li></ul> |
  • —Samples: | sentence0 | sentence1 | sentence_2 | |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>What specific detail about a mirror in the first book, when paired with a family revelation in the fifth book, suggests a hidden bloodline connection?</code> | <code>Book: 1, Chapter: 12<br>Passage: He had seen his parents and would be seeing them again tonight. He had almost forgotten about Flamel. It didn't seem very important anymore. Who cared what the three-headed dog was guarding? What did it matter if Snape stole it, really? "Are you all right?" said Ron. "You look odd." What Harry feared most was that he might not be able to find the mirror room again. With Ron covered in the cloak, too, they had to walk much more slowly the next night. They tried retracing Harry's route from the library, wandering around the dark passageways for nearly an hour. "I'm freezing," said Ron.</code> | <code>Book: 2, Chapter: 17<br>Passage: I wondered, you see. There are strange likenesses between us, after all. Even you must have noticed. Both half-bloods, orphans, raised by Muggles. Probably the only two Parselmouths to come to Hogwarts since the great Slytherin himself. We even look something alike ... but after all, it was merely a lucky chance that saved you from me.</code> | | <code>What is the name of the broomstick Harry receives in his third year?</code> | <code>Book: 3, Chapter: 11<br>Passage: As he moved all these things aside, he saw a long, thin package lying underneath. "What's that?" said Ron, looking over, a freshly unwrapped pair of maroon socks in his hand. "Dunno ..."<br>Harry ripped the parcel open and gasped as a magnificent, gleaming broomstick rolled out onto his bedspread. Ron dropped his socks and jumped off his bed for a closer look.</code> | <code>Book: 3, Chapter: 12<br>Passage: I reckon it's time you ordered a new broom, Harry. There's an order form at the back of Which Broomstick ... you could get a Nimbus Two Thousand and One, like Malfoy's got." "I'm not buying anything Malfoy thinks is good," said Harry flatly. January faded imperceptibly into February, with no change in the bitterly cold weather. The match against Ravenclaw was drawing nearer and nearer, but Harry still hadn't ordered a new broom. He was now asking Professor McGonagall for news of the Firebolt after every Transfiguration lesson, Ron standing hopefully at his shoulder, Hermione rushing past with her face averted. "No, Potter, you can't have it back yet," Professor McGonagall told him the twelfth time this happened, before he'd even opened his mouth. "We've checked for most of the usual curses, but Professor Flitwick believes the broom might be carrying a Hurling Hex.</code> | | <code>What creature does Harry encounter in the Chamber of Secrets?</code> | <code>Book: 2, Chapter: 17<br>Passage: Harry backed away until he hit the dark Chamber wall, and as he shut his eyes tight he felt Fawkes' wing sweep his cheek as he took flight. Harry wanted to shout, "Don't leave me!" but what chance did a phoenix have against the king of serpents? Something huge hit the stone floor of the Chamber. Harry felt it shudder - he knew what was happening, he could sense it, could almost see the giant serpent uncoiling itself from Slytherin's mouth.</code> | <code>Book: 2, Chapter: 15<br>Passage: Ron fell onto his bed without bothering to get undressed. Harry, however, didn't feel very sleepy. He sat on the edge of his fourposter, thinking hard about everything Aragog had said. The creature that was lurking somewhere in the castle, he thought, sounded like a sort of monster Voldemort - even other monsters didn't want to name it. But he and Ron were no closer to finding out what it was, or how it Petrified its victims. Even Hagrid had never known what was in the Chamber of Secrets. Harry swung his legs up onto his bed and leaned back against his pillows, watching the moon glinting at him through the tower window. He couldn't see what else they could do. They had hit dead ends everywhere. Riddle had caught the wrong person, the Heir of Slytherin had got off, and no one could tell whether it was the same person, or a different one, who had opened the Chamber this time. There was nobody else to ask.</code> |
  • —Loss: <code>TripletLoss</code> with these parameters:
json
  {
      "distance_metric": "TripletDistanceMetric.COSINE",
      "triplet_margin": 0.3
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —eval_strategy: steps
  • —per_device_train_batch_size: 16
  • —per_device_eval_batch_size: 16
  • —num_train_epochs: 1
  • —multi_dataset_batch_sampler: round_robin
All Hyperparameters

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

  • —overwrite_output_dir: False
  • —do_predict: False
  • —eval_strategy: steps
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 16
  • —per_device_eval_batch_size: 16
  • —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: 1
  • —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: False
  • —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
  • —dispatch_batches: None
  • —split_batches: 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

EpochStepcosine_ndcg@10
0.5100.1678
1.0200.1786
-1-10.1786

Framework Versions

  • —Python: 3.12.2
  • —Sentence Transformers: 3.4.1
  • —Transformers: 4.50.0
  • —PyTorch: 2.4.1
  • —Accelerate: 1.4.0
  • —Datasets: 2.19.2
  • —Tokenizers: 0.21.0

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. -->