Downloads · 30 days
0
fahrendrakhoirul/indobert-lstm-finetuned-ecommerce-reviews
indobert-lstm-finetuned-ecommerce-reviews is a machine learning model from fahrendrakhoirul. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
This model leverages IndoBERT for understanding language and a Long Short-Term Memory (LSTM) network to capture sequential information in customer reviews. It's designed for multi-label classification of e-commerce re…
Downloads · 30 days
0
Access
Public
Updated Oct 17, 2024
Repo size
1.5 GB
Likes
0
Public
Click a slice to open those files.
.bin500 MB · 100%
From the Hugging Face model README
This model leverages IndoBERT for understanding language and a Long Short-Term Memory (LSTM) network to capture sequential information in customer reviews. It's designed for multi-label classification of e-commerce reviews, focusing on:
How to import in PyTorch:
import torch.nn as nn
from huggingface_hub import PyTorchModelHubMixin
from transformers import BertModel, AutoTokenizer
class IndoBertLSTMEcommerceReview(nn.Module, PyTorchModelHubMixin):
def __init__(self, bert):
super().__init__()
self.bert = bert
self.lstm = nn.LSTM(bert.config.hidden_size, 128)
self.linear = nn.Linear(128, 3)
self.sigmoid = nn.Sigmoid()
def forward(self, input_ids, attention_mask):
outputs = self.bert(input_ids=input_ids, attention_mask=attention_mask)
last_hidden_state = outputs.last_hidden_state
lstm_out, _ = self.lstm(last_hidden_state)
pooled = lstm_out[:, -1, :]
logits = self.linear(pooled)
probabilities = self.sigmoid(logits)
return probabilities
bert = BertModel.from_pretrained("indobenchmark/indobert-base-p1")
tokenizer = AutoTokenizer.from_pretrained("fahrendrakhoirul/indobert-lstm-finetuned-ecommerce-reviews")
model = IndoBertLSTMEcommerceReview.from_pretrained("fahrendrakhoirul/indobert-lstm-finetuned-ecommerce-reviews", bert=bert)