Views
No views yet
DistilBERT-base-uncaseddatasets library.1training_args = TrainingArguments(
2 output_dir="distilbert-base-uncased-finetuned-sentiment-analysis",
3 learning_rate=2e-5,
4 per_device_train_batch_size=16,
5 per_device_eval_batch_size=16,
6 num_train_epochs=4,
7 weight_decay=0.01,
8 evaluation_strategy="epoch",
9 save_strategy="epoch",
10 load_best_model_at_end=True,
11 push_to_hub=True,
12)| Epoch | Eval Loss | Eval Accuracy |
|---|---|---|
| 1 | 0.1881 | 92.90% |
| 2 | 0.2331 | 93.39% |
| 3 | 0.2919 | 93.39% |
| 4 | 0.3253 | 93.67% |
pipeline as follows:1from transformers import pipeline
2
3# Load the model from Hugging Face Hub
4sentiment_analysis = pipeline("sentiment-analysis", model="Sathyam03/distilbert-base-uncased-finetuned-sentiment-analysis")
5
6# Example usage
7reviews = [
8 "I absolutely loved this movie! It was fantastic.",
9 "The film was okay, but it dragged on in some parts.",
10 "I didn't like this movie at all. It was boring."
11]
12
13results = sentiment_analysis(reviews)
14
15# Print the results
16for review, result in zip(reviews, results):
17 print(f"Review: {review}")
18 print(f"Sentiment: {result['label']}, Confidence: {result['score']:.4f}\n")
19)