Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 17
How to use ManasaKaza/knowledge-search-reranker-scifact-v1 with sentence-transformers:
from sentence_transformers import CrossEncoder
model = CrossEncoder("ManasaKaza/knowledge-search-reranker-scifact-v1")
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 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.
CrossEncoder(
(0): Transformer({'transformer_task': 'sequence-classification', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'scores', 'architecture': 'BertForSequenceClassification'})
)
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 = [
['CD28 signals regulate trafficking of murine auto-reactive T cells into target tissues.', 'CD28 and ITK signals regulate autoreactive T cell trafficking\nActivation of self-reactive T cells and their trafficking to target tissues leads to autoimmune organ destruction. Mice lacking the co-inhibitory receptor cytotoxic T lymphocyte antigen-4 (CTLA-4) develop fatal autoimmunity characterized by lymphocytic infiltration into nonlymphoid tissues. Here, we demonstrate that the CD28 co-stimulatory pathway regulates the trafficking of self-reactive Ctla4(-/-) T cells to tissues. Concurrent ablation of the CD28-activated Tec family kinase ITK does not block spontaneous T cell activation but instead causes self-reactive Ctla4(-/-) T cells to accumulate in secondary lymphoid organs. Despite excessive spontaneous T cell activation and proliferation in lymphoid organs, Itk(-/-); Ctla4(-/-) mice are otherwise healthy, mount antiviral immune responses and exhibit a long lifespan. We propose that ITK specifically licenses autoreactive T cells to enter tissues to mount destructive immune responses. Notably, ITK inhibitors mimic the null mutant phenotype and also prevent pancreatic islet infiltration by diabetogenic T cells in mouse models of type 1 diabetes, highlighting their potential utility for the treatment of human autoimmune disorders.'],
['CD28 signals regulate trafficking of murine auto-reactive T cells into target tissues.', 'RANK signals from CD4+3− inducer cells regulate development of Aire-expressing epithelial cells in the thymic medulla\nAire-expressing medullary thymic epithelial cells (mTECs) play a key role in preventing autoimmunity by expressing tissue-restricted antigens to help purge the emerging T cell receptor repertoire of self-reactive specificities. Here we demonstrate a novel role for a CD4+3− inducer cell population, previously linked to development of organized secondary lymphoid structures and maintenance of T cell memory in the functional regulation of Aire-mediated promiscuous gene expression in the thymus. CD4+3− cells are closely associated with mTECs in adult thymus, and in fetal thymus their appearance is temporally linked with the appearance of Aire+ mTECs. We show that RANKL signals from this cell promote the maturation of RANK-expressing CD80−Aire− mTEC progenitors into CD80+Aire+ mTECs, and that transplantation of RANK-deficient thymic stroma into immunodeficient hosts induces autoimmunity. Collectively, our data reveal cellular and molecular mechanisms leading to the generation of Aire+ mTECs and highlight a previously unrecognized role for CD4+3−RANKL+ inducer cells in intrathymic self-tolerance.'],
['CD28 signals regulate trafficking of murine auto-reactive T cells into target tissues.', 'Role of CD28-B7 interactions in generation and maintenance of CD8 T cell memory.\nAlthough the role of CD28-B7 interaction in the activation of naive T cells is well established, its importance in the generation and maintenance of T cell memory is not well understood. In this study, we examined the requirement for CD28-B7 interactions in primary T cell activation and immune memory. Ag-specific CD8 T cell responses were compared between wild-type (+/+) and CD28-deficient (CD28(-/-)) mice following an acute infection with lymphocytic choriomeningitis virus (LCMV). During the primary response, there was a substantial activation and expansion of LCMV-specific CD8 T cells in both +/+ and CD28(-/-) mice. However, the magnitude of the primary CD8 T cell response to both dominant and subdominant LCMV CTL epitopes was approximately 2- to 3-fold lower in CD28(-/-) mice compared with +/+ mice; the lack of CD28-mediated costimulation did not lead to preferential suppression of CD8 T cell responses to the weaker subdominant epitopes. As seen in CD28(-/-) mice, blockade of B7-mediated costimulation by CTLA4-Ig treatment of +/+ mice also resulted in a 2-fold reduction in the anti-LCMV CD8 T cell responses. Loss of CD28/B7 interactions did not significantly affect the generation and maintenance of CD8 T cell memory; the magnitude of CD8 T cell memory was approximately 2-fold lower in CD28(-/-) mice as compared with +/+ mice. Further, in CD28(-/-) mice, LCMV-specific memory CD8 T cells showed normal homeostatic proliferation in vivo and also conferred protective immunity. Therefore, CD28 signaling is not necessary for the proliferative renewal and maintenance of memory CD8 T cells.'],
['CD28 signals regulate trafficking of murine auto-reactive T cells into target tissues.', 'The role of iron in Mycobacterium smegmatis biofilm formation: the exochelin siderophore is essential in limiting iron conditions for biofilm formation but not for planktonic growth\nMany species of mycobacteria form structured biofilm communities at liquid–air interfaces and on solid surfaces. Full development of Mycobacterium smegmatis biofilms requires addition of supplemental iron above 1 μM ferrous sulphate, although addition of iron is not needed for planktonic growth. Microarray analysis of the M. smegmatis transcriptome shows that iron-responsive genes – especially those involved in siderophore synthesis and iron uptake – are strongly induced during biofilm formation reflecting a response to iron deprivation, even when 2 μM iron is present. The acquisition of iron under these conditions is specifically dependent on the exochelin synthesis and uptake pathways, and the strong defect of an iron–exochelin uptake mutant suggests a regulatory role of iron in the transition to biofilm growth. In contrast, although the expression of mycobactin and iron ABC transport operons is highly upregulated during biofilm formation, mutants in these systems form normal biofilms in low-iron (2 μM) conditions. A close correlation between iron availability and matrix-associated fatty acids implies a possible metabolic role in the late stages of biofilm maturation, in addition to the early regulatory role. M. smegmatis surface motility is similarly dependent on iron availability, requiring both supplemental iron and the exochelin pathway to acquire it.'],
['Low expression of miR7a does not repress target genes or exert a biological function in ovaries.', 'Assessing the ceRNA hypothesis with quantitative measurements of miRNA and target abundance.\nRecent studies have reported that competitive endogenous RNAs (ceRNAs) can act as sponges for a microRNA (miRNA) through their binding sites and that changes in ceRNA abundances from individual genes can modulate the activity of miRNAs. Consideration of this hypothesis would benefit from knowing the quantitative relationship between a miRNA and its endogenous target sites. Here, we altered intracellular target site abundance through expression of an miR-122 target in hepatocytes and livers and analyzed the effects on miR-122 target genes. Target repression was released in a threshold-like manner at high target site abundance (≥1.5 × 10(5) added target sites per cell), and this threshold was insensitive to the effective levels of the miRNA. Furthermore, in response to extreme metabolic liver disease models, global target site abundance of hepatocytes did not change sufficiently to affect miRNA-mediated repression. Thus, modulation of miRNA target abundance is unlikely to cause significant effects on gene expression and metabolism through a ceRNA effect.'],
]
scores = model.predict(pairs)
print(scores)
# [ 6.7873 0.742 0.3609 -5.0563 0.7686]
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'CD28 signals regulate trafficking of murine auto-reactive T cells into target tissues.',
[
'CD28 and ITK signals regulate autoreactive T cell trafficking\nActivation of self-reactive T cells and their trafficking to target tissues leads to autoimmune organ destruction. Mice lacking the co-inhibitory receptor cytotoxic T lymphocyte antigen-4 (CTLA-4) develop fatal autoimmunity characterized by lymphocytic infiltration into nonlymphoid tissues. Here, we demonstrate that the CD28 co-stimulatory pathway regulates the trafficking of self-reactive Ctla4(-/-) T cells to tissues. Concurrent ablation of the CD28-activated Tec family kinase ITK does not block spontaneous T cell activation but instead causes self-reactive Ctla4(-/-) T cells to accumulate in secondary lymphoid organs. Despite excessive spontaneous T cell activation and proliferation in lymphoid organs, Itk(-/-); Ctla4(-/-) mice are otherwise healthy, mount antiviral immune responses and exhibit a long lifespan. We propose that ITK specifically licenses autoreactive T cells to enter tissues to mount destructive immune responses. Notably, ITK inhibitors mimic the null mutant phenotype and also prevent pancreatic islet infiltration by diabetogenic T cells in mouse models of type 1 diabetes, highlighting their potential utility for the treatment of human autoimmune disorders.',
'RANK signals from CD4+3− inducer cells regulate development of Aire-expressing epithelial cells in the thymic medulla\nAire-expressing medullary thymic epithelial cells (mTECs) play a key role in preventing autoimmunity by expressing tissue-restricted antigens to help purge the emerging T cell receptor repertoire of self-reactive specificities. Here we demonstrate a novel role for a CD4+3− inducer cell population, previously linked to development of organized secondary lymphoid structures and maintenance of T cell memory in the functional regulation of Aire-mediated promiscuous gene expression in the thymus. CD4+3− cells are closely associated with mTECs in adult thymus, and in fetal thymus their appearance is temporally linked with the appearance of Aire+ mTECs. We show that RANKL signals from this cell promote the maturation of RANK-expressing CD80−Aire− mTEC progenitors into CD80+Aire+ mTECs, and that transplantation of RANK-deficient thymic stroma into immunodeficient hosts induces autoimmunity. Collectively, our data reveal cellular and molecular mechanisms leading to the generation of Aire+ mTECs and highlight a previously unrecognized role for CD4+3−RANKL+ inducer cells in intrathymic self-tolerance.',
'Role of CD28-B7 interactions in generation and maintenance of CD8 T cell memory.\nAlthough the role of CD28-B7 interaction in the activation of naive T cells is well established, its importance in the generation and maintenance of T cell memory is not well understood. In this study, we examined the requirement for CD28-B7 interactions in primary T cell activation and immune memory. Ag-specific CD8 T cell responses were compared between wild-type (+/+) and CD28-deficient (CD28(-/-)) mice following an acute infection with lymphocytic choriomeningitis virus (LCMV). During the primary response, there was a substantial activation and expansion of LCMV-specific CD8 T cells in both +/+ and CD28(-/-) mice. However, the magnitude of the primary CD8 T cell response to both dominant and subdominant LCMV CTL epitopes was approximately 2- to 3-fold lower in CD28(-/-) mice compared with +/+ mice; the lack of CD28-mediated costimulation did not lead to preferential suppression of CD8 T cell responses to the weaker subdominant epitopes. As seen in CD28(-/-) mice, blockade of B7-mediated costimulation by CTLA4-Ig treatment of +/+ mice also resulted in a 2-fold reduction in the anti-LCMV CD8 T cell responses. Loss of CD28/B7 interactions did not significantly affect the generation and maintenance of CD8 T cell memory; the magnitude of CD8 T cell memory was approximately 2-fold lower in CD28(-/-) mice as compared with +/+ mice. Further, in CD28(-/-) mice, LCMV-specific memory CD8 T cells showed normal homeostatic proliferation in vivo and also conferred protective immunity. Therefore, CD28 signaling is not necessary for the proliferative renewal and maintenance of memory CD8 T cells.',
'The role of iron in Mycobacterium smegmatis biofilm formation: the exochelin siderophore is essential in limiting iron conditions for biofilm formation but not for planktonic growth\nMany species of mycobacteria form structured biofilm communities at liquid–air interfaces and on solid surfaces. Full development of Mycobacterium smegmatis biofilms requires addition of supplemental iron above 1 μM ferrous sulphate, although addition of iron is not needed for planktonic growth. Microarray analysis of the M. smegmatis transcriptome shows that iron-responsive genes – especially those involved in siderophore synthesis and iron uptake – are strongly induced during biofilm formation reflecting a response to iron deprivation, even when 2 μM iron is present. The acquisition of iron under these conditions is specifically dependent on the exochelin synthesis and uptake pathways, and the strong defect of an iron–exochelin uptake mutant suggests a regulatory role of iron in the transition to biofilm growth. In contrast, although the expression of mycobactin and iron ABC transport operons is highly upregulated during biofilm formation, mutants in these systems form normal biofilms in low-iron (2 μM) conditions. A close correlation between iron availability and matrix-associated fatty acids implies a possible metabolic role in the late stages of biofilm maturation, in addition to the early regulatory role. M. smegmatis surface motility is similarly dependent on iron availability, requiring both supplemental iron and the exochelin pathway to acquire it.',
'Assessing the ceRNA hypothesis with quantitative measurements of miRNA and target abundance.\nRecent studies have reported that competitive endogenous RNAs (ceRNAs) can act as sponges for a microRNA (miRNA) through their binding sites and that changes in ceRNA abundances from individual genes can modulate the activity of miRNAs. Consideration of this hypothesis would benefit from knowing the quantitative relationship between a miRNA and its endogenous target sites. Here, we altered intracellular target site abundance through expression of an miR-122 target in hepatocytes and livers and analyzed the effects on miR-122 target genes. Target repression was released in a threshold-like manner at high target site abundance (≥1.5 × 10(5) added target sites per cell), and this threshold was insensitive to the effective levels of the miRNA. Furthermore, in response to extreme metabolic liver disease models, global target site abundance of hepatocytes did not change sufficiently to affect miRNA-mediated repression. Thus, modulation of miRNA target abundance is unlikely to cause significant effects on gene expression and metabolism through a ceRNA effect.',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
query, document, and label| query | document | label | |
|---|---|---|---|
| type | string | string | float |
| modality | text | text | |
| details |
|
|
|
| query | document | label |
|---|---|---|
CD28 signals regulate trafficking of murine auto-reactive T cells into target tissues. |
CD28 and ITK signals regulate autoreactive T cell trafficking |
1.0 |
CD28 signals regulate trafficking of murine auto-reactive T cells into target tissues. |
RANK signals from CD4+3− inducer cells regulate development of Aire-expressing epithelial cells in the thymic medulla |
0.0 |
CD28 signals regulate trafficking of murine auto-reactive T cells into target tissues. |
Role of CD28-B7 interactions in generation and maintenance of CD8 T cell memory. |
0.0 |
BinaryCrossEntropyLoss with these parameters:{
"activation_fn": "torch.nn.modules.linear.Identity",
"pos_weight": 3.0
}
per_device_train_batch_size: 16num_train_epochs: 1learning_rate: 2e-05warmup_steps: 0.1weight_decay: 0.01data_seed: 42per_device_train_batch_size: 16num_train_epochs: 1max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.1optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.01adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_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: 42use_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: Nonedataloader_multiprocessing_context: Nonedataloader_in_order: Trueremove_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: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}warmup_ratio: None| Epoch | Step | Training Loss |
|---|---|---|
| 0.0054 | 1 | 2.0646 |
| 0.1087 | 20 | 0.8748 |
| 0.2174 | 40 | 0.9376 |
| 0.3261 | 60 | 0.8500 |
| 0.4348 | 80 | 0.7693 |
| 0.5435 | 100 | 0.7058 |
| 0.6522 | 120 | 0.6021 |
| 0.7609 | 140 | 0.7662 |
| 0.8696 | 160 | 0.6734 |
| 0.9783 | 180 | 0.9192 |
@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
microsoft/MiniLM-L12-H384-uncased