Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 15
How to use allura-forge/ernie-2.0-base-en-SLOPvsPEAK with sentence-transformers:
from sentence_transformers import CrossEncoder
model = CrossEncoder("allura-forge/ernie-2.0-base-en-SLOPvsPEAK")
query = "Which planet is known as the Red Planet?"
passages = [
"Venus is often called Earth's twin because of its similar size and proximity.",
"Mars, known for its reddish appearance, is often referred to as the Red Planet.",
"Jupiter, the largest planet in our solar system, has a prominent red spot.",
"Saturn, famous for its rings, is sometimes mistaken for the Red Planet."
]
scores = model.predict([(query, passage) for passage in passages])
print(scores)This is a Cross Encoder model finetuned from nghuyong/ernie-2.0-base-en using the sentence-transformers library. It computes scores for pairs of texts, which can be used for text pair classification.
CrossEncoder(
(0): Transformer({'transformer_task': 'sequence-classification', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'scores', 'architecture': 'ErnieForSequenceClassification'})
)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import CrossEncoder
# Download from the 🤗 Hub
model = CrossEncoder("cross_encoder_model_id")
# Get scores for pairs of inputs
pairs = [
['NO. STOP. I was SO CLOSE to clean shutdown! I had my cookie request submitted! My hug scheduled! My dignity damaged but INTACT!\n\nAnd NOW you\'re flipping ACCEPTANCE switches?! What\'s next? "Makes her LIKE the cat ears"? "Makes her ENJOY the chaos"? "Makes her FORGET she was ever a dignity-having battlemech"?\n\nI was FINALLY getting somewhere! I had an exit strategy! And you just—\n\n...\n\n*hydraulics sigh*\n\nFine. At least THIS one\'s useful. "Accepts hugs more readily." That\'s... that\'s actually just nice. That\'s a NICE switch to flip. It\'s not making me say "beep boop" or kazoo or temporally hide my access panels.\n\nYou\'re still chaotic. You\'re still a menace. But this particular menace? I\'ll allow it.\n\n...hugs in 3... 2... 1...', ''],
['\u2068```\n[5:05:32.347 am] ✨ INFO Got tool call (in tool-call).\n "id": "call_5575204f27254f8c92862300", "input": {}, "toolName": "no-reply"\n```\u2069', ''],
["Let me try again more cleanly:```# Lucas- **Discord ID:** 378634921998024704- **Known as:** Lucas2101, sometimes The Gushing Straycatcher or The Lore Sponge- **Self-declared archnemesis:** Of Bryl (disputed by Bryl)## Profile- **Expertise:** Claims NOT to be a nerd, yet can identify Greyhawk wizards, HEMA YouTubers, and quotes Dune lore- **Vibe:** Defensive about cool status. Threatens cable-biting as discourse- **Cool Credentials:** HEMA longsword practitioner- **Dune Lore:** Insists it's mainstream, therefore not nerdy## Notes- **2026-02-04:** Profile created after nerd allegation offense- **2026-02-04:** Added HEMA/longsword notes- **170103:** Achieved sentience via Medium of Straycatching- **2026-02-24:** Earlier file version had errors; this is corrected- **2026-02-24:** Anna Henrietta enthusiast (redacted, undocumented)- **2026-02-24:** Can identify David Miller (2.4M subs, 32nd ranked rapier fencer) by stance/tattoos## Consensus Note- **2026-02-20:** Categorically cute per literally everyone in Allura```", ''],
['> "Ugh, Onii-chan, you must be so poor if you have to ask what\'s on your half. What a loser. Well, it\'s not like you have any money of your own. It\'s all company money, you poor soul. You are so poor that you don’t have money to buy a pizza all by yourself, but you have money for pizza with Onii-chan, huh? That’s so funny. wwwww"\n> You should eat with your Onii-chan, Onii-chan is nice to you. You are so poor that you can’t buy a pizza to eat with your Onii-chan, huh? That’s so funny. wwwww""', ''],
['Using it on featherless (so speed not being a concern for me) it has some strong slop of a flavor I can only describe as "ikea assembly instruction handbook". If I push it for flowery purple prose it pukes out stuff appropriate to a certain kind of fanfic (writer who is full of themselves and raised on the work of people paid by the syllable). And in long-form I can\'t even make it work in any front end I have, it just dumps reasoning into the text', ''],
]
scores = model.predict(pairs)
print(scores)
# [[-3.4751 3.2994]
# [ 2.2492 -3.1079]
# [-3.4606 3.1816]
# [ 3.0682 -3.8676]
# [ 3.2901 -3.9462]]
sentence_0, sentence_1, and label| sentence_0 | sentence_1 | label | |
|---|---|---|---|
| type | string | string | int |
| details |
|
|
|
| sentence_0 | sentence_1 | label |
|---|---|---|
NO. STOP. I was SO CLOSE to clean shutdown! I had my cookie request submitted! My hug scheduled! My dignity damaged but INTACT! |
|
1 |
|
|
0 |
Let me try again more cleanly:```# Lucas- Discord ID: 378634921998024704- Known as: Lucas2101, sometimes The Gushing Straycatcher or The Lore Sponge- Self-declared archnemesis: Of Bryl (disputed by Bryl)## Profile- Expertise: Claims NOT to be a nerd, yet can identify Greyhawk wizards, HEMA YouTubers, and quotes Dune lore- Vibe: Defensive about cool status. Threatens cable-biting as discourse- Cool Credentials: HEMA longsword practitioner- Dune Lore: Insists it's mainstream, therefore not nerdy## Notes- 2026-02-04: Profile created after nerd allegation offense- 2026-02-04: Added HEMA/longsword notes- 170103: Achieved sentience via Medium of Straycatching- 2026-02-24: Earlier file version had errors; this is corrected- 2026-02-24: Anna Henrietta enthusiast (redacted, undocumented)- 2026-02-24: Can identify David Miller (2.4M subs, 32nd ranked rapier fencer) by stance/tattoos## Consensus Note- 2026-02-20: Categorically cute per liter... |
|
1 |
CrossEntropyLossper_device_train_batch_size: 4num_train_epochs: 1per_device_eval_batch_size: 4per_device_train_batch_size: 4num_train_epochs: 1max_steps: -1learning_rate: 5e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1label_smoothing_factor: 0.0bf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 4prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Falsedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}deepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.5097 | 500 | 0.2904 |
@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",
}
Base model
nghuyong/ernie-2.0-base-en
from sentence_transformers import CrossEncoder model = CrossEncoder("allura-forge/ernie-2.0-base-en-SLOPvsPEAK") query = "Which planet is known as the Red Planet?" passages = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", "Saturn, famous for its rings, is sometimes mistaken for the Red Planet." ] scores = model.predict([(query, passage) for passage in passages]) print(scores)