diff --git a/app.ipynb b/app.ipynb index bca20253bdd8b347e65fec258d5d8a9357ece113..4496698ff9bf6e87f0b2ab4ff6df6dd08a437847 100644 --- a/app.ipynb +++ b/app.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -22,7 +22,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -31,7 +31,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -45,7 +45,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -58,7 +58,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -72,7 +72,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -107,7 +107,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -124,7 +124,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -154,7 +154,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -171,7 +171,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -184,7 +184,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -201,7 +201,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -210,7 +210,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -226,7 +226,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -247,7 +247,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -335,7 +335,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -357,7 +357,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -372,299 +372,9 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " * Serving Flask app '__main__'\n", - " * Debug mode: off\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.\n", - " * Running on http://127.0.0.1:8080\n", - "Press CTRL+C to quit\n", - "127.0.0.1 - - [23/May/2024 13:01:01] \"GET /read_logs HTTP/1.1\" 200 -\n", - "/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n", - " warnings.warn(\n", - "Some weights of BertForTokenClassification were not initialized from the model checkpoint at allenai/scibert_scivocab_uncased and are newly initialized: ['classifier.bias', 'classifier.weight']\n", - "You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n", - "/Users/lukemenezes/anaconda3/lib/python3.11/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" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "d77dd376727c4a36a1ee1a534bcac5fe", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0/200 [00:00<?, ?it/s]" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "a664a7603f5e47489d54148ea0df322a", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0/80 [00:00<?, ?it/s]" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 0.2954792082309723, 'eval_precision': 0.9192034139402561, 'eval_recall': 0.9145202377582791, 'eval_f1': 0.9168558456299659, 'eval_accuracy': 0.8985082578582845, 'eval_runtime': 14.9365, 'eval_samples_per_second': 5.356, 'eval_steps_per_second': 5.356, 'epoch': 0.2}\n", - "{'loss': 0.4214, 'grad_norm': 5.093618869781494, 'learning_rate': 1.2e-05, 'epoch': 0.4}\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "fa9a911837844e33a6bf1da8d0a78685", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0/80 [00:00<?, ?it/s]" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 0.2313002347946167, 'eval_precision': 0.9325906883747501, 'eval_recall': 0.9241437871497311, 'eval_f1': 0.9283480238839921, 'eval_accuracy': 0.9211507725093234, 'eval_runtime': 1.7865, 'eval_samples_per_second': 44.78, 'eval_steps_per_second': 44.78, 'epoch': 0.4}\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "dd3cbb9f87c6455f8ce0dfbe87a65e24", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0/80 [00:00<?, ?it/s]" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 0.19281569123268127, 'eval_precision': 0.9394714407502132, 'eval_recall': 0.9357486555335409, 'eval_f1': 0.9376063528077142, 'eval_accuracy': 0.933404368673415, 'eval_runtime': 1.7433, 'eval_samples_per_second': 45.889, 'eval_steps_per_second': 45.889, 'epoch': 0.6}\n", - "{'loss': 0.2374, 'grad_norm': 2.5805234909057617, 'learning_rate': 4.000000000000001e-06, 'epoch': 0.8}\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "7f4d46a1e57d4e8f9c3c3c39a39ca2ed", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0/80 [00:00<?, ?it/s]" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 0.20157472789287567, 'eval_precision': 0.9435206422018348, 'eval_recall': 0.9315029719784885, 'eval_f1': 0.9374732944025067, 'eval_accuracy': 0.9331379861481087, 'eval_runtime': 1.7554, 'eval_samples_per_second': 45.575, 'eval_steps_per_second': 45.575, 'epoch': 0.8}\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "3071f54c2c48447980968e8c85ec0440", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0/80 [00:00<?, ?it/s]" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 0.18856896460056305, 'eval_precision': 0.941643059490085, 'eval_recall': 0.9408434757996037, 'eval_f1': 0.9412430978337817, 'eval_accuracy': 0.9363345764517848, 'eval_runtime': 1.8332, 'eval_samples_per_second': 43.64, 'eval_steps_per_second': 43.64, 'epoch': 1.0}\n", - "{'train_runtime': 97.3226, 'train_samples_per_second': 4.11, 'train_steps_per_second': 2.055, 'train_loss': 0.3157902050018311, 'epoch': 1.0}\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "53f66fbb204045529e17c1adca818fc9", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0/80 [00:00<?, ?it/s]" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "127.0.0.1 - - [23/May/2024 13:02:52] \"POST /train HTTP/1.1\" 200 -\n", - "[2024-05-23 13:03:15,257] ERROR in app: Exception on /predict [POST]\n", - "Traceback (most recent call last):\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/flask/app.py\", line 2529, in wsgi_app\n", - " response = self.full_dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/flask/app.py\", line 1825, in full_dispatch_request\n", - " rv = self.handle_user_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/flask/app.py\", line 1823, in full_dispatch_request\n", - " rv = self.dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/flask/app.py\", line 1799, in dispatch_request\n", - " return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/var/folders/r3/rgdzj4k90y31832__9r63w9w0000gn/T/ipykernel_20301/1553366013.py\", line 10, in predict\n", - " predictions = predict_tags(converted_inputs, loaded_tokenizer, loaded_model, label_encoding)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/var/folders/r3/rgdzj4k90y31832__9r63w9w0000gn/T/ipykernel_20301/3237725419.py\", line 9, in predict_tags\n", - " outputs = model(input_ids, attention_mask=attention_mask)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1511, in _wrapped_call_impl\n", - " return self._call_impl(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1520, in _call_impl\n", - " return forward_call(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/transformers/models/bert/modeling_bert.py\", line 1885, in forward\n", - " outputs = self.bert(\n", - " ^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1511, in _wrapped_call_impl\n", - " return self._call_impl(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1520, in _call_impl\n", - " return forward_call(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/transformers/models/bert/modeling_bert.py\", line 1073, in forward\n", - " embedding_output = self.embeddings(\n", - " ^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1511, in _wrapped_call_impl\n", - " return self._call_impl(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1520, in _call_impl\n", - " return forward_call(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/transformers/models/bert/modeling_bert.py\", line 210, in forward\n", - " inputs_embeds = self.word_embeddings(input_ids)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1511, in _wrapped_call_impl\n", - " return self._call_impl(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1520, in _call_impl\n", - " return forward_call(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/sparse.py\", line 163, in forward\n", - " return F.embedding(\n", - " ^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/functional.py\", line 2237, in embedding\n", - " return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - "RuntimeError: Placeholder storage has not been allocated on MPS device!\n", - "127.0.0.1 - - [23/May/2024 13:03:15] \"POST /predict HTTP/1.1\" 500 -\n", - "[2024-05-23 13:03:22,677] ERROR in app: Exception on /predict [POST]\n", - "Traceback (most recent call last):\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/flask/app.py\", line 2529, in wsgi_app\n", - " response = self.full_dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/flask/app.py\", line 1825, in full_dispatch_request\n", - " rv = self.handle_user_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/flask/app.py\", line 1823, in full_dispatch_request\n", - " rv = self.dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/flask/app.py\", line 1799, in dispatch_request\n", - " return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/var/folders/r3/rgdzj4k90y31832__9r63w9w0000gn/T/ipykernel_20301/1553366013.py\", line 10, in predict\n", - " predictions = predict_tags(converted_inputs, loaded_tokenizer, loaded_model, label_encoding)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/var/folders/r3/rgdzj4k90y31832__9r63w9w0000gn/T/ipykernel_20301/3237725419.py\", line 9, in predict_tags\n", - " outputs = model(input_ids, attention_mask=attention_mask)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1511, in _wrapped_call_impl\n", - " return self._call_impl(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1520, in _call_impl\n", - " return forward_call(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/transformers/models/bert/modeling_bert.py\", line 1885, in forward\n", - " outputs = self.bert(\n", - " ^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1511, in _wrapped_call_impl\n", - " return self._call_impl(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1520, in _call_impl\n", - " return forward_call(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/transformers/models/bert/modeling_bert.py\", line 1073, in forward\n", - " embedding_output = self.embeddings(\n", - " ^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1511, in _wrapped_call_impl\n", - " return self._call_impl(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1520, in _call_impl\n", - " return forward_call(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/transformers/models/bert/modeling_bert.py\", line 210, in forward\n", - " inputs_embeds = self.word_embeddings(input_ids)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1511, in _wrapped_call_impl\n", - " return self._call_impl(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/module.py\", line 1520, in _call_impl\n", - " return forward_call(*args, **kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/modules/sparse.py\", line 163, in forward\n", - " return F.embedding(\n", - " ^^^^^^^^^^^^\n", - " File \"/Users/lukemenezes/anaconda3/lib/python3.11/site-packages/torch/nn/functional.py\", line 2237, in embedding\n", - " return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - "RuntimeError: Placeholder storage has not been allocated on MPS device!\n", - "127.0.0.1 - - [23/May/2024 13:03:22] \"POST /predict HTTP/1.1\" 500 -\n" - ] - } - ], + "outputs": [], "source": [ "## Must be run with debug=False\n", "if __name__ == '__main__':\n",