Views
No views yet
pip install -U sentence-transformers1from sentence_transformers import CrossEncoder
2
3# Download from the 🤗 Hub
4model = CrossEncoder("tomaarsen/reranker-msmarco-v1.1-MiniLM-L12-H384-uncased-bce")
5# Get scores for pairs of texts
6pairs = [
7 ['is the calla lily poisonous', 'wholeblossoms.com. Even just a bite or two of the elegant calla lily can cause liver failure in pets and the mouths and tongues of humans to swell. The protein asparagine, found particularly concentrated in the roots of this plant, is poisonous, so be extra prudent with this popular cut flower. Bob Vila. Calla Lily. Even just a bite or two of the elegant calla lily can cause liver failure in pets and the mouths and tongues of humans to swell.'],
8 ['how long do you have to go to school to be a nurse practitioner', "A: To become a nurse practitioner at the quickest, you can take up the certificate of nursing which is a one year program and the shortest to get nursing education. Certificate in nursing allows students to be able to practice and have introductory level knowledge and skills in the field of nursing. A: In order to become a nurse, you must complete a 2 year associate's or 4 years bachelor's degree program in nursing. Upon graduation, you should obtain an RN certification and pursue a specialization through an accredited MSN degree program."],
9 ['what is true about atp molecule', 'Energy is usually liberated from the ATP molecule to do work in the cell by a reaction that removes one of the phosphate-oxygen groups, leaving adenosine diphosphate (ADP). When the ATP converts to ADP, the ATP is said to be spent. '],
10 ['matter ejected from lungs is called', 'sputum. mucous secretion from the lungs, bronchi, and trachea that is ejected through the mouth, in contrast to saliva, which is the secretion of the salivary glands. Called also expectoration. sputum. mucous secretion from the lungs, bronchi and trachea which is ejected through the mouth by humans but not so in animals and it is assumed that it is swallowed. sputum cup. a small—1 inch diameter—cup on a long handle for the collection of sputum from the pharynx of a large animal. sputum specime'],
11 ['average iron distances for senior golfers', 'Woods. Although is difficult to take all of these factors into consideration and determine an average distance for each club, there are charts that try. For the driver, a typical woman amateur can expect to get up to 180 yards. The 3-wood can provide 160 yards and the 5-wood 140. While there are charts that list the average distance for each golf club for women, the numbers are only averages and don’t reflect how far individuals actually hit the ball. There are many factors that influence distance, including your physical characteristics and conditions on the course.'],
12]
13scores = model.predict(pairs)
14print(scores.shape)
15# (5,)
16
17# Or rank different texts based on similarity to a single text
18ranks = model.rank(
19 'is the calla lily poisonous',
20 [
21 'wholeblossoms.com. Even just a bite or two of the elegant calla lily can cause liver failure in pets and the mouths and tongues of humans to swell. The protein asparagine, found particularly concentrated in the roots of this plant, is poisonous, so be extra prudent with this popular cut flower. Bob Vila. Calla Lily. Even just a bite or two of the elegant calla lily can cause liver failure in pets and the mouths and tongues of humans to swell.',
22 "A: To become a nurse practitioner at the quickest, you can take up the certificate of nursing which is a one year program and the shortest to get nursing education. Certificate in nursing allows students to be able to practice and have introductory level knowledge and skills in the field of nursing. A: In order to become a nurse, you must complete a 2 year associate's or 4 years bachelor's degree program in nursing. Upon graduation, you should obtain an RN certification and pursue a specialization through an accredited MSN degree program.",
23 'Energy is usually liberated from the ATP molecule to do work in the cell by a reaction that removes one of the phosphate-oxygen groups, leaving adenosine diphosphate (ADP). When the ATP converts to ADP, the ATP is said to be spent. ',
24 'sputum. mucous secretion from the lungs, bronchi, and trachea that is ejected through the mouth, in contrast to saliva, which is the secretion of the salivary glands. Called also expectoration. sputum. mucous secretion from the lungs, bronchi and trachea which is ejected through the mouth by humans but not so in animals and it is assumed that it is swallowed. sputum cup. a small—1 inch diameter—cup on a long handle for the collection of sputum from the pharynx of a large animal. sputum specime',
25 'Woods. Although is difficult to take all of these factors into consideration and determine an average distance for each club, there are charts that try. For the driver, a typical woman amateur can expect to get up to 180 yards. The 3-wood can provide 160 yards and the 5-wood 140. While there are charts that list the average distance for each golf club for women, the numbers are only averages and don’t reflect how far individuals actually hit the ball. There are many factors that influence distance, including your physical characteristics and conditions on the course.',
26 ]
27)
28# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]NanoMSMARCO_R100, NanoNFCorpus_R100 and NanoNQ_R100CrossEncoderRerankingEvaluator with these parameters:
1{
2 "at_k": 10,
3 "always_rerank_positives": true
4}| Metric | NanoMSMARCO_R100 | NanoNFCorpus_R100 | NanoNQ_R100 |
|---|---|---|---|
| map | 0.4241 (-0.0655) | 0.2867 (+0.0257) | 0.5166 (+0.0970) |
| mrr@10 | 0.4173 (-0.0602) | 0.4599 (-0.0399) | 0.5251 (+0.0984) |
| ndcg@10 | 0.5014 (-0.0390) | 0.2880 (-0.0370) | 0.5684 (+0.0678) |
NanoBEIR_R100_meanCrossEncoderNanoBEIREvaluator with these parameters:
1{
2 "dataset_names": [
3 "msmarco",
4 "nfcorpus",
5 "nq"
6 ],
7 "rerank_k": 100,
8 "at_k": 10,
9 "always_rerank_positives": true
10}| Metric | Value |
|---|---|
| map | 0.4091 (+0.0191) |
| mrr@10 | 0.4674 (-0.0006) |
| ndcg@10 | 0.4526 (-0.0027) |
query, passage, and label| query | passage | label | |
|---|---|---|---|
| type | string | string | int |
| details |
|
|
|
| query | passage | label |
|---|---|---|
is a meal allowance taxable | 1 An exemption applies of up to three months for meal payments if the employee is required to work away from their normal work location because they're travelling on business. 2 This may be for a specific short-term, work-related journey or for a longer period such as a secondment to a distant work location. The rules also don't apply in the case where fringe benefit tax (FBT) is payable on meals directly provided by the employer such as a discount in the work canteen. The rules that limit employers' deductions of entertainment expenses also continue to apply. | 0 |
average temperature may alaska | Precipitation [edit]. Juneau averages over 50 inches (1,270 mm) of precipitation a year, while some other areas in southeast Alaska receive as much as 275 inches (6,980 mm). Average monthly precipitation generally peaks in September or October, and is lowest in May and June. | 0 |
asic registered fixed and floating charge | Fixed and Floating Charge. Definition: A fixed and floating charge is a form of security interest usually taken by a lender from a company to secure repayment of a loan. The company granting the charge is usually referred to as the Chargor and the person in whose favour the charge is granted is typically called the Chargee . This form of security is called fixed and floating because the chargee has: The true ingenuity of the fixed and floating charge is that it permits the chargor to deal with and sell their stock etc in the ordinary course of business without requiring consent from the chargor. | 0 |
BinaryCrossEntropyLoss with these parameters:
1{
2 "activation_fct": "torch.nn.modules.linear.Identity",
3 "pos_weight": null
4}query, passage, and label| query | passage | label | |
|---|---|---|---|
| type | string | string | int |
| details |
|
|
|
| query | passage | label |
|---|---|---|
is the calla lily poisonous | wholeblossoms.com. Even just a bite or two of the elegant calla lily can cause liver failure in pets and the mouths and tongues of humans to swell. The protein asparagine, found particularly concentrated in the roots of this plant, is poisonous, so be extra prudent with this popular cut flower. Bob Vila. Calla Lily. Even just a bite or two of the elegant calla lily can cause liver failure in pets and the mouths and tongues of humans to swell. | 1 |
how long do you have to go to school to be a nurse practitioner | A: To become a nurse practitioner at the quickest, you can take up the certificate of nursing which is a one year program and the shortest to get nursing education. Certificate in nursing allows students to be able to practice and have introductory level knowledge and skills in the field of nursing. A: In order to become a nurse, you must complete a 2 year associate's or 4 years bachelor's degree program in nursing. Upon graduation, you should obtain an RN certification and pursue a specialization through an accredited MSN degree program. | 0 |
what is true about atp molecule | Energy is usually liberated from the ATP molecule to do work in the cell by a reaction that removes one of the phosphate-oxygen groups, leaving adenosine diphosphate (ADP). When the ATP converts to ADP, the ATP is said to be spent. | 0 |
BinaryCrossEntropyLoss with these parameters:
1{
2 "activation_fct": "torch.nn.modules.linear.Identity",
3 "pos_weight": null
4}eval_strategy: stepsper_device_train_batch_size: 32per_device_eval_batch_size: 32learning_rate: 2e-05num_train_epochs: 1warmup_ratio: 0.1seed: 12bf16: Trueload_best_model_at_end: Trueoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 32per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 12data_seed: Nonejit_mode_eval: Falseuse_ipex: Falsebf16: Truefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Trueignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters:auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Nonedispatch_batches: Nonesplit_batches: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | Validation Loss | NanoMSMARCO_R100_ndcg@10 | NanoNFCorpus_R100_ndcg@10 | NanoNQ_R100_ndcg@10 | NanoBEIR_R100_mean_ndcg@10 |
|---|---|---|---|---|---|---|---|
| -1 | -1 | - | - | 0.0357 (-0.5047) | 0.2806 (-0.0444) | 0.0527 (-0.4479) | 0.1230 (-0.3323) |
| 0.0000 | 1 | 0.6838 | - | - | - | - | - |
| 0.0480 | 1000 | 0.4514 | - | - | - | - | - |
| 0.0961 | 2000 | 0.385 | - | - | - | - | - |
| 0.1441 | 3000 | 0.3892 | - | - | - | - | - |
| 0.1921 | 4000 | 0.3819 | 0.3777 | 0.2751 (-0.2653) | 0.2555 (-0.0696) | 0.2689 (-0.2318) | 0.2665 (-0.1889) |
| 0.2402 | 5000 | 0.3694 | - | - | - | - | - |
| 0.2882 | 6000 | 0.3641 | - | - | - | - | - |
| 0.3362 | 7000 | 0.3679 | - | - | - | - | - |
| 0.3843 | 8000 | 0.3674 | 0.3566 | 0.4745 (-0.0660) | 0.2459 (-0.0792) | 0.4967 (-0.0040) | 0.4057 (-0.0497) |
| 0.4323 | 9000 | 0.3677 | - | - | - | - | - |
| 0.4803 | 10000 | 0.3606 | - | - | - | - | - |
| 0.5284 | 11000 | 0.3651 | - | - | - | - | - |
| 0.5764 | 12000 | 0.3586 | 0.3556 | 0.4666 (-0.0738) | 0.2720 (-0.0531) | 0.5513 (+0.0506) | 0.4300 (-0.0254) |
| 0.6244 | 13000 | 0.3535 | - | - | - | - | - |
| 0.6725 | 14000 | 0.3551 | - | - | - | - | - |
| 0.7205 | 15000 | 0.3552 | - | - | - | - | - |
| 0.7685 | 16000 | 0.3516 | 0.3439 | 0.5014 (-0.0390) | 0.2880 (-0.0370) | 0.5684 (+0.0678) | 0.4526 (-0.0027) |
| 0.8166 | 17000 | 0.3486 | - | - | - | - | - |
| 0.8646 | 18000 | 0.3528 | - | - | - | - | - |
| 0.9126 | 19000 | 0.3526 | - | - | - | - | - |
| 0.9607 | 20000 | 0.3415 | 0.3423 | 0.4898 (-0.0507) | 0.2794 (-0.0457) | 0.5792 (+0.0785) | 0.4494 (-0.0059) |
| -1 | -1 | - | - | 0.5014 (-0.0390) | 0.2880 (-0.0370) | 0.5684 (+0.0678) | 0.4526 (-0.0027) |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}