tamiti1610001 commited on
Commit
d1cc761
1 Parent(s): acbc52e

Uploading the python notebook that used to fine - tune the model.

Browse files
Files changed (1) hide show
  1. hf-4-3-push-to-hub-api.ipynb +1 -0
hf-4-3-push-to-hub-api.ipynb ADDED
@@ -0,0 +1 @@
 
 
1
+ {"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import huggingface_hub\nfrom datasets import load_dataset, load_metric\nfrom transformers import AutoTokenizer, AutoModelForSequenceClassification, TrainingArguments, Trainer\nimport numpy as np","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-08-01T15:21:08.914868Z","iopub.execute_input":"2023-08-01T15:21:08.915592Z","iopub.status.idle":"2023-08-01T15:21:35.735373Z","shell.execute_reply.started":"2023-08-01T15:21:08.915557Z","shell.execute_reply":"2023-08-01T15:21:35.734143Z"},"trusted":true},"execution_count":1,"outputs":[{"name":"stderr","text":"/opt/conda/lib/python3.10/site-packages/scipy/__init__.py:146: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.23.5\n warnings.warn(f\"A NumPy version >={np_minversion} and <{np_maxversion}\"\n/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/__init__.py:98: UserWarning: unable to load libtensorflow_io_plugins.so: unable to open file: libtensorflow_io_plugins.so, from paths: ['/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so']\ncaused by: ['/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so: undefined symbol: _ZN3tsl6StatusC1EN10tensorflow5error4CodeESt17basic_string_viewIcSt11char_traitsIcEENS_14SourceLocationE']\n warnings.warn(f\"unable to load libtensorflow_io_plugins.so: {e}\")\n/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/__init__.py:104: UserWarning: file system plugins are not loaded: unable to open file: libtensorflow_io.so, from paths: ['/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/libtensorflow_io.so']\ncaused by: ['/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/libtensorflow_io.so: undefined symbol: _ZTVN10tensorflow13GcsFileSystemE']\n warnings.warn(f\"file system plugins are not loaded: {e}\")\n","output_type":"stream"}]},{"cell_type":"code","source":"hf_token = \"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\"","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:21:35.740994Z","iopub.execute_input":"2023-08-01T15:21:35.741876Z","iopub.status.idle":"2023-08-01T15:21:35.747270Z","shell.execute_reply.started":"2023-08-01T15:21:35.741839Z","shell.execute_reply":"2023-08-01T15:21:35.745907Z"},"trusted":true},"execution_count":2,"outputs":[]},{"cell_type":"code","source":"huggingface_hub.login(token=hf_token, add_to_git_credential=True)","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:21:35.752493Z","iopub.execute_input":"2023-08-01T15:21:35.753603Z","iopub.status.idle":"2023-08-01T15:21:35.933786Z","shell.execute_reply.started":"2023-08-01T15:21:35.753565Z","shell.execute_reply":"2023-08-01T15:21:35.932483Z"},"trusted":true},"execution_count":3,"outputs":[{"name":"stdout","text":"Token is valid (permission: write).\n\u001b[1m\u001b[31mCannot authenticate through git-credential as no helper is defined on your machine.\nYou might have to re-authenticate when pushing to the Hugging Face Hub.\nRun the following command in your terminal in case you want to set the 'store' credential helper as default.\n\ngit config --global credential.helper store\n\nRead https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage for more details.\u001b[0m\nToken has not been saved to git credential helper.\nYour token has been saved to /root/.cache/huggingface/token\nLogin successful\n","output_type":"stream"}]},{"cell_type":"code","source":"\nraw_datasets = load_dataset(\"glue\",\"cola\")\n","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:21:35.938802Z","iopub.execute_input":"2023-08-01T15:21:35.939157Z","iopub.status.idle":"2023-08-01T15:21:38.545504Z","shell.execute_reply.started":"2023-08-01T15:21:35.939125Z","shell.execute_reply":"2023-08-01T15:21:38.544585Z"},"trusted":true},"execution_count":4,"outputs":[{"output_type":"display_data","data":{"text/plain":"Downloading builder script: 0%| | 0.00/7.78k [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"4395cbac70094541b4b0ebd26eb6a290"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"Downloading metadata: 0%| | 0.00/4.47k [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"568b4c666a7b4be598b41eebb5f8a233"}},"metadata":{}},{"name":"stdout","text":"Downloading and preparing dataset glue/cola (download: 368.14 KiB, generated: 596.73 KiB, post-processed: Unknown size, total: 964.86 KiB) to /root/.cache/huggingface/datasets/glue/cola/1.0.0/dacbe3125aa31d7f70367a07a8a9e72a5a0bfeb5fc42e75c9db75b96da6053ad...\n","output_type":"stream"},{"output_type":"display_data","data":{"text/plain":"Downloading data: 0%| | 0.00/377k [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"7dab7f52d2ab4c9681dbb8ec0025c706"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"Generating train split: 0%| | 0/8551 [00:00<?, ? examples/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":""}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"Generating validation split: 0%| | 0/1043 [00:00<?, ? examples/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":""}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"Generating test split: 0%| | 0/1063 [00:00<?, ? examples/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":""}},"metadata":{}},{"name":"stdout","text":"Dataset glue downloaded and prepared to /root/.cache/huggingface/datasets/glue/cola/1.0.0/dacbe3125aa31d7f70367a07a8a9e72a5a0bfeb5fc42e75c9db75b96da6053ad. Subsequent calls will reuse this data.\n","output_type":"stream"},{"output_type":"display_data","data":{"text/plain":" 0%| | 0/3 [00:00<?, ?it/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"863376ec8c6b4e1d9afeb55d5e111471"}},"metadata":{}}]},{"cell_type":"code","source":"raw_datasets","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:21:38.546478Z","iopub.execute_input":"2023-08-01T15:21:38.546805Z","iopub.status.idle":"2023-08-01T15:21:38.561054Z","shell.execute_reply.started":"2023-08-01T15:21:38.546775Z","shell.execute_reply":"2023-08-01T15:21:38.560159Z"},"trusted":true},"execution_count":5,"outputs":[{"execution_count":5,"output_type":"execute_result","data":{"text/plain":"DatasetDict({\n train: Dataset({\n features: ['sentence', 'label', 'idx'],\n num_rows: 8551\n })\n validation: Dataset({\n features: ['sentence', 'label', 'idx'],\n num_rows: 1043\n })\n test: Dataset({\n features: ['sentence', 'label', 'idx'],\n num_rows: 1063\n })\n})"},"metadata":{}}]},{"cell_type":"code","source":"model_checkpoint = \"bert-base-cased\"","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:21:38.563030Z","iopub.execute_input":"2023-08-01T15:21:38.563905Z","iopub.status.idle":"2023-08-01T15:21:38.569660Z","shell.execute_reply.started":"2023-08-01T15:21:38.563867Z","shell.execute_reply":"2023-08-01T15:21:38.568463Z"},"trusted":true},"execution_count":6,"outputs":[]},{"cell_type":"code","source":"tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:21:38.571279Z","iopub.execute_input":"2023-08-01T15:21:38.572080Z","iopub.status.idle":"2023-08-01T15:21:39.462338Z","shell.execute_reply.started":"2023-08-01T15:21:38.572045Z","shell.execute_reply":"2023-08-01T15:21:39.461363Z"},"trusted":true},"execution_count":7,"outputs":[{"output_type":"display_data","data":{"text/plain":"Downloading (…)okenizer_config.json: 0%| | 0.00/29.0 [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"a22f1a71bf704f97b4f3c84a78bf819d"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"Downloading (…)lve/main/config.json: 0%| | 0.00/570 [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"570cb22118f04f64b3e6a2445d060385"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"Downloading (…)solve/main/vocab.txt: 0%| | 0.00/213k [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"0a07e47654794fff91036ddeb12b5325"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"Downloading (…)/main/tokenizer.json: 0%| | 0.00/436k [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"220c5272b7fc45beaf5ff8621945d2a1"}},"metadata":{}}]},{"cell_type":"code","source":"model = AutoModelForSequenceClassification.from_pretrained(model_checkpoint)","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:21:39.467232Z","iopub.execute_input":"2023-08-01T15:21:39.469452Z","iopub.status.idle":"2023-08-01T15:21:48.185307Z","shell.execute_reply.started":"2023-08-01T15:21:39.469401Z","shell.execute_reply":"2023-08-01T15:21:48.184190Z"},"trusted":true},"execution_count":8,"outputs":[{"output_type":"display_data","data":{"text/plain":"Downloading model.safetensors: 0%| | 0.00/436M [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"81cb18ab25b24731907f91ec5b4dcde9"}},"metadata":{}},{"name":"stderr","text":"Some weights of the model checkpoint at bert-base-cased were not used when initializing BertForSequenceClassification: ['cls.predictions.transform.LayerNorm.weight', 'cls.seq_relationship.bias', 'cls.predictions.bias', 'cls.predictions.transform.LayerNorm.bias', 'cls.predictions.transform.dense.bias', 'cls.seq_relationship.weight', 'cls.predictions.transform.dense.weight']\n- This IS expected if you are initializing BertForSequenceClassification from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n- This IS NOT expected if you are initializing BertForSequenceClassification from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\nSome weights of BertForSequenceClassification were not initialized from the model checkpoint at bert-base-cased and are newly initialized: ['classifier.weight', 'classifier.bias']\nYou should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n","output_type":"stream"}]},{"cell_type":"code","source":"def preprocess_fn(examples):\n return tokenizer(examples['sentence'], truncation = True)","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:21:48.187100Z","iopub.execute_input":"2023-08-01T15:21:48.187854Z","iopub.status.idle":"2023-08-01T15:21:48.193663Z","shell.execute_reply.started":"2023-08-01T15:21:48.187816Z","shell.execute_reply":"2023-08-01T15:21:48.191996Z"},"trusted":true},"execution_count":9,"outputs":[]},{"cell_type":"code","source":"tokenized_datasets = raw_datasets.map(preprocess_fn)","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:21:48.199563Z","iopub.execute_input":"2023-08-01T15:21:48.200234Z","iopub.status.idle":"2023-08-01T15:21:52.712286Z","shell.execute_reply.started":"2023-08-01T15:21:48.200201Z","shell.execute_reply":"2023-08-01T15:21:52.711298Z"},"trusted":true},"execution_count":10,"outputs":[{"output_type":"display_data","data":{"text/plain":" 0%| | 0/8551 [00:00<?, ?ex/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"8867b293a3dd424abd6d5042608fbe35"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":" 0%| | 0/1043 [00:00<?, ?ex/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"3988a785ef9a4f11a3dc7b15b6d775a9"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":" 0%| | 0/1063 [00:00<?, ?ex/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"a3463daf89354598b6b32d00ae0bd485"}},"metadata":{}}]},{"cell_type":"code","source":"metric = load_metric(\"glue\", \"cola\")","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:21:52.716765Z","iopub.execute_input":"2023-08-01T15:21:52.719333Z","iopub.status.idle":"2023-08-01T15:21:53.208553Z","shell.execute_reply.started":"2023-08-01T15:21:52.719295Z","shell.execute_reply":"2023-08-01T15:21:53.207508Z"},"trusted":true},"execution_count":11,"outputs":[{"output_type":"display_data","data":{"text/plain":"Downloading builder script: 0%| | 0.00/1.84k [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"8d2b5e4f654e46939110c3e0d308305f"}},"metadata":{}}]},{"cell_type":"code","source":"def compute_metrics(eval_pred):\n predictions, labels = eval_pred\n predictions = np.argmax(predictions, axis = -1)\n return metric.compute(predictions = predictions, references = labels)","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:21:53.210184Z","iopub.execute_input":"2023-08-01T15:21:53.210836Z","iopub.status.idle":"2023-08-01T15:21:53.216500Z","shell.execute_reply.started":"2023-08-01T15:21:53.210798Z","shell.execute_reply":"2023-08-01T15:21:53.215391Z"},"trusted":true},"execution_count":12,"outputs":[]},{"cell_type":"code","source":"args = TrainingArguments(\n \"bert-fine-tuned-cola\",\n evaluation_strategy = \"epoch\",\n save_strategy = \"epoch\",\n learning_rate = 2e-5,\n num_train_epochs = 3,\n weight_decay = 0.01,\n push_to_hub =True,\n hub_model_id = \"bert-fine-tuned-cola\"\n\n)","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:21:53.218129Z","iopub.execute_input":"2023-08-01T15:21:53.218755Z","iopub.status.idle":"2023-08-01T15:21:53.351808Z","shell.execute_reply.started":"2023-08-01T15:21:53.218721Z","shell.execute_reply":"2023-08-01T15:21:53.350679Z"},"trusted":true},"execution_count":13,"outputs":[]},{"cell_type":"code","source":"trainer = Trainer(\nmodel,\nargs,\ntrain_dataset = tokenized_datasets['train'],\neval_dataset = tokenized_datasets[\"validation\"],\ncompute_metrics = compute_metrics,\ntokenizer = tokenizer,)\ntrainer.train()","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:21:53.357069Z","iopub.execute_input":"2023-08-01T15:21:53.359635Z","iopub.status.idle":"2023-08-01T15:29:42.965386Z","shell.execute_reply.started":"2023-08-01T15:21:53.359596Z","shell.execute_reply":"2023-08-01T15:29:42.964482Z"},"trusted":true},"execution_count":14,"outputs":[{"name":"stderr","text":"Cloning https://huggingface.co/tamiti1610001/bert-fine-tuned-cola into local empty directory.\n/opt/conda/lib/python3.10/site-packages/transformers/optimization.py:411: FutureWarning: This implementation of AdamW is deprecated and will be removed in a future version. Use the PyTorch implementation torch.optim.AdamW instead, or set `no_deprecation_warning=True` to disable this warning\n warnings.warn(\n\u001b[34m\u001b[1mwandb\u001b[0m: Logging into wandb.ai. (Learn how to deploy a W&B server locally: https://wandb.me/wandb-server)\n\u001b[34m\u001b[1mwandb\u001b[0m: You can find your API key in your browser here: https://wandb.ai/authorize\n\u001b[34m\u001b[1mwandb\u001b[0m: Paste an API key from your profile and hit enter, or press ctrl+c to quit:","output_type":"stream"},{"output_type":"stream","name":"stdin","text":" ········································\n"},{"name":"stderr","text":"\u001b[34m\u001b[1mwandb\u001b[0m: Appending key for api.wandb.ai to your netrc file: /root/.netrc\n","output_type":"stream"},{"output_type":"display_data","data":{"text/plain":"VBox(children=(Label(value='Waiting for wandb.init()...\\r'), FloatProgress(value=0.016669323166667027, max=1.0…","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"bf49e1386340478bb8db77e1b3dd3d4e"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"<IPython.core.display.HTML object>","text/html":"wandb version 0.15.7 is available! To upgrade, please run:\n $ pip install wandb --upgrade"},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"<IPython.core.display.HTML object>","text/html":"Tracking run with wandb version 0.15.5"},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"<IPython.core.display.HTML object>","text/html":"Run data is saved locally in <code>/kaggle/working/wandb/run-20230801_152218-vw2cnry6</code>"},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"<IPython.core.display.HTML object>","text/html":"Syncing run <strong><a href='https://wandb.ai/tamiti/huggingface/runs/vw2cnry6' target=\"_blank\">flowing-wind-18</a></strong> to <a href='https://wandb.ai/tamiti/huggingface' target=\"_blank\">Weights & Biases</a> (<a href='https://wandb.me/run' target=\"_blank\">docs</a>)<br/>"},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"<IPython.core.display.HTML object>","text/html":" View project at <a href='https://wandb.ai/tamiti/huggingface' target=\"_blank\">https://wandb.ai/tamiti/huggingface</a>"},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"<IPython.core.display.HTML object>","text/html":" View run at <a href='https://wandb.ai/tamiti/huggingface/runs/vw2cnry6' target=\"_blank\">https://wandb.ai/tamiti/huggingface/runs/vw2cnry6</a>"},"metadata":{}},{"name":"stderr","text":"You're using a BertTokenizerFast tokenizer. Please note that with a fast tokenizer, using the `__call__` method is faster than using a method to encode the text followed by a call to the `pad` method to get a padded encoding.\n/opt/conda/lib/python3.10/site-packages/torch/nn/parallel/_functions.py:68: UserWarning: Was asked to gather along dimension 0, but all input tensors were scalars; will instead unsqueeze and return a vector.\n warnings.warn('Was asked to gather along dimension 0, but all '\n","output_type":"stream"},{"output_type":"display_data","data":{"text/plain":"<IPython.core.display.HTML object>","text/html":"\n <div>\n \n <progress value='1605' max='1605' style='width:300px; height:20px; vertical-align: middle;'></progress>\n [1605/1605 06:42, Epoch 3/3]\n </div>\n <table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: left;\">\n <th>Epoch</th>\n <th>Training Loss</th>\n <th>Validation Loss</th>\n <th>Matthews Correlation</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>1</td>\n <td>0.498300</td>\n <td>0.489036</td>\n <td>0.507785</td>\n </tr>\n <tr>\n <td>2</td>\n <td>0.285600</td>\n <td>0.500088</td>\n <td>0.567760</td>\n </tr>\n <tr>\n <td>3</td>\n <td>0.177400</td>\n <td>0.699280</td>\n <td>0.580413</td>\n </tr>\n </tbody>\n</table><p>"},"metadata":{}},{"name":"stderr","text":"/opt/conda/lib/python3.10/site-packages/torch/nn/parallel/_functions.py:68: UserWarning: Was asked to gather along dimension 0, but all input tensors were scalars; will instead unsqueeze and return a vector.\n warnings.warn('Was asked to gather along dimension 0, but all '\n/opt/conda/lib/python3.10/site-packages/torch/nn/parallel/_functions.py:68: UserWarning: Was asked to gather along dimension 0, but all input tensors were scalars; will instead unsqueeze and return a vector.\n warnings.warn('Was asked to gather along dimension 0, but all '\n","output_type":"stream"},{"execution_count":14,"output_type":"execute_result","data":{"text/plain":"TrainOutput(global_step=1605, training_loss=0.31038934464023865, metrics={'train_runtime': 454.94, 'train_samples_per_second': 56.388, 'train_steps_per_second': 3.528, 'total_flos': 277935718885440.0, 'train_loss': 0.31038934464023865, 'epoch': 3.0})"},"metadata":{}}]},{"cell_type":"code","source":"trainer.push_to_hub(\"End of Training\")","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:29:43.386829Z","iopub.execute_input":"2023-08-01T15:29:43.389506Z","iopub.status.idle":"2023-08-01T15:30:12.363190Z","shell.execute_reply.started":"2023-08-01T15:29:43.389467Z","shell.execute_reply":"2023-08-01T15:30:12.361186Z"},"trusted":true},"execution_count":15,"outputs":[{"name":"stderr","text":"Several commits (2) will be pushed upstream.\nThe progress bars may be unreliable.\n","output_type":"stream"},{"output_type":"display_data","data":{"text/plain":"Upload file pytorch_model.bin: 0%| | 1.00/413M [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"1b160d54e3884eda99ae6119fa5f9d25"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"Upload file runs/Aug01_15-21-53_216369d9b4ba/events.out.tfevents.1690903327.216369d9b4ba.28.0: 0%| …","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"fffc4c2706f046b5bd3e43f42ea8958b"}},"metadata":{}},{"name":"stderr","text":"To https://huggingface.co/tamiti1610001/bert-fine-tuned-cola\n d72627f..80a477b main -> main\n\nTo https://huggingface.co/tamiti1610001/bert-fine-tuned-cola\n 80a477b..9c8d057 main -> main\n\n","output_type":"stream"},{"execution_count":15,"output_type":"execute_result","data":{"text/plain":"'https://huggingface.co/tamiti1610001/bert-fine-tuned-cola/commit/80a477b35d96c3b28570817747065d174b960617'"},"metadata":{}}]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"**In case of not using Trainer directly\n# I can push components individually**","metadata":{}},{"cell_type":"code","source":"repo_name = \"bert-fine-tuned-cola\"\nmodel.push_to_hub(repo_name)\ntokenizer.push_to_hub(repo_name)","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:34:09.186447Z","iopub.execute_input":"2023-08-01T15:34:09.186867Z","iopub.status.idle":"2023-08-01T15:34:12.125325Z","shell.execute_reply.started":"2023-08-01T15:34:09.186836Z","shell.execute_reply":"2023-08-01T15:34:12.124325Z"},"trusted":true},"execution_count":16,"outputs":[{"execution_count":16,"output_type":"execute_result","data":{"text/plain":"CommitInfo(commit_url='https://huggingface.co/tamiti1610001/bert-fine-tuned-cola/commit/d780eee28069c785bf518ef9d68f1fbaa096cf25', commit_message='Upload tokenizer', commit_description='', oid='d780eee28069c785bf518ef9d68f1fbaa096cf25', pr_url=None, pr_revision=None, pr_num=None)"},"metadata":{}}]},{"cell_type":"code","source":"label_names = raw_datasets[\"train\"].features[\"label\"].names\nlabel_names","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:38:28.291213Z","iopub.execute_input":"2023-08-01T15:38:28.291627Z","iopub.status.idle":"2023-08-01T15:38:28.301713Z","shell.execute_reply.started":"2023-08-01T15:38:28.291585Z","shell.execute_reply":"2023-08-01T15:38:28.299796Z"},"trusted":true},"execution_count":19,"outputs":[{"execution_count":19,"output_type":"execute_result","data":{"text/plain":"['unacceptable', 'acceptable']"},"metadata":{}}]},{"cell_type":"code","source":"model.config.id2label = {str(i): label for i, label in enumerate(label_names)}\nmodel.config.label2id = {label:str(i) for i, label in enumerate(label_names)}","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:40:13.880173Z","iopub.execute_input":"2023-08-01T15:40:13.880577Z","iopub.status.idle":"2023-08-01T15:40:13.887897Z","shell.execute_reply.started":"2023-08-01T15:40:13.880544Z","shell.execute_reply":"2023-08-01T15:40:13.886762Z"},"trusted":true},"execution_count":21,"outputs":[]},{"cell_type":"code","source":"print({str(i): label for i, label in enumerate(label_names)})\nprint({label:str(i) for i, label in enumerate(label_names)})","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:40:57.368841Z","iopub.execute_input":"2023-08-01T15:40:57.369230Z","iopub.status.idle":"2023-08-01T15:40:57.381273Z","shell.execute_reply.started":"2023-08-01T15:40:57.369197Z","shell.execute_reply":"2023-08-01T15:40:57.380278Z"},"trusted":true},"execution_count":23,"outputs":[{"name":"stdout","text":"{'0': 'unacceptable', '1': 'acceptable'}\n{'unacceptable': '0', 'acceptable': '1'}\n","output_type":"stream"}]},{"cell_type":"code","source":"repo_name = \"bert-fine-tuned-cola\"\nmodel.config.push_to_hub(repo_name)","metadata":{"execution":{"iopub.status.busy":"2023-08-01T15:41:39.804987Z","iopub.execute_input":"2023-08-01T15:41:39.805968Z","iopub.status.idle":"2023-08-01T15:41:40.132542Z","shell.execute_reply.started":"2023-08-01T15:41:39.805929Z","shell.execute_reply":"2023-08-01T15:41:40.131461Z"},"trusted":true},"execution_count":24,"outputs":[{"execution_count":24,"output_type":"execute_result","data":{"text/plain":"CommitInfo(commit_url='https://huggingface.co/tamiti1610001/bert-fine-tuned-cola/commit/acbc52ec09252288196431273a0713ffea42eff7', commit_message='Upload config', commit_description='', oid='acbc52ec09252288196431273a0713ffea42eff7', pr_url=None, pr_revision=None, pr_num=None)"},"metadata":{}}]}]}