{ "cells": [ { "cell_type": "code", "id": "initial_id", "metadata": { "collapsed": true, "ExecuteTime": { "end_time": "2026-07-05T15:05:59.049967188Z", "start_time": "2026-07-05T15:05:56.833387637Z" } }, "source": [ "import os\n", "os.environ[\"HF_ENDPOINT\"] = \"https://hf-mirror.com\"\n", "import torch\n", "from torch.utils.data import Dataset, DataLoader\n", "import pandas as pd\n", "import transformers\n", "from transformers import AutoTokenizer, AutoModelForSequenceClassification, Trainer, TrainingArguments\n", "from tqdm import tqdm" ], "outputs": [], "execution_count": 2 }, { "metadata": { "ExecuteTime": { "end_time": "2026-07-05T15:05:59.150289671Z", "start_time": "2026-07-05T15:05:59.051997256Z" } }, "cell_type": "code", "source": [ "train_df = pd.read_csv('./train.csv')\n", "test_df = pd.read_csv('./test.csv')\n", "from sklearn.model_selection import train_test_split\n", "train_df, val_df = train_test_split(train_df, test_size=0.1, random_state=42, stratify=train_df['label'])\n", "print(f\"Train: {len(train_df)}, Val: {len(val_df)}, Test: {len(test_df)}\")" ], "id": "f32065752f1597fb", "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Train: 10908, Val: 1212, Test: 5195\n" ] } ], "execution_count": 3 }, { "metadata": { "ExecuteTime": { "end_time": "2026-07-05T15:05:59.184794043Z", "start_time": "2026-07-05T15:05:59.156968452Z" } }, "cell_type": "code", "source": "train_df.head()", "id": "460c6fffc81814df", "outputs": [ { "data": { "text/plain": [ " id premise \\\n", "9989 6417481c8d यद्यपि हम आज के समय में अल कायदा के साथ केएसएए... \n", "3880 5c5ca34cf6 'Upload him into his body? What body?' \n", "8559 1d3c28ecff yeah and then about every five years you have ... \n", "6316 22e2a4903d θέλω να πω ότι υπήρχε είχα, είχα το ρολόι μου ... \n", "762 307016c21f Yet, in the mouths of the white townsfolk of S... \n", "\n", " hypothesis lang_abv language \\\n", "9989 हर व्यक्ति केएसएम को हमेशा अल कायदा के बराबर म... hi Hindi \n", "3880 I don't think he has a body at all. en English \n", "8559 You have to dig them up every five years, thro... en English \n", "6316 Ήταν ενοχλητικό όταν κάλυψε τα παπούτσια μου. el Greek \n", "762 White townsfolk in Salisbury, N.C. are easily ... en English \n", "\n", " label \n", "9989 2 \n", "3880 1 \n", "8559 1 \n", "6316 1 \n", "762 1 " ], "text/html": [ "
| \n", " | id | \n", "premise | \n", "hypothesis | \n", "lang_abv | \n", "language | \n", "label | \n", "
|---|---|---|---|---|---|---|
| 9989 | \n", "6417481c8d | \n", "यद्यपि हम आज के समय में अल कायदा के साथ केएसएए... | \n", "हर व्यक्ति केएसएम को हमेशा अल कायदा के बराबर म... | \n", "hi | \n", "Hindi | \n", "2 | \n", "
| 3880 | \n", "5c5ca34cf6 | \n", "'Upload him into his body? What body?' | \n", "I don't think he has a body at all. | \n", "en | \n", "English | \n", "1 | \n", "
| 8559 | \n", "1d3c28ecff | \n", "yeah and then about every five years you have ... | \n", "You have to dig them up every five years, thro... | \n", "en | \n", "English | \n", "1 | \n", "
| 6316 | \n", "22e2a4903d | \n", "θέλω να πω ότι υπήρχε είχα, είχα το ρολόι μου ... | \n", "Ήταν ενοχλητικό όταν κάλυψε τα παπούτσια μου. | \n", "el | \n", "Greek | \n", "1 | \n", "
| 762 | \n", "307016c21f | \n", "Yet, in the mouths of the white townsfolk of S... | \n", "White townsfolk in Salisbury, N.C. are easily ... | \n", "en | \n", "English | \n", "1 | \n", "