Hugging Face provides pre-trained models and tools for NLP tasks.
1. Introduction to AI
What is AI?
2. Machine Learning Basics
How Machine Learning Works
3. AI Applications
AI in the Real World
10. Reinforcement Learning
Reinforcement Learning Basics
Syntax
AI
from transformers import pipeline
# Sentiment Analysis
classifier = pipeline("sentiment-analysis")
result = classifier("I love this!")
# Text Generation
generator = pipeline("text-generation", model="gpt2")
Hugging Face Transformers
PYTHON
# Hugging Face concept (conceptual) # from transformers import pipeline # classifier = pipeline("sentiment-analysis") def simple_sentiment(text): positive = ["good", "great", "love", "excellent", "amazing"] negative = ["bad", "terrible", "hate", "awful", "worst"] pos_count = sum(1 for w in positive if w in text.lower()) neg_count = sum(1 for w in negative if w in text.lower()) if pos_count > neg_count: return {"label": "POSITIVE", "score": 0.95} elif neg_count > pos_count: return {"label": "NEGATIVE", "score": 0.88} return {"label": "NEUTRAL", "score": 0.5} print(simple_sentiment("This is great!")) print(simple_sentiment("This is terrible!"))