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