Skip to content

Instantly share code, notes, and snippets.

@ritog
Created July 19, 2021 14:44
Show Gist options
  • Save ritog/7110eb74eaac5c24160d33d3837a36f6 to your computer and use it in GitHub Desktop.
Save ritog/7110eb74eaac5c24160d33d3837a36f6 to your computer and use it in GitHub Desktop.
bengali-poets.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "bengali-poets.ipynb",
"provenance": [],
"authorship_tag": "ABX9TyMyyOvuJvNiY10ApxJj5lnC",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU",
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"bddf8bcc6b964ae393e36e4c3b475b41": {
"model_module": "@jupyter-widgets/controls",
"model_name": "CheckboxModel",
"state": {
"_view_name": "CheckboxView",
"style": "IPY_MODEL_1b73331dd6f24a93b1b4d1b0155d9c36",
"_dom_classes": [],
"description": "Generate Rabindranath Tagore-styled poem.",
"_model_name": "CheckboxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": true,
"_view_count": null,
"disabled": false,
"_view_module_version": "1.5.0",
"indent": false,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_01981782c53e45e0baeb86e39b6d5a59"
}
},
"1b73331dd6f24a93b1b4d1b0155d9c36": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"01981782c53e45e0baeb86e39b6d5a59": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"771f597cac2846d7980b2797b9d721c7": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_6549ff4dfa8e4425a75784fd2a82d410",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_c66ce843cb304d8989d97f59776ef9af",
"IPY_MODEL_d99a26ccc6a54b4dbf6ac23ed79fe386"
]
}
},
"6549ff4dfa8e4425a75784fd2a82d410": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"c66ce843cb304d8989d97f59776ef9af": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_8d40446729c34aab9f6b158035c8f78e",
"_dom_classes": [],
"description": "Downloading: 100%",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 876,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 876,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_da6373c0ddf443da91fcff29183fb271"
}
},
"d99a26ccc6a54b4dbf6ac23ed79fe386": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_2ac29ced1d1a447f9828b8c17915b9a8",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "​",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 876/876 [00:00<00:00, 1.18kB/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_08d935f21c1149e09fc7ee4480d145d9"
}
},
"8d40446729c34aab9f6b158035c8f78e": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"da6373c0ddf443da91fcff29183fb271": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"2ac29ced1d1a447f9828b8c17915b9a8": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"08d935f21c1149e09fc7ee4480d145d9": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"55206792edca497fa0326a6a13212423": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_edcd061d14f646e1a97f1e7ff8b5dd15",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_c2c3e88f1d094663aba78c44f9798f62",
"IPY_MODEL_bd06337e4a754e9cb576683c4b1ff40a"
]
}
},
"edcd061d14f646e1a97f1e7ff8b5dd15": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"c2c3e88f1d094663aba78c44f9798f62": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_644c74405e7b44bc8f244e592e0271c0",
"_dom_classes": [],
"description": "Downloading: 100%",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 510403817,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 510403817,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_5828cf5171564ee4ad9b336ce7bcf256"
}
},
"bd06337e4a754e9cb576683c4b1ff40a": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_cd6fbd5465df4f4e9afa3d60850fe4de",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "​",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 510M/510M [00:14<00:00, 36.1MB/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_d7b0f52b71cc4e388a3064a82262d0d2"
}
},
"644c74405e7b44bc8f244e592e0271c0": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"5828cf5171564ee4ad9b336ce7bcf256": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"cd6fbd5465df4f4e9afa3d60850fe4de": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"d7b0f52b71cc4e388a3064a82262d0d2": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"ba6b900c666847baaae0fb1a84ac7864": {
"model_module": "@jupyter-widgets/controls",
"model_name": "TextModel",
"state": {
"_view_name": "TextView",
"style": "IPY_MODEL_a80e7cd0166746ef94711a335f4ca32e",
"_dom_classes": [],
"description": "Enter first line:",
"_model_name": "TextModel",
"placeholder": "তোমাকে দেখেছি আমার হৃদয় মাঝে",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": "তৃণতরুর ন্যায় তুমি",
"_view_count": null,
"disabled": false,
"_view_module_version": "1.5.0",
"continuous_update": true,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_4bf3ad0c26f243e7825b2d5c48f35a64"
}
},
"a80e7cd0166746ef94711a335f4ca32e": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"4bf3ad0c26f243e7825b2d5c48f35a64": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"c506293ba37c4d278f8a0f0b6e0f1faa": {
"model_module": "@jupyter-widgets/controls",
"model_name": "IntSliderModel",
"state": {
"_view_name": "IntSliderView",
"style": "IPY_MODEL_78b3006aa2cb48fc8ac415bf1e112719",
"_dom_classes": [],
"description": "Letters:",
"step": 10,
"_model_name": "IntSliderModel",
"orientation": "horizontal",
"max": 250,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 250,
"_view_count": null,
"disabled": false,
"_view_module_version": "1.5.0",
"min": 150,
"continuous_update": true,
"readout_format": "d",
"description_tooltip": null,
"readout": true,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_13a9ae2bf20c48f1bfdee4e90f2bde58"
}
},
"78b3006aa2cb48fc8ac415bf1e112719": {
"model_module": "@jupyter-widgets/controls",
"model_name": "SliderStyleModel",
"state": {
"_view_name": "StyleView",
"handle_color": null,
"_model_name": "SliderStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"13a9ae2bf20c48f1bfdee4e90f2bde58": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
}
}
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/ghosh-r/7110eb74eaac5c24160d33d3837a36f6/bengali-poets.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "yMSoafZeXMIs"
},
"source": [
"# Bengali Poets"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "nxr0HDeDXUNl"
},
"source": [
"### **Bengali-Poets** is an app, developed by [Ritobrata Ghosh](https://ghosh-r.github.io), where you can generate Bengali poetry using a prompt of your choice. You can choose a model that writes poetry in the style of [Rabindranath Tagore](https://wikipedia.org/wiki/Rabindranath_Tagore), Asia's first Nobel Laureate in Literature, or in a general style learned from ten classical poets of Bengali literature."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "mARlI7N8IrtM"
},
"source": [
"_______________"
]
},
{
"cell_type": "code",
"metadata": {
"id": "6uwH_QlSWFvD"
},
"source": [
"#@title ⬅️ Click Here { display-mode: \"form\" }\n",
"\n",
"! pip install transformers > /dev/null\n",
"from transformers import pipeline\n",
"import ipywidgets as widgets\n",
"\n",
"generate_tagore_style = widgets.Checkbox(value=False,\n",
" description='Generate Rabindranath Tagore-styled poem.',\n",
" disabled=False,\n",
" indent=False\n",
")"
],
"execution_count": 31,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 49,
"referenced_widgets": [
"bddf8bcc6b964ae393e36e4c3b475b41",
"1b73331dd6f24a93b1b4d1b0155d9c36",
"01981782c53e45e0baeb86e39b6d5a59"
]
},
"id": "TAws60YZA4L5",
"outputId": "3de6e00c-f785-4e6f-a359-3cb29e964db6"
},
"source": [
"#@title ⬅️ Select if you want to generate poetry in the style of Rabindranath Tagore (Click button, then mark checkbox) -- আপনি কি রবীন্দ্রনাথ ঠাকুরের ধাঁচে কবিতা লিখতে চান? (ক্লিক করে বক্সে টিক দিন) { display-mode: \"form\" }\n",
"\n",
"\n",
"display(generate_tagore_style)"
],
"execution_count": 56,
"outputs": [
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "bddf8bcc6b964ae393e36e4c3b475b41",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"Checkbox(value=False, description='Generate Rabindranath Tagore-styled poem.', indent=False)"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 149,
"referenced_widgets": [
"771f597cac2846d7980b2797b9d721c7",
"6549ff4dfa8e4425a75784fd2a82d410",
"c66ce843cb304d8989d97f59776ef9af",
"d99a26ccc6a54b4dbf6ac23ed79fe386",
"8d40446729c34aab9f6b158035c8f78e",
"da6373c0ddf443da91fcff29183fb271",
"2ac29ced1d1a447f9828b8c17915b9a8",
"08d935f21c1149e09fc7ee4480d145d9",
"55206792edca497fa0326a6a13212423",
"edcd061d14f646e1a97f1e7ff8b5dd15",
"c2c3e88f1d094663aba78c44f9798f62",
"bd06337e4a754e9cb576683c4b1ff40a",
"644c74405e7b44bc8f244e592e0271c0",
"5828cf5171564ee4ad9b336ce7bcf256",
"cd6fbd5465df4f4e9afa3d60850fe4de",
"d7b0f52b71cc4e388a3064a82262d0d2"
]
},
"id": "9k8VKsYO9tZ7",
"outputId": "6d7ea361-3f24-4161-fa89-99839264790f"
},
"source": [
"#@title ⬅️ Click here { display-mode: \"form\" }\n",
"\n",
"\n",
"if generate_tagore_style.value:\n",
" poet = pipeline('text-generation',\n",
" model='ghosh-r/robi-kobi',\n",
" tokenizer='ghosh-r/bangla-gpt2')\n",
" print('Poem in Rabindranath Tagore\\'s style will be generated.')\n",
"else:\n",
" poet = pipeline('text-generation',\n",
" model='ghosh-r/bn-poets',\n",
" tokenizer='ghosh-r/bangla-gpt2')\n",
" print('\\n', '__' * 25, '\\n', 'Poem in general style will be generated.')\n",
"\n",
"prompt = widgets.Text(value='তোমাকে দেখেছি আমার হৃদয় মাঝে',\n",
" placeholder='তোমাকে দেখেছি আমার হৃদয় মাঝে',\n",
" description='Enter first line:',\n",
" disabled=False\n",
")\n",
"\n",
"max_len = widgets.IntSlider(value=150,\n",
" min=150,\n",
" max=250,\n",
" step=10,\n",
" description='Letters:'\n",
")"
],
"execution_count": 57,
"outputs": [
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "771f597cac2846d7980b2797b9d721c7",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=876.0, style=ProgressStyle(description_…"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "55206792edca497fa0326a6a13212423",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=510403817.0, style=ProgressStyle(descri…"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n"
],
"name": "stdout"
},
{
"output_type": "stream",
"text": [
"Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n"
],
"name": "stderr"
},
{
"output_type": "stream",
"text": [
"Poem in Rabindranath Tagore's style will be generated.\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 49,
"referenced_widgets": [
"ba6b900c666847baaae0fb1a84ac7864",
"a80e7cd0166746ef94711a335f4ca32e",
"4bf3ad0c26f243e7825b2d5c48f35a64"
]
},
"id": "by4yqiH0B3Nm",
"outputId": "3a7325aa-67db-4ecb-9e7b-c9cf845f6ffe"
},
"source": [
"#@title ⬅️ Click button, then write the first line -- বোতামে ক্লিক করে কবিতার প্রথম লাইন লিখুন { display-mode: \"form\" }\n",
"\n",
"display(prompt)"
],
"execution_count": 58,
"outputs": [
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ba6b900c666847baaae0fb1a84ac7864",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"Text(value='তোমাকে দেখেছি আমার হৃদয় মাঝে', description='Enter first line:', placeholder='তোমাকে দেখেছি আমার হৃ…"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 49,
"referenced_widgets": [
"c506293ba37c4d278f8a0f0b6e0f1faa",
"78b3006aa2cb48fc8ac415bf1e112719",
"13a9ae2bf20c48f1bfdee4e90f2bde58"
]
},
"id": "FTZUI7urLnxN",
"outputId": "c99b9ff4-f81c-422e-ed3e-894fcb600771"
},
"source": [
"#@title ⬅️ Click button, then choose length in letters -- বোতামে ক্লিক করে কবিতার দৈর্ঘ্য নির্ধারণ করুন (অক্ষর-সংখ্যা) { display-mode: \"form\" }\n",
"\n",
"\n",
"display(max_len)"
],
"execution_count": 53,
"outputs": [
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c506293ba37c4d278f8a0f0b6e0f1faa",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"IntSlider(value=150, description='Letters:', max=250, min=150, step=10)"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "8O9HcaJpbgPh",
"outputId": "2af736a4-9e9a-446c-ab72-6b26b69f472b"
},
"source": [
"#@title ⬅️ Click here to get your poem 🖋️ -- কবিতা পেতে এখানে ক্লিক করুন 🖋️ { display-mode: \"form\" }\n",
"\n",
"poem = poet(prompt.value, max_length=max_len.value)\n",
"\n",
"output = poem[0]['generated_text'].replace('\\n', ' ').replace('\\xa0', '')\n",
"\n",
"print('\\n' * 4, '=' * 200, '\\n\\n', output, '\\n\\n', '=' * 200)"
],
"execution_count": 59,
"outputs": [
{
"output_type": "stream",
"text": [
"Setting `pad_token_id` to `eos_token_id`:50256 for open-end generation.\n"
],
"name": "stderr"
},
{
"output_type": "stream",
"text": [
"\n",
"\n",
"\n",
"\n",
" ======================================================================================================================================================================================================== \n",
"\n",
" তৃণতরুর ন্যায় তুমি বিমল, সন্তরণ তোমার স্রোতে, যৌবনের শুভদিনে প্রবাসীদের উদ্দেশ্যে তোমার তাঁর মহিমা রাখিতে হইবে করিতে সার্থকতা, ক্ষমতা নহে কর্মজীবনের সর্বোচ্চ যোগ্যতা।৩ ওই যে কেঁদে কেঁদে কাতরায়, হায়, তোমার নির \n",
"\n",
" ========================================================================================================================================================================================================\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Q5JrhlhWIpW4"
},
"source": [
"____________"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "wZfHrZk0XoaU"
},
"source": [
"### Training Procedure\n",
"\n",
"* First a 117 million parameter GPT-2 model was trained from scratch on TPUv3-8 enabled virtual machines. You can find the model [here](https://huggingface.co/ghosh-r/bangla-gpt2).\n",
"* Next, that model was fine-tuned on Bengali Poems on text-fortmat. The data can be found [here](https://kaggle.com/truthr/https://www.kaggle.com/truthr/free-bengali-poetry).\n",
"* The training Notebook can be found [here](https://colab.research.google.com/drive/1zXpoWWdFoNmMKvlZT1bOboHBY5rWKtuk?usp=sharing).\n",
"\n",
"### References:\n",
"\n",
"* Bangla-GPT2, Ritobrata Ghosh, Hugging Face, 2021\n",
"* Ritobrata Ghosh, “Free Bengali Poetry.” Kaggle, 2021, doi: 10.34740/KAGGLE/DSV/2400728.\n",
"\n",
"### Acknowledgements:\n",
"\n",
"* The **Hugging Face Team** for providing thorough and continuous support during the project.\n",
"* **Google Cloud** for providing the TPUv3 enabled Virtual Machines.\n",
"\n",
"Copyright Ritobrata Ghosh 2021. [Source Code](https://github.com/ghosh-r/BN-Poets)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Ura_7g-oNu0s"
},
"source": [
"____________"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment