Welcome to the topic classification demonstration! This example showcases how to use pre-trained models from HuggingFace to categorize text into specific topics. 🌐🤖
Model Overview
- Model Type: Text Classification
- Pre-trained Models:
bert-base-uncased
,distilbert-base-uncased
- Task: Identify the main topic of a given text
- Supported Languages: English, French, Spanish, German, etc.
How to Use
Install Transformers
pip install transformers
Load Pre-trained Model
from transformers import pipeline classifier = pipeline("text-classification", model="bert-base-uncased")
Classify Text
result = classifier("The new iPhone was announced today!", top_k=2) print(result)
Example Results
Label | Score |
---|---|
Technology | 0.98 |
Mobile Phones | 0.85 |
💡 Try this with different texts! Explore more NLP demos