YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Build a complete text classification model for the Kaggle competition "HerWILL X UAP Datathon 2026" using XLM-RoBERTa.
Problem
The task is to classify social media posts into three classes:
- 0 = Explicitly Toxic/Hateful
- 1 = Subtly Toxic
- 2 = Non-toxic/Neutral
The dataset contains approximately 60K Bangla, English, Banglish, code-mixed, and noisy social media posts.
Dataset
Use:
train.csvwith columns:id,text,ytest.csvwith columns:id,textsample_submission.csvwith columns:id,y_pred
Requirements
- Load the training and test datasets.
- Check for missing values and duplicate texts.
- Perform basic text cleaning while preserving important information such as emojis, punctuation, and Banglish words.
- Split the training data into training and validation sets using a stratified split.
- Use
XLM-RoBERTa(xlm-roberta-base) as the pretrained model. - Fine-tune XLM-RoBERTa for 3-class sequence classification.
- Use the Hugging Face Transformers library.
- Tokenize the text using the XLM-RoBERTa tokenizer.
- Handle class imbalance if it exists. Compare the class distribution before deciding whether class weights are necessary.
- Evaluate the model using:
- Macro F1 Score
- Accuracy
- Precision
- Recall
- Confusion Matrix
- Save the best model based on validation Macro F1.
- Use early stopping if appropriate.
- Use GPU if available.
- Train with reasonable settings so that it can run within Kaggle's available resources.
- After training, predict the labels for
test.csv. - Create
submission.csvwith exactly two columns:
idy_pred
- Make sure predictions contain only
0,1, or2. - Display the final validation Macro F1 score and a few sample predictions.
- Keep the code clean, reproducible, and beginner-friendly.
- Include comments explaining the important parts of the code.
Important
Because the dataset contains Bangla, English, Banglish, code-mixed, sarcastic, and noisy social-media text, do not aggressively normalize or remove punctuation/emojis if they may contain useful classification signals.
Provide the complete Python code in a Kaggle Notebook format, divided into clear sections:
- Import Libraries
- Load Dataset
- Exploratory Data Analysis
- Data Cleaning
- Train/Validation Split
- XLM-RoBERTa Tokenization
- Model Setup
- Training
- Validation and Evaluation
- Confusion Matrix
- Test Prediction
- Create Submission File
The final code should be directly runnable in a Kaggle Notebook.