Edit model card

This is the repo for Gen AI final project

Info

License: Mit

Original code: https://github.com/hyunwoongko/transformer

My version: https://github.com/Agaresd47/transformer_SAE

Data: Source: https://huggingface.co/datasets/li2017dailydialog/daily_dialog

Usage

import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch.nn.functional as F

# Load the model and tokenizer
model = AutoModelForSequenceClassification.from_pretrained("agaresd/your-model-name")
tokenizer = AutoTokenizer.from_pretrained("agaresd/your-model-name")

# Define the label mapping
label_mapping = {
    0: "no emotion",
    1: "anger ",
    2: "disgust ",
    3: "fear ",
    4: "Emotion: Happy",
    5: "Emotion: Sad",
    6: "Emotion: surprise"
}

# Input text
input_text = "happy"

# Tokenize and get model outputs
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model(**inputs)

# Get logits, apply softmax, and find the predicted class
logits = outputs.logits
probabilities = F.softmax(logits, dim=-1)
predicted_class = torch.argmax(probabilities, dim=-1).item()

# Map the predicted class to a word
predicted_label = label_mapping[predicted_class]
print(f"Input: {input_text}")
print(f"Predicted Label: {predicted_label}")
Downloads last month
38
Safetensors
Model size
109M params
Tensor type
F32
·
Inference Examples
Unable to determine this model's library. Check the docs .

Dataset used to train agaresd/GEN-AI-Final-project