Downloads · 30 days
13
7% of all-time downloads
alwanadi17/distilbert-base-q-cat
distilbert-base-q-cat is a text classification model from alwanadi17. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as gpl-3.0.
distilbert-base-q-cat is a lightweight, fine-tuned DistilBERT model designed for text classification, specifically focusing on categorizing questions into three distinct categories: fact, opinion, and hypothetical. Th…
Downloads · 30 days
13
7% of all-time downloads
All-time downloads
192
Public
Parameters
67M
804 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors268 MB · 100%
From the Hugging Face model README
distilbert-base-q-cat is a lightweight, fine-tuned DistilBERT model designed for text classification, specifically focusing on categorizing questions into three distinct categories: fact, opinion, and hypothetical. The model was trained on a Quora dataset, leveraging keyword-based labeling and sentiment analysis to ensure high-quality categorization.
Built on DistilBERT, ensuring faster inference and lower computational requirements compared to standard BERT.
Three Class Categories:
Pretrained and Fine-Tuned: Utilizes DistilBERT’s pretrained weights with additional fine-tuning on labeled data.
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->The model was trained using a custom dataset derived from Quora questions:
Data Preparation:
Labeling involved keyword-based rules for fact and hypothetical questions.
Sentiment analysis determined questions as opinion-based.
Dataset Size: ~50k samples, split into training, validation, and test sets.
The model achieves the following metrics on the validation set:
To use this model, install the required dependencies:
pip install transformers torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
# Load model and tokenizer
model_name = "distilbert-base-q-cat"
model = AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=3, ignore_mismatched_sizes=True)
tokenizer = AutoTokenizer.from_pretrained(model_name)
def predict_question(question):
inputs = tokenizer(question, return_tensors="pt", truncation=True, padding=True)
outputs = model(**inputs)
logits = outputs.logits
predicted_class = logits.argmax(dim=-1).item()
label_map = {0: "fact", 1: "opinion", 2: "hypothetical"}
return label_map[predicted_class]
# Example usage
question = "What is artificial intelligence?"
print(predict_question(question))