Views
No views yet
id)TFRobertaModel from Hugging Face's transformers library, coupled with custom classification layers using Keras. It expects input sequences of maximum length 128.0: Kenaikan Biaya & Penurunan Manfaat Promo GoFood1: Masalah Driver & Layanan (Ketersediaan, Profesionalitas, Keselamatan)2: Masalah Akun, GoPaylater & Transaksi3: Pujian & Kepuasan Pengguna4: Masalah Performa & Stabilitas Aplikasi.h5) format. It can be loaded using Keras:1import tensorflow as tf
2from tensorflow import keras
3from transformers import TFRobertaModel, RobertaTokenizerFast
4
5# Load tokenizer
6tokenizer = RobertaTokenizerFast.from_pretrained("roberta_tokenizer_aspect")
7
8# Load model
9model = keras.models.load_model(
10 "roberta_aspect_model.h5",
11 custom_objects={"TFRobertaModel": TFRobertaModel},
12 compile=False
13)
14
15# Example usage
16text = "drivernya ramah banget dan cepat sampai"
17encoded = tokenizer(
18 text,
19 padding="max_length",
20 truncation=True,
21 max_length=128,
22 return_tensors="tf"
23)
24
25predictions = model({
26 "input_1": encoded["input_ids"],
27 "input_2": encoded["attention_mask"]
28})
29
30aspect_idx = int(tf.argmax(predictions, axis=1)[0])
31print(f"Predicted Aspect: {aspect_idx}")