Can Similarity Sentence Returns the Similarity Content?

Hi There,

Iā€™m a new fan of hugging face (also NLP / LLMs). All these are fresh new to me. Iā€™m trying the SentenceTransformers library these days.

I copied below SCRIPT from Semantic Textual Similarity ā€” Sentence-Transformers documentation,
the code generate embedding for sentence,I cannot get the similarity content from the page but only the cosine_scores, does anybody can give some clues how to do that? Thank you in advance.

SCRIPT:
from sentence_transformers import SentenceTransformer, util

model = SentenceTransformer(ā€˜/Users/xxx/xxx/all-MiniLM-L6-v2ā€™)

sentences = [ā€˜The cat sits outsideā€™,
ā€˜A man is playing guitarā€™,
ā€˜I love pastaā€™,
ā€˜The new movie is awesomeā€™,
ā€˜The cat plays in the gardenā€™,
ā€˜A woman watches TVā€™,
ā€˜The new movie is so greatā€™,
ā€˜Do you like pizza?ā€™]

#Compute embeddings
embeddings = model.encode(sentences, convert_to_tensor=True)

#Compute cosine-similarities for each sentence with each other sentence
cosine_scores = util.cos_sim(embeddings, embeddings)

#Find the pairs with the highest cosine similarity scores
pairs =
for i in range(len(cosine_scores)-1):
for j in range(i+1, len(cosine_scores)):
pairs.append({ā€˜indexā€™: [i, j], ā€˜scoreā€™: cosine_scores[i][j]})

#Sort scores in decreasing order
pairs = sorted(pairs, key=lambda x: x[ā€˜scoreā€™], reverse=True)

for pair in pairs[0:10]:
i, j = pair[ā€˜indexā€™]
print(ā€œ{} \t\t {} \t\t Score: {:.4f}ā€.format(sentences[i], sentences[j], pair[ā€˜scoreā€™]))
print(pair)

RESULTS:
The new movie is awesome The new movie is so great Score: 0.9286
{ā€˜indexā€™: [3, 6], ā€˜scoreā€™: tensor(0.9286)}
ā€¦ ā€¦