Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBOW model equivalent to the supervised learning model of fastText #960

Open
giacbrd opened this issue Oct 19, 2016 · 8 comments
Open

CBOW model equivalent to the supervised learning model of fastText #960

giacbrd opened this issue Oct 19, 2016 · 8 comments
Labels
difficulty medium Medium issue: required good gensim understanding & python skills feature Issue described a new feature

Comments

@giacbrd
Copy link

giacbrd commented Oct 19, 2016

fastText is an "evolution" of word2vec, it contains new models for word embeddings and models for learning the association document -> label, i.e. classification.

Implementing the latter can be obtained by reusing the Word2vec class (only for CBOW), defining an input layer of words and an output layer of labels with their specific vocabulary. The concept of windows in training can be dropped. It is possible to implement, for output computation, the softmax function, together with its already present "approximations" (negative sampling and huffman tree).

A LabeledWord2Vec class is already implemented https://github.com/giacbrd/ShallowLearn/blob/master/shallowlearn/word2vec.py , it should be ported and improved (it misses negative sampling, some methods implementation)

@tmylk
Copy link
Contributor

tmylk commented Oct 19, 2016

For completeness linking to Fasttext Wrapper #847

@giacbrd
Copy link
Author

giacbrd commented Nov 14, 2016

I am still developing the code for this PR in https://github.com/giacbrd/ShallowLearn, I hope to start working on the fork ASAP

@piskvorky
Copy link
Owner

@giacbrd any progress on the PR? Cheers.

@giacbrd
Copy link
Author

giacbrd commented Dec 13, 2016

I am going to release a more stable model on my project, before Christmas, then I can port it in Gensim, it should be "easy"!
Cheers

@giacbrd
Copy link
Author

giacbrd commented Jan 25, 2017

I am finalizing the pull request. I am just thinking to design a better interface, but in general there is not much code.
Sorry but my spare time in the last two months has been minimal.
Cheers

@tmylk
Copy link
Contributor

tmylk commented Jan 25, 2017

From Gensim integration point of view, an API extending the existing FastText Wrapper API would be preferable. Though FastText wrapper API is not yet released so can be changed

@giacbrd
Copy link
Author

giacbrd commented Jan 25, 2017

Here I am doing something slightly different than re-implementing fastText. I have practically written a variant of the Word2Vec model, with the goal of learning the combinations sets_of_words->labels (i.e. text classification), where:

  • Output layer and its vocabulary is independent of the input layer
  • It is limited to CBOW
  • Given that the output layer is usually of a pre-defined size (e.g. labels in a text classification scenario), it is feasible to directly compute the softmax instead of its "approximations" (negative sampling and huffman tree). Then there are 3 loss methods

The wrapper, for now, is only for word embedding applications, but yes, it could be extended with the "supervised learning" component of fastText

@giacbrd
Copy link
Author

giacbrd commented Feb 17, 2017

See the pull request #1153

@menshikh-iv menshikh-iv added feature Issue described a new feature difficulty medium Medium issue: required good gensim understanding & python skills labels Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty medium Medium issue: required good gensim understanding & python skills feature Issue described a new feature
Projects
None yet
Development

No branches or pull requests

4 participants