iSathyam03 commited on
Commit
0b84518
·
verified ·
1 Parent(s): df1ec00

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +89 -0
README.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ # For reference on model card metadata, see the spec: https://github.com/huggingface/hub-docs/blob/main/modelcard.md?plain=1
3
+ # Doc / guide: https://huggingface.co/docs/hub/model-cards
4
+ {}
5
+ ---
6
+
7
+ # Model Details
8
+ This project demonstrates the fine-tuning of the DistilBERT model on the IMDB dataset for text classification, using the Hugging Face Transformers library.
9
+
10
+ ## Model Architecture
11
+
12
+ - **Model**: `DistilBERT-base-uncased`
13
+ - **Optimizer**: AdamW
14
+ - **Loss Function**: Cross-entropy loss
15
+ - **Epochs**: 4
16
+ - **Learning Rate**: 2e-5
17
+ - **Batch Size**: 16
18
+
19
+ ## Dataset
20
+
21
+ The imdb data is the collection of reviews of movies categorized into TWO classes:
22
+
23
+ - **POSITIVE**
24
+ - **NEGATIVE**
25
+
26
+ You can access the dataset via the Hugging Face `datasets` library.
27
+
28
+ ## Training Configuration
29
+
30
+ The training arguments are set as follows:
31
+
32
+ ```python
33
+ training_args = TrainingArguments(
34
+ output_dir="distilbert-base-uncased-finetuned-sentiment-analysis",
35
+ learning_rate=2e-5,
36
+ per_device_train_batch_size=16,
37
+ per_device_eval_batch_size=16,
38
+ num_train_epochs=4,
39
+ weight_decay=0.01,
40
+ evaluation_strategy="epoch",
41
+ save_strategy="epoch",
42
+ load_best_model_at_end=True,
43
+ push_to_hub=True,
44
+ )
45
+ ```
46
+ You can change the parameters according to your requirements!!
47
+
48
+ ## Model Evaluation Results
49
+
50
+ | Epoch | Eval Loss | Eval Accuracy |
51
+ |-------|-------------|---------------|
52
+ | 1 | 0.1881 | 92.90% |
53
+ | 2 | 0.2331 | 93.39% |
54
+ | 3 | 0.2919 | 93.39% |
55
+ | 4 | 0.3253 | 93.67% |
56
+
57
+ ## Dependencies
58
+ The required dependencies for this project are:
59
+
60
+ * transformers
61
+ * datasets
62
+ * torch
63
+ * sklearn
64
+ * numpy
65
+
66
+ ## How to Use the Model
67
+ You can use the fine-tuned model for sentiment analysis using the Hugging Face `pipeline` as follows:
68
+
69
+ ```python
70
+ from transformers import pipeline
71
+
72
+ # Load the model from Hugging Face Hub
73
+ sentiment_analysis = pipeline("sentiment-analysis", model="Sathyam03/distilbert-base-uncased-finetuned-sentiment-analysis")
74
+
75
+ # Example usage
76
+ reviews = [
77
+ "I absolutely loved this movie! It was fantastic.",
78
+ "The film was okay, but it dragged on in some parts.",
79
+ "I didn't like this movie at all. It was boring."
80
+ ]
81
+
82
+ results = sentiment_analysis(reviews)
83
+
84
+ # Print the results
85
+ for review, result in zip(reviews, results):
86
+ print(f"Review: {review}")
87
+ print(f"Sentiment: {result['label']}, Confidence: {result['score']:.4f}\n")
88
+ )
89
+ ```