Improve question generation efficiency In Response Relevancy metrics #1810
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description: This update refactors the _ascore method to use asyncio.gather for parallel execution of question generation tasks. Key improvements include:
Issue : When ResponseRelevancy evaluation loops based on the strictness variable (default 3), which is taking longer than expected
Performance Enhancement: By processing all tasks concurrently, the overall execution time is significantly reduced, especially for high strictness values.
Code Simplification: The refactored code is more concise and aligns better with Python's asynchronous programming patterns.
Scalability: The new implementation handles a larger number of tasks without blocking, making it more suitable for use cases requiring high concurrency.
Backward Compatibility: All existing functionality remains intact, with no changes required to external interfaces.
This change improves the efficiency and maintainability of the codebase, aligning with best practices for asynchronous programming in Python.
Result after resolution : Average 1 run of Example code based on tutorial code (10 runs total) reduced to 4.35s => 2.82s