kevintu commited on
Commit
6205308
·
verified ·
1 Parent(s): a9e980f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +45 -3
README.md CHANGED
@@ -1,3 +1,45 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+ The LM is to detect the attitutde to a text on climate changes. The attitutde includes three types: risk, neutral and opportunity, which is
5
+ similar to negative, neutral and positive in sentmental analysis. We used fine-tuning method to change the last layer of "cardiffnlp/twitter-roberta-base-sentiment-latest" using the
6
+ training dataset from "climatebert/climate_sentiment".
7
+
8
+ Compared with the existing similar models (e.g, climatebert/distilroberta-base-climate-sentiment, XerOpred/twitter-climate-sentiment-model ) with the accuracy ranging from 10% to 30% and F1 score about 15%, our model shows wonderful results: accuracy 89%, and F1 score 89% if we use the test dataset from climatebert/climate_sentiment.
9
+
10
+ The following code shows how to test in the model.
11
+ python
12
+ ```
13
+ import torch
14
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
15
+
16
+ # Load the model and tokenizer from the directory where it's saved
17
+ model_path = "model"
18
+ model = AutoModelForSequenceClassification.from_pretrained(model_path)
19
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
20
+
21
+ # Function to prepare and make predictions on text
22
+ def predict_climate_att(text):
23
+ # Encode the text using the tokenizer
24
+ encoded_input = tokenizer(text, return_tensors='pt', padding=True, truncation=True, max_length=64)
25
+
26
+ # Evaluate the model on the encoded text
27
+ model.eval()
28
+ with torch.no_grad():
29
+ outputs = model(**encoded_input)
30
+
31
+ # Extract logits (the outputs of the model before any final activation function)
32
+ logits = outputs.logits.squeeze()
33
+
34
+ # (Optional) Apply a final activation function if necessary (e.g., softmax for classification)
35
+ # probabilities = torch.softmax(logits, dim=0)
36
+
37
+ # For now, let's just return the raw logits
38
+ return logits
39
+
40
+ # Example usage
41
+ text = "Your example text goes here."
42
+ predictions = predict_climate_att(text)
43
+ print(predictions)
44
+
45
+ '''