2
$\begingroup$

I have a list of sentences and a 10 dimensional embedding for each of the sentence. I am trying to visualize these embeddings so that i can see if several sentence embeddings form a cluster such that these have similar embeddings which in turn mean similar context's. How can i do this in python? Also, i am wondering if there's any good metric or method using which i can form cluster's or calculate similarity between sentences that can tell me how close two sentences are?

$\endgroup$

1 Answer 1

2
$\begingroup$

One method to visualize high-dimensional data in lower dimensions is t-sne, which has a python implementation in scikit-learn (here)

To calculate similarity between two sentences, having their embeddings, its common to use the cosine similarity

$\endgroup$
2
  • $\begingroup$ So, i should just calculate cosine of every pair? $\endgroup$
    – rawwar
    Commented Feb 29, 2020 at 20:21
  • 1
    $\begingroup$ For clustering, depending on the algorithm and the implementation, you might be able to specify the metric directly. For instance, DBSCAN from scikit-learn, scikit-learn.org/stable/modules/generated/…, allows you to specify the cosine similarity via the 'metric' argument. $\endgroup$ Commented Feb 29, 2020 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.