{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [], "gpuType": "T4" }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "efd10009d7df4f5192d1232f58bd3dba": { "model_module": "@jupyter-widgets/controls", "model_name": "VBoxModel", "model_module_version": "1.5.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "VBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "VBoxView", "box_style": "", "children": [ "IPY_MODEL_88f5f6b5e65a4c94ae4e6094b06762ef", "IPY_MODEL_869dd0a55a5f409b92a70684b48055a7", "IPY_MODEL_2182f650327c4b2ca2af0816bacf037b", "IPY_MODEL_7c566d90ee124d91a82c08fa7856b7ee" ], "layout": "IPY_MODEL_0da3b2e5de3a4c65b303ac2229409c69" } }, "9a08d9583bc64a1784776bbadeb81d31": { "model_module": "@jupyter-widgets/controls", "model_name": "HTMLModel", "model_module_version": "1.5.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_eeb6d7463f694693a16f53ad42ef65c6", "placeholder": "", "style": "IPY_MODEL_0465b922acb44ddc83e359221ef10605", "value": "
Epoch | \n", "Training Loss | \n", "Validation Loss | \n", "Rouge1 | \n", "Rouge2 | \n", "Rougel | \n", "Rougelsum | \n", "Gen Len | \n", "
---|---|---|---|---|---|---|---|
1 | \n", "No log | \n", "0.823874 | \n", "0.626300 | \n", "0.397300 | \n", "0.523800 | \n", "0.523700 | \n", "84.202300 | \n", "
2 | \n", "No log | \n", "0.820075 | \n", "0.646100 | \n", "0.418400 | \n", "0.541700 | \n", "0.541600 | \n", "81.165900 | \n", "
3 | \n", "0.712100 | \n", "0.866132 | \n", "0.647900 | \n", "0.422600 | \n", "0.544800 | \n", "0.545400 | \n", "80.540900 | \n", "
4 | \n", "0.712100 | \n", "0.978417 | \n", "0.647400 | \n", "0.424200 | \n", "0.542400 | \n", "0.542500 | \n", "82.293200 | \n", "
5 | \n", "0.261900 | \n", "1.064502 | \n", "0.655000 | \n", "0.432700 | \n", "0.551700 | \n", "0.551700 | \n", "80.838600 | \n", "
6 | \n", "0.261900 | \n", "1.109778 | \n", "0.654800 | \n", "0.433900 | \n", "0.554200 | \n", "0.554300 | \n", "81.354500 | \n", "
"
],
"text/plain": [
" "
]
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"Some non-default generation parameters are set in the model config. These should go into a GenerationConfig file (https://huggingface.co/docs/transformers/generation_strategies#save-a-custom-decoding-strategy-with-your-model) instead. This warning will be raised to an exception in v4.41.\n",
"Non-default generation parameters: {'max_length': 142, 'min_length': 56, 'early_stopping': True, 'num_beams': 4, 'length_penalty': 2.0, 'no_repeat_ngram_size': 3, 'forced_bos_token_id': 0, 'forced_eos_token_id': 2}\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"TrainOutput(global_step=1760, training_loss=0.31845587491989136, metrics={'train_runtime': 3685.0836, 'train_samples_per_second': 3.814, 'train_steps_per_second': 0.478, 'total_flos': 1.0526537067085824e+16, 'train_loss': 0.31845587491989136, 'epoch': 8.0})"
]
},
"metadata": {},
"execution_count": 14
}
]
},
{
"cell_type": "code",
"source": [
"trainer.push_to_hub()"
],
"metadata": {
"id": "5OgdT1JkKOp9",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 202,
"referenced_widgets": [
"0ee68d718a02412387434f14aefa8624",
"65bc34d556d64f9496ac19af2f9f1f92",
"e33e3a939ca64c7eb7e113f7c1eb1b47",
"001bf98f36e64525ba5e6b9a19e936a9",
"c8aa19f3f6324dc29fbdef86758bf3c7",
"d1b8d7a1528743b18cf43675790ab774",
"cf6d68d94ccf4c9ba22209b71c6a9084",
"7bac73accde74c4ea54214014ccbb5ae",
"697335d7fb85412db85dbe64f340ac03",
"39f455cd9fbd47c885bb22abbb2b741c",
"c47ce0b2c8ce432584b9c4976879020a",
"0b9c778410df4dc0a02e3043aa7045d5",
"5500a2241a324bdaa44fb4262c0b47d8",
"28c976b86a1e4f4395665a5b4fd5e05d",
"b5a5ea0fdc3d4db2925f2a685afcb85c",
"137fb0e5642e4f12ac9839bd5cb0e896",
"e0e9dd17f77f4adb99309909068e0b37",
"ad764a48fd0a4217b989bd844bd16e75",
"ca9a1deda96f4b7ca2f5737770cc7fcf",
"7eed38acce92492c98e68bfab17d50f3",
"a8cab29a52454308b9a3ac8a509568e6",
"f8e60e1e031042919ad9e808b5d3b5ad",
"6d66e456e6204cde9903a0b671ef63d3",
"3a66970fccc846b6abd2ee785f8119a9",
"fae854f6e5ec4aca9c40d5c156f525e7",
"65f49656a31c4f7aa51506cba963cc35",
"1942baed8a574db78ff852ce99386b59",
"5c7d7d1dba36493dba9badea2747ec9d",
"54ba024c634c4b719369fe856aa33d76",
"858a3bbc4c6d4657b86fc903df73f8a6",
"a13d2ee269314652b6dbcdbef2862315",
"8f3e605e977646749f7be3dd71eb7575",
"8dcd464d517341c4bc3833ca1b57acaa"
]
},
"outputId": "4722d6d2-0881-445a-d4d6-b9ca3c887097"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"Some non-default generation parameters are set in the model config. These should go into a GenerationConfig file (https://huggingface.co/docs/transformers/generation_strategies#save-a-custom-decoding-strategy-with-your-model) instead. This warning will be raised to an exception in v4.41.\n",
"Non-default generation parameters: {'max_length': 142, 'min_length': 56, 'early_stopping': True, 'num_beams': 4, 'length_penalty': 2.0, 'no_repeat_ngram_size': 3, 'forced_bos_token_id': 0, 'forced_eos_token_id': 2}\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"Upload 2 LFS files: 0%| | 0/2 [00:00, ?it/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "0ee68d718a02412387434f14aefa8624"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"model.safetensors: 0%| | 0.00/1.63G [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "0b9c778410df4dc0a02e3043aa7045d5"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"events.out.tfevents.1719246228.a407000c0675.257.0: 0%| | 0.00/11.1k [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "6d66e456e6204cde9903a0b671ef63d3"
}
},
"metadata": {}
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"CommitInfo(commit_url='https://huggingface.co/ahmedmbutt/PTS-Bart-Large-CNN/commit/45b40aa1a83c2e26440c31f8221928ba6f0783fe', commit_message='End of training', commit_description='', oid='45b40aa1a83c2e26440c31f8221928ba6f0783fe', pr_url=None, pr_revision=None, pr_num=None)"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 15
}
]
},
{
"cell_type": "markdown",
"source": [
"# Inference"
],
"metadata": {
"id": "T-qjQUmyy128"
}
},
{
"cell_type": "code",
"source": [
"original_text = dataset['test'][0]['Text']\n",
"original_text"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 122
},
"id": "gCAcoPVGS6mH",
"outputId": "93cade93-cc9d-4403-dde1-56d7516b35e6"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'People showing this behavior struggle with cognitive dissonance, or the mental discomfort you may have holding two conflicting ideas at the same time. Human beings like to have consistency between their beliefs and actions. For example, you are marrying someone great, but you come from a dysfunctional family. Your dad left, and your mother went from one abusive relationship to another. You, therefore, don’t believe in a stable, loving marriage. Yet, you are continuing to plan the wedding and send invitations. Here’s a work-related example: You are about to land a great client and earn more money than ever before. Rather than do what it takes to propel yourself forward, you hold back because you don’t feel worthy. So, you get drunk the night before the client meeting and miss it entirely. Rather than move ahead, you take actions to screw things up for yourself.'"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 18
}
]
},
{
"cell_type": "code",
"source": [
"from transformers import pipeline\n",
"\n",
"summarizer = pipeline(\"summarization\", model=\"PTS-Bart-Large-CNN\")\n",
"summarized_text = summarizer(original_text)\n",
"summarized_text = summarized_text[0]['summary_text']\n",
"summarized_text"
],
"metadata": {
"id": "ATRAd0FwzIjh",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 70
},
"outputId": "2b9327cc-3369-49e3-dfc5-968d9ea8706b"
},
"execution_count": null,
"outputs": [
{
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"\"Cognitive dissonance is the mental discomfort of holding conflicting ideas at the same time. Human beings like consistency between beliefs and actions. For example, if you're marrying someone great but come from a dysfunctional family, you may struggle with cognitive dissonance. In a work-related example, you might hold back from a client meeting due to feeling unworthy, leading to actions that hinder your progress.\""
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
]
}
]
}\n",
" \n",
"
\n",
" \n",
" \n",
" \n",
" Epoch \n",
" Training Loss \n",
" Validation Loss \n",
" Rouge1 \n",
" Rouge2 \n",
" Rougel \n",
" Rougelsum \n",
" Gen Len \n",
" \n",
" \n",
" 1 \n",
" No log \n",
" 0.823874 \n",
" 0.626300 \n",
" 0.397300 \n",
" 0.523800 \n",
" 0.523700 \n",
" 84.202300 \n",
" \n",
" \n",
" 2 \n",
" No log \n",
" 0.820075 \n",
" 0.646100 \n",
" 0.418400 \n",
" 0.541700 \n",
" 0.541600 \n",
" 81.165900 \n",
" \n",
" \n",
" 3 \n",
" 0.712100 \n",
" 0.866132 \n",
" 0.647900 \n",
" 0.422600 \n",
" 0.544800 \n",
" 0.545400 \n",
" 80.540900 \n",
" \n",
" \n",
" 4 \n",
" 0.712100 \n",
" 0.978417 \n",
" 0.647400 \n",
" 0.424200 \n",
" 0.542400 \n",
" 0.542500 \n",
" 82.293200 \n",
" \n",
" \n",
" 5 \n",
" 0.261900 \n",
" 1.064502 \n",
" 0.655000 \n",
" 0.432700 \n",
" 0.551700 \n",
" 0.551700 \n",
" 80.838600 \n",
" \n",
" \n",
" 6 \n",
" 0.261900 \n",
" 1.109778 \n",
" 0.654800 \n",
" 0.433900 \n",
" 0.554200 \n",
" 0.554300 \n",
" 81.354500 \n",
" \n",
" \n",
" 7 \n",
" 0.112400 \n",
" 1.152843 \n",
" 0.652800 \n",
" 0.429800 \n",
" 0.551100 \n",
" 0.551000 \n",
" 80.570500 \n",
" \n",
" \n",
" \n",
"8 \n",
" 0.112400 \n",
" 1.175985 \n",
" 0.655100 \n",
" 0.433200 \n",
" 0.554300 \n",
" 0.554100 \n",
" 80.088600 \n",
"