I found that obtaining text similarity is very slow. Are there any faster methods?

#3
by caochengchen - opened

I found that obtaining text similarity is very slow. Are there any faster methods?
from sentence_transformers import SentenceTransformer

model = SentenceTransformer("aari1995/German_Semantic_V3b", trust_remote_code=True)

sentences = [
"Ein Mann übt Boxen",
"Ein Affe praktiziert Kampfsportarten.",
"Eine Person faltet ein Blatt Papier.",
"Eine Frau geht mit ihrem Hund spazieren."
]
embeddings = model.encode(sentences)

similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)

[4, 4]

Sign up or log in to comment