Upload folder using huggingface_hub
Browse files- data new/data-00000-of-00001.arrow +3 -0
- data new/dataset_info.json +72 -0
- data new/state.json +13 -0
- data.ipynb +479 -0
data new/data-00000-of-00001.arrow
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:da700db67c98a1bd85ef9f06dceb60582d446419766237ec0ea804ae582a880b
|
| 3 |
+
size 2583640
|
data new/dataset_info.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"builder_name": "parquet",
|
| 3 |
+
"citation": "",
|
| 4 |
+
"config_name": "default",
|
| 5 |
+
"dataset_name": "rotten_tomatoes",
|
| 6 |
+
"dataset_size": 1346784,
|
| 7 |
+
"description": "",
|
| 8 |
+
"download_size": 881052,
|
| 9 |
+
"features": {
|
| 10 |
+
"text": {
|
| 11 |
+
"dtype": "string",
|
| 12 |
+
"_type": "Value"
|
| 13 |
+
},
|
| 14 |
+
"label": {
|
| 15 |
+
"names": [
|
| 16 |
+
"neg",
|
| 17 |
+
"pos"
|
| 18 |
+
],
|
| 19 |
+
"_type": "ClassLabel"
|
| 20 |
+
},
|
| 21 |
+
"input_ids": {
|
| 22 |
+
"feature": {
|
| 23 |
+
"dtype": "int32",
|
| 24 |
+
"_type": "Value"
|
| 25 |
+
},
|
| 26 |
+
"_type": "List"
|
| 27 |
+
},
|
| 28 |
+
"token_type_ids": {
|
| 29 |
+
"feature": {
|
| 30 |
+
"dtype": "int8",
|
| 31 |
+
"_type": "Value"
|
| 32 |
+
},
|
| 33 |
+
"_type": "List"
|
| 34 |
+
},
|
| 35 |
+
"attention_mask": {
|
| 36 |
+
"feature": {
|
| 37 |
+
"dtype": "int8",
|
| 38 |
+
"_type": "Value"
|
| 39 |
+
},
|
| 40 |
+
"_type": "List"
|
| 41 |
+
}
|
| 42 |
+
},
|
| 43 |
+
"homepage": "",
|
| 44 |
+
"license": "",
|
| 45 |
+
"size_in_bytes": 2227836,
|
| 46 |
+
"splits": {
|
| 47 |
+
"train": {
|
| 48 |
+
"name": "train",
|
| 49 |
+
"num_bytes": 1075873,
|
| 50 |
+
"num_examples": 8530,
|
| 51 |
+
"dataset_name": "rotten_tomatoes"
|
| 52 |
+
},
|
| 53 |
+
"validation": {
|
| 54 |
+
"name": "validation",
|
| 55 |
+
"num_bytes": 134809,
|
| 56 |
+
"num_examples": 1066,
|
| 57 |
+
"dataset_name": "rotten_tomatoes"
|
| 58 |
+
},
|
| 59 |
+
"test": {
|
| 60 |
+
"name": "test",
|
| 61 |
+
"num_bytes": 136102,
|
| 62 |
+
"num_examples": 1066,
|
| 63 |
+
"dataset_name": "rotten_tomatoes"
|
| 64 |
+
}
|
| 65 |
+
},
|
| 66 |
+
"version": {
|
| 67 |
+
"version_str": "0.0.0",
|
| 68 |
+
"major": 0,
|
| 69 |
+
"minor": 0,
|
| 70 |
+
"patch": 0
|
| 71 |
+
}
|
| 72 |
+
}
|
data new/state.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_data_files": [
|
| 3 |
+
{
|
| 4 |
+
"filename": "data-00000-of-00001.arrow"
|
| 5 |
+
}
|
| 6 |
+
],
|
| 7 |
+
"_fingerprint": "76aa1ee7c42fa680",
|
| 8 |
+
"_format_columns": null,
|
| 9 |
+
"_format_kwargs": {},
|
| 10 |
+
"_format_type": null,
|
| 11 |
+
"_output_all_columns": false,
|
| 12 |
+
"_split": "train"
|
| 13 |
+
}
|
data.ipynb
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 5,
|
| 6 |
+
"id": "97b0d8fe",
|
| 7 |
+
"metadata": {},
|
| 8 |
+
"outputs": [],
|
| 9 |
+
"source": [
|
| 10 |
+
"from datasets import load_dataset\n",
|
| 11 |
+
"\n",
|
| 12 |
+
"ds = load_dataset(\"Trelis/tiny-shakespeare\")"
|
| 13 |
+
]
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"cell_type": "code",
|
| 17 |
+
"execution_count": 17,
|
| 18 |
+
"id": "d54a70f3",
|
| 19 |
+
"metadata": {},
|
| 20 |
+
"outputs": [
|
| 21 |
+
{
|
| 22 |
+
"data": {
|
| 23 |
+
"text/plain": [
|
| 24 |
+
"DatasetDict({\n",
|
| 25 |
+
" train: Dataset({\n",
|
| 26 |
+
" features: ['Text'],\n",
|
| 27 |
+
" num_rows: 472\n",
|
| 28 |
+
" })\n",
|
| 29 |
+
" test: Dataset({\n",
|
| 30 |
+
" features: ['Text'],\n",
|
| 31 |
+
" num_rows: 49\n",
|
| 32 |
+
" })\n",
|
| 33 |
+
"})"
|
| 34 |
+
]
|
| 35 |
+
},
|
| 36 |
+
"execution_count": 17,
|
| 37 |
+
"metadata": {},
|
| 38 |
+
"output_type": "execute_result"
|
| 39 |
+
}
|
| 40 |
+
],
|
| 41 |
+
"source": [
|
| 42 |
+
"ds"
|
| 43 |
+
]
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"cell_type": "code",
|
| 47 |
+
"execution_count": 18,
|
| 48 |
+
"id": "f97c17e3",
|
| 49 |
+
"metadata": {},
|
| 50 |
+
"outputs": [],
|
| 51 |
+
"source": [
|
| 52 |
+
"train = load_dataset(\"Trelis/tiny-shakespeare\", split=\"train\")"
|
| 53 |
+
]
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"cell_type": "code",
|
| 57 |
+
"execution_count": 19,
|
| 58 |
+
"id": "6e24f16c",
|
| 59 |
+
"metadata": {},
|
| 60 |
+
"outputs": [
|
| 61 |
+
{
|
| 62 |
+
"data": {
|
| 63 |
+
"text/plain": [
|
| 64 |
+
"{'Text': \"First Citizen:\\nBefore we proceed any further, hear me speak.\\n\\nAll:\\nSpeak, speak.\\n\\nFirst Citizen:\\nYou are all resolved rather to die than to famish?\\n\\nAll:\\nResolved. resolved.\\n\\nFirst Citizen:\\nFirst, you know Caius Marcius is chief enemy to the people.\\n\\nAll:\\nWe know't, we know't.\\n\\nFirst Citizen:\\nLet us kill him, and we'll have corn at our own price.\\nIs't a verdict?\\n\\nAll:\\nNo more talking on't; let it be done: away, away!\\n\\nSecond Citizen:\\nOne word, good citizens.\\n\\nFirst Citizen:\\nWe are accounted poor citizens, the patricians good.\\nWhat authority surfeits on would relieve us: if they\\nwould yield us but the superfluity, while it were\\nwholesome, we might guess they relieved us humanely;\\nbut they think we are too dear: the leanness that\\nafflicts us, the object of our misery, is as an\\ninventory to particularise their abundance; our\\nsufferance is a gain to them Let us revenge this with\\nour pikes, ere we become rakes: for the gods know I\\nspeak this in hunger for bread, not in thirst for revenge.\\n\\nSecond Citizen:\\nWould you proceed especially against Caius Marcius?\\n\\nAll:\\nAgainst him first: he's a very dog to the commonalty.\\n\\nSecond Citizen:\\nConsider you what services he has done for his country?\\n\\nFirst Citizen:\\nVery well; and could be content to give him good\\nreport fort, but that he pays himself with being proud.\\n\\nSecond Citizen:\\nNay, but speak not maliciously.\\n\\nFirst Citizen:\\nI say unto you, what he hath done famously, he did\\nit to that end: though soft-conscienced men can be\\ncontent to say it was for his country he did it to\\nplease his mother and to be partly proud; which he\\nis, even till the altitude of his virtue.\\n\\nSecond Citizen:\\nWhat he cannot help in his nature, you account a\\nvice in him. You must in no way say he is covetous.\\n\\nFirst Citizen:\\nIf I must not, I need not be barren of accusations;\\nhe hath faults, with surplus, to tire in repetition.\\nWhat shouts are these? The other side o' the city\\nis risen: why stay we prating here? to the Capitol!\\n\\nAll:\\nCome, come.\\n\\nFirst Citizen:\\nSoft! who comes here?\\n\\nSecond Citizen:\\nWorthy Menenius Agrippa; one that hath always loved\\nthe people.\\n\\nFirst Citizen:\\nHe's one honest enough: would all the rest were so!\\n\\nMENENIUS:\\nWhat work's, my countrymen, in hand? where go you\\nWith bats and clubs? The matter? speak, I pray you.\\n\\nFirst Citizen:\\nOur business is not unknown to the senate; they have\\nhad inkling this fortnight what we intend to do,\\nwhich now we'll show 'em in deeds. They say poor\\nsuitors have strong breaths: they shall know we\\nhave strong arms too.\\n\\nMENENIUS:\\nWhy, masters, my good friends, mine honest neighbours,\\nWill you undo yourselves?\\n\\nFirst Citizen:\\nWe cannot, sir, we are undone already.\\n\\nMENENIUS:\\nI tell you, friends, most charitable care\\nHave the patricians of you. For your wants,\\nYour suffering in this dearth, you may as well\\nStrike at the heaven with your staves as lift them\\nAgainst the Roman state, whose course will on\\nThe way it takes, cracking ten thousand curbs\\nOf more strong link asunder than can ever\\nAppear in your impediment. For the dearth,\\nThe gods, not the patricians, make it, and\\nYour knees to them, not arms, must help.\"}"
|
| 65 |
+
]
|
| 66 |
+
},
|
| 67 |
+
"execution_count": 19,
|
| 68 |
+
"metadata": {},
|
| 69 |
+
"output_type": "execute_result"
|
| 70 |
+
}
|
| 71 |
+
],
|
| 72 |
+
"source": [
|
| 73 |
+
"train[0]"
|
| 74 |
+
]
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"cell_type": "code",
|
| 78 |
+
"execution_count": 11,
|
| 79 |
+
"id": "74397d27",
|
| 80 |
+
"metadata": {},
|
| 81 |
+
"outputs": [
|
| 82 |
+
{
|
| 83 |
+
"name": "stdout",
|
| 84 |
+
"output_type": "stream",
|
| 85 |
+
"text": [
|
| 86 |
+
"{'Text': \"First Citizen:\\nBefore we proceed any further, hear me speak.\\n\\nAll:\\nSpeak, speak.\\n\\nFirst Citizen:\\nYou are all resolved rather to die than to famish?\\n\\nAll:\\nResolved. resolved.\\n\\nFirst Citizen:\\nFirst, you know Caius Marcius is chief enemy to the people.\\n\\nAll:\\nWe know't, we know't.\\n\\nFirst Citizen:\\nLet us kill him, and we'll have corn at our own price.\\nIs't a verdict?\\n\\nAll:\\nNo more talking on't; let it be done: away, away!\\n\\nSecond Citizen:\\nOne word, good citizens.\\n\\nFirst Citizen:\\nWe are accounted poor citizens, the patricians good.\\nWhat authority surfeits on would relieve us: if they\\nwould yield us but the superfluity, while it were\\nwholesome, we might guess they relieved us humanely;\\nbut they think we are too dear: the leanness that\\nafflicts us, the object of our misery, is as an\\ninventory to particularise their abundance; our\\nsufferance is a gain to them Let us revenge this with\\nour pikes, ere we become rakes: for the gods know I\\nspeak this in hunger for bread, not in thirst for revenge.\\n\\nSecond Citizen:\\nWould you proceed especially against Caius Marcius?\\n\\nAll:\\nAgainst him first: he's a very dog to the commonalty.\\n\\nSecond Citizen:\\nConsider you what services he has done for his country?\\n\\nFirst Citizen:\\nVery well; and could be content to give him good\\nreport fort, but that he pays himself with being proud.\\n\\nSecond Citizen:\\nNay, but speak not maliciously.\\n\\nFirst Citizen:\\nI say unto you, what he hath done famously, he did\\nit to that end: though soft-conscienced men can be\\ncontent to say it was for his country he did it to\\nplease his mother and to be partly proud; which he\\nis, even till the altitude of his virtue.\\n\\nSecond Citizen:\\nWhat he cannot help in his nature, you account a\\nvice in him. You must in no way say he is covetous.\\n\\nFirst Citizen:\\nIf I must not, I need not be barren of accusations;\\nhe hath faults, with surplus, to tire in repetition.\\nWhat shouts are these? The other side o' the city\\nis risen: why stay we prating here? to the Capitol!\\n\\nAll:\\nCome, come.\\n\\nFirst Citizen:\\nSoft! who comes here?\\n\\nSecond Citizen:\\nWorthy Menenius Agrippa; one that hath always loved\\nthe people.\\n\\nFirst Citizen:\\nHe's one honest enough: would all the rest were so!\\n\\nMENENIUS:\\nWhat work's, my countrymen, in hand? where go you\\nWith bats and clubs? The matter? speak, I pray you.\\n\\nFirst Citizen:\\nOur business is not unknown to the senate; they have\\nhad inkling this fortnight what we intend to do,\\nwhich now we'll show 'em in deeds. They say poor\\nsuitors have strong breaths: they shall know we\\nhave strong arms too.\\n\\nMENENIUS:\\nWhy, masters, my good friends, mine honest neighbours,\\nWill you undo yourselves?\\n\\nFirst Citizen:\\nWe cannot, sir, we are undone already.\\n\\nMENENIUS:\\nI tell you, friends, most charitable care\\nHave the patricians of you. For your wants,\\nYour suffering in this dearth, you may as well\\nStrike at the heaven with your staves as lift them\\nAgainst the Roman state, whose course will on\\nThe way it takes, cracking ten thousand curbs\\nOf more strong link asunder than can ever\\nAppear in your impediment. For the dearth,\\nThe gods, not the patricians, make it, and\\nYour knees to them, not arms, must help.\"}\n"
|
| 87 |
+
]
|
| 88 |
+
}
|
| 89 |
+
],
|
| 90 |
+
"source": [
|
| 91 |
+
"train = load_dataset(\"Trelis/tiny-shakespeare\", split=\"train\", streaming=True)\n",
|
| 92 |
+
"\n",
|
| 93 |
+
"for item in train:\n",
|
| 94 |
+
" print(item)\n",
|
| 95 |
+
" break"
|
| 96 |
+
]
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"cell_type": "code",
|
| 100 |
+
"execution_count": 21,
|
| 101 |
+
"id": "3fa7ab22",
|
| 102 |
+
"metadata": {},
|
| 103 |
+
"outputs": [
|
| 104 |
+
{
|
| 105 |
+
"data": {
|
| 106 |
+
"text/plain": [
|
| 107 |
+
"{'text': 'the rock is destined to be the 21st century\\'s new \" conan \" and that he\\'s going to make a splash even greater than arnold schwarzenegger , jean-claud van damme or steven segal .',\n",
|
| 108 |
+
" 'label': 1}"
|
| 109 |
+
]
|
| 110 |
+
},
|
| 111 |
+
"execution_count": 21,
|
| 112 |
+
"metadata": {},
|
| 113 |
+
"output_type": "execute_result"
|
| 114 |
+
}
|
| 115 |
+
],
|
| 116 |
+
"source": [
|
| 117 |
+
"ds = load_dataset(\"cornell-movie-review-data/rotten_tomatoes\", split=\"train\")\n",
|
| 118 |
+
"ds[0]"
|
| 119 |
+
]
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"cell_type": "code",
|
| 123 |
+
"execution_count": 23,
|
| 124 |
+
"id": "762a90a2",
|
| 125 |
+
"metadata": {},
|
| 126 |
+
"outputs": [],
|
| 127 |
+
"source": [
|
| 128 |
+
"data= ds[0]['text']"
|
| 129 |
+
]
|
| 130 |
+
},
|
| 131 |
+
{
|
| 132 |
+
"cell_type": "code",
|
| 133 |
+
"execution_count": 25,
|
| 134 |
+
"id": "7218f579",
|
| 135 |
+
"metadata": {},
|
| 136 |
+
"outputs": [
|
| 137 |
+
{
|
| 138 |
+
"name": "stdout",
|
| 139 |
+
"output_type": "stream",
|
| 140 |
+
"text": [
|
| 141 |
+
"{'input_ids': [101, 1996, 2600, 2003, 16036, 2000, 2022, 1996, 7398, 2301, 1005, 1055, 2047, 1000, 16608, 1000, 1998, 2008, 2002, 1005, 1055, 2183, 2000, 2191, 1037, 17624, 2130, 3618, 2084, 7779, 29058, 8625, 13327, 1010, 3744, 1011, 18856, 19513, 3158, 5477, 4168, 2030, 7112, 16562, 2140, 1012, 102], 'token_type_ids': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}\n"
|
| 142 |
+
]
|
| 143 |
+
}
|
| 144 |
+
],
|
| 145 |
+
"source": [
|
| 146 |
+
"from transformers import BertTokenizer, BertModel, AutoTokenizer\n",
|
| 147 |
+
"from datasets import load_dataset\n",
|
| 148 |
+
"\n",
|
| 149 |
+
"\n",
|
| 150 |
+
"tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')\n",
|
| 151 |
+
"\n",
|
| 152 |
+
"print(tokenizer(data))"
|
| 153 |
+
]
|
| 154 |
+
},
|
| 155 |
+
{
|
| 156 |
+
"cell_type": "code",
|
| 157 |
+
"execution_count": 26,
|
| 158 |
+
"id": "3a53eeb8",
|
| 159 |
+
"metadata": {},
|
| 160 |
+
"outputs": [
|
| 161 |
+
{
|
| 162 |
+
"data": {
|
| 163 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 164 |
+
"model_id": "8fe471cac9ef435b8c4528f234f74400",
|
| 165 |
+
"version_major": 2,
|
| 166 |
+
"version_minor": 0
|
| 167 |
+
},
|
| 168 |
+
"text/plain": [
|
| 169 |
+
"Map: 0%| | 0/8530 [00:00<?, ? examples/s]"
|
| 170 |
+
]
|
| 171 |
+
},
|
| 172 |
+
"metadata": {},
|
| 173 |
+
"output_type": "display_data"
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
"data": {
|
| 177 |
+
"text/plain": [
|
| 178 |
+
"Dataset({\n",
|
| 179 |
+
" features: ['text', 'label', 'input_ids', 'token_type_ids', 'attention_mask'],\n",
|
| 180 |
+
" num_rows: 8530\n",
|
| 181 |
+
"})"
|
| 182 |
+
]
|
| 183 |
+
},
|
| 184 |
+
"execution_count": 26,
|
| 185 |
+
"metadata": {},
|
| 186 |
+
"output_type": "execute_result"
|
| 187 |
+
}
|
| 188 |
+
],
|
| 189 |
+
"source": [
|
| 190 |
+
"def token_data(text):\n",
|
| 191 |
+
" data = text[\"text\"]\n",
|
| 192 |
+
" return tokenizer(data)\n",
|
| 193 |
+
"\n",
|
| 194 |
+
"data_token= ds.map(token_data,batched=True)\n",
|
| 195 |
+
"data_token"
|
| 196 |
+
]
|
| 197 |
+
},
|
| 198 |
+
{
|
| 199 |
+
"cell_type": "code",
|
| 200 |
+
"execution_count": 27,
|
| 201 |
+
"id": "fd54bc7a",
|
| 202 |
+
"metadata": {},
|
| 203 |
+
"outputs": [
|
| 204 |
+
{
|
| 205 |
+
"data": {
|
| 206 |
+
"text/plain": [
|
| 207 |
+
"{'text': 'the rock is destined to be the 21st century\\'s new \" conan \" and that he\\'s going to make a splash even greater than arnold schwarzenegger , jean-claud van damme or steven segal .',\n",
|
| 208 |
+
" 'label': 1,\n",
|
| 209 |
+
" 'input_ids': [101,\n",
|
| 210 |
+
" 1996,\n",
|
| 211 |
+
" 2600,\n",
|
| 212 |
+
" 2003,\n",
|
| 213 |
+
" 16036,\n",
|
| 214 |
+
" 2000,\n",
|
| 215 |
+
" 2022,\n",
|
| 216 |
+
" 1996,\n",
|
| 217 |
+
" 7398,\n",
|
| 218 |
+
" 2301,\n",
|
| 219 |
+
" 1005,\n",
|
| 220 |
+
" 1055,\n",
|
| 221 |
+
" 2047,\n",
|
| 222 |
+
" 1000,\n",
|
| 223 |
+
" 16608,\n",
|
| 224 |
+
" 1000,\n",
|
| 225 |
+
" 1998,\n",
|
| 226 |
+
" 2008,\n",
|
| 227 |
+
" 2002,\n",
|
| 228 |
+
" 1005,\n",
|
| 229 |
+
" 1055,\n",
|
| 230 |
+
" 2183,\n",
|
| 231 |
+
" 2000,\n",
|
| 232 |
+
" 2191,\n",
|
| 233 |
+
" 1037,\n",
|
| 234 |
+
" 17624,\n",
|
| 235 |
+
" 2130,\n",
|
| 236 |
+
" 3618,\n",
|
| 237 |
+
" 2084,\n",
|
| 238 |
+
" 7779,\n",
|
| 239 |
+
" 29058,\n",
|
| 240 |
+
" 8625,\n",
|
| 241 |
+
" 13327,\n",
|
| 242 |
+
" 1010,\n",
|
| 243 |
+
" 3744,\n",
|
| 244 |
+
" 1011,\n",
|
| 245 |
+
" 18856,\n",
|
| 246 |
+
" 19513,\n",
|
| 247 |
+
" 3158,\n",
|
| 248 |
+
" 5477,\n",
|
| 249 |
+
" 4168,\n",
|
| 250 |
+
" 2030,\n",
|
| 251 |
+
" 7112,\n",
|
| 252 |
+
" 16562,\n",
|
| 253 |
+
" 2140,\n",
|
| 254 |
+
" 1012,\n",
|
| 255 |
+
" 102],\n",
|
| 256 |
+
" 'token_type_ids': [0,\n",
|
| 257 |
+
" 0,\n",
|
| 258 |
+
" 0,\n",
|
| 259 |
+
" 0,\n",
|
| 260 |
+
" 0,\n",
|
| 261 |
+
" 0,\n",
|
| 262 |
+
" 0,\n",
|
| 263 |
+
" 0,\n",
|
| 264 |
+
" 0,\n",
|
| 265 |
+
" 0,\n",
|
| 266 |
+
" 0,\n",
|
| 267 |
+
" 0,\n",
|
| 268 |
+
" 0,\n",
|
| 269 |
+
" 0,\n",
|
| 270 |
+
" 0,\n",
|
| 271 |
+
" 0,\n",
|
| 272 |
+
" 0,\n",
|
| 273 |
+
" 0,\n",
|
| 274 |
+
" 0,\n",
|
| 275 |
+
" 0,\n",
|
| 276 |
+
" 0,\n",
|
| 277 |
+
" 0,\n",
|
| 278 |
+
" 0,\n",
|
| 279 |
+
" 0,\n",
|
| 280 |
+
" 0,\n",
|
| 281 |
+
" 0,\n",
|
| 282 |
+
" 0,\n",
|
| 283 |
+
" 0,\n",
|
| 284 |
+
" 0,\n",
|
| 285 |
+
" 0,\n",
|
| 286 |
+
" 0,\n",
|
| 287 |
+
" 0,\n",
|
| 288 |
+
" 0,\n",
|
| 289 |
+
" 0,\n",
|
| 290 |
+
" 0,\n",
|
| 291 |
+
" 0,\n",
|
| 292 |
+
" 0,\n",
|
| 293 |
+
" 0,\n",
|
| 294 |
+
" 0,\n",
|
| 295 |
+
" 0,\n",
|
| 296 |
+
" 0,\n",
|
| 297 |
+
" 0,\n",
|
| 298 |
+
" 0,\n",
|
| 299 |
+
" 0,\n",
|
| 300 |
+
" 0,\n",
|
| 301 |
+
" 0,\n",
|
| 302 |
+
" 0],\n",
|
| 303 |
+
" 'attention_mask': [1,\n",
|
| 304 |
+
" 1,\n",
|
| 305 |
+
" 1,\n",
|
| 306 |
+
" 1,\n",
|
| 307 |
+
" 1,\n",
|
| 308 |
+
" 1,\n",
|
| 309 |
+
" 1,\n",
|
| 310 |
+
" 1,\n",
|
| 311 |
+
" 1,\n",
|
| 312 |
+
" 1,\n",
|
| 313 |
+
" 1,\n",
|
| 314 |
+
" 1,\n",
|
| 315 |
+
" 1,\n",
|
| 316 |
+
" 1,\n",
|
| 317 |
+
" 1,\n",
|
| 318 |
+
" 1,\n",
|
| 319 |
+
" 1,\n",
|
| 320 |
+
" 1,\n",
|
| 321 |
+
" 1,\n",
|
| 322 |
+
" 1,\n",
|
| 323 |
+
" 1,\n",
|
| 324 |
+
" 1,\n",
|
| 325 |
+
" 1,\n",
|
| 326 |
+
" 1,\n",
|
| 327 |
+
" 1,\n",
|
| 328 |
+
" 1,\n",
|
| 329 |
+
" 1,\n",
|
| 330 |
+
" 1,\n",
|
| 331 |
+
" 1,\n",
|
| 332 |
+
" 1,\n",
|
| 333 |
+
" 1,\n",
|
| 334 |
+
" 1,\n",
|
| 335 |
+
" 1,\n",
|
| 336 |
+
" 1,\n",
|
| 337 |
+
" 1,\n",
|
| 338 |
+
" 1,\n",
|
| 339 |
+
" 1,\n",
|
| 340 |
+
" 1,\n",
|
| 341 |
+
" 1,\n",
|
| 342 |
+
" 1,\n",
|
| 343 |
+
" 1,\n",
|
| 344 |
+
" 1,\n",
|
| 345 |
+
" 1,\n",
|
| 346 |
+
" 1,\n",
|
| 347 |
+
" 1,\n",
|
| 348 |
+
" 1,\n",
|
| 349 |
+
" 1]}"
|
| 350 |
+
]
|
| 351 |
+
},
|
| 352 |
+
"execution_count": 27,
|
| 353 |
+
"metadata": {},
|
| 354 |
+
"output_type": "execute_result"
|
| 355 |
+
}
|
| 356 |
+
],
|
| 357 |
+
"source": [
|
| 358 |
+
"data_token[0]"
|
| 359 |
+
]
|
| 360 |
+
},
|
| 361 |
+
{
|
| 362 |
+
"cell_type": "code",
|
| 363 |
+
"execution_count": 28,
|
| 364 |
+
"id": "5cb8c88c",
|
| 365 |
+
"metadata": {},
|
| 366 |
+
"outputs": [
|
| 367 |
+
{
|
| 368 |
+
"data": {
|
| 369 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 370 |
+
"model_id": "0fbd40c118b14b018eb6157010f53259",
|
| 371 |
+
"version_major": 2,
|
| 372 |
+
"version_minor": 0
|
| 373 |
+
},
|
| 374 |
+
"text/plain": [
|
| 375 |
+
"Saving the dataset (0/1 shards): 0%| | 0/8530 [00:00<?, ? examples/s]"
|
| 376 |
+
]
|
| 377 |
+
},
|
| 378 |
+
"metadata": {},
|
| 379 |
+
"output_type": "display_data"
|
| 380 |
+
}
|
| 381 |
+
],
|
| 382 |
+
"source": [
|
| 383 |
+
"data_token.save_to_disk(\"data new\")"
|
| 384 |
+
]
|
| 385 |
+
},
|
| 386 |
+
{
|
| 387 |
+
"cell_type": "code",
|
| 388 |
+
"execution_count": 30,
|
| 389 |
+
"id": "687fcd08",
|
| 390 |
+
"metadata": {},
|
| 391 |
+
"outputs": [
|
| 392 |
+
{
|
| 393 |
+
"data": {
|
| 394 |
+
"text/plain": [
|
| 395 |
+
"Dataset({\n",
|
| 396 |
+
" features: ['text', 'label', 'input_ids', 'token_type_ids', 'attention_mask'],\n",
|
| 397 |
+
" num_rows: 8530\n",
|
| 398 |
+
"})"
|
| 399 |
+
]
|
| 400 |
+
},
|
| 401 |
+
"execution_count": 30,
|
| 402 |
+
"metadata": {},
|
| 403 |
+
"output_type": "execute_result"
|
| 404 |
+
}
|
| 405 |
+
],
|
| 406 |
+
"source": [
|
| 407 |
+
"from datasets import load_from_disk\n",
|
| 408 |
+
"loaded = load_from_disk(\"data new\")\n",
|
| 409 |
+
"loaded"
|
| 410 |
+
]
|
| 411 |
+
},
|
| 412 |
+
{
|
| 413 |
+
"cell_type": "code",
|
| 414 |
+
"execution_count": null,
|
| 415 |
+
"id": "5a651301",
|
| 416 |
+
"metadata": {},
|
| 417 |
+
"outputs": [
|
| 418 |
+
{
|
| 419 |
+
"data": {
|
| 420 |
+
"text/html": [
|
| 421 |
+
"<center><img src=\"https://huggingface.co/front/assets/huggingface_logo-noborder.svg\" width=\"100\" alt=\"Hugging Face\"><br><br><p>To log in, open this URL and enter the code:</p><p><a href=\"https://hf.co/oauth/device\" target=\"_blank\"><b>https://hf.co/oauth/device</b></a></p><p style=\"font-size: 1.6em; letter-spacing: 0.3em; font-family: monospace;\"><b>DG6I-HE76</b></p></center>"
|
| 422 |
+
],
|
| 423 |
+
"text/plain": [
|
| 424 |
+
"<IPython.core.display.HTML object>"
|
| 425 |
+
]
|
| 426 |
+
},
|
| 427 |
+
"metadata": {},
|
| 428 |
+
"output_type": "display_data"
|
| 429 |
+
},
|
| 430 |
+
{
|
| 431 |
+
"data": {
|
| 432 |
+
"text/html": [
|
| 433 |
+
"<center><i>Waiting for authorization...</i></center>"
|
| 434 |
+
],
|
| 435 |
+
"text/plain": [
|
| 436 |
+
"<IPython.core.display.HTML object>"
|
| 437 |
+
]
|
| 438 |
+
},
|
| 439 |
+
"metadata": {},
|
| 440 |
+
"output_type": "display_data"
|
| 441 |
+
}
|
| 442 |
+
],
|
| 443 |
+
"source": [
|
| 444 |
+
"from huggingface_hub import login, upload_folder\n",
|
| 445 |
+
"login()\n",
|
| 446 |
+
"upload_folder(folder_path=\".\", repo_id=\"QuickLearnerAI/data new\", repo_type=\"dataset\")"
|
| 447 |
+
]
|
| 448 |
+
},
|
| 449 |
+
{
|
| 450 |
+
"cell_type": "code",
|
| 451 |
+
"execution_count": null,
|
| 452 |
+
"id": "33bc56e9",
|
| 453 |
+
"metadata": {},
|
| 454 |
+
"outputs": [],
|
| 455 |
+
"source": []
|
| 456 |
+
}
|
| 457 |
+
],
|
| 458 |
+
"metadata": {
|
| 459 |
+
"kernelspec": {
|
| 460 |
+
"display_name": "Python 3",
|
| 461 |
+
"language": "python",
|
| 462 |
+
"name": "python3"
|
| 463 |
+
},
|
| 464 |
+
"language_info": {
|
| 465 |
+
"codemirror_mode": {
|
| 466 |
+
"name": "ipython",
|
| 467 |
+
"version": 3
|
| 468 |
+
},
|
| 469 |
+
"file_extension": ".py",
|
| 470 |
+
"mimetype": "text/x-python",
|
| 471 |
+
"name": "python",
|
| 472 |
+
"nbconvert_exporter": "python",
|
| 473 |
+
"pygments_lexer": "ipython3",
|
| 474 |
+
"version": "3.11.4"
|
| 475 |
+
}
|
| 476 |
+
},
|
| 477 |
+
"nbformat": 4,
|
| 478 |
+
"nbformat_minor": 5
|
| 479 |
+
}
|