Sentiment Analysis
Sentiment Analysis
Determining the sentiment or opinion in text. Used for social media analysis and customer feedback.
Sentiment Analysis
Determining the sentiment or opinion in text. Used for social media analysis and customer feedback.
Sentiment analysis is a natural language processing (NLP) technique that automatically identifies and classifies the emotions, opinions, and attitudes expressed in text. It is mainly classified into three categories: positive, negative, and neutral, and more fine-grained analysis detects various emotions such as joy, sadness, anger, and fear.
This technology developed in the early 2000s alongside the need to analyze online reviews. Early on, the lexicon-based approach (using sentiment dictionaries) was dominant, but in the 2010s, with advances in machine learning and deep learning, methods using pre-trained language models such as BERT and RoBERTa became the standard.
Sentiment analysis is highly context-dependent. In an expression like "This movie is killer," the word 'killer' is used in a positive sense, and detecting irony and sarcasm is also a major challenge. The latest LLMs can perform sentiment analysis zero-shot with just a prompt, and they also have excellent multilingual support.
In practice, sentiment analysis is widely used for customer VOC (Voice of Customer) analysis, social media monitoring, brand reputation management, and financial market sentiment analysis. It has become an essential technology especially in fields that require real-time processing of large volumes of data.
An example of Korean sentiment analysis using Hugging Face Transformers.
# pip install transformers torch
from transformers import pipeline
# 다국어 감정 분석 모델 로드
sentiment_analyzer = pipeline(
"sentiment-analysis",
model="nlptown/bert-base-multilingual-uncased-sentiment"
)
# 분석할 텍스트
texts = [
"이 제품 정말 만족스러워요! 배송도 빠르고 품질도 좋아요.",
"완전 실망입니다. 사진과 너무 다르네요.",
"그냥 평범해요. 가격 대비 무난합니다."
]
# 감정 분석 수행
for text in texts:
result = sentiment_analyzer(text)[0]
stars = int(result['label'].split()[0]) # "5 stars" -> 5
if stars >= 4:
sentiment = "긍정"
elif stars <= 2:
sentiment = "부정"
else:
sentiment = "중립"
print(f"텍스트: {text}")
print(f" → 감정: {sentiment} ({result['label']}, 신뢰도: {result['score']:.2%})")
print()
# 출력 예시:
# 텍스트: 이 제품 정말 만족스러워요! 배송도 빠르고 품질도 좋아요.
# → 감정: 긍정 (5 stars, 신뢰도: 72.35%)
"We ran sentiment analysis on 50,000 customer reviews, and 42% of the negative reviews are about delivery. It looks like we need to work with the logistics team."
"We achieved an F1 score of 0.89 with a BERT-based sentiment analysis model. We improved performance by expanding the context window to detect irony."
"For Korean sentiment analysis, KoBERT and KoELECTRA perform better than multilingual models. That said, the zero-shot performance of the latest LLMs is also quite competitive."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
If a model trained on movie reviews is applied to financial news, accuracy drops significantly. Fine-tuning on domain-specific data is needed.
Expressions whose meaning depends on context, such as "Oh, you're really something~", are often misclassified as simply positive.
Fine-tune on a domain-specific dataset, and include emojis/emoticons in the analysis. Design it so that it can also detect mixed emotions (positive mixed with complaints).