đ DeCLUTR-sci-base
A sentence encoder model, especially suitable for scientific text, based on extended pretraining of scibert_scivocab_uncased with self - supervised learning strategy.
đ Quick Start
This model is designed to be used as a sentence encoder, similar to Google's Universal Sentence Encoder or Sentence Transformers. It's particularly well - suited for scientific text.
⨠Features
đĻ Installation
No specific installation steps are provided in the original README. If you want to use this model, you need to install relevant libraries such as sentence - transformers
or transformers
.
đģ Usage Examples
Basic Usage
from scipy.spatial.distance import cosine
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("johngiorgi/declutr-sci-base")
text = [
"Oncogenic KRAS mutations are common in cancer.",
"Notably, c-Raf has recently been found essential for development of K-Ras-driven NSCLCs.",
]
embeddings = model.encode(texts)
semantic_sim = 1 - cosine(embeddings[0], embeddings[1])
With đ¤ Transformers
import torch
from scipy.spatial.distance import cosine
from transformers import AutoModel, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("johngiorgi/declutr-sci-base")
model = AutoModel.from_pretrained("johngiorgi/declutr-sci-base")
text = [
"Oncogenic KRAS mutations are common in cancer.",
"Notably, c-Raf has recently been found essential for development of K-Ras-driven NSCLCs.",
]
inputs = tokenizer(text, padding=True, truncation=True, return_tensors="pt")
with torch.no_grad():
sequence_output = model(**inputs)[0]
embeddings = torch.sum(
sequence_output * inputs["attention_mask"].unsqueeze(-1), dim=1
) / torch.clamp(torch.sum(inputs["attention_mask"], dim=1, keepdims=True), min=1e-9)
semantic_sim = 1 - cosine(embeddings[0], embeddings[1])
đ Documentation
Model description
This is the allenai/scibert_scivocab_uncased model, with extended pretraining on over 2 million scientific papers from S2ORC using the self - supervised training strategy presented in DeCLUTR: Deep Contrastive Learning for Unsupervised Textual Representations.
Intended uses & limitations
The model is intended to be used as a sentence encoder, similar to Google's Universal Sentence Encoder or Sentence Transformers. It is particularly suitable for scientific text.
How to use
Please see our repo for full details.
đ License
The model is released under the apache - 2.0 license.
BibTeX entry and citation info
@inproceedings{giorgi-etal-2021-declutr,
title = {{D}e{CLUTR}: Deep Contrastive Learning for Unsupervised Textual Representations},
author = {Giorgi, John and Nitski, Osvald and Wang, Bo and Bader, Gary},
year = 2021,
month = aug,
booktitle = {Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers)},
publisher = {Association for Computational Linguistics},
address = {Online},
pages = {879--895},
doi = {10.18653/v1/2021.acl-long.72},
url = {https://aclanthology.org/2021.acl-long.72}
}
Property |
Details |
Model Type |
Sentence encoder |
Training Data |
Over 2 million scientific papers from S2ORC |