Neural Sync Active
NLP with Hugging Face
Registry Synced
NLP with Hugging Face
64 words
1 min read
NLP with Hugging Face
pythonfrom transformers import pipeline # Sentiment analysis classifier = pipeline("sentiment-analysis") result = classifier("I love this course!") print(result) # Text generation generator = pipeline("text-generation", model="gpt2") result = generator("The future of AI is", max_length=30) print(result[0]['generated_text']) # Text classification with BERT from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased") model = AutoModelForSequenceClassification.from_pretrained( "bert-base-uncased", num_labels=2 )