Baiming123/MeSHDS
Viewer • Updated • 2.25M • 27 • 3
How to use Baiming123/Calcu_Disease_Similarity with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Baiming123/Calcu_Disease_Similarity")
sentences = [
"That is a happy person",
"That is a happy dog",
"That is a very happy person",
"Today is a sunny day"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
(2): Normalize()
)
pip install -U sentence-transformers
Then you can use the model like this:
# Load the pre-trained SBERT model
from sentence_transformers import SentenceTransformer, util
# Directly use the following code to download model from hugging face or Replace 'Baiming123/Calcu_Disease_Similarity' with the local path to run model
model = SentenceTransformer("Baiming123/Calcu_Disease_Similarity")
# Example usage
disease1 = "lung cancer"
disease2 = "pulmonary fibrosis"
def sts(sentence_a, sentence_b) -> float:
query_emb = model.encode(sentence_a)
doc_emb = model.encode(sentence_b)
[score] = util.dot_score(query_emb, doc_emb)[0].tolist()
return score
similarity = sts(disease1, disease2)
print(similarity)
This model is licensed under CC-BY-NC 4.0 International license. If you use this model, please adhere to the license requirements.
If you encounter any issues or have any questions while using the model, feel free to reach out to the author for assistance. Thank you for your support and for using this model!