--- license: apache-2.0 --- The LM is to detect the attitutde to a text on climate changes. The attitutde includes three types: risk, neutral and opportunity, which is 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 training dataset from "climatebert/climate_sentiment". 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. The following code shows how to test in the model. python ``` import torch from transformers import AutoModelForSequenceClassification, AutoTokenizer # Load the model and tokenizer from the directory where it's saved model_path = "model" model = AutoModelForSequenceClassification.from_pretrained(model_path) tokenizer = AutoTokenizer.from_pretrained(model_path) # Function to prepare and make predictions on text def predict_climate_att(text): # Encode the text using the tokenizer encoded_input = tokenizer(text, return_tensors='pt', padding=True, truncation=True, max_length=64) # Evaluate the model on the encoded text model.eval() with torch.no_grad(): outputs = model(**encoded_input) # Extract logits (the outputs of the model before any final activation function) logits = outputs.logits.squeeze() # (Optional) Apply a final activation function if necessary (e.g., softmax for classification) # probabilities = torch.softmax(logits, dim=0) # For now, let's just return the raw logits return logits # Example usage text = "Your example text goes here." predictions = predict_climate_att(text) print(predictions) '''