0
$\begingroup$

I have a use case where i need to find two similar documents. Each document has some (long) description and some metadata. I can go with TF-IDF representation but i want to take advantage of glove embedding (e.g. "woman is playing" and "man is playing" is same).

I have derived array of embedded vector for documents (firstly i converted document to padded sequences of same length, then replaced each word with corresponding embedding) & metadata vector

 ------------------------------Glove Emb-----------------------------   --metadata---
[[[-1.2555, 0.6999, ..., 0.0000], ..., [2.6958, 0.6999, ..., 0.0120]], 0, 0, 1, 2, 5]

How can i calculate consine similarity from it?

EDIT: I have glove embedded sequences for each document. i.e. vector of embedding. I don't have any idea about calculating cosine similarity from it

$\endgroup$

migrated from stackoverflow.com May 3 '18 at 12:08

This question came from our site for professional and enthusiast programmers.

0
$\begingroup$

No need to pad all the sequences to the same length. All you have to do to get a reasonable document representation is to average all the individual glove embeddings in your array. If you want to do a little bit better try doing a tf-idf weighted average of those embeddings.

$\endgroup$

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.