### Run IndoBERTweet Hate Speech Classification Command Source: https://context7.com/indolem/indobertweet/llms.txt Example command to run the IndoBERTweet script for hate speech classification (HS1). Configures model, data path, batch size, epochs, learning rate, and patience. ```bash # python hate_speech_HS1/indobertweet.py \ # --bert_model indobertweet \ # --data_path hate_speech_HS1/data/ \ # --batch_size 30 \ # --num_train_epochs 20 \ # --learning_rate 5e-5 \ # --patience 5 ``` -------------------------------- ### Load IndoBERTweet Model and Tokenizer Source: https://github.com/indolem/indobertweet/blob/main/README.md Load the pre-trained IndoBERTweet model and its corresponding tokenizer using the transformers library. Ensure you have transformers version 3.5.1 or compatible installed. ```python from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("indolem/indobertweet-base-uncased") model = AutoModel.from_pretrained("indolem/indobertweet-base-uncased") ``` -------------------------------- ### Instantiate and Perform Single Forward Pass with IndoBERTweet Source: https://context7.com/indolem/indobertweet/llms.txt Instantiate the IndoBERTweet model for 3-class emotion detection and perform a single forward pass to get logits and predictions. Ensure the model and data are on the correct device. ```python args = argparse.Namespace(bert_model='indobertweet', vocab_label_size=3) device = torch.device("cpu") model = Model(args, device) model.to(device) # Single forward pass src, seg, label, mask_src = Batch(dataset, 0, 2, device).get() logits = model.forward(src, seg, mask_src) print(logits.shape) # torch.Size([2, 3]) preds = model.predict(src, seg, mask_src) print(preds) # e.g. [2, 0] ```