MuRIL for Sarcasm Detection (English, Hindi, & Hinglish)
This model is a fine-tuned version of Google's google/muril-base-cased specialized for Sarcasm Detection across English, Hinglish (code-mixed / transliterated Hindi), and Hindi (Devanagari script).
Model Details
- Base Architecture: Multilingual Representations for Indian Languages (MuRIL)
- Task: Binary Sequence Classification (
0: Not Sarcastic,1: Sarcastic) - Languages: English, Hindi, Hinglish (and applicable to Indian languages)
- Regularization: Label Smoothing (0.1) & L2 Weight Decay (0.05) to ensure calibrated, non-overfit confidence scores.
How to Use in Python
You can load and use this model directly in your Python scripts with 3 lines of code:
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
# Load model and tokenizer
model_id = "YOUR_HF_USERNAME/muril-sarcasm-detector"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
model.eval()
# Input sentences
texts = [
"Oh brilliant! Another meeting that could have been an email.",
"Arey wah! 3 ghante late aakar bolte ho 'I am on time'!",
"The package arrived safely today and was packed well."
]
# Tokenize & Predict
inputs = tokenizer(texts, padding=True, truncation=True, max_length=128, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probabilities = torch.softmax(outputs.logits, dim=-1)
for text, prob in zip(texts, probabilities):
label = "Sarcastic" if prob[1] > 0.5 else "Not Sarcastic"
confidence = max(prob[0], prob[1]).item()
print(f"Text: '{text}' -> {label} ({confidence:.1%})")
Intended Use & Limitations
- Trained to identify irony, situational sarcasm, and sarcastic colloquialisms in Indian social media, workplace, and conversational contexts.
- Downloads last month
- 10