This is the first classification of sentiment analysis for police new task
How to import
import torch
from transformers import BertForSequenceClassification, BertTokenizer, BertConfig, pipeline
# Load the tokenizer and model
tokenizer = BertTokenizer.from_pretrained("nfhakim/police-sentiment-c1-v2")
config = BertConfig.from_pretrained("nfhakim/police-sentiment-c1-v2")
model = BertForSequenceClassification.from_pretrained("nfhakim/police-sentiment-c1-v2", config=config)
How to use
# Initialize the pipeline
nlp = pipeline("text-classification", model=model, tokenizer=tokenizer)
# Define a function to handle input text
def classify_text(text):
# Tokenize the text and truncate to the first 512 tokens if necessary
inputs = tokenizer(text, truncation=True, max_length=512, return_tensors="pt")
# Use the model to classify the text
results = nlp(inputs['input_ids'])
return results
# Example usage
input_text = "Your input text here"
output = classify_text(input_text)
print(output)
- Downloads last month
- 7
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social
visibility and check back later, or deploy to Inference Endpoints (dedicated)
instead.