dnzblgn's picture
Update README.md
7deacc7
# Model Card: BART-based Sentiment Classification Model
# LABEL_0 = NEGATIVE
# LABEL_1 = NEUTRAL
# LABEL_2 = POSITIVE
# Model Details
Model Name: BART-based Sentiment Classification Model
Description: This model is trained using BART (Bidirectional and Auto-Regressive Transformers) for sentiment classification on the chat_dataset. It takes a message as input and predicts the sentiment category, which can be one of three labels: LABEL_0, LABEL_1, or LABEL_2.
Framework: PyTorch
Model Architecture: BARTForSequenceClassification (based on the BART model architecture)
Pretrained Model: Facebook's BART-base
# Intended Use
Primary Task: Sentiment Classification
Input: Textual message (string)
Output: Sentiment category label (LABEL_0(NEGATIVE), LABEL_1(NEUTRAL), or LABEL_2(POSITIVE))
# Training Data
Dataset: chat_dataset.csv
Data Preprocessing: The dataset is loaded from the CSV file. The messages are tokenized using the BART tokenizer, and the sentiment labels are encoded using a LabelEncoder. The dataset is split into training and testing sets.
Model Training: The model is trained using the training set with a batch size of 4 and AdamW optimizer. The training loop runs for 5 epochs, optimizing the cross-entropy loss between predicted and true labels.
# Evaluation
Evaluation Dataset: The model's performance can be evaluated using the provided testing set or any other suitable dataset with sentiment labels.
Expected Performance: The model is expected to achieve reasonable accuracy in sentiment classification based on the quality and representativeness of the training data.
# Usage Example
Load the model and tokenizer
model = BartForSequenceClassification.from_pretrained("path/to/model/directory")
tokenizer = BartTokenizer.from_pretrained("path/to/tokenizer/directory")
Perform sentiment classification on a sample sentence
input_text = "This is a great product!"
input_tokens = tokenizer.encode_plus(input_text, padding="max_length", truncation=True, max_length=max_length, return_tensors="pt")
input_ids = input_tokens["input_ids"].to(device)
attention_mask = input_tokens["attention_mask"].to(device)
with torch.no_grad():
outputs = model(input_ids=input_ids, attention_mask=attention_mask)
logits = outputs.logits
predicted_label = torch.argmax(logits, dim=1).item()
sentiment_category = le.inverse_transform([predicted_label])[0]
print(f"Input: {input_text}")
print(f"Predicted Sentiment: {sentiment_category}")