情感分析資料集 Template

    用於訓練文字情感分類和意見挖掘 AI 模型的資料集範本

    Classification

    Overview

    情感分析資料集訓練 AI 模型識別文字中表達的情緒語調和意見——客戶評論是正面、負面還是中性,社群媒體貼文是表達滿意還是不滿,以及產品或服務的哪些具體面向受到讚揚或批評。這是最成熟且應用最廣泛的 NLP 任務之一,應用範圍涵蓋客戶回饋分析、品牌監測、市場研究和產品開發優先排序。

    現代情感分析已超越簡單的正面/負面分類。面向式情感分析(ABSA)識別對產品特定功能或面向的情感——餐廳評論可能對食物品質表達正面情感,但對服務速度表達負面情感。多維度情感不僅捕捉極性,還包括強度(略微正面與極度正面)和情緒類別(憤怒、喜悅、失望、驚訝)。訓練資料應反映您的應用所需的粒度等級。

    情感表達的領域特定性是一個關鍵考量。「sick」這個詞在醫學語境和休閒社群媒體中的含義截然不同。「aggressive」在描述客戶服務時可能是負面的,但在描述跑車造型時則可能是正面的。訓練資料必須來自模型將部署的相同領域,或者必須包含足夠的跨領域範例,以教導模型領域特定的情感模式。

    Dataset Schema

    typescript
    interface SentimentExample {
      text: string;
      sentiment: "positive" | "negative" | "neutral" | "mixed";
      confidence: number;    // 0.0 - 1.0
      aspects?: {
        aspect: string;      // e.g., "battery_life", "customer_service"
        sentiment: "positive" | "negative" | "neutral";
        snippet: string;     // Text span supporting the label
      }[];
      metadata: {
        source: string;
        domain: string;
        language: string;
        word_count: number;
      };
    }
    包含選用面向式情感標籤的情感分析結構定義

    Sample Data

    json
    [
      {
        "text": "Absolutely love this laptop. The battery easily lasts 12 hours of real work, and the keyboard feel is the best I've used on any ultrabook. My only gripe is the webcam quality — it's noticeably grainy in video calls. For the price point though, this is an incredible value.",
        "sentiment": "positive",
        "confidence": 0.88,
        "aspects": [
          {"aspect": "battery_life", "sentiment": "positive", "snippet": "battery easily lasts 12 hours of real work"},
          {"aspect": "keyboard", "sentiment": "positive", "snippet": "keyboard feel is the best I've used"},
          {"aspect": "webcam", "sentiment": "negative", "snippet": "webcam quality — it's noticeably grainy"},
          {"aspect": "value", "sentiment": "positive", "snippet": "incredible value"}
        ],
        "metadata": {"source": "product_review", "domain": "electronics", "language": "en", "word_count": 52}
      },
      {
        "text": "The hotel location was perfect, right on the beach with ocean views from our room. However, the check-in process took over 45 minutes due to understaffing, and our room wasn't ready until 5pm despite a 3pm check-in time. The pool area was nice but very crowded. Mixed feelings overall.",
        "sentiment": "mixed",
        "confidence": 0.82,
        "aspects": [
          {"aspect": "location", "sentiment": "positive", "snippet": "location was perfect, right on the beach"},
          {"aspect": "check_in", "sentiment": "negative", "snippet": "check-in process took over 45 minutes"},
          {"aspect": "room_readiness", "sentiment": "negative", "snippet": "room wasn't ready until 5pm"},
          {"aspect": "amenities", "sentiment": "neutral", "snippet": "pool area was nice but very crowded"}
        ],
        "metadata": {"source": "travel_review", "domain": "hospitality", "language": "en", "word_count": 58}
      },
      {
        "text": "Ordered the medium roast blend. Arrived on time, packaging intact. Tastes like coffee.",
        "sentiment": "neutral",
        "confidence": 0.75,
        "aspects": [
          {"aspect": "delivery", "sentiment": "neutral", "snippet": "Arrived on time"},
          {"aspect": "taste", "sentiment": "neutral", "snippet": "Tastes like coffee"}
        ],
        "metadata": {"source": "product_review", "domain": "food_beverage", "language": "en", "word_count": 16}
      }
    ]
    涵蓋電子、飯店和食品領域的面向式情感分析範例

    Data Collection Guide

    從您的模型將運作的平台和領域取得文字。對於產品評論情感,從您的電商平台匯出評論。對於社群媒體監測,收集提及您品牌或產業關鍵字的貼文。對於客戶回饋分析,匯出調查回應和支援工單留言。每個領域都有其表達情感的獨特語言模式,在領域內資料上訓練對於準確分類至關重要。

    標籤品質在很大程度上取決於清楚的標註指南。用領域特定的範例明確定義什麼構成正面、負面、中性和混合情感。在指南中處理邊緣案例:反諷、比較陳述(「比 X 好但比 Y 差」)、條件情感(「如果⋯⋯就好了」)和強度變化。在標註者開始標記之前,提供 20-30 個校準範例以建立一致的標準。

    對於面向式情感,在標註開始前定義您的面向分類法。列出您領域中所有相關的面向(餐廳:food_quality、service、ambiance、price、cleanliness、wait_time),並為每個面向提供清楚的定義和範例。標註者應識別支持每個面向層級情感標籤的文字片段,建立可在品質審查中驗證的證據。

    Quality Criteria

    使用 Cohen's kappa 或 Krippendorff's alpha 衡量標註者間一致性。對於文件層級的情感,目標 kappa 大於 0.80。對於更主觀的面向式情感,kappa 大於 0.70 是合理的目標。低一致性表明指南模糊或存在確實模稜兩可的文字,應予以審查。

    平衡資料集中的情感類別。自然分佈通常是偏斜的——大多數評論要麼非常正面要麼非常負面,中性範例較少。不平衡的資料集會產生偏向多數類別的模型。要麼為代表不足的類別收集額外範例,要麼使用分層抽樣來建立平衡的訓練集。目標是每個情感類別至少有 500 個範例以確保可靠的分類。

    驗證面向標籤是否與被標記為證據的文字片段一致。如果標註者將一個面向標記為「負面」,但支持的片段沒有明確傳達負面情感,該範例應予以更正或移除。面向與文字的對齊是標註品質的強力指標,並直接影響模型在面向式任務上的效能。

    Using This Template with Ertas

    將原始文字資料(評論、調查回應、社群貼文)匯入 Ertas Data Suite 進行個資遮蔽。客戶評論通常包含姓名、電子郵件地址、訂單號碼和地點詳情,這些在用於訓練之前必須遮蔽。遮蔽後,匯出清理後的文字進行標註,然後重新匯入已標註的資料進行最終的資料集準備和格式轉換。

    以 JSONL 格式匯出用於 LLM 微調,或以 CSV 格式匯出用於基於編碼器的分類模型訓練。Ertas Studio 支援這兩種方法——微調生成式模型以進行帶解釋的情感分析,或訓練較小的分類模型以進行高吞吐量的情感評分。

    Recommended Model

    對於不需要解釋的高吞吐量情感分類,微調編碼器模型(BERT、DeBERTa 或 RoBERTa),其推論速度更快且資源需求低於生成式模型。對於帶自然語言解釋的情感分析(解釋為什麼情感是這樣的),微調一個 7B 的生成式模型。

    面向式情感分析受益於能夠在單次處理中識別面向、提取相關片段和指定情感的生成式模型。在面向層級訓練資料上微調的 7B-8B 模型可良好地處理此任務。以 Q4_K_M 量化匯出為 GGUF,在生產環境中進行高效的本地推論。

    Ship AI that runs on your users' devices.

    Early bird pricing starts at $14.50/mo — locked in for life. Plans for builders and agencies.