-
Notifications
You must be signed in to change notification settings - Fork 103
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
[FEAT] Add async support to SDPMChunker and to SemanticChunker #39
Comments
Hey @rodion-m! Thanks for opening the issue 😊 Could you please elaborate on the benefits of adding async and the use case for it? Personally, I haven't used the async chunking support offered by other libraries before, nor am I aware of devs/companies who use it often. Maybe I just haven't been exposed to those use cases, so having some context would help here... If you think this could be of wider utility, I'd be happy to accept PRs for it. Thanks! |
Sure, here is my use case:
So, we need speed :) |
Correct me if I am wrong, but essentially, this is for faster embeddings computation with APIs like OpenAI, Anthropic etc to pass a bunch of chunks to get their embeddings async? By proper async support, you mean only for the embeddings right? Or do you mean that chunks should also be generated asynchronously? I plan to add async/batching support for embedding APIs like OpenAI, because we would need that capability, yes! I'm not sure of the second one i.e. async chunk generation yet. Sorry for all the questions, just trying to make sure I understand this correctly Thanks! |
I mean we should be able to call IO operations (like API calls for embeddings) asynchronously to get an ability to speed up embeddings generation in cases when we need to embed huge datasets and batch possibilities are exhausted. Here is an example of LiteLLM's implementation: https://docs.litellm.ai/docs/embedding/async_embedding |
Hey @rodion-m, Yes, this makes a lot more sense to me now! Thanks for the link with the example... 😊 I'm thinking about adding this feature into the What do you think about this? |
@bhavnicksm and thank you for your attention to this topic! I think that it's ok to call sync methods from async classes (let the problem of excessive parallelism fall on the developer himself). So, we just can add new async methods into the base class started with "a", like Did I get your question right? If not, please provide code examples. Also, I didn't get why do you want to call |
I think I finally understand... Yes, so currently, the semantic chunkers work on a "Scan and Look-back" style algorithm, which is why they require all the sentence embeddings before they begin. This is for one piece of text which let say has M sentences.
But as we go from one to many pieces, we currently use multiprocessing at the moment to tackle this with N texts. Here's what I understand from our discussion:
(NOTE: I'm assuming there's no seperate
Did I understand this correctly? |
Proper async support will give an ability to properly parallelize the execution of remote embeddings computation.
The text was updated successfully, but these errors were encountered: