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: tlm batch api #149

Merged
merged 17 commits into from
Jan 19, 2024
Merged

Feature: tlm batch api #149

merged 17 commits into from
Jan 19, 2024

Conversation

ryansingman
Copy link
Member

@ryansingman ryansingman commented Nov 28, 2023

Adds batch_prompt, batch_get_confidence_score APIs to enable scale use of TLM

Includes refactor to use of async requests (enabling request concurrency)

Both batch methods are intended to gracefully handle query exceptions w/ retries. For rate limit errors, the retry occurs after a wait specified by the backend. For other errors, an exponential backoff is applied.

See testing instructions: https://github.com/cleanlab/cleanlab-studio-backend/pull/988

@ryansingman ryansingman marked this pull request as ready for review November 29, 2023 01:07
@@ -46,21 +63,147 @@ def __init__(self, api_key: str, quality_preset: QualityPreset) -> None:

self._quality_preset = quality_preset

self._event_loop = asyncio.get_event_loop()
self._query_semaphore = asyncio.Semaphore(max_concurrent_requests)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to limit concurrency with the asyncio semaphore? if i set it to a high value, i.e. 1000, i get the generic API error. note: it doesn't hit the RateLimitError, which seems to be the expected one based on the error message suggesting to lower max_concurrent_requests . not sure how likely it is that the typical user will be setting this value or just using the default

Screenshot 2023-12-01 at 12 08 49 PM

@ulya-tkch
Copy link
Collaborator

ulya-tkch commented Jan 5, 2024

When trying to run scenario 1 linked for testing from the staging environment, I get below error. I am not sure if it is my environment or code issue. My env: staging, cleanlab-studio is pointed to editable install of feature/tlm-batch-api (this branch)

api_key = <api_key>
tlm = Studio(api_key).TLM(quality_preset="low", max_concurrent_requests=64)

tlm.batch_prompt([f"what's 2 + {i}?" for i in range(128)], retries=1)
image

@ryansingman
Copy link
Member Author

When trying to run scenario 1 linked for testing from the staging environment, I get below error. I am not sure if it is my environment or code issue. My env: staging, cleanlab-studio is pointed to editable install of feature/tlm-batch-api (this branch)

api_key = <api_key>
tlm = Studio(api_key).TLM(quality_preset="low", max_concurrent_requests=64)

tlm.batch_prompt([f"what's 2 + {i}?" for i in range(128)], retries=1)
image

Running async code in a Jupyter notebook will require the following: https://github.com/erdewit/nest_asyncio

@ryansingman ryansingman merged commit 9de06ef into main Jan 19, 2024
23 checks passed
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

Successfully merging this pull request may close these issues.

3 participants