Views
No views yet
text-classification: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.TextClassificationPipeline
| Label | Description |
|---|---|
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 |
neutral is the default label for text that is either factual or does not express a clear emotion.<YOUR_API_KEY> in the code below with your API Key and use this snippet:1import requests
2
3session = requests.Session()
4
5ed_out = session.post(
6 "https://slm.tanaos.com/models/emotion-detection",
7 headers={
8 "X-API-Key": "<YOUR_API_KEY>",
9 },
10 json={
11 "text": "I can't wait for the concert tonight!"
12 }
13)
14
15print(ed_out.json()["data"])
16# >>> [{'label': 'excitement', 'score': 0.9941}]microsoft/Multilingual-MiniLM-L12-H384pip install artifex1from artifex import Artifex
2
3ed = Artifex().emotion_detection
4
5ed.train(
6 domain="general",
7 classes={
8 "joy": "text that expresses happiness or positivity",
9 "anger": "text that expresses anger or frustration",
10 "fear": "text that expresses fear or anxiety",
11 "sadness": "text that expresses sadness or sorrow",
12 "surprise": "text that expresses surprise or shock",
13 "disgust": "text that expresses disgust or revulsion",
14 "excitement": "text that expresses excitement or enthusiasm",
15 "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."
16 },
17 num_samples=10000
18)