Text Classification
Transformers
ONNX
Safetensors
English
Portuguese
bert
classification
questioning
directed
generic
text-embeddings-inference
Instructions to use cnmoro/bert-tiny-question-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cnmoro/bert-tiny-question-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="cnmoro/bert-tiny-question-classifier")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("cnmoro/bert-tiny-question-classifier") model = AutoModelForSequenceClassification.from_pretrained("cnmoro/bert-tiny-question-classifier") - Notebooks
- Google Colab
- Kaggle
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 |
+
```
|