Downloads · 30 days
19
11% of all-time downloads
fabhiansan/bertsumabs-indonesian-XLSum-filtered
bertsumabs-indonesian-XLSum-filtered is a machine learning model from fabhiansan. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
19
11% of all-time downloads
All-time downloads
172
Public
Repo size
2.9 GB
Likes
0
Public
Click a slice to open those files.
.pt1.4 GB · 67%
From the Hugging Face model README
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import torch
MODEL_ID = "fabhiansan/bertsumabs-indonesian-XLSum-filtered"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_ID, trust_remote_code=True)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
model.eval()
artikel_contoh = """
Presiden Joko Widodo secara resmi meluncurkan logo Ibu Kota Nusantara (IKN) di Istana Negara, Jakarta, Selasa (30/5/2023).
Logo yang terpilih adalah hasil sayembara yang diikuti oleh ratusan peserta dari berbagai daerah di Indonesia.
Logo IKN yang baru ini memiliki desain modern dan filosofis, melambangkan semangat persatuan dan kemajuan bangsa.
"""
inputs = tokenizer(
artikel_contoh,
max_length=512,
truncation=True,
padding="max_length",
return_tensors="pt"
)
input_ids = inputs["input_ids"].to(device)
attention_mask = inputs["attention_mask"].to(device)
with torch.no_grad():
summary_ids = model.generate(
input_ids=input_ids,
attention_mask=attention_mask,
max_length=model.config.max_target_length,
num_beams=model.config.num_beams,
length_penalty=model.config.length_penalty,
early_stopping=True,
bos_token_id=model.config.decoder_start_token_id,
pad_token_id=model.config.pad_token_id,
eos_token_id=model.config.eos_token_id
)
ringkasan_dihasilkan = tokenizer.decode(summary_ids[0], skip_special_tokens=True, clean_up_tokenization_spaces=True)
print("\nArtikel Asli:\n", artikel_contoh)
print("\nRingkasan yang Dihasilkan:\n", ringkasan_dihasilkan)