JARVIS/nlg_train.ipynb
2024-06-04 10:46:12 +02:00

2 lines
24 KiB
Plaintext

{"cells":[{"cell_type":"code","execution_count":1,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:18:55.033345Z","iopub.status.busy":"2024-06-03T11:18:55.032642Z","iopub.status.idle":"2024-06-03T11:19:13.773777Z","shell.execute_reply":"2024-06-03T11:19:13.772989Z","shell.execute_reply.started":"2024-06-03T11:18:55.033313Z"},"trusted":true},"outputs":[{"name":"stderr","output_type":"stream","text":["2024-06-03 11:19:02.256736: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n","2024-06-03 11:19:02.256864: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n","2024-06-03 11:19:02.368948: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n"]}],"source":["from transformers import (\n"," AutoModelForSeq2SeqLM,\n"," AutoTokenizer,\n"," DataCollatorForSeq2Seq,\n"," Seq2SeqTrainer,\n"," Seq2SeqTrainingArguments,\n"," pipeline,\n",")\n","\n","from datasets import load_dataset\n","\n","model_name = \"google/umt5-small\""]},{"cell_type":"code","execution_count":2,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:19:13.775904Z","iopub.status.busy":"2024-06-03T11:19:13.775364Z","iopub.status.idle":"2024-06-03T11:19:14.356839Z","shell.execute_reply":"2024-06-03T11:19:14.355976Z","shell.execute_reply.started":"2024-06-03T11:19:13.775878Z"},"trusted":true},"outputs":[{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"fdd37b65a44d42b2931bdc0db8229fa7","version_major":2,"version_minor":0},"text/plain":["Generating train split: 0 examples [00:00, ? examples/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"text/plain":["DatasetDict({\n"," train: Dataset({\n"," features: ['mr', 'ref'],\n"," num_rows: 18564\n"," })\n"," test: Dataset({\n"," features: ['mr', 'ref'],\n"," num_rows: 2063\n"," })\n","})"]},"execution_count":2,"metadata":{},"output_type":"execute_result"}],"source":["dataset = load_dataset('csv', data_files='/kaggle/input/ngl-data/nlg_data.csv', split='train').train_test_split(test_size=0.1)\n","dataset"]},{"cell_type":"code","execution_count":3,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:19:14.358052Z","iopub.status.busy":"2024-06-03T11:19:14.357803Z","iopub.status.idle":"2024-06-03T11:19:24.614600Z","shell.execute_reply":"2024-06-03T11:19:24.613696Z","shell.execute_reply.started":"2024-06-03T11:19:14.358030Z"},"trusted":true},"outputs":[{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"9418d01ad2124c74bcd05cc4d41b9b1d","version_major":2,"version_minor":0},"text/plain":["tokenizer_config.json: 0%| | 0.00/6.84k [00:00<?, ?B/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"935f78ee0b3148929c9c0e022d590930","version_major":2,"version_minor":0},"text/plain":["spiece.model: 0%| | 0.00/4.55M [00:00<?, ?B/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"7eed04b1f7464253aa0be410233d4be2","version_major":2,"version_minor":0},"text/plain":["tokenizer.json: 0%| | 0.00/16.9M [00:00<?, ?B/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"2d97cb1699b64507a746e6ca305e5dc9","version_major":2,"version_minor":0},"text/plain":["special_tokens_map.json: 0%| | 0.00/6.62k [00:00<?, ?B/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"c01c194e06124c7098a0488f52459b65","version_major":2,"version_minor":0},"text/plain":["Map: 0%| | 0/18564 [00:00<?, ? examples/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"c0281a7c463d4b01aad30fb53bb116a3","version_major":2,"version_minor":0},"text/plain":["Map: 0%| | 0/2063 [00:00<?, ? examples/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"text/plain":["DatasetDict({\n"," train: Dataset({\n"," features: ['input_ids', 'attention_mask', 'labels'],\n"," num_rows: 18564\n"," })\n"," test: Dataset({\n"," features: ['input_ids', 'attention_mask', 'labels'],\n"," num_rows: 2063\n"," })\n","})"]},"execution_count":3,"metadata":{},"output_type":"execute_result"}],"source":["tokenizer = AutoTokenizer.from_pretrained(model_name)\n","\n","\n","def tokenize_samples(samples):\n"," inputs = [f\"generate text: {mr}\" for mr in samples[\"mr\"]]\n","\n"," tokenized_inputs = tokenizer(\n"," inputs,\n"," max_length=128,\n"," padding=\"max_length\",\n"," truncation=True,\n"," )\n","\n"," labels = tokenizer(\n"," text_target=samples[\"ref\"],\n"," max_length=128,\n"," padding=\"max_length\",\n"," truncation=True,\n"," )\n","\n"," labels[\"input_ids\"] = [\n"," [\n"," (token_id if token_id != tokenizer.pad_token_id else -100)\n"," for token_id in label\n"," ]\n"," for label in labels[\"input_ids\"]\n"," ]\n","\n"," tokenized_inputs[\"labels\"] = labels[\"input_ids\"]\n"," return tokenized_inputs\n","\n","\n","tokenized_dataset = dataset.map(\n"," tokenize_samples,\n"," batched=True,\n"," remove_columns=[\"mr\", \"ref\"],\n",")\n","\n","tokenized_dataset"]},{"cell_type":"code","execution_count":4,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:19:24.617755Z","iopub.status.busy":"2024-06-03T11:19:24.617326Z","iopub.status.idle":"2024-06-03T11:19:32.668136Z","shell.execute_reply":"2024-06-03T11:19:32.667368Z","shell.execute_reply.started":"2024-06-03T11:19:24.617722Z"},"trusted":true},"outputs":[{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"e47f1b3962e1476a92d6a882cb4c6a29","version_major":2,"version_minor":0},"text/plain":["config.json: 0%| | 0.00/771 [00:00<?, ?B/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"b37a692087264ab695bf1523f9e17d18","version_major":2,"version_minor":0},"text/plain":["pytorch_model.bin: 0%| | 0.00/1.23G [00:00<?, ?B/s]"]},"metadata":{},"output_type":"display_data"},{"name":"stderr","output_type":"stream","text":["/opt/conda/lib/python3.10/site-packages/torch/_utils.py:831: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()\n"," return self.fget.__get__(instance, owner)()\n"]},{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"bc2f8a03813c447cb86c287ea44fdefe","version_major":2,"version_minor":0},"text/plain":["generation_config.json: 0%| | 0.00/171 [00:00<?, ?B/s]"]},"metadata":{},"output_type":"display_data"}],"source":["model = AutoModelForSeq2SeqLM.from_pretrained(model_name)\n","data_collator = DataCollatorForSeq2Seq(tokenizer, model=model, label_pad_token_id=-100, pad_to_multiple_of=8)"]},{"cell_type":"code","execution_count":5,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:19:32.669593Z","iopub.status.busy":"2024-06-03T11:19:32.669304Z","iopub.status.idle":"2024-06-03T11:19:33.908748Z","shell.execute_reply":"2024-06-03T11:19:33.907938Z","shell.execute_reply.started":"2024-06-03T11:19:32.669569Z"},"trusted":true},"outputs":[{"name":"stderr","output_type":"stream","text":["/opt/conda/lib/python3.10/site-packages/transformers/training_args.py:1474: FutureWarning: `evaluation_strategy` is deprecated and will be removed in version 4.46 of 🤗 Transformers. Use `eval_strategy` instead\n"," warnings.warn(\n"]}],"source":["training_args = Seq2SeqTrainingArguments(\n"," output_dir=\"/kaggle/working\",\n"," per_device_train_batch_size=8,\n"," per_device_eval_batch_size=16,\n"," predict_with_generate=True,\n"," learning_rate=5e-5,\n"," num_train_epochs=3,\n"," evaluation_strategy=\"epoch\",\n"," save_strategy=\"epoch\",\n"," save_total_limit=1,\n"," load_best_model_at_end=True,\n",")\n","\n","trainer = Seq2SeqTrainer(\n"," model=model,\n"," args=training_args,\n"," data_collator=data_collator,\n"," train_dataset=tokenized_dataset[\"train\"],\n"," eval_dataset=tokenized_dataset[\"test\"],\n",")"]},{"cell_type":"code","execution_count":6,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:19:33.910359Z","iopub.status.busy":"2024-06-03T11:19:33.910001Z","iopub.status.idle":"2024-06-03T11:58:53.889473Z","shell.execute_reply":"2024-06-03T11:58:53.888465Z","shell.execute_reply.started":"2024-06-03T11:19:33.910324Z"},"trusted":true},"outputs":[{"name":"stderr","output_type":"stream","text":["\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m The `run_name` is currently set to the same value as `TrainingArguments.output_dir`. If this was not intended, please specify a different run name by setting the `TrainingArguments.run_name` parameter.\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:"]},{"name":"stdout","output_type":"stream","text":[" ········································\n"]},{"name":"stderr","output_type":"stream","text":["\u001b[34m\u001b[1mwandb\u001b[0m: Appending key for api.wandb.ai to your netrc file: /root/.netrc\n"]},{"data":{"text/html":["Tracking run with wandb version 0.17.0"],"text/plain":["<IPython.core.display.HTML object>"]},"metadata":{},"output_type":"display_data"},{"data":{"text/html":["Run data is saved locally in <code>/kaggle/working/wandb/run-20240603_111947-zd4tutif</code>"],"text/plain":["<IPython.core.display.HTML object>"]},"metadata":{},"output_type":"display_data"},{"data":{"text/html":["Syncing run <strong><a href='https://wandb.ai/filnow42/huggingface/runs/zd4tutif' target=\"_blank\">/kaggle/working</a></strong> to <a href='https://wandb.ai/filnow42/huggingface' target=\"_blank\">Weights & Biases</a> (<a href='https://wandb.me/run' target=\"_blank\">docs</a>)<br/>"],"text/plain":["<IPython.core.display.HTML object>"]},"metadata":{},"output_type":"display_data"},{"data":{"text/html":[" View project at <a href='https://wandb.ai/filnow42/huggingface' target=\"_blank\">https://wandb.ai/filnow42/huggingface</a>"],"text/plain":["<IPython.core.display.HTML object>"]},"metadata":{},"output_type":"display_data"},{"data":{"text/html":[" View run at <a href='https://wandb.ai/filnow42/huggingface/runs/zd4tutif' target=\"_blank\">https://wandb.ai/filnow42/huggingface/runs/zd4tutif</a>"],"text/plain":["<IPython.core.display.HTML object>"]},"metadata":{},"output_type":"display_data"},{"data":{"text/html":["\n"," <div>\n"," \n"," <progress value='6963' max='6963' style='width:300px; height:20px; vertical-align: middle;'></progress>\n"," [6963/6963 38:47, 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"," </tr>\n"," </thead>\n"," <tbody>\n"," <tr>\n"," <td>1</td>\n"," <td>0.732900</td>\n"," <td>0.331611</td>\n"," </tr>\n"," <tr>\n"," <td>2</td>\n"," <td>0.373100</td>\n"," <td>0.246366</td>\n"," </tr>\n"," <tr>\n"," <td>3</td>\n"," <td>0.326900</td>\n"," <td>0.231167</td>\n"," </tr>\n"," </tbody>\n","</table><p>"],"text/plain":["<IPython.core.display.HTML object>"]},"metadata":{},"output_type":"display_data"},{"name":"stderr","output_type":"stream","text":["There were missing keys in the checkpoint model loaded: ['encoder.embed_tokens.weight', 'decoder.embed_tokens.weight'].\n"]},{"data":{"text/plain":["TrainOutput(global_step=6963, training_loss=1.0388871652717377, metrics={'train_runtime': 2359.6292, 'train_samples_per_second': 23.602, 'train_steps_per_second': 2.951, 'total_flos': 7499132383002624.0, 'train_loss': 1.0388871652717377, 'epoch': 3.0})"]},"execution_count":6,"metadata":{},"output_type":"execute_result"}],"source":["trainer.train()"]},{"cell_type":"code","execution_count":7,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:58:53.891952Z","iopub.status.busy":"2024-06-03T11:58:53.891542Z","iopub.status.idle":"2024-06-03T11:58:53.897775Z","shell.execute_reply":"2024-06-03T11:58:53.896741Z","shell.execute_reply.started":"2024-06-03T11:58:53.891924Z"},"trusted":true},"outputs":[],"source":["nlg = pipeline('summarization', model=model, tokenizer=tokenizer)"]},{"cell_type":"code","execution_count":8,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:58:53.899234Z","iopub.status.busy":"2024-06-03T11:58:53.898928Z","iopub.status.idle":"2024-06-03T11:59:05.979970Z","shell.execute_reply":"2024-06-03T11:59:05.978805Z","shell.execute_reply.started":"2024-06-03T11:58:53.899195Z"},"trusted":true},"outputs":[{"data":{"text/plain":["'Nie mamy tatar w menu. Cena wynosi 50. Składnik to owoce.'"]},"execution_count":8,"metadata":{},"output_type":"execute_result"}],"source":["nlg(f'generate text: dish[tatar], price[50], ingredient[wolowina]')[0]['summary_text']"]},{"cell_type":"code","execution_count":9,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:59:05.981585Z","iopub.status.busy":"2024-06-03T11:59:05.981291Z","iopub.status.idle":"2024-06-03T11:59:06.533378Z","shell.execute_reply":"2024-06-03T11:59:06.532379Z","shell.execute_reply.started":"2024-06-03T11:59:05.981559Z"},"trusted":true},"outputs":[{"data":{"text/plain":["'Nie obsługujemy płatności gotowka. Cena wynosi 150. Oczywiście, dostarczymy na ulica Dluga 5.'"]},"execution_count":9,"metadata":{},"output_type":"execute_result"}],"source":["nlg(f'generate text: payment_methods[gotowka], price[150], addresses[ulica Dluga 5]')[0]['summary_text']"]},{"cell_type":"code","execution_count":10,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:59:06.538123Z","iopub.status.busy":"2024-06-03T11:59:06.537427Z","iopub.status.idle":"2024-06-03T11:59:06.938435Z","shell.execute_reply":"2024-06-03T11:59:06.937299Z","shell.execute_reply.started":"2024-06-03T11:59:06.538081Z"},"trusted":true},"outputs":[{"data":{"text/plain":["'Nie mamy tiramisu w menu. Składnik mleko jest dostępny. Nie zawiera alergenu laktoza.'"]},"execution_count":10,"metadata":{},"output_type":"execute_result"}],"source":["nlg(f'generate text: dish[tiramisu], ingredient[mleko], allergy[laktoza]')[0]['summary_text']"]},{"cell_type":"code","execution_count":11,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:59:06.940331Z","iopub.status.busy":"2024-06-03T11:59:06.939929Z","iopub.status.idle":"2024-06-03T11:59:07.132913Z","shell.execute_reply":"2024-06-03T11:59:07.131901Z","shell.execute_reply.started":"2024-06-03T11:59:06.940292Z"},"trusted":true},"outputs":[{"name":"stderr","output_type":"stream","text":["Your max_length is set to 20, but your input_length is only 10. Since this is a summarization task, where outputs shorter than the input are typically wanted, you might consider decreasing max_length manually, e.g. summarizer('...', max_length=5)\n"]},{"data":{"text/plain":["'Zamknięte o dziesiata.'"]},"execution_count":11,"metadata":{},"output_type":"execute_result"}],"source":["nlg(f'generate text: time[dziesiata]')[0]['summary_text']"]},{"cell_type":"code","execution_count":12,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:59:07.134671Z","iopub.status.busy":"2024-06-03T11:59:07.134067Z","iopub.status.idle":"2024-06-03T11:59:07.405347Z","shell.execute_reply":"2024-06-03T11:59:07.404117Z","shell.execute_reply.started":"2024-06-03T11:59:07.134642Z"},"trusted":true},"outputs":[{"name":"stderr","output_type":"stream","text":["Your max_length is set to 20, but your input_length is only 14. Since this is a summarization task, where outputs shorter than the input are typically wanted, you might consider decreasing max_length manually, e.g. summarizer('...', max_length=7)\n"]},{"data":{"text/plain":["'Nie mamy spaghetti w menu. Składnik ser jest dostępny.'"]},"execution_count":12,"metadata":{},"output_type":"execute_result"}],"source":["nlg(f'generate text: dish[spaghetti], ingredient[ser]')[0]['summary_text']"]},{"cell_type":"code","execution_count":13,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:59:07.410442Z","iopub.status.busy":"2024-06-03T11:59:07.407270Z","iopub.status.idle":"2024-06-03T11:59:07.697634Z","shell.execute_reply":"2024-06-03T11:59:07.695355Z","shell.execute_reply.started":"2024-06-03T11:59:07.410396Z"},"trusted":true},"outputs":[{"name":"stderr","output_type":"stream","text":["Your max_length is set to 20, but your input_length is only 16. Since this is a summarization task, where outputs shorter than the input are typically wanted, you might consider decreasing max_length manually, e.g. summarizer('...', max_length=8)\n"]},{"data":{"text/plain":["'Nie mamy pierogi w menu. Składnik to koti ser.'"]},"execution_count":13,"metadata":{},"output_type":"execute_result"}],"source":["nlg(f'generate text: dish[pierogi], ingredient[kozi ser]')[0]['summary_text']"]},{"cell_type":"code","execution_count":14,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:59:07.699269Z","iopub.status.busy":"2024-06-03T11:59:07.698906Z","iopub.status.idle":"2024-06-03T11:59:08.138934Z","shell.execute_reply":"2024-06-03T11:59:08.137833Z","shell.execute_reply.started":"2024-06-03T11:59:07.699233Z"},"trusted":true},"outputs":[{"data":{"text/plain":["'Zamknięte o 23:00. Nie dostarczamy na ulica Krótka 256.'"]},"execution_count":14,"metadata":{},"output_type":"execute_result"}],"source":["nlg(f'generate text: time[23:00], adres[ul Krótka 256]')[0]['summary_text']"]},{"cell_type":"code","execution_count":15,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T11:59:08.140718Z","iopub.status.busy":"2024-06-03T11:59:08.140399Z","iopub.status.idle":"2024-06-03T11:59:11.078579Z","shell.execute_reply":"2024-06-03T11:59:11.077378Z","shell.execute_reply.started":"2024-06-03T11:59:08.140689Z"},"trusted":true},"outputs":[],"source":["model.save_pretrained(\"/kaggle/working\")"]},{"cell_type":"code","execution_count":18,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T12:03:34.284674Z","iopub.status.busy":"2024-06-03T12:03:34.283930Z","iopub.status.idle":"2024-06-03T12:03:34.468881Z","shell.execute_reply":"2024-06-03T12:03:34.467812Z","shell.execute_reply.started":"2024-06-03T12:03:34.284637Z"},"trusted":true},"outputs":[],"source":["from kaggle_secrets import UserSecretsClient\n","user_secrets = UserSecretsClient()\n","secret_value_0 = user_secrets.get_secret(\"huggingface-write\")"]},{"cell_type":"code","execution_count":19,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T12:03:38.980042Z","iopub.status.busy":"2024-06-03T12:03:38.979682Z","iopub.status.idle":"2024-06-03T12:03:39.119457Z","shell.execute_reply":"2024-06-03T12:03:39.118367Z","shell.execute_reply.started":"2024-06-03T12:03:38.980011Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":["The token has not been saved to the git credentials helper. Pass `add_to_git_credential=True` in this function directly or `--add-to-git-credential` if using via `huggingface-cli` if you want to set the git credential as well.\n","Token is valid (permission: write).\n","Your token has been saved to /root/.cache/huggingface/token\n","Login successful\n"]}],"source":["from huggingface_hub import login\n","login(secret_value_0)"]},{"cell_type":"code","execution_count":20,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T12:03:45.290131Z","iopub.status.busy":"2024-06-03T12:03:45.289755Z","iopub.status.idle":"2024-06-03T12:04:24.555639Z","shell.execute_reply":"2024-06-03T12:04:24.554427Z","shell.execute_reply.started":"2024-06-03T12:03:45.290099Z"},"trusted":true},"outputs":[{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"bc999b688b0b4163b518f7047380dc7d","version_major":2,"version_minor":0},"text/plain":["events.out.tfevents.1717413574.743112a2decd.34.0: 0%| | 0.00/9.10k [00:00<?, ?B/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"bbc79a9e89444b41b2df98deeb0b4add","version_major":2,"version_minor":0},"text/plain":["model.safetensors: 0%| | 0.00/1.23G [00:00<?, ?B/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"bec70bfa21154c47a7680cdc214dd320","version_major":2,"version_minor":0},"text/plain":["Upload 3 LFS files: 0%| | 0/3 [00:00<?, ?it/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"fc812bdfac0d4fc0ac5bab1590240a73","version_major":2,"version_minor":0},"text/plain":["training_args.bin: 0%| | 0.00/5.24k [00:00<?, ?B/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"text/plain":["CommitInfo(commit_url='https://huggingface.co/filnow/working/commit/72c855645f38e057804135cb1de549ce045e18ea', commit_message='filnow/nlg-umt5-pol', commit_description='', oid='72c855645f38e057804135cb1de549ce045e18ea', pr_url=None, pr_revision=None, pr_num=None)"]},"execution_count":20,"metadata":{},"output_type":"execute_result"}],"source":["trainer.push_to_hub(\"filnow/nlg-umt5-pol\")"]},{"cell_type":"code","execution_count":21,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T12:14:22.429205Z","iopub.status.busy":"2024-06-03T12:14:22.428309Z","iopub.status.idle":"2024-06-03T12:14:44.972041Z","shell.execute_reply":"2024-06-03T12:14:44.970939Z","shell.execute_reply.started":"2024-06-03T12:14:22.429157Z"},"trusted":true},"outputs":[{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"c0cdb81c53394a9981be4af7cadc1b27","version_major":2,"version_minor":0},"text/plain":["config.json: 0%| | 0.00/859 [00:00<?, ?B/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"87317339f97b4710b6ca2112bf689984","version_major":2,"version_minor":0},"text/plain":["model.safetensors: 0%| | 0.00/1.23G [00:00<?, ?B/s]"]},"metadata":{},"output_type":"display_data"},{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"25639ec6e2e4415bb5d9d51d1755fc4c","version_major":2,"version_minor":0},"text/plain":["generation_config.json: 0%| | 0.00/166 [00:00<?, ?B/s]"]},"metadata":{},"output_type":"display_data"}],"source":["my_model = AutoModelForSeq2SeqLM.from_pretrained(\"filnow/nlg-umt5-pol\")"]},{"cell_type":"code","execution_count":23,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T12:15:13.704377Z","iopub.status.busy":"2024-06-03T12:15:13.703433Z","iopub.status.idle":"2024-06-03T12:15:13.710676Z","shell.execute_reply":"2024-06-03T12:15:13.709499Z","shell.execute_reply.started":"2024-06-03T12:15:13.704327Z"},"trusted":true},"outputs":[],"source":["my_nlg = pipeline('summarization', model=my_model, tokenizer=tokenizer)"]},{"cell_type":"code","execution_count":25,"metadata":{"execution":{"iopub.execute_input":"2024-06-03T12:15:31.134884Z","iopub.status.busy":"2024-06-03T12:15:31.134517Z","iopub.status.idle":"2024-06-03T12:15:32.440573Z","shell.execute_reply":"2024-06-03T12:15:32.439690Z","shell.execute_reply.started":"2024-06-03T12:15:31.134855Z"},"trusted":true},"outputs":[{"data":{"text/plain":["'Zamknięte o 23:00. Nie dostarczamy na ulica Krótka 256.'"]},"execution_count":25,"metadata":{},"output_type":"execute_result"}],"source":["my_nlg(f'generate text: time[23:00], adres[ul Krótka 256]')[0]['summary_text']"]}],"metadata":{"kaggle":{"accelerator":"gpu","dataSources":[{"datasetId":5135632,"sourceId":8587424,"sourceType":"datasetVersion"}],"dockerImageVersionId":30716,"isGpuEnabled":true,"isInternetEnabled":true,"language":"python","sourceType":"notebook"},"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.9.19"}},"nbformat":4,"nbformat_minor":4}