You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Combining {wordsalad} and step_word_embeddings should theoretically make this (and #103 and #104) pretty straightforward to implement! If someone works on this, let me know if you need any help! I'll try to dig into it soon if nobody beats me into it.
@EmilHvitfeldt The slightly hairy part of this is that ... is already used for selectors, so we'll need to explicitly include all of the wordsalad::glove() arguments. I'm picturing those after the dots, but before the other generic step_ arguments. Sound good? If so, I'll knock these out.
Yes I kinda took a break at these issues because the total amount of parameters is going to be huge since glove is 8 and then we need a couple to handle the aggregation.
I'm thinking the best way forward might be to do something like
If you feel up for it, I think having step_glove() receive a tokenlist would be the option we have. You would need to turn the tokenlist back into strings with a non-space separator (properly use \t) to allow and then have that being fed into wordsalad::glove()
I went with "glove_embed" for the prefix so we could (for example) easily select all "_embed" predictors. I don't have a specific case where that would be necessary, but I can imagine maybe it being a thing.
Now I need to walk through the logic and figure out which functions/methods we need to write especially for this. I think we can just have the main step_glove function, which would do the glove work then call step_word_embeddings_new, I think. Does that sound right? I haven't written a step in over a year now I think, and I get a little lost in the process.
Er wait, nope, because the selector hasn't done its job until deeper in, so we won't know what to call glove with. So I think it will share some unexported functions with step_word_embeddings, but it won't call step_word_embeddings() directly. Ok, I'm getting there...
Closing this without adding a dedicated step. step_word_embeddings() already accepts any tibble of token vectors, and I checked that the output of wordsalad::glove(), word2vec() and fasttext() works with it as is. Training inside prep() would be slow, would repeat for every resample, and needs a large corpus to give useful vectors. It would also add a heavy dependency and a long list of training arguments.
For the case where you do want embeddings trained on your own text, the "Static embeddings with Model2Vec and BPEmb" vignette now has a "Training your own embeddings" section showing the workflow. It covers matching the tokenizer to step_tokenize() and avoiding leakage from assessment data. Pretrained options are covered by step_word_embeddings() and step_sentence_embeddings().
Thanks @jonthegeek for the earlier design discussion here.
Activity
jonthegeek commentedon Feb 5, 2021
Combining {wordsalad} and
step_word_embeddingsshould theoretically make this (and #103 and #104) pretty straightforward to implement! If someone works on this, let me know if you need any help! I'll try to dig into it soon if nobody beats me into it.jonthegeek commentedon Feb 5, 2021
@EmilHvitfeldt The slightly hairy part of this is that
...is already used for selectors, so we'll need to explicitly include all of thewordsalad::glove()arguments. I'm picturing those after the dots, but before the other genericstep_arguments. Sound good? If so, I'll knock these out.EmilHvitfeldt commentedon Feb 6, 2021
Yes I kinda took a break at these issues because the total amount of parameters is going to be huge since
gloveis 8 and then we need a couple to handle the aggregation.I'm thinking the best way forward might be to do something like
But on the other hand, it would be nice if we could eliminate the
tokenizerandstopwordsand have step_glove receive a tokenlist.It appears that spacing isn't going to be an issue when stopwords are removed.
Created on 2021-02-05 by the reprex package (v0.3.0)
If you feel up for it, I think having
step_glove()receive a tokenlist would be the option we have. You would need to turn the tokenlist back into strings with a non-space separator (properly use\t) to allow and then have that being fed intowordsalad::glove()jonthegeek commentedon Feb 7, 2021
That makes sense to me. This is what I'm looking at for the arguments, then:
I went with "glove_embed" for the prefix so we could (for example) easily select all "_embed" predictors. I don't have a specific case where that would be necessary, but I can imagine maybe it being a thing.
Now I need to walk through the logic and figure out which functions/methods we need to write especially for this. I think we can just have the main
step_glovefunction, which would do the glove work then callstep_word_embeddings_new, I think. Does that sound right? I haven't written a step in over a year now I think, and I get a little lost in the process.jonthegeek commentedon Feb 7, 2021
Er wait, nope, because the selector hasn't done its job until deeper in, so we won't know what to call
glovewith. So I think it will share some unexported functions withstep_word_embeddings, but it won't callstep_word_embeddings()directly. Ok, I'm getting there...EmilHvitfeldt commentedon Oct 23, 2026
Closing this without adding a dedicated step.
step_word_embeddings()already accepts any tibble of token vectors, and I checked that the output ofwordsalad::glove(),word2vec()andfasttext()works with it as is. Training insideprep()would be slow, would repeat for every resample, and needs a large corpus to give useful vectors. It would also add a heavy dependency and a long list of training arguments.For the case where you do want embeddings trained on your own text, the "Static embeddings with Model2Vec and BPEmb" vignette now has a "Training your own embeddings" section showing the workflow. It covers matching the tokenizer to
step_tokenize()and avoiding leakage from assessment data. Pretrained options are covered bystep_word_embeddings()andstep_sentence_embeddings().Thanks @jonthegeek for the earlier design discussion here.