UE22AM343BB5
Large Language Models and Their Applications
Dr. Shylaja S S
Director of Cloud Computing & Big Data (CCBD), Centre for
Data Sciences & Applied Machine Learning (CDSAML)
Department of Computer Science and Engineering
[email protected]
Sentiment Analysis in NLP
What is Sentiment Analysis?
• Also called Opinion Mining.
• Determines emotional tone behind text.
• Used in NLP applications to classify sentiment.
Why is Sentiment Analysis Important?
• Business Insights – Understand customer opinions.
• Social Media Monitoring – Analyze public reactions.
• Customer Support – Automate feedback processing.
• Stock Market Analysis – Gauge market sentiment.
• Political Analysis – Understand public opinion.
Types of Sentiment Analysis
1. Binary Sentiment Analysis – Positive/Negative.
2. Multiclass Sentiment Analysis – Positive/Neutral/Negative.
3. Fine-Grained Sentiment – Very Positive to Very Negative.
4. Aspect-Based Sentiment – Focuses on specific features.
5. Emotion Detection – Happy, Angry, Sad, etc.
How Does Sentiment Analysis Work?
• Text Preprocessing – Tokenization, Stopword Removal, Stemming/
Lemmatization.
• Feature Extraction – Bag of Words, TF-IDF, Word Embeddings.
• Model Training – Rule-Based, Machine Learning, Deep Learning.
Rule-Based Sentiment Analysis using TextBlob
```python
from textblob import TextBlob
text = "I love this product! It's amazing."
sentiment = TextBlob(text).sentiment.polarity
print("Sentiment Score:", sentiment)
```
Sentiment Analysis using VADER (Python)
```python
from nltk.sentiment import SentimentIntensityAnalyzer
sia = SentimentIntensityAnalyzer()
text = "The movie was really good, I loved it!"
sentiment = sia.polarity_scores(text)
print(sentiment)
```
Sentiment Analysis using Machine Learning (Scikit-Learn)
```python
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
texts = ["I love this!", "This is bad.", "Amazing experience!", "Not good at all."]
labels = [1, 0, 1, 0]
vectorizer = CountVectorizer()
X = vectorizer.fit_transform(texts)
model = MultinomialNB()
model.fit(X, labels)
new_text = ["I really enjoy this!"]
new_X = vectorizer.transform(new_text)
prediction = model.predict(new_X)
print("Sentiment:", "Positive" if prediction[0] == 1 else "Negative")
```
Sentiment Analysis using Deep Learning (BERT)
```python
from transformers import pipeline
classifier = pipeline("sentiment-analysis")
result = classifier("I absolutely love this movie! It’s fantastic.")
print(result)
```
Challenges in Sentiment Analysis
• Sarcasm Detection – 'Oh great, another delay!' (negative meaning but positive words).
• Context Understanding – 'The movie was sick!' (positive slang vs. literal meaning).
• Domain Dependency – 'The stock is going down' (negative for holders, positive for
buyers).
• Multilingual Sentiment – Different languages and cultural expressions.
Conclusion
• Sentiment Analysis is crucial for business, social media, and finance.
• Combining rule-based, ML, and deep learning models improves accuracy.
• Advanced models like BERT and GPT handle complex sentiment detection.
• Challenges like sarcasm, context, and multilingual analysis remain active
research areas.
Thank You
Dr. Shylaja S S
Director of Cloud Computing & Big Data (CCBD),
Centre for Data Sciences & Applied Machine
Learning (CDSAML)
Department of Computer Science and Engineering
[email protected]