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$
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

| improve this answer | |
$\endgroup$
  • $\begingroup$ So, i should just calculate cosine of every pair? $\endgroup$ – InAFlash Feb 29 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$ – Alejandro Celis Feb 29 at 20:32
  • $\begingroup$ got it.. thanks $\endgroup$ – InAFlash Mar 1 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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