feat(sentiment): add batch processing for transcript chunks #8
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.
This PR introduces batch processing for sentiment analysis at the per-request level. Instead of processing each transcript chunk sequentially, the new changes allow multiple chunks from a single input to be processed together in a single batch.
The improvements include:
Model Layer:
Added a new batch_forward() method in the BertweetSentiment model that accepts a list of texts and returns sentiment predictions for all texts in one call.
Data Layer:
Added an analyze_batch() function that leverages the model’s batch_forward() method to perform batch sentiment analysis.
Service Layer:
Introduced a corresponding analyze_batch() function in the sentiment service layer.
Updated the main processing function to collect transcript chunk texts from an input, process them in a batch using the new method, and then map the results back to the chunks.
Notes
Please review and provide feedback.