How to vectorize all text with swift text?

To get the vector of a word, I can use:

model["word"]

      

but if I want to get a vector of a sentence, I need to either sum the vectors of all words, or get the average of all vectors.

Does FastText provide a method to do this?

+3


source to share


2 answers


If you want to compute vector representations of sentences or paragraphs, use:

$ ./fasttext print-sentence-vectors model.bin < text.txt



This assumes that the text.txt file contains the paragraphs for which you want vectors. The program outputs one vector representation per line in the file.

This was clearly mentioned in the README of the quick text repo. https://github.com/facebookresearch/fastText

+4


source


To get a vector for a sentence using quick text try the following command

$ echo "Your Sentence Here" | ./fasttext print-sentence-vectors model.bin

      



For an example, see Learning Word Views in Fasttext

0


source







All Articles