Downloads · 30 days
33
0% of all-time downloads
dipawidia/xlnet-base-cased-product-review-sentiment-analysis
xlnet-base-cased-product-review-sentiment-analysis is a text classification model from dipawidia. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
probably proofread and complete it, then remove this comment. --
Downloads · 30 days
33
0% of all-time downloads
All-time downloads
62.4K
Public
Parameters
117M
3.3 GB on disk
Likes
0
Public
Click a slice to open those files.
.h5469 MB · 50%
From the Hugging Face model README
This model is a fine-tuned version of xlnet-base-cased on any type of product reviews dataset gathered from several e-commerce such as shopee, tokopedia, blibli, lazada, and zalora. The dataset can be found here It achieves the following results on the evaluation set:
This fine-tuned XLNet model is used for sentiment analysis with 2 labels text classification: 0 -> Negative; 1 -> Positive.
from transformers import pipeline
pipe = pipeline("text-classification", model="dipawidia/xlnet-base-cased-product-review-sentiment-analysis")
pipe("This shoes is awesome")
[{'label': 'Positive', 'score': 0.9995703101158142}]
from transformers import XLNetTokenizer, TFXLNetForSequenceClassification
import tensorflow as tf
import numpy as np
tokenizer = XLNetTokenizer.from_pretrained("dipawidia/xlnet-base-cased-product-review-sentiment-analysis")
model = TFXLNetForSequenceClassification.from_pretrained("dipawidia/xlnet-base-cased-product-review-sentiment-analysis")
def get_sentimen(text):
tokenize_text = tokenizer(text, return_tensors = 'tf')
preds = model.predict(dict(tokenize_text))['logits']
class_preds = np.argmax(tf.keras.layers.Softmax()(preds))
if class_preds == 1:
label = 'Positive'
else:
label = 'Negative'
return(label)
get_sentimen('i hate this product')
Output:
Negative
The following hyperparameters were used during training:
| Train Loss | Train Accuracy | Validation Loss | Validation Accuracy | Epoch |
|---|---|---|---|---|
| 0.3417 | 0.8491 | 0.1568 | 0.9449 | 0 |
| 0.1943 | 0.9235 | 0.1504 | 0.9466 | 1 |
| 0.1569 | 0.9404 | 0.1612 | 0.9466 | 2 |
| 0.1238 | 0.9572 | 0.1748 | 0.9475 | 3 |
| 0.1085 | 0.9617 | 0.1910 | 0.9414 | 4 |