yash3056 commited on
Commit
15d53cf
1 Parent(s): cd8617f

Fill the required Information

Browse files
Files changed (1) hide show
  1. README.md +274 -3
README.md CHANGED
@@ -1,3 +1,274 @@
1
- ---
2
- license: llama3.2
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama3.2
3
+ datasets:
4
+ - stanfordnlp/imdb
5
+ language:
6
+ - en
7
+ metrics:
8
+ - accuracy
9
+ base_model:
10
+ - meta-llama/Llama-3.2-1B
11
+ new_version: yash3056/Llama-3.2-1B-imdb
12
+ pipeline_tag: text-classification
13
+ library_name: transformers
14
+ tags:
15
+ - transformers
16
+ - pytorch
17
+ - llama
18
+ - llama-3
19
+ - 1b
20
+ ---
21
+
22
+ ## Model Details
23
+
24
+ ### Model Description
25
+
26
+ <!-- Provide a longer summary of what this model is. -->
27
+
28
+ - **Funded by [Intel]:** [https://console.cloud.intel.com/]
29
+ - **Shared by [optional]:** [More Information Needed]
30
+ - **Model type:** Text Classification
31
+ - **Language(s) (NLP):** [More Information Needed]
32
+ - **License:** [Llama 3.2 Community License Agreement]
33
+ - **Finetuned from model [meta-llama/Llama-3.2-1B]:** [https://huggingface.co/meta-llama/Llama-3.2-1B]
34
+
35
+ ## Uses
36
+
37
+ This model is designed for text classification tasks, specifically for binary sentiment analysis on datasets like IMDb, where the goal is to classify text as positive or negative. It can be used by data scientists, researchers, and developers to build applications for sentiment analysis, content moderation, or customer feedback analysis. The model can be fine-tuned for other binary or multi-class classification tasks in domains like social media monitoring, product reviews, and support ticket triage. Foreseeable users include AI researchers, developers, and businesses looking to automate text analysis at scale.
38
+ ### Direct Use
39
+
40
+ This model can be used directly to identify sentiments from text-based reviews, such as classifying whether a movie or product review is positive or negative. Without any further fine-tuning, it performs well on binary sentiment analysis tasks and can be employed out of the box for various applications like analyzing customer feedback, monitoring social media opinions, or automating sentiment tagging. The model is ideal for scenarios where sentiment needs to be quickly assessed from textual input without the need for deeper customizations.
41
+
42
+ ### Downstream Use
43
+
44
+ *Fine-tuning for Binary Classification*
45
+ ```python
46
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, Trainer, TrainingArguments
47
+ from datasets import load_dataset
48
+
49
+ # Load IMDb dataset for binary classification
50
+ dataset = load_dataset("imdb")
51
+ tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
52
+
53
+ # Tokenize the dataset
54
+ def preprocess(example):
55
+ return tokenizer(example['text'], truncation=True, padding='max_length', max_length=128)
56
+
57
+ tokenized_datasets = dataset.map(preprocess, batched=True)
58
+
59
+ # Load model for binary classification (num_labels=2)
60
+ model = AutoModelForSequenceClassification.from_pretrained("bert-base-uncased", num_labels=2)
61
+
62
+ # Training arguments
63
+ training_args = TrainingArguments(
64
+ output_dir="./results",
65
+ evaluation_strategy="epoch",
66
+ learning_rate=2e-5,
67
+ per_device_train_batch_size=16,
68
+ per_device_eval_batch_size=16,
69
+ num_train_epochs=3,
70
+ weight_decay=0.01,
71
+ )
72
+
73
+ # Trainer
74
+ trainer = Trainer(
75
+ model=model,
76
+ args=training_args,
77
+ train_dataset=tokenized_datasets["train"],
78
+ eval_dataset=tokenized_datasets["test"],
79
+ )
80
+
81
+ # Fine-tune the model
82
+ trainer.train()
83
+ ```
84
+
85
+ *Fine-tuning for Multi-Class Classification*
86
+
87
+ ```python
88
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, Trainer, TrainingArguments
89
+ from datasets import load_dataset
90
+
91
+ # Load AG News dataset for multi-class classification (4 labels)
92
+ dataset = load_dataset("ag_news")
93
+ tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
94
+
95
+ # Tokenize the dataset
96
+ def preprocess(example):
97
+ return tokenizer(example['text'], truncation=True, padding='max_length', max_length=128)
98
+
99
+ tokenized_datasets = dataset.map(preprocess, batched=True)
100
+
101
+ # Load model for multi-class classification (num_labels=4)
102
+ model = AutoModelForSequenceClassification.from_pretrained("bert-base-uncased", num_labels=4)
103
+
104
+ # Training arguments
105
+ training_args = TrainingArguments(
106
+ output_dir="./results",
107
+ evaluation_strategy="epoch",
108
+ learning_rate=2e-5,
109
+ per_device_train_batch_size=16,
110
+ per_device_eval_batch_size=16,
111
+ num_train_epochs=3,
112
+ weight_decay=0.01,
113
+ )
114
+
115
+ # Trainer
116
+ trainer = Trainer(
117
+ model=model,
118
+ args=training_args,
119
+ train_dataset=tokenized_datasets["train"],
120
+ eval_dataset=tokenized_datasets["test"],
121
+ )
122
+
123
+ # Fine-tune the model
124
+ trainer.train()
125
+ ```
126
+ <!--
127
+ ### Out-of-Scope Use
128
+
129
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
130
+
131
+ [More Information Needed]
132
+ -->
133
+ ## Bias, Risks, and Limitations
134
+
135
+ While this model is effective for text classification and sentiment analysis, it has certain limitations and potential biases. The training data, such as the IMDb dataset, may contain inherent biases related to language use, cultural context, or demographics of reviewers, which could influence the model’s predictions. For example, the model might struggle with nuanced sentiment, sarcasm, or slang, leading to misclassifications. Additionally, it could exhibit biases toward particular opinions or groups if those were overrepresented or underrepresented in the training data.
136
+
137
+ The model is also limited to binary sentiment classification, meaning it may oversimplify more complex emotional states expressed in text. Users should be cautious when applying the model in sensitive domains such as legal, medical, or psychological settings, where misclassification could have serious consequences. Proper review and adjustment of predictions are recommended, especially in high-stakes applications.
138
+
139
+ ### Recommendations
140
+
141
+ Users (both direct and downstream) should be aware of the potential risks, biases, and limitations inherent in this model. Given that the model may reflect biases present in the training data, it is recommended that users critically evaluate the model’s performance on specific datasets or contexts where fairness and accuracy are essential.
142
+
143
+ For applications in sensitive areas like legal, healthcare, or hiring decisions, additional care should be taken to review the model's predictions, possibly combining them with human oversight. Fine-tuning the model on domain-specific data or implementing bias mitigation techniques can help reduce unintended bias. Additionally, regular re-evaluation and monitoring of the model in production environments are encouraged to ensure it continues to meet desired ethical and performance standards.
144
+
145
+ ## How to Get Started with the Model
146
+
147
+ Use the code below to get started with the model.
148
+ ```python
149
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
150
+
151
+ # Load Model and tokenizers
152
+ tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
153
+ model = AutoModelForSequenceClassification.from_pretrained("bert-base-uncased", num_labels=n) #n is the number of labels in the code
154
+ ```
155
+
156
+
157
+ ## Training Details
158
+
159
+ ### Training Data
160
+
161
+ The model was trained on the IMDb dataset, a widely used benchmark for binary sentiment classification tasks. The dataset consists of movie reviews labeled as positive or negative, making it suitable for training models to understand sentiment in text. The dataset contains 50,000 reviews in total, evenly split between positive and negative labels, providing a balanced dataset for training and evaluation. Preprocessing involved tokenizing the text using the AutoTokenizer from Hugging Face's Transformers library, truncating and padding the sequences to a maximum length of 512 tokens. The training data was further split into training and validation sets with an 80-20 ratio.
162
+
163
+ More information about the IMDb dataset can be found [here](https://huggingface.co/datasets/stanfordnlp/imdb).
164
+
165
+ ### Training Procedure
166
+
167
+ Training Procedure
168
+ The training procedure used the Llama-3.2-1B model with modifications to suit the binary sentiment classification task. Training was performed for 10 epochs using a batch size of 8 and the AdamW optimizer with a learning rate of 3e-5. The learning rate was adjusted with a linear schedule, including a warmup of 40% of the total steps. The model was fine-tuned using the IMDb training dataset and evaluated on a separate test set.
169
+
170
+ Validation and evaluation metrics were calculated after each epoch, including accuracy, precision, recall, F1-score, and ROC-AUC. The final model was saved after the last epoch, along with the tokenizer. Several plots, such as loss curves, accuracy curves, confusion matrix, and ROC curve, were generated to visually assess the model's performance.
171
+ #### Preprocessing [optional]
172
+
173
+ Text data was preprocessed by tokenizing with the Llama-3.2-1B model tokenizer. Sequences were truncated and padded to a maximum length of 512 tokens to ensure consistent input sizes for the model. Labels were encoded as integers (0 for negative and 1 for positive) for compatibility with the model.
174
+
175
+ <!--
176
+ #### Training Hyperparameters
177
+
178
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
179
+ <!--
180
+ #### Speeds, Sizes, Times [optional]
181
+
182
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
183
+ <!--
184
+ [More Information Needed]
185
+ -->
186
+ ## Evaluation
187
+
188
+ Training Loss: 0.0030, Accuracy: 0.9999
189
+ Validation Loss: 0.1196, Accuracy: 0.9628
190
+
191
+ ### Testing Data, Factors & Metrics
192
+
193
+ #### Testing Data
194
+
195
+ Test Loss: 0.1315
196
+ Test Accuracy: 0.9604
197
+ Precision: 0.9604
198
+ Recall: 0.9604
199
+ F1-score: 0.9604
200
+ AUC: 0.9604
201
+ <!--
202
+ #### Factors
203
+
204
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
205
+ <!--
206
+
207
+ [More Information Needed]
208
+ #### Metrics
209
+
210
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
211
+ <!--
212
+ [More Information Needed]
213
+
214
+ ### Results
215
+
216
+ [More Information Needed]-->
217
+
218
+ #### Summary
219
+ <!--
220
+ ## Model Examination [optional]
221
+
222
+ <!-- Relevant interpretability work for the model goes here -->
223
+ <!--
224
+ [More Information Needed]
225
+ <!--
226
+ ## Environmental Impact
227
+
228
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
229
+ <!--
230
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
231
+
232
+ - **Hardware Type:** [More Information Needed]
233
+ - **Hours used:** [More Information Needed]
234
+ - **Cloud Provider:** [More Information Needed]
235
+ - **Compute Region:** [More Information Needed]
236
+ - **Carbon Emitted:** [More Information Needed]
237
+ -->
238
+
239
+ ## Technical Specifications
240
+ <!--
241
+ ### Model Architecture and Objective
242
+
243
+ [More Information Needed]
244
+
245
+ ### Compute Infrastructure
246
+
247
+ [More Information Needed]
248
+ -->
249
+ #### Hardware
250
+
251
+ [Intel® Data Center GPU Max 1550](https://www.intel.com/content/www/us/en/products/sku/232873/intel-data-center-gpu-max-1550/specifications.html)
252
+ <!--
253
+
254
+ ## Citation [optional]
255
+
256
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
257
+ <!--
258
+
259
+ **BibTeX:**
260
+
261
+ [More Information Needed]
262
+
263
+ **APA:**
264
+
265
+ [More Information Needed]
266
+ -->
267
+ ## Model Card Authors
268
+
269
+ -Yash Prakash Narayan ([github](https://github.com/yash3056))
270
+ <!--
271
+
272
+ ## Model Card Contact
273
+
274
+ [More Information Needed]-->