Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 17
How to use istt-aiml-data/Criminal-Qwen3-Reranker-0.6Bov with sentence-transformers:
from sentence_transformers import CrossEncoder
model = CrossEncoder("istt-aiml-data/Criminal-Qwen3-Reranker-0.6Bov")
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 Qwen/Qwen3-Reranker-0.6B using the sentence-transformers library. It computes scores for pairs of texts, which can be used for text reranking and semantic search.
CrossEncoder(
(0): Transformer({'transformer_task': 'text-generation', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}, 'message': {'method': 'forward', 'method_output_name': 'logits', 'format': 'flat'}}, 'module_output_name': 'causal_logits', 'architecture': 'Qwen3ForCausalLM'})
(1): LogitScore({'true_token_id': 9693, 'false_token_id': 2152, 'module_input_name': 'causal_logits'})
)
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("istt-aiml-data/Criminal-Qwen3-Reranker-0.6Bov")
# Get scores for pairs of inputs
pairs = [
['nghe bảo bên đức lúc trước em ở thì mua coca thì có mà bán nhà để chÆ¡i kk', 'Trong ngữ cảnh nà y, "coca" chỉ cocaine, má»™t loại ma túy gây nghiện kÃch thÃch hệ thần kinh trung ương.'],
['Mà bên mỹ hay chÆ¡i coca mà ', 'Trong ngữ cảnh nà y, "coca" chỉ cocaine, má»™t loại ma túy gây nghiện kÃch thÃch hệ thần kinh trung ương.'],
['Shop hệ ke kẹo nc vui molly coca', 'Trong ngữ cảnh nà y, "coca" chỉ cocaine, má»™t loại ma túy gây nghiện kÃch thÃch hệ thần kinh trung ương.'],
['Coca chÆ¡i nó vẫn sẽ oke hÆ¡n ke', 'Trong ngữ cảnh nà y, "coca" chỉ cocaine, má»™t loại ma túy gây nghiện kÃch thÃch hệ thần kinh trung ương.'],
['Coca thấy bảo đứng đầu vì nguồn gốc tá»± nhiên vá»›i nó feee hÆ¡n à bùm', 'Trong ngữ cảnh nà y, "coca" chỉ cocaine, má»™t loại ma túy gây nghiện kÃch thÃch hệ thần kinh trung ương.'],
]
scores = model.predict(pairs)
print(scores)
# [13.25 13.1875 13.25 13.75 13.625 ]
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'nghe bảo bên đức lúc trước em ở thì mua coca thì có mà bán nhà để chơi kk',
[
'Trong ngữ cảnh nà y, "coca" chỉ cocaine, má»™t loại ma túy gây nghiện kÃch thÃch hệ thần kinh trung ương.',
'Trong ngữ cảnh nà y, "coca" chỉ cocaine, má»™t loại ma túy gây nghiện kÃch thÃch hệ thần kinh trung ương.',
'Trong ngữ cảnh nà y, "coca" chỉ cocaine, má»™t loại ma túy gây nghiện kÃch thÃch hệ thần kinh trung ương.',
'Trong ngữ cảnh nà y, "coca" chỉ cocaine, má»™t loại ma túy gây nghiện kÃch thÃch hệ thần kinh trung ương.',
'Trong ngữ cảnh nà y, "coca" chỉ cocaine, má»™t loại ma túy gây nghiện kÃch thÃch hệ thần kinh trung ương.',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
query, passage, and label| query | passage | label | |
|---|---|---|---|
| type | string | string | float |
| modality | text | text | |
| details |
|
|
|
| query | passage | label |
|---|---|---|
nghe bảo bên đức lúc trước em ở thì mua coca thì có mà bán nhà để chơi kk |
Trong ngữ cảnh nà y, "coca" chỉ cocaine, má»™t loại ma túy gây nghiện kÃch thÃch hệ thần kinh trung ương. |
1.0 |
Mà bên mỹ hay chơi coca mà |
Trong ngữ cảnh nà y, "coca" chỉ cocaine, má»™t loại ma túy gây nghiện kÃch thÃch hệ thần kinh trung ương. |
1.0 |
Shop hệ ke kẹo nc vui molly coca |
Trong ngữ cảnh nà y, "coca" chỉ cocaine, má»™t loại ma túy gây nghiện kÃch thÃch hệ thần kinh trung ương. |
1.0 |
BinaryCrossEntropyLoss with these parameters:{
"activation_fn": "torch.nn.modules.linear.Identity",
"pos_weight": null
}
num_train_epochs: 5learning_rate: 2e-05lr_scheduler_type: cosineweight_decay: 0.01gradient_accumulation_steps: 2per_device_train_batch_size: 8num_train_epochs: 5max_steps: -1learning_rate: 2e-05lr_scheduler_type: cosinelr_scheduler_kwargs: Nonewarmup_steps: 0optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.01adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 2average_tokens_across_devices: Truemax_grad_norm: 1.0label_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: 8prediction_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: Nonefsdp_config: Nonedeepspeed: 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.4255 | 10 | 0.2362 |
| 0.8511 | 20 | 0.0000 |
| 1.2553 | 30 | 0.0000 |
| 1.6809 | 40 | 0.0000 |
| 2.0851 | 50 | 0.0000 |
| 2.5106 | 60 | 0.0000 |
| 2.9362 | 70 | 0.0000 |
| 3.3404 | 80 | 0.0000 |
| 3.7660 | 90 | 0.0000 |
| 4.1702 | 100 | 0.0000 |
| 4.5957 | 110 | 0.0000 |
| 5.0 | 120 | 0.0000 |
@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",
}