CoolFace
Modelpublic

onnx-community/tanaos-emotion-detection-v1-ONNX

sourceHugging Facemitupdated 8mo agoView on Hugging Face
0likes216downloads
Model Card

tanaos-emotion-detection-v1 (ONNX)

This is an ONNX version of tanaos/tanaos-emotion-detection-v1. It was automatically converted and uploaded using this Hugging Face Space.

Usage with Transformers.js

See the pipeline documentation for text-classification: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.TextClassificationPipeline


<p align="center"> <img src="https://raw.githubusercontent.com/tanaos/.github/master/assets/logo.png" width="250px" alt="Tanaos – Train task specific LLMs without training data, for offline NLP and Text Classification"> </p>

tanaos-emotion-detection-v1: A small but performant emotion detection model

This model was created by Tanaos with the Artifex Python library.

This is an emotion detection model based on microsoft/Multilingual-MiniLM-L12-H384 and fine-tuned on a synthetic dataset to classify the main emotion expressed in any text input into one of the following categories:

LabelDescription
joyText that expresses happiness or positivity
angerText that expresses anger or frustration
fearText that expresses fear or anxiety
sadnessText that expresses sadness or sorrow
surpriseText that expresses surprise or shock
disgustText that expresses disgust or revulsion
excitementText that expresses excitement or enthusiasm
neutralText that either expresses a neutral or indifferent emotion, or that does not express any emotion at all on account of being purely factual or descriptive

neutral is the default label for text that is either factual or does not express a clear emotion.

These categories were chosen to cover a wide range of common emotions in text, in order to create a versatile and general-purpose emotion detection model, applicable across various industries and use cases.

This model can be used to analyze customer feedback, social media posts, reviews, and other text data to gain insights into the emotional tone and sentiment expressed by users.

<!-- While the default language is English, this model can be fine-tuned to any language. See the fine tune to any language section below for more details. -->

How to Use

<!-- ### Via the Tanaos API -->

Use this model for free via the Tanaos API in 3 simple steps:

  1. 1.Sign up for a free account at https://platform.tanaos.com/
  2. 2.Create a free API Key from the API Keys section
  3. 3.Replace <YOUR_API_KEY> in the code below with your API Key and use this snippet:
python
import requests

session = requests.Session()

ed_out = session.post(
    "https://slm.tanaos.com/models/emotion-detection",
    headers={
        "X-API-Key": "<YOUR_API_KEY>",
    },
    json={
        "text": "I can't wait for the concert tonight!"
    }
)

print(ed_out.json()["data"])
# >>> [{'label': 'excitement', 'score': 0.9941}]

<!-- ### Via the Artifex library (pip install artifex)

python
from artifex import Artifex

emotion_detection = Artifex().emotion_detection

print(emotion_detection("I can't wait for the concert tonight!"))
# >>> [{'label': 'excitement', 'score': 0.9941}]

Via the Transformers library

python
from transformers import pipeline

clf = pipeline("text-classification", model="tanaos/tanaos-emotion-detection-v1")

print(clf("I can't wait for the concert tonight!"))
# >>> [{'label': 'excitement', 'score': 0.9941}]

<!-- ## How to fine-tune (without training data)

Use the Artifex library to fine-tune the model to any language other than English, to custom domains or emotion categories by generating synthetic training data on-the-fly. Install Artifex with

bash
pip install artifex

Fine-tune to any language

python
from artifex import Artifex

emotion_detection = Artifex().emotion_detection

model_output_path = "./output_model/"

emotion_detection.train(
    domain="soporte al cliente para una plataforma de comercio electrónico",
    classes={
        "joy": "texto que expresa felicidad o positividad",
        "anger": "texto que expresa ira o frustración",
        "sadness": "texto que expresa tristeza o aflicción",
        "surprise": "texto que expresa sorpresa o impacto",
        "disgust": "texto que expresa disgusto o repulsión",
        "excitement": "texto que expresa entusiasmo o emoción",
        "neutral": "texto que expresa una emoción neutral o indiferente, o que no expresa ninguna emoción por ser puramente factual o descriptivo"
    },
    language="spanish",
    output_path=model_output_path
)

emotion_detection.load(model_output_path)
print(emotion_detection("Esto es inaceptable, quiero un reembolso."))

# >>> [{'label': 'anger', 'score': 0.9965}]

Fine-tune to custom emotion categories or domains

python
from artifex import Artifex

emotion_detection = Artifex().emotion_detection

model_output_path = "./output_model/"

emotion_detection.train(
    domain="travel reviews posted online",
    classes={
        "happiness": "text that expresses delight or positivity",
        "anger": "text that expresses anger or frustration",
        "annoyance": "text that expresses mild irritation or annoyance",
        "frustration": "text that expresses a stronger sense of frustration or dissatisfaction",
        "neutral": "text that either expresses a neutral or indifferent emotion, or that does not express any emotion at all on account of being purely factual or descriptive."
    },
    output_path=model_output_path
)

emotion_detection.load(model_output_path)
print(emotion_detection("The hotel staff were somewhat rude, which ruined my stay a bit."))

# >>> [{'label': 'annoyance', 'score': 0.9965}]

Model Description

  • —Base model: microsoft/Multilingual-MiniLM-L12-H384
  • —Task: Text classification (emotion detection)
  • —Languages: English
  • —Fine-tuning data: A synthetic, custom dataset of 10,000 utterances, each belonging to one of 12 different emotion categories.

Training Details

This model was trained using the Artifex Python library

bash
pip install artifex

by providing the following instructions and generating 10,000 synthetic training samples:

python
from artifex import Artifex

ed = Artifex().emotion_detection

ed.train(
    domain="general",
    classes={
        "joy": "text that expresses happiness or positivity",
        "anger": "text that expresses anger or frustration",
        "fear": "text that expresses fear or anxiety",
        "sadness": "text that expresses sadness or sorrow",
        "surprise": "text that expresses surprise or shock",
        "disgust": "text that expresses disgust or revulsion",
        "excitement": "text that expresses excitement or enthusiasm",
        "neutral": "text that either expresses a neutral or indifferent emotion, or that does not express any emotion at all on account of being purely factual or descriptive."
    },
    num_samples=10000
)

Intended Uses

This model is intended to:

  • —Classify the emotional tone of text inputs across multiple languages.
  • —Be used in applications such as customer feedback analysis, social media monitoring, and sentiment analysis.
  • —Serve as a lightweight alternative to larger models for emotion detection tasks.

Not intended for:

  • —Highly specialized domains where emotions differ significantly from the predefined categories.