webersni commited on
Commit
fedc1fb
1 Parent(s): cdb81d4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +26 -0
README.md CHANGED
@@ -28,4 +28,30 @@ Using the [climatebert/distilroberta-base-climate-f](https://huggingface.co/clim
28
  institution={Available at SSRN 3998435},
29
  year={2023}
30
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  ```
 
28
  institution={Available at SSRN 3998435},
29
  year={2023}
30
  }
31
+ ```
32
+
33
+ ## How to Get Started With the Model
34
+
35
+ You can use the model with a pipeline for text classification:
36
+
37
+ ```python
38
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
39
+ from transformers.pipelines.pt_utils import KeyDataset
40
+ import datasets
41
+ from tqdm.auto import tqdm
42
+
43
+ dataset_name = "climatebert/climate_detection"
44
+ model_name = "climatebert/distilroberta-base-climate-detector"
45
+
46
+ # If you want to use your own data, simply load them as 🤗 Datasets dataset, see https://huggingface.co/docs/datasets/loading
47
+ dataset = datasets.load_dataset(dataset_name, split="test")
48
+
49
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
50
+ tokenizer = AutoTokenizer.from_pretrained(model_name, max_len=512)
51
+
52
+ pipe = pipeline("text-classification", model=model, tokenizer=tokenizer, device=0)
53
+
54
+ # See https://huggingface.co/docs/transformers/main_classes/pipelines#transformers.pipeline
55
+ for out in tqdm(pipe(KeyDataset(dataset, "text"), padding=True, truncation=True)):
56
+ print(out)
57
  ```