descartes100 commited on
Commit
28ab487
1 Parent(s): f3eff79

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +34 -0
README.md CHANGED
@@ -39,6 +39,40 @@ This repository contains a fine-tuned DistilBERT model using the [esg-sentiment
39
  - Fine-tuned on the esg-sentiment dataset
40
  - Optimized for sentiment analysis in the context of ESG
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  ## Intended uses & limitations
43
 
44
  ### Intended Uses
 
39
  - Fine-tuned on the esg-sentiment dataset
40
  - Optimized for sentiment analysis in the context of ESG
41
 
42
+ ## Usage
43
+ ```
44
+ from transformers import DistilBertTokenizer, DistilBertForSequenceClassification
45
+ import torch
46
+
47
+ tokenizer = DistilBertTokenizer.from_pretrained('descartes100/distilBERT_ESG')
48
+ model = DistilBertForSequenceClassification.from_pretrained('descartes100/distilBERT_ESG')
49
+
50
+ text = "Our waste reduction initiatives aim to minimize environmental impact. From recycling programs to waste reduction technologies, we're dedicated to responsibly managing resources."
51
+ encoding = tokenizer(text, return_tensors="pt")
52
+ encoding = {k: v.to(trainer.model.device) for k,v in encoding.items()}
53
+ outputs = model(**encoding)
54
+ logits = outputs.logits
55
+ sigmoid = torch.nn.Sigmoid()
56
+ probs = sigmoid(logits.squeeze().cpu())
57
+ predictions = np.zeros(probs.shape)
58
+ predictions[np.where(probs >= 0.5)] = 1
59
+
60
+ for idx, label in enumerate(predictions):
61
+ print(id2label[idx], ':', label)
62
+ ```
63
+ ### Result
64
+ ```
65
+ Environmental Negative : 0.0
66
+ Environmental Neutral : 0.0
67
+ Environmental Positive : 1.0
68
+ Social Negative : 0.0
69
+ Social Neutral : 0.0
70
+ Social Positive : 1.0
71
+ Governance Negative : 0.0
72
+ Governance Neutral : 0.0
73
+ Governance Positive : 0.0
74
+ ```
75
+
76
  ## Intended uses & limitations
77
 
78
  ### Intended Uses