使用 fastText 句子向量作为输入特征

Using fastText Sentence Vector as an Input Feature

我想使用 fastText 句子向量作为输入特征。

vector = model.get_sentence_vector('Original Sentence')

我正在尝试使用 MLP 对句子进行二元分类,并将使用上述代码生成的固定大小的特征来训练算法。这样做合理吗?

你可以取词嵌入的均值,即将句子标记化,查找所有词的嵌入,计算平均值。通过这种方式,您将获得一个 NumPy 数组,您可以将其用作您想要的任何分类器的输入。根据分类任务,先删除功能词可能会有用。

Gensim has a richer Python API than FastText itself. If you just want to quickly train a classifier, the best option is using the command line interface of FastText.