BERT Text Classification

This is a BERT-based text classification model trained on the "socialmedia-disaster-tweets" dataset. It performs sentiment analysis to classify tweets as "Relevant" or "Not Relevant" to a disaster event.

Model Description

The model uses the BERT (Bidirectional Encoder Representations from Transformers) architecture to generate embeddings for the input text. These embeddings are then fed into a sequential Keras model with a dense hidden layer and a sigmoid output layer for binary classification.

Intended Use

This model is intended to be used for text classification on short text snippets, specifically tweets related to disaster events. It can help in identifying relevant tweets for further analysis and response.

Limitations and Ethical Considerations

Usage

Here's an example of how to use the model for inference:

from transformers import TFAutoModel, AutoTokenizer
import tensorflow as tf
import numpy as np

# Load the pre-trained model and tokenizer
model = TFAutoModel.from_pretrained("dnzblgn/BERT_Text_Classification")
tokenizer = AutoTokenizer.from_pretrained("dnzblgn/BERT_Text_Classification")

# Preprocess the input sentence
input_sentence = " Horrible Accident |  Man Died In Wings of AirplaneåÊ(29-07-2015)"
input_sentence = tokenizer.encode_plus(
    input_sentence,
    add_special_tokens=True,
    max_length=768,
    padding="longest",
    truncation=True,
    return_attention_mask=True,
    return_tensors="tf",
)

# Make the prediction
prediction = model.predict(input_sentence)[0][0]
label = "Relevant" if prediction == 0 else "Not Relevant"

print("Input Sentence:", input_sentence)
print("Prediction:", label)