Takes a text and predicts the sentiment value between -1 (Negative) to 1 (Positive) with 0 being Neutral.
Regression Value Description:
Value
Sentiment
-1
Negative
0
Neutral
1
Positive
How to Get Started with the Model
Use the code below to get started with the model.
import math
import torch
import pandas as pd
from transformers import AutoModelForSequenceClassification, AutoTokenizer
BATCH_SIZE = 32
ds = pd.read_csv('test.csv')
BASE_MODEL = 'HausaNLP/afrisenti-ary-regression'
device = 'cuda' if torch.cuda.is_available() else 'cpu'
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
model = AutoModelForSequenceClassification.from_pretrained(BASE_MODEL)
nb_batches = math.ceil(len(ds)/BATCH_SIZE)
y_preds = []
for i in range(nb_batches):
input_texts = ds[i * BATCH_SIZE: (i+1) * BATCH_SIZE]["tweet"]
encoded = tokenizer(input_texts, truncation=True, padding="max_length", max_length=256, return_tensors="pt").to(device)
y_preds += model(**encoded).logits.reshape(-1).tolist()
df = pd.DataFrame([ds['tweet'], ds['label'], y_preds], ["Text", "Label", "Prediction"]).T
df.to_csv('predictions.csv', index=False)
Runs of HausaNLP afrisenti-ary-regression on huggingface.co
11
Total runs
0
24-hour runs
-1
3-day runs
0
7-day runs
9
30-day runs
More Information About afrisenti-ary-regression huggingface.co Model
afrisenti-ary-regression huggingface.co
afrisenti-ary-regression huggingface.co is an AI model on huggingface.co that provides afrisenti-ary-regression's model effect (), which can be used instantly with this HausaNLP afrisenti-ary-regression model. huggingface.co supports a free trial of the afrisenti-ary-regression model, and also provides paid use of the afrisenti-ary-regression. Support call afrisenti-ary-regression model through api, including Node.js, Python, http.
afrisenti-ary-regression huggingface.co is an online trial and call api platform, which integrates afrisenti-ary-regression's modeling effects, including api services, and provides a free online trial of afrisenti-ary-regression, you can try afrisenti-ary-regression online for free by clicking the link below.
HausaNLP afrisenti-ary-regression online free url in huggingface.co:
afrisenti-ary-regression is an open source model from GitHub that offers a free installation service, and any user can find afrisenti-ary-regression on GitHub to install. At the same time, huggingface.co provides the effect of afrisenti-ary-regression install, users can directly use afrisenti-ary-regression installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
afrisenti-ary-regression install url in huggingface.co: