Skip to content

[PYTHON] Add Sentiment Classification Generation Support #19

@ryanweiler92

Description

@ryanweiler92

Add Sentiment Classification Generation Support

Overview

Implement sentiment classification generation class and related infrastructure to support both binary and 3-class sentiment analysis using CPU-friendly HuggingFace models. Use CPU friendly HF models such as distilbert-base-uncased-finetuned-sst-2-english and twitter-roberta-base-sentiment for development. Any new classes should follow the style of the existing classes.

Technical Requirements

1. Model Configuration

  • Add new model type "sentiment" in model configuration
  • Support for both binary and 3-class sentiment models:
    • Default binary: "distilbert-base-uncased-finetuned-sst-2-english"
    • Default multi-class: "twitter-roberta-base-sentiment"

2. Create SentimentGen Class

Create new file gaas/sentiment_gen/sentiment_gen.py:

  • Implement SentimentGen class following existing pattern from similar classes
  • Support both single text and batch inference
  • Include proper error handling and logging

3. Update Main Application

  • Add SentimentGen to model type initialization in main.py
elif model_type == "sentiment":
    app.state.gaas = SentimentGen(model_manager=model_manager)

4. Request/Response Models

  • Create new Pydantic models in pydantic_models/

5. Integration Requirements

  • Support responses through /api/generate endpoint

6. Update documentation

Metadata

Metadata

Labels

enhancementNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions