Views
No views yet
1@article{deng2023war,
2 title={War and Policy: Investor Expectations on the Net-Zero Transition},
3 author={Deng, Ming and Leippold, Markus and Wagner, Alexander F and Wang, Qian},
4 journal={Swiss Finance Institute Research Paper},
5 number={22-29},
6 year={2023}
7}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-detector"
8model_name = "climatebert/renewable"
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 out in tqdm(pipe(KeyDataset(dataset, "text"), padding=True, truncation=True)):
20 print(out)