Update README.md
Browse files
README.md
CHANGED
@@ -64,4 +64,23 @@ def predict(text):
|
|
64 |
return probs, pred_label_idx, pred_label
|
65 |
```
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
|
|
64 |
return probs, pred_label_idx, pred_label
|
65 |
```
|
66 |
|
67 |
+
- How to infer the model in huggingface ?
|
68 |
+
|
69 |
+
```
|
70 |
+
model_path = "KN123/PromptClassifier-v1.0"
|
71 |
+
|
72 |
+
|
73 |
+
model = BertForSequenceClassification.from_pretrained(model_path)
|
74 |
+
tokenizer= BertTokenizerFast.from_pretrained(model_path)
|
75 |
+
nlp= pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
|
76 |
+
```
|
77 |
+
|
78 |
+
```
|
79 |
+
print(predict("set the color Red to items F-3333"))
|
80 |
+
(tensor([[0.9979, 0.0021]], grad_fn=<SoftmaxBackward0>), tensor(0), 'instruction_prompt')
|
81 |
+
|
82 |
+
nlp("Calculate the average attendance at each sports stadium.")
|
83 |
+
(tensor([[0.0038, 0.9962]], grad_fn=<SoftmaxBackward0>), tensor(1), 'sql_prompt')
|
84 |
+
```
|
85 |
+
|
86 |
|