Views
No views yet
1@article{schimanski2023climatebertnetzero,
2 title={ClimateBERT-NetZero: Detecting and Assessing Net Zero and Reduction Targets},
3 author={Tobias Schimanski and Julia Bingler and Camilla Hyslop and Mathias Kraus and Markus Leippold},
4 year={2023},
5 eprint={2310.08096},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG}
8}1from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
2from transformers.pipelines.pt_utils import KeyDataset
3import datasets
4from tqdm.auto import tqdm
5
6dataset_name = "climatebert/climate_detection"
7tokenizer_name = "climatebert/distilroberta-base-climate-f"
8model_name = "climatebert/netzero-reduction"
9
10# If you want to use your own data, simply load them as 🤗 Datasets dataset, see https://huggingface.co/docs/datasets/loading
11dataset = datasets.load_dataset(dataset_name, split="test")
12
13model = AutoModelForSequenceClassification.from_pretrained(model_name)
14tokenizer = AutoTokenizer.from_pretrained(tokenizer_name, max_len=512)
15
16pipe = pipeline("text-classification", model=model, tokenizer=tokenizer, device=0)
17
18# See https://huggingface.co/docs/transformers/main_classes/pipelines#transformers.pipeline
19for i, out in enumerate(tqdm(pipe(KeyDataset(dataset, "text"), padding=True, truncation=True))):
20 print(dataset["text"][i])
21 print(out)
22
23### IMPORTANT REMARK: It is highly recommended to use a prior classification step before applying ClimateBERT-NetZero.
24### Establish a climate context with "climatebert/distilroberta-base-climate-detector" for paragraphs
25### or "ESGBERT/EnvironmentalBERT-environmental" for sentences and then label the data with ClimateBERT-NetZero.