-
Notifications
You must be signed in to change notification settings - Fork 47
feat: implement batch sentiment analysis and add batch endpoint #26
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
base: main
Are you sure you want to change the base?
Changes from all commits
a4eacee
6ae0c87
737cbe1
a09941c
ca3179e
5d0b214
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same why did u changed in this file ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I modified the Service Layer to ensure compatibility with the new batch processing logic in the model. Since the model now returns a list of dictionaries instead of a single result, the Service Layer needed to be Type-Aware." I implemented two main things there: Handling Polymorphism: I used isinstance() to check if the input is a single string or a list. This keeps the API backward compatible, meaning it still works perfectly for single requests. Standardizing the Response by using a list comprehension to call format_response, I ensured that the output format remains consistent and clean, whether the user sends one sentence or a many.
|

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did u modify in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to my understanding of the issue, I modified bertweet_model.py to implement Tensor-based batching directly within the model's forward pass.
Handling batches at the model level (using padding=True and truncation=True) leverages PyTorch's parallelism, making inference significantly faster than looping over strings. I've also ensured the method remains backward-compatible, so it still works perfectly for single strings (as it used to) while supporting lists of strings.
Regarding the logs, I've removed the initial debug logs to keep the PR focused and clean.