ashish-001/tweet-emoji-predictor
By ashish-001 · ↓ 1 · ♥ 0 · Updated 2025-06-14
What's in this repo
This page lists the files in ashish-001/tweet-emoji-predictor, including model_quantized.onnx.
- 1 ONNX models (.onnx files)
- 12 files, including 4 .json, 1 .md, 1 .codes, 1 .pkl, 1 .safetensors, 1 .onnx
- Last updated 2025-06-14
ONNX files
| File | Size | Download |
|---|---|---|
| model_quantized.onnx | — | Download |
How to use
These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.
README
🧠 Tweet Emoji Predictor
This repository hosts a fine-tuned version of the vinai/bertweet-base model for multi-label emoji prediction. Given a short text or tweet, it predicts one or more emojis that reflect the sentiment, context, or activity described.
🛠 Installation
Make sure you have the following libraries installed:
pip install torch numpy scikit-learn transformers huggingface_hub
🚀 How to Use
Step 1: Load the Model and Resources
import torch
import numpy as np
import joblib
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from huggingface_hub import hf_hub_download
REPO_ID = "ashish-001/tweet-emoji-predictor"
# Load label encoder
mlb_path = hf_hub_download(repo_id=REPO_ID, filename="mlb_emoji_encoder.pkl")
with open(mlb_path, "rb") as f:
label_map = joblib.load(f)
# Load emoji thresholds
threshold_path = hf_hub_download(repo_id=REPO_ID, filename="thresholds.npy")
thresholds = np.load(threshold_path)
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained(REPO_ID)
model = AutoModelForSequenceClassification.from_pretrained(REPO_ID)
model.eval()
Step 2: Define Prediction Function
def predict_emojis(text, thresholds=thresholds, label_map=label_map):
inputs = tokenizer(
text,
return_tensors="pt",
truncation=True,
padding="max_length",
max_length=128,
)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.sigmoid(outputs.logits).squeeze(0).numpy()
predictions = (probs >= thresholds).astype(int).reshape(1, -1)
return "".join(label_map.inverse_transform(predictions)[0])
Step 3: Run Example
text = "It is gonna be fun today, will play games and do fun activities. Let's go!!!"
print(predict_emojis(text))
Expected Output (example):
💪🔥
⚙️ Model Details
- Base model:
vinai/bertweet-base - Fine-tuned for: Multi-label emoji classification
- Task type: Sequence classification
- Output: Multi-hot encoded labels, decoded into emojis
- Activation: Sigmoid with class-wise thresholds
🧾 Supported Emojis
This model supports prediction from the following emoji label set (multi-label):
‼ ☺ ♀ ♂ ♥ ✔ ✨ ❤ ➡ 🌟 🎉 🏆 👀
👇 👉 👌 👍 👏 💀 💕 💖 💙 💛 💜 💥 💪
💯 🔥 🗣 😁 😂 😉 😊 😍 😎 😘 😢 😩 😭
😳 🙄 🙌 🙏 🚨 🤔 🤣 🤦 🤷
Total supported emojis: 49
Model info
Created: 2025-06-14
Updated: 2025-06-14
View on Hugging FaceFiles (12)
Related models
More from ashish-001
No other models by this author.