Update README.md
Browse files
README.md
CHANGED
@@ -24,4 +24,33 @@ If a question is not directed, we would change the actions we perform on a RAG p
|
|
24 |
|
25 |
(Class 0 is Generic; Class 1 is Directed)
|
26 |
|
27 |
-
The accuracy on the training dataset is around 87.5%
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
(Class 0 is Generic; Class 1 is Directed)
|
26 |
|
27 |
+
The accuracy on the training dataset is around 87.5%
|
28 |
+
|
29 |
+
```python
|
30 |
+
from transformers import BertForSequenceClassification, BertTokenizerFast
|
31 |
+
import torch
|
32 |
+
|
33 |
+
# Load the model and tokenizer
|
34 |
+
model = BertForSequenceClassification.from_pretrained("cnmoro/bert-tiny-question-classifier")
|
35 |
+
tokenizer = BertTokenizerFast.from_pretrained("cnmoro/bert-tiny-question-classifier")
|
36 |
+
|
37 |
+
def is_question_generic(question):
|
38 |
+
# Tokenize the sentence and convert to PyTorch tensors
|
39 |
+
inputs = tokenizer(
|
40 |
+
question.lower(),
|
41 |
+
truncation=True,
|
42 |
+
padding=True,
|
43 |
+
return_tensors="pt",
|
44 |
+
max_length=512
|
45 |
+
)
|
46 |
+
|
47 |
+
# Get the model's predictions
|
48 |
+
with torch.no_grad():
|
49 |
+
outputs = model(**inputs)
|
50 |
+
|
51 |
+
# Extract the prediction
|
52 |
+
predictions = outputs.logits
|
53 |
+
predicted_class = torch.argmax(predictions).item()
|
54 |
+
|
55 |
+
return int(predicted_class) == 0
|
56 |
+
```
|