Using Climate-TwitterBERT-step-1 (
https://huggingface.co/Climate-TwitterBERT/Climate-TwitterBERT-step1) as the starting model, we fine-tuned on the downstream task to classify whether a given climate tweet belongs to hard/soft/promotion climate tweet.
The model provides a label and probability score, indicating whether a given tweet belongs to hard (label = 0), soft (label = 1), or promotion (label = 2).
1from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
2
3task_name = 'text-classification'
4model_name = 'Climate-TwitterBERT/ Climate-TwitterBERT-step2'
5
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForSequenceClassification.from_pretrained(model_name)
8
9pipe = pipeline(task=task_name, model=model, tokenizer=tokenizer)
10
11tweet = "We are committed to significantly cutting our carbon emissions by 30% before 2030."
12result = pipe(tweet)
13# The 'result' variable will contain the classification output: 0 = hard climate tweet, 1= soft climate tweet, and 2 = promotion tweet.
1@article{fzz2025climatetwitter,
2 title={Responding to Climate Change Crisis: Firms' Tradeoffs},
3 author={Fritsch, Felix and Zhang, Qi and Zheng, Xiang},
4 journal={Journal of Accounting Research},
5 year={2025},
6 doi={10.1111/1475-679X.12625}
7}
8
Fritsch, F., Zhang, Q., & Zheng, X. (2025). Responding to Climate Change Crisis: Firms' Tradeoffs. Journal of Accounting Research.
https://doi.org/10.1111/1475-679X.12625
• Transformers 4.28.1
• Pytorch 2.0.1+cu118
• Datasets 2.14.1
• Tokenizers 0.13.3