########## Supervised ########## # Load the pre-trained model model = SentenceTransformer('princeton-nlp/sup-simcse-roberta-large') # Generate Embeddings sentence1_emb = model.encode(stsb_test['sentence1'], show_progress_bar=True) sentence2_emb = model.encode(stsb_test['sentence2'], show_progress_bar=True) # Cosine Similarity stsb_test['SimCSE Supervised_cosine_score'] = cos_sim(sentence1_emb, sentence2_emb) ########## Un-Supervised ########## # Load the pre-trained model model = SentenceTransformer('princeton-nlp/unsup-simcse-roberta-large') # Generate Embeddings sentence1_emb = model.encode(stsb_test['sentence1'], show_progress_bar=True) sentence2_emb = model.encode(stsb_test['sentence2'], show_progress_bar=True) # Cosine Similarity stsb_test['SimCSE Unsupervised_cosine_score'] = cos_sim(sentence1_emb, sentence2_emb)