ashish-001 commited on
Commit
15dc177
·
verified ·
1 Parent(s): ebbfbbc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +56 -3
README.md CHANGED
@@ -1,3 +1,56 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - SetFit/amazon_reviews_multi_en
5
+ language:
6
+ - en
7
+ metrics:
8
+ - accuracy
9
+ base_model:
10
+ - distilbert/distilbert-base-uncased
11
+ pipeline_tag: text-classification
12
+ ---
13
+ This repository contains a fine-tuned DistilBERT model for sentiment classification of Amazon product reviews The model classifies a given review into two classes: Positive and Negative
14
+
15
+ ---
16
+
17
+ ## **Model Overview**
18
+ - **Base Model**: [distilbert/distilbert-base-uncased](https://huggingface.co/distilbert/distilbert-base-uncased)
19
+ - **Dataset**: [SetFit/amazon_reviews_multi_en](https://huggingface.co/datasets/SetFit/amazon_reviews_multi_en),
20
+ - **Classes**: Binary classification (`Positive`, `Negative`)
21
+ - **Performance**:
22
+ - **Test Accuracy**: 90%
23
+ - **Validation Accuracy**: 90%
24
+
25
+ *Figure 1: Confusion matrix for test data*
26
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6585ab80ef59559493941225/IXLTT970lQzQqeGHNbkv6.png)
27
+
28
+ )
29
+
30
+ *Figure 2: Confusion matrix for validation data*
31
+
32
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6585ab80ef59559493941225/JhE5eZPpHCxXEJkdaKRyI.png)
33
+
34
+ ### How to Use the Model
35
+
36
+ Below is an example of how to load and use the model for sentiment classification:
37
+
38
+ ```python
39
+ from transformers import DistilBertTokenizer,DistilBertForSequenceClassification,
40
+ import torch
41
+ import streamlit as st
42
+
43
+ # Load the tokenizer and model
44
+ tokenizer = DistilBertForSequenceClassification.from_pretrained(
45
+ "ashish-001/DistilBert-Amazon-review-sentiment-classifier")
46
+ model = DistilBertTokenizer.from_pretrained(
47
+ "ashish-001/DistilBert-Amazon-review-sentiment-classifier")
48
+
49
+ # Example usage
50
+ text = "This product is amazing!"
51
+ inputs = tokenizer(text, return_tensors="pt")
52
+ outputs = model(**inputs)
53
+ logits = outputs.logits
54
+ sentiment = torch.argmax(logits, dim=1).item()
55
+
56
+ print(f"Predicted sentiment: {'Positive' if sentiment else 'Negative'}")