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

[Feature Request]: Batched Async Prediction #84

Open
WindChimeRan opened this issue Feb 13, 2024 · 2 comments
Open

[Feature Request]: Batched Async Prediction #84

WindChimeRan opened this issue Feb 13, 2024 · 2 comments

Comments

@WindChimeRan
Copy link

Hi,

The current scikit-llm is implemented in a synchronous way - the prompts are sent to the api one-by-one.

This is not ideal when we have a large dataset and a high tier (high TPM/RPM) account. Is it possible to incorporate batched async feature?

Reference:

oaib

@OKUA1
Copy link
Collaborator

OKUA1 commented Feb 13, 2024

Hi @WindChimeRan,

Unfortunately, the OpenAI api does not support batched requests, so there is going to be 1 request per 1 sample anyway.

The only possibility of speedup is to send multiple requests in parallel. Adding an async api could be nice (e.g. a_predict method), but this is not really compliant with scikit-learn API and might be confusing for some users. The more straightforward way would be to just support synchronous parallel processing and allow to specify n_jobs hyperparameter. This is something we had in mind since day 1, but never prioritised as until relatively recently the rate limits would not allow for sufficient parallelisation anyway.

As for now, you can simply split your dataset and run predict on each chunk in a thread pool.

@AndreasKarasenko
Copy link
Contributor

AndreasKarasenko commented Jun 10, 2024

@WindChimeRan see #101.
Edit: I did some experimenting with the FewShotClassifier and I quickly run into rate limits. Tbf it's for sentiment classification and some of the reviews sampled are VERY long (which i do not monitor), so potentially there is no real speed-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants