-
Notifications
You must be signed in to change notification settings - Fork 722
Best practices for running a model for sentence embeddings on two different columns #14468
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
Comments
Hey @macarran, thanks for reporting this!. Are you the same guy that used to work for Intel in Cordoba? |
@albertoandreottiATgmail, that is correct! Of all places to find you this is it, that's funny. |
Funny indeed, ok, being a friend of the house, I'll push for this to be taken care of. Have an awesome night! |
@albertoandreottiATgmail, @DevinTDHa hope you're well! Perhaps this would have been better suited as a I guess my question boils down to whether the approach I shared above is the recommended way to compute embeddings over two (or more) columns when utilizing the same model, or if there are any better ways I might have missed in the documentation. |
Hello Marcos, nice to hear from you again!. I think that in terms of parallelism, if your dataset is big enough, computing 1 step at a time(first the date, then the name) is good.
and then assemble back everything again with the same instances for all the other stages(don't create new ones). This will avoid keeping 2 copies of the same models in memory.
|
@albertoandreottiATgmail appreciate the response! We were observing the behavior you mention where we'd pass in the same data frame on the second pass and it'd recompute the first set of embeddings again. Heading out for PTO but I'll pass this on to our team in the meantime, very helpful. |
Glad to hear! Enjoy your vacation :) |
Link to the documentation pages (if available)
No response
How could the documentation be improved?
Hi,
I tried searching for existing documentation or discussions on how to run a model for sentence embeddings over two separate columns and did not find any. I was wondering if there are any recommendations or known gotchas on the topic. Say I have a data frame with a
name
andaddress
column, and would like to use a RoBERTa model to compute sentence embeddings for both. Best I could come up with was something as follows:And then basically doing something like this:
This appears to work, but feels... wrong? The existence of
MultiDocumentAssembler
andsetInputCols
APIs on several of the stages led me down a rabbit hole of trying out different approaches to see if I could annotate and tokenize multiple columns in one stage, but I hit a variety of issues and assertions for different components of the pipeline. For example, callingsetInputCols
onTokenizer
with an array containing more than one column results in:IllegalArgumentException: requirement failed: setInputCols in REGEX_TOKENIZER_2889f26665ad expecting 1 columns. Provided column amount: 2. Which should be columns from the following annotators: document
.Closest thing I stumbled upon is this old issue where someone was trying to run multiple models in one pipeline, but if I try to add two
embeddings
stages in the pipeline spark-ml fails with:IllegalArgumentException: requirement failed: Cannot have duplicate components in a pipeline.
Not sure how common of a use case this is given there don't seem to be other issues like it, would appreciate some thoughts on the topic.
Thanks!
Environment:
Spark 3.5.0, Scala 2.12, Spark NLP 5.5.1
The text was updated successfully, but these errors were encountered: