I have a file with word embeddings (defining word embedding as the vector representation of a word), with the following format:
a | [0.23, 0.04, ..., -0.22]
aaron | [0.21, 0.08, ..., -0.41]
... | ...
zebra | [0.97, 0.01, ..., -0.34]
This file is about 2.5 GB. I also have a large amount of sentences I want to convert into vectors, for example:
Yes sir, today is a great day.
Would you want to buy that blue shirt?
...
Is there anything else I can help you with?
My sentence embedding strategy is simple for now:
For each sentence:
For each word:
Obtain the vector representation of the word using the word embedding file.
End
Calculate the average of the word vectors of the sentence.
End
I figured that since I have a large amount of sentences I want to embed, I could use Spark for this task; storing the word embeddings as a file in the HDFS and using Spark SQL to query the sentences from a Hive table, but since each node would likely need to have access to the entire word embedding file that would imply collecting the entire word embedding RDD in each node, making communication between nodes very expensive.
Anyone has any ideas on how could this problem be efficiently solved? Please also let me know if the problem is not clear or you think I've misunderstood something about the way Spark works. I'm still learning and would really appreciate your help!
Thanks in advance.