luerhard commited on
Commit
cf44004
·
verified ·
1 Parent(s): b67ea4f

Fix Code Example in README

Browse files
Files changed (1) hide show
  1. README.md +6 -5
README.md CHANGED
@@ -30,14 +30,15 @@ The table connects the position of the predicted probability to its dimension.
30
  # Usage Example
31
 
32
  ```python
33
- from transformers import AutoModel
 
34
  from transformers import AutoTokenizer
35
 
36
  # load tokenizer
37
  tokenizer = AutoTokenizer.from_pretrained("luerhard/PopBERT")
38
 
39
  # load model
40
- model = AutoModel.from_pretrained("luerhard/PopBERT")
41
 
42
  # define text to be predicted
43
  text = (
@@ -47,7 +48,7 @@ text = (
47
  )
48
 
49
  # encode text with tokenizer
50
- encodings = tokenizer(text)
51
 
52
  # predict
53
  with torch.inference_mode():
@@ -59,7 +60,7 @@ print(probs.detach().numpy())
59
  ```
60
 
61
  ```
62
- array([[0.87651485, 0.34838045, 0.983123 , 0.02148381]], dtype=float32)
63
  ```
64
 
65
 
@@ -71,7 +72,7 @@ To maximize performance, it is recommended to use the following thresholds per d
71
  [0.415961, 0.295400, 0.429109, 0.302714]
72
  ```
73
 
74
- Using these thresholds, the model achieves the follwing performance on the test set:
75
 
76
  | Dimension | Precision | Recall | F1 |
77
  |---------------------|---------------|---------------|---------------|
 
30
  # Usage Example
31
 
32
  ```python
33
+ import torch
34
+ from transformers import AutoModelForSequenceClassification
35
  from transformers import AutoTokenizer
36
 
37
  # load tokenizer
38
  tokenizer = AutoTokenizer.from_pretrained("luerhard/PopBERT")
39
 
40
  # load model
41
+ model = AutoModelForSequenceClassification.from_pretrained("luerhard/PopBERT")
42
 
43
  # define text to be predicted
44
  text = (
 
48
  )
49
 
50
  # encode text with tokenizer
51
+ encodings = tokenizer(text, return_tensors="pt")
52
 
53
  # predict
54
  with torch.inference_mode():
 
60
  ```
61
 
62
  ```
63
+ [[0.8765146 0.34838045 0.983123 0.02148379]]
64
  ```
65
 
66
 
 
72
  [0.415961, 0.295400, 0.429109, 0.302714]
73
  ```
74
 
75
+ Using these thresholds, the model achieves the following performance on the test set:
76
 
77
  | Dimension | Precision | Recall | F1 |
78
  |---------------------|---------------|---------------|---------------|