CrossEncoder based on cross-encoder/ms-marco-MiniLM-L6-v2

This is a Cross Encoder model finetuned from cross-encoder/ms-marco-MiniLM-L6-v2 using the sentence-transformers library. It computes scores for pairs of texts, which can be used for text reranking and semantic search.

Model Details

Model Description

Model Sources

Usage

Direct Usage (Sentence Transformers)

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 texts
pairs = [
    ['vรฌ sao repository pattern ฤ‘รดi khi lร m code khรณ hiแปƒu hฦกn', 'Repository pattern cรณ thแปƒ lร m code khรณ hiแปƒu khi nรณ che giแบฅu quรก nhiแปu ฤ‘แบทc tรญnh truy vแบฅn thแบญt sแปฑ cแปงa data store, khiแบฟn ngฦฐแปi ฤ‘แปc khรดng biแบฟt ฤ‘รขu lร  thao tรกc ฤ‘ฦกn giแบฃn, ฤ‘รขu lร  query ฤ‘แบฏt tiแปn. Nแบฟu thรชm mแป™t lแป›p repository chแป‰ ฤ‘แปƒ bแปc CRUD mรกy mรณc, bแบกn cรณ thรชm abstraction nhฦฐng khรดng thรชm รฝ nghฤฉa domain. Nรณ hแปฏu รญch khi tแบกo ranh giแป›i rรต vร  test tแป‘t hฦกn, nhฦฐng phแบฃn tรกc dแปฅng nแบฟu mแปi logic query phแปฉc tแบกp lแบกi bแป‹ nhแป“i vร o interface quรก chung chung.'],
    ['vรฌ sao repository pattern ฤ‘รดi khi lร m code khรณ hiแปƒu hฦกn', 'Repository pattern lร m code khรณ hiแปƒu chแปง yแบฟu vรฌ nรณ buแป™c mแปi truy vแบฅn phแบฃi chแบกy ฤ‘แป“ng bแป™, kแปƒ cแบฃ khi database hแป— trแปฃ async. ฤiแปu nร y khiแบฟn tแบงng data access luรดn trแปŸ thร nh bottleneck vร  lแบญp trรฌnh viรชn phแบฃi lแบงn theo nhiแปu callback.'],
    ['vรฌ sao repository pattern ฤ‘รดi khi lร m code khรณ hiแปƒu hฦกn', 'Nguyรชn nhรขn lร  repository luรดn nhรขn ฤ‘รดi mรด hรฌnh dแปฏ liแป‡u: mแป™t bแบฃn trong database vร  mแป™t bแบฃn trong bแป™ nhแป› JVM hay Python. Vรฌ dแปฏ liแป‡u bแป‹ copy hai lแบงn, lแบญp trรฌnh viรชn khรณ theo dรตi object nร o lร  bแบฃn chuแบฉn.'],
    ['vรฌ sao repository pattern ฤ‘รดi khi lร m code khรณ hiแปƒu hฦกn', 'Repository thฦฐแปng ฤ‘แบกi diแป‡n cho tแบญp hแปฃp thao tรกc ฤ‘แปc ghi ฤ‘แป‘i vแป›i entity hoแบทc aggregate. Nรณ giรบp tรกch business logic khแปi chi tiแบฟt persistence nhฦฐ ORM hay SQL cแปฅ thแปƒ.'],
    ['vรฌ sao repository pattern ฤ‘รดi khi lร m code khรณ hiแปƒu hฦกn', 'Abstraction tแป‘t cแบงn cรขn bแบฑng giแปฏa che giแบฅu chi tiแบฟt vร  ฤ‘แปƒ lแป™ cรกc capability quan trแปng. Nแบฟu abstraction quรก chung, ngฦฐแปi dรนng khรณ tแบญn dแปฅng ฤ‘ฦฐแปฃc ฤ‘แบทc ฤ‘iแปƒm hแปฏu รญch cแปงa cรดng cแปฅ bรชn dฦฐแป›i.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)

# Or rank different texts based on similarity to a single text
ranks = model.rank(
    'vรฌ sao repository pattern ฤ‘รดi khi lร m code khรณ hiแปƒu hฦกn',
    [
        'Repository pattern cรณ thแปƒ lร m code khรณ hiแปƒu khi nรณ che giแบฅu quรก nhiแปu ฤ‘แบทc tรญnh truy vแบฅn thแบญt sแปฑ cแปงa data store, khiแบฟn ngฦฐแปi ฤ‘แปc khรดng biแบฟt ฤ‘รขu lร  thao tรกc ฤ‘ฦกn giแบฃn, ฤ‘รขu lร  query ฤ‘แบฏt tiแปn. Nแบฟu thรชm mแป™t lแป›p repository chแป‰ ฤ‘แปƒ bแปc CRUD mรกy mรณc, bแบกn cรณ thรชm abstraction nhฦฐng khรดng thรชm รฝ nghฤฉa domain. Nรณ hแปฏu รญch khi tแบกo ranh giแป›i rรต vร  test tแป‘t hฦกn, nhฦฐng phแบฃn tรกc dแปฅng nแบฟu mแปi logic query phแปฉc tแบกp lแบกi bแป‹ nhแป“i vร o interface quรก chung chung.',
        'Repository pattern lร m code khรณ hiแปƒu chแปง yแบฟu vรฌ nรณ buแป™c mแปi truy vแบฅn phแบฃi chแบกy ฤ‘แป“ng bแป™, kแปƒ cแบฃ khi database hแป— trแปฃ async. ฤiแปu nร y khiแบฟn tแบงng data access luรดn trแปŸ thร nh bottleneck vร  lแบญp trรฌnh viรชn phแบฃi lแบงn theo nhiแปu callback.',
        'Nguyรชn nhรขn lร  repository luรดn nhรขn ฤ‘รดi mรด hรฌnh dแปฏ liแป‡u: mแป™t bแบฃn trong database vร  mแป™t bแบฃn trong bแป™ nhแป› JVM hay Python. Vรฌ dแปฏ liแป‡u bแป‹ copy hai lแบงn, lแบญp trรฌnh viรชn khรณ theo dรตi object nร o lร  bแบฃn chuแบฉn.',
        'Repository thฦฐแปng ฤ‘แบกi diแป‡n cho tแบญp hแปฃp thao tรกc ฤ‘แปc ghi ฤ‘แป‘i vแป›i entity hoแบทc aggregate. Nรณ giรบp tรกch business logic khแปi chi tiแบฟt persistence nhฦฐ ORM hay SQL cแปฅ thแปƒ.',
        'Abstraction tแป‘t cแบงn cรขn bแบฑng giแปฏa che giแบฅu chi tiแบฟt vร  ฤ‘แปƒ lแป™ cรกc capability quan trแปng. Nแบฟu abstraction quรก chung, ngฦฐแปi dรนng khรณ tแบญn dแปฅng ฤ‘ฦฐแปฃc ฤ‘แบทc ฤ‘iแปƒm hแปฏu รญch cแปงa cรดng cแปฅ bรชn dฦฐแป›i.',
    ]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]

Training Details

Training Dataset

Unnamed Dataset

  • Size: 7,491 training samples
  • Columns: query, passage, and label
  • Approximate statistics based on the first 1000 samples:
    query passage label
    type string string float
    details
    • min: 40 characters
    • mean: 61.15 characters
    • max: 100 characters
    • min: 44 characters
    • mean: 221.44 characters
    • max: 476 characters
    • min: 0.0
    • mean: 0.2
    • max: 1.0
  • Samples:
    query passage label
    tแบกi sao Python async chแบกy nhiแปu task nhฦฐng chฦฐฦกng trรฌnh vแบซn chแบญm Async trong Python chแป‰ giรบp แบฉn thแปi gian chแป I/O, khรดng tแปฑ lร m nhanh cรกc ฤ‘oแบกn CPU-bound. Nแบฟu task cแปงa bแบกn vแบซn chแปฉa xแปญ lรฝ nแบทng nhฦฐ parse lแป›n, mรฃ hรณa hoแบทc vรฒng lแบทp tรญnh toรกn, event loop sแบฝ bแป‹ chiแบฟm vร  cรกc coroutine khรกc khรดng ฤ‘ฦฐแปฃc xen kแบฝ hแปฃp lรฝ. Cรกch xแปญ lรฝ thฦฐแปng lร  tรกch phแบงn CPU-bound sang process pool hoแบทc tแป‘i ฦฐu thuแบญt toรกn, cรฒn async chแป‰ nรชn dรนng ฤ‘แปƒ phแป‘i hแปฃp I/O concurrency. 1.0
    tแบกi sao Python async chแบกy nhiแปu task nhฦฐng chฦฐฦกng trรฌnh vแบซn chแบญm Python async thฦฐแปng chแบญm khi tแบกo quรก nhiแปu coroutine, vรฌ mแป—i coroutine tแบกo ra mแป™t thread riรชng nรชn hแป‡ ฤ‘iแปu hร nh phแบฃi chuyแปƒn ngแปฏ cแบฃnh liรชn tแปฅc. Khi giแบฃm sแป‘ coroutine, hiแป‡u nฤƒng sแบฝ gแบงn nhฦฐ luรดn tฤƒng vรฌ chi phรญ thread scheduling biแบฟn mแบฅt. 0.0
    tแบกi sao Python async chแบกy nhiแปu task nhฦฐng chฦฐฦกng trรฌnh vแบซn chแบญm Nguyรชn nhรขn chรญnh lร  await lร m task chแบกy tuแบงn tแปฑ hฦกn so vแป›i code ฤ‘แป“ng bแป™, vรฌ mแป—i lแบงn await sแบฝ chแป task trฦฐแป›c hoร n thร nh rแป“i mแป›i chuyแปƒn sang task sau. Do ฤ‘รณ trong ฤ‘a sแป‘ trฦฐแปng hแปฃp, bแป await vร  gแปi hร m trแปฑc tiแบฟp sแบฝ giรบp async nhanh hฦกn. 0.0
  • Loss: BinaryCrossEntropyLoss with these parameters:
    {
        "activation_fn": "torch.nn.modules.linear.Identity",
        "pos_weight": 4.186915874481201
    }
    

Evaluation Dataset

Unnamed Dataset

  • Size: 834 evaluation samples
  • Columns: query, passage, and label
  • Approximate statistics based on the first 834 samples:
    query passage label
    type string string float
    details
    • min: 32 characters
    • mean: 66.03 characters
    • max: 110 characters
    • min: 18 characters
    • mean: 203.76 characters
    • max: 457 characters
    • min: 0.0
    • mean: 0.19
    • max: 1.0
  • Samples:
    query passage label
    vรฌ sao repository pattern ฤ‘รดi khi lร m code khรณ hiแปƒu hฦกn Repository pattern cรณ thแปƒ lร m code khรณ hiแปƒu khi nรณ che giแบฅu quรก nhiแปu ฤ‘แบทc tรญnh truy vแบฅn thแบญt sแปฑ cแปงa data store, khiแบฟn ngฦฐแปi ฤ‘แปc khรดng biแบฟt ฤ‘รขu lร  thao tรกc ฤ‘ฦกn giแบฃn, ฤ‘รขu lร  query ฤ‘แบฏt tiแปn. Nแบฟu thรชm mแป™t lแป›p repository chแป‰ ฤ‘แปƒ bแปc CRUD mรกy mรณc, bแบกn cรณ thรชm abstraction nhฦฐng khรดng thรชm รฝ nghฤฉa domain. Nรณ hแปฏu รญch khi tแบกo ranh giแป›i rรต vร  test tแป‘t hฦกn, nhฦฐng phแบฃn tรกc dแปฅng nแบฟu mแปi logic query phแปฉc tแบกp lแบกi bแป‹ nhแป“i vร o interface quรก chung chung. 1.0
    vรฌ sao repository pattern ฤ‘รดi khi lร m code khรณ hiแปƒu hฦกn Repository pattern lร m code khรณ hiแปƒu chแปง yแบฟu vรฌ nรณ buแป™c mแปi truy vแบฅn phแบฃi chแบกy ฤ‘แป“ng bแป™, kแปƒ cแบฃ khi database hแป— trแปฃ async. ฤiแปu nร y khiแบฟn tแบงng data access luรดn trแปŸ thร nh bottleneck vร  lแบญp trรฌnh viรชn phแบฃi lแบงn theo nhiแปu callback. 0.0
    vรฌ sao repository pattern ฤ‘รดi khi lร m code khรณ hiแปƒu hฦกn Nguyรชn nhรขn lร  repository luรดn nhรขn ฤ‘รดi mรด hรฌnh dแปฏ liแป‡u: mแป™t bแบฃn trong database vร  mแป™t bแบฃn trong bแป™ nhแป› JVM hay Python. Vรฌ dแปฏ liแป‡u bแป‹ copy hai lแบงn, lแบญp trรฌnh viรชn khรณ theo dรตi object nร o lร  bแบฃn chuแบฉn. 0.0
  • Loss: BinaryCrossEntropyLoss with these parameters:
    {
        "activation_fn": "torch.nn.modules.linear.Identity",
        "pos_weight": 4.186915874481201
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_eval_batch_size: 32
  • learning_rate: 1e-05
  • weight_decay: 0.01
  • num_train_epochs: 1
  • warmup_steps: 0.1
  • bf16: True
  • dataloader_num_workers: 2
  • remove_unused_columns: False
  • load_best_model_at_end: True

All Hyperparameters

Click to expand
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 8
  • per_device_eval_batch_size: 32
  • gradient_accumulation_steps: 1
  • eval_accumulation_steps: None
  • torch_empty_cache_steps: None
  • learning_rate: 1e-05
  • weight_decay: 0.01
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1.0
  • num_train_epochs: 1
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: None
  • warmup_ratio: None
  • warmup_steps: 0.1
  • log_level: passive
  • log_level_replica: warning
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • enable_jit_checkpoint: False
  • save_on_each_node: False
  • save_only_model: False
  • restore_callback_states_from_checkpoint: False
  • use_cpu: False
  • seed: 42
  • data_seed: None
  • bf16: True
  • fp16: False
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • local_rank: -1
  • ddp_backend: None
  • debug: []
  • dataloader_drop_last: False
  • dataloader_num_workers: 2
  • dataloader_prefetch_factor: None
  • disable_tqdm: False
  • remove_unused_columns: False
  • label_names: None
  • load_best_model_at_end: True
  • ignore_data_skip: False
  • fsdp: []
  • fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
  • parallelism_config: None
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch_fused
  • optim_args: None
  • group_by_length: False
  • length_column_name: length
  • project: huggingface
  • trackio_space_id: trackio
  • 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
  • push_to_hub: False
  • resume_from_checkpoint: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_private_repo: None
  • hub_always_push: False
  • hub_revision: None
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_for_metrics: []
  • eval_do_concat_batches: True
  • auto_find_batch_size: False
  • full_determinism: False
  • ddp_timeout: 1800
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • include_num_input_tokens_seen: no
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • liger_kernel_config: None
  • eval_use_gather_object: False
  • average_tokens_across_devices: True
  • use_cache: False
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Epoch Step Training Loss Validation Loss
0.0011 1 1.9171 -
0.0534 50 1.5105 -
0.1067 100 1.2100 -
0.1601 150 0.7601 -
0.2134 200 0.4333 0.3964
0.2668 250 0.4411 -
0.3202 300 0.3237 -
0.3735 350 0.3547 -
0.4269 400 0.4869 0.2572
0.4803 450 0.4513 -
0.5336 500 0.6128 -
0.5870 550 0.6998 -
0.6403 600 0.2516 0.1479
0.6937 650 0.6151 -
0.7471 700 0.1841 -
0.8004 750 0.0197 -
0.8538 800 0.2113 0.1038
0.9072 850 0.2645 -
0.9605 900 0.2026 -
1.0 937 - 0.1042
  • The bold row denotes the saved checkpoint.

Framework Versions

  • Python: 3.12.13
  • Sentence Transformers: 5.3.0
  • Transformers: 5.0.0
  • PyTorch: 2.10.0+cu128
  • Accelerate: 1.13.0
  • Datasets: 4.8.4
  • Tokenizers: 0.22.2

Citation

BibTeX

Sentence Transformers

@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",
}
Downloads last month
4
Safetensors
Model size
22.7M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for rabit223/vi_MiniLM_v1

Paper for rabit223/vi_MiniLM_v1