the-needl / hf-app-fastapi

Base template for Huggingface containerised FastAPI apps
0 stars 0 forks source link

Change SENTResult class output entities #4

Open emmepra opened 11 months ago

emmepra commented 11 months ago

SENTResult currently returns the following:

class SENTResult(BaseModel):
    class Sentiment(BaseModel):
        label: str
        score: float

    sentiments: List[Sentiment]

This setup was made to allow processing of longer than model's context input strings. Sentiment score should be considered as a single value, not a list of values. With this in mind required modification is to implement an average of scores in the list as:

sentiments = sum(sentiments)/len(sentiments)

class SENTResult(BaseModel):
    class Sentiment(BaseModel):
        label: str
        score: float

    sentiment: List[Sentiment]