Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
•
1908.10084
•
Published
•
12
This is a sentence-transformers model finetuned from google-bert/bert-base-cased on the csv dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False, 'architecture': 'BertModel'})
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("Jimmy-Ooi/Tyrisonase_test_model")
# Run inference
sentences = [
'NC(=S)c1cccnc1',
'Cc1ccc(C(C)C)c(OC(=O)/C=C/c2ccc(O)cc2)c1',
'C/C(=N\\NC(N)=S)c1cccc(NC(=O)C(F)(F)F)c1',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.9019, 0.8925],
# [0.9019, 1.0000, 0.9356],
# [0.8925, 0.9356, 1.0000]])
premise, hypothesis, and label| premise | hypothesis | label | |
|---|---|---|---|
| type | string | string | int |
| details |
|
|
|
| premise | hypothesis | label |
|---|---|---|
NC(=O)C@HNC(=O)OCc1cc(=O)c(O)co1 |
CNC(=S)N/N=C(\C)c1ccc(OC)cc1O |
2 |
CC/C(=N\NC(N)=S)c1ccc(C2CCCCC2)cc1 |
COc1cccc(C(=O)N2CCN(Cc3ccc(F)cc3)CC2)c1 |
2 |
O=C(O)CSc1nnc(NC(=S)Nc2cccc(C(F)(F)F)c2)s1 |
CCCCOc1cccc2c1C(=O)c1c(OCCCC)cc(CO)cc1C2=O |
0 |
SoftmaxLosspremise, hypothesis, and label| premise | hypothesis | label | |
|---|---|---|---|
| type | string | string | int |
| details |
|
|
|
| premise | hypothesis | label |
|---|---|---|
O=Cc1ccoc1 |
Cn1c2ccccc2c2cc(/C=C/C(=O)c3cccc(NC(=O)c4ccccc4F)c3)ccc21 |
2 |
COc1cc(C=O)ccc1OC(=O)CN1CCN(C)CC1 |
Oc1ccc(O)cc1 |
2 |
O=C(c1cccc(N+[O-])c1)N1CCN(Cc2ccc(F)cc2)CC1 |
CNC(=S)N/N=C(\C)c1ccc(OC)cc1O |
2 |
SoftmaxLoss@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
google-bert/bert-base-cased