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

Enhancements to OpenAI Embedding: Batch Processing, Customer Support and Dynamic Model Selection #1844

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

RahulVadisetty91
Copy link

@RahulVadisetty91 RahulVadisetty91 commented Sep 10, 2024

Summary
In the current update of the OpenAI embedding script there are new features such as batch processing, asynchronous support, dynamic model selection, and improved error handling. These enhancements are concerned with increasing the performance, flexibility, and the level of error shown to the user.

  1. Related Issues
    None on associated concerns, where proactive performance enhancement is being implemented.

  2. Discussions
    Some discussion focused on enhancing script throughput by means of batch operations and async capability.

  3. QA Instructions
    To validate the enhancements, one should perform the embedding requests in both batch and async modes.

  4. Merge Plan
    Before merge, make certain that all changes are good with different sizes of input.

  5. Motivation and Context
    This update is focused on enhancing the work of requests’ embedding and streamlines methods.

  6. How we test:
    Performance enhancements: Batch mode capability with asynchronous features.
    Flexibility: Dynamic model selection.
    Improved error handling: Saying the wrong thing at the wrong time.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Please delete options that are not relevant.

  • Unit Test
  • Test Script (please provide)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed

In this update to the `OpenAIEmbedding` class, we have introduced several significant enhancements to improve functionality and performance.

1. Batch Processing Support: 
The embedding method has been enhanced to handle multiple texts in a single request. This change allows for more efficient processing by reducing the number of API calls. Instead of processing one text at a time, you can now pass a list of texts to the `embed` method, which the class will handle in a single API request. This batch processing improves throughput and minimizes latency.

2. Asynchronous Support:
 We have incorporated asynchronous handling into the `embed` method to enable non-blocking operations. By using Python's `asyncio` library, the embedding requests can be processed concurrently, which is particularly beneficial for applications with high volumes of text or those requiring real-time responsiveness.

3. Dynamic Model Selection: 
The class now supports dynamic model selection based on input parameters. This allows users to choose different OpenAI models for embedding depending on their needs, such as performance versus accuracy trade-offs. The model selection is more flexible, making it easier to adapt to various use cases.

4. Enhanced Error Handling: I
mproved error handling has been added to provide clearer and more informative error messages. This ensures that issues such as API rate limits or invalid inputs are handled gracefully, with appropriate feedback provided to users.

5. Optimized API Integration: The initialization process for the OpenAI client has been streamlined. Environment variables for API keys and base URLs are checked, and defaults are set if they are not provided. This ensures that the client is properly configured and reduces the likelihood of configuration errors.

Overall, these updates enhance the usability, efficiency, and flexibility of the `OpenAIEmbedding` class, making it better suited for a variety of applications involving text embeddings.
Enhance OpenAIEmbedding Class with Batch Processing, Async Support, and Dynamic Model Selection
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.

1 participant