philippgawlik commited on
Commit
8d234af
1 Parent(s): a13a231

Added application example

Browse files
Files changed (1) hide show
  1. README.md +27 -0
README.md CHANGED
@@ -55,3 +55,30 @@ After multiple test runs of finetuning the present model was further trained usi
55
  - weight_decay: 0.1
56
  - metric_for_best_model: precision
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  - weight_decay: 0.1
56
  - metric_for_best_model: precision
57
 
58
+ ### Example: Direct model evaluation
59
+
60
+ ```python
61
+
62
+ from transformers import (
63
+ AutoModelForSequenceClassification,
64
+ AutoTokenizer,
65
+ pipeline,
66
+ )
67
+
68
+ comment = "The preprocessed comment to classify"
69
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
70
+ tokenizer.pad_token = tokenizer.eos_token
71
+ model = AutoModelForSequenceClassification.from_pretrained(model_path)
72
+ pipe = pipeline("text-classification", model=model, tokenizer=tokenizer)
73
+
74
+ result = pipe(comment)
75
+ label = result[0]["label"]
76
+ if label == "LABEL_1":
77
+ has_mention = True
78
+ elif label == "LABEL_0":
79
+ has_mention = False
80
+
81
+ print(f"Comment includes mention {has_mention}")
82
+ ```
83
+
84
+