Sponsored by
Designkit Free Background Remover
-Designkit offers free AI background removal for up to 100 images daily, with batch processing, custom backgrounds, and resizing.
from scipy.spatial.distance import cosine
from sentence_transformers import SentenceTransformer
# Load the model
model = SentenceTransformer("johngiorgi/declutr-sci-base")
# Prepare some text to embed
text = [
"Oncogenic KRAS mutations are common in cancer.",
"Notably, c-Raf has recently been found essential for development of K-Ras-driven NSCLCs.",
]
# Embed the text
embeddings = model.encode(texts)
# Compute a semantic similarity via the cosine distance
semantic_sim = 1 - cosine(embeddings[0], embeddings[1])
With 🤗 Transformers
import torch
from scipy.spatial.distance import cosine
from transformers import AutoModel, AutoTokenizer
# Load the model
tokenizer = AutoTokenizer.from_pretrained("johngiorgi/declutr-sci-base")
model = AutoModel.from_pretrained("johngiorgi/declutr-sci-base")
# Prepare some text to embed
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")
# Embed the textwith torch.no_grad():
sequence_output = model(**inputs)[0]
# Mean pool the token-level embeddings to get sentence-level embeddings
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)
# Compute a semantic similarity via the cosine distance
semantic_sim = 1 - cosine(embeddings[0], embeddings[1])
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}
}
Runs of johngiorgi declutr-sci-base on huggingface.co
236
Total runs
2
24-hour runs
21
3-day runs
53
7-day runs
-19
30-day runs
More Information About declutr-sci-base huggingface.co Model
declutr-sci-base huggingface.co is an AI model on huggingface.co that provides declutr-sci-base's model effect (), which can be used instantly with this johngiorgi declutr-sci-base model. huggingface.co supports a free trial of the declutr-sci-base model, and also provides paid use of the declutr-sci-base. Support call declutr-sci-base model through api, including Node.js, Python, http.
declutr-sci-base huggingface.co is an online trial and call api platform, which integrates declutr-sci-base's modeling effects, including api services, and provides a free online trial of declutr-sci-base, you can try declutr-sci-base online for free by clicking the link below.
johngiorgi declutr-sci-base online free url in huggingface.co:
declutr-sci-base is an open source model from GitHub that offers a free installation service, and any user can find declutr-sci-base on GitHub to install. At the same time, huggingface.co provides the effect of declutr-sci-base install, users can directly use declutr-sci-base installed effect in huggingface.co for debugging and trial. It also supports api for free installation.