ongaunjie commited on
Commit
7f103fe
1 Parent(s): fa15d2a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +15 -2
README.md CHANGED
@@ -28,11 +28,24 @@ pip install transformers
28
 
29
  You can easily load the pre-trained model for sentiment analysis using Hugging Face's AutoModelForSequenceClassification.
30
 
31
- ```bash
32
  from transformers import DistilBertForSequenceClassification, DistilBertTokenizerFast
 
33
 
34
- model_name = "ongaunjie/distilbert-cloths-sentiment" # Replace with a valid model name from Hugging Face's model hub
35
  tokenizer = DistilBertTokenizerFast.from_pretrained(model_name)
36
  model = DistilBertForSequenceClassification.from_pretrained(model_name)
37
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
 
28
 
29
  You can easily load the pre-trained model for sentiment analysis using Hugging Face's AutoModelForSequenceClassification.
30
 
31
+ ```python
32
  from transformers import DistilBertForSequenceClassification, DistilBertTokenizerFast
33
+ import torch
34
 
35
+ model_name = "ongaunjie/distilbert-cloths-sentiment"
36
  tokenizer = DistilBertTokenizerFast.from_pretrained(model_name)
37
  model = DistilBertForSequenceClassification.from_pretrained(model_name)
38
 
39
+ ## Inference
40
+ You can use this model to perform sentiment analysis on text. Here's an example of how to do it in Python:
41
+
42
+ ```python
43
+ review = "This dress is amazing, I love it!"
44
+ inputs = tokenizer.encode(review, return_tensors="pt")
45
+ with torch.no_grad():
46
+ outputs = model(inputs)
47
+ predicted_class = int(torch.argmax(outputs.logits))
48
+
49
+
50
+
51