Downloads · 30 days
6
5% of all-time downloads
SamanthaStorm/intentanalyzer
intentanalyzer is a text classification model from SamanthaStorm. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
IntentAnalyzer is a state-of-the-art multi-label text classification model designed to detect underlying intentions in human communication. Built on DistilBERT architecture, this model can simultaneously identify mult…
Downloads · 30 days
6
5% of all-time downloads
All-time downloads
128
Public
Parameters
66.4M
796 MB on disk
Likes
0
Public
Click a slice to open those files.
.bin266 MB · 50%
From the Hugging Face model README
IntentAnalyzer is a state-of-the-art multi-label text classification model designed to detect underlying intentions in human communication. Built on DistilBERT architecture, this model can simultaneously identify multiple intent categories with high precision, helping understand the psychological and communicative patterns behind text.
The model detects 6 different intent categories (multi-label):
import torch
from transformers import AutoTokenizer, AutoModel
import torch.nn as nn
# Define the model architecture
class MultiLabelIntentClassifier(nn.Module):
def __init__(self, model_name, num_labels):
super().__init__()
self.bert = AutoModel.from_pretrained(model_name)
self.dropout = nn.Dropout(0.3)
self.classifier = nn.Linear(self.bert.config.hidden_size, num_labels)
def forward(self, input_ids, attention_mask):
outputs = self.bert(input_ids=input_ids, attention_mask=attention_mask)
pooled_output = outputs.last_hidden_state[:, 0]
pooled_output = self.dropout(pooled_output)
logits = self.classifier(pooled_output)
return logits
# Load model and tokenizer
model_name = "SamanthaStorm/intentanalyzer"
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
# Load the custom model (you'll need to download the .pth file)
model = MultiLabelIntentClassifier("distilbert-base-uncased", 6)
# model.load_state_dict(torch.load('pytorch_model.bin'))
# Intent categories
intent_categories = ['trolling', 'dismissive', 'manipulative', 'emotionally_reactive', 'constructive', 'unclear']
def predict_intent(text, threshold=0.5):
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
with torch.no_grad():
outputs = model(inputs['input_ids'], inputs['attention_mask'])
probabilities = torch.sigmoid(outputs).numpy()[0]
# Return predictions above threshold
predictions = {}
for i, category in enumerate(intent_categories):
prob = probabilities[i]
if prob > threshold:
predictions[category] = prob
return predictions
# Example usage
text = "You're just being emotional and can't think rationally"
intents = predict_intent(text)
print("Detected intents:", intents)
The model was trained on a carefully curated dataset of 1,226 examples with:
For questions, issues, or collaboration opportunities, please open an issue on the model repository.
This model is designed to help understand communication patterns for constructive purposes such as:
Important: This model should not be used for:
If you use this model in your research, please cite:
@misc{intentanalyzer2024,
author = {SamanthaStorm},
title = {IntentAnalyzer: Multi-Label Communication Intent Detection},
year = {2024},
publisher = {Hugging Face},
url = {https://huggingface.co/SamanthaStorm/intentanalyzer}
}
This model is released under the MIT License.
This model works excellently in combination with:
IntentAnalyzer - Understanding the psychology behind human communication 🎭