Samuel Scheidegger commited on
Commit
c32c4c1
·
1 Parent(s): fc3885b

Add Example Usage

Browse files
Files changed (1) hide show
  1. README.md +29 -0
README.md CHANGED
@@ -17,6 +17,35 @@ The model is ideal for:
17
  + Research in financial sustainability and climate economics.
18
  + Tracking how banks articulate their climate-related activities.
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  ## Limitations
21
  + Optimized for EU bank reports; performance may vary for other regions.
22
  + Primarily focused on climate and finance domains.
 
17
  + Research in financial sustainability and climate economics.
18
  + Tracking how banks articulate their climate-related activities.
19
 
20
+ ## Example Usage
21
+ Here is an example of how to use the climateBUG-LM model for classifying text as climate-related or not:
22
+
23
+ ```python
24
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
25
+
26
+ tokenizer_name = "lumilogic/climateBUG-LM"
27
+ model_name = "lumilogic/climateBUG-LM"
28
+
29
+
30
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
31
+ tokenizer = AutoTokenizer.from_pretrained(tokenizer_name, max_len=512)
32
+
33
+ pipe = pipeline("text-classification", model=model,
34
+ tokenizer=tokenizer, device_map='auto')
35
+
36
+
37
+ # Climate related text
38
+ text = 'In one case, it was decided not to pursue commercial opportunities based on its recommendation, while in other cases, specific conditions for managing environmental and social risks were imposed.'
39
+ output = pipe(text)
40
+ print(output) # [{'label': 'LABEL_1', 'score': 0.9939790964126587}]
41
+
42
+
43
+ # Non-climate related text
44
+ text = 'Major updates were brought to this software in order to optimise the management and monitoring of expenses under the agreement in 2015.'
45
+ output = pipe(text)
46
+ print(output) # [{'label': 'LABEL_0', 'score': 0.9936821460723877}]
47
+ ```
48
+
49
  ## Limitations
50
  + Optimized for EU bank reports; performance may vary for other regions.
51
  + Primarily focused on climate and finance domains.