Skip to content

Commit

Permalink
Migrating Abstractive Text Summarization with BART example to Keras 3 (
Browse files Browse the repository at this point in the history
…keras-team#1807)

* migrated the bart summarization example

* .md and .ipynb files are added
  • Loading branch information
sitamgithub-MSIT authored Mar 21, 2024
1 parent 215d087 commit c99e77b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
10 changes: 5 additions & 5 deletions examples/nlp/abstractive_summarization_with_bart.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
Title: Abstractive Text Summarization with BART
Author: [Abheesht Sharma](https://github.com/abheesht17/)
Date created: 2023/07/08
Last modified: 2023/07/08
Last modified: 2024/03/20
Description: Use KerasNLP to fine-tune BART on the abstractive summarization task.
Accelerator: GPU
Converted to Keras 3 by: [Sitam Meur](https://github.com/sitamgithub-MSIT)
"""

"""
Expand Down Expand Up @@ -42,8 +43,8 @@
"""

"""
This examples uses [Keras Core](https://keras.io/keras_core/) to work in any of
`"tensorflow"`, `"jax"` or `"torch"`. Support for Keras Core is baked into
This examples uses [Keras 3](https://keras.io/keras_3/) to work in any of
`"tensorflow"`, `"jax"` or `"torch"`. Support for Keras 3 is baked into
KerasNLP, simply change the `"KERAS_BACKEND"` environment variable to select
the backend of your choice. We select the JAX backend below.
"""
Expand All @@ -60,11 +61,10 @@
import time

import keras_nlp
import keras
import tensorflow as tf
import tensorflow_datasets as tfds

import keras_core as keras

"""
Let's also define our hyperparameters.
"""
Expand Down
37 changes: 18 additions & 19 deletions examples/nlp/ipynb/abstractive_summarization_with_bart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"\n",
"**Author:** [Abheesht Sharma](https://github.com/abheesht17/)<br>\n",
"**Date created:** 2023/07/08<br>\n",
"**Last modified:** 2023/07/08<br>\n",
"**Last modified:** 2024/03/20<br>\n",
"**Description:** Use KerasNLP to fine-tune BART on the abstractive summarization task."
]
},
Expand Down Expand Up @@ -56,7 +56,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand All @@ -71,15 +71,15 @@
"colab_type": "text"
},
"source": [
"This examples uses [Keras Core](https://keras.io/keras_core/) to work in any of\n",
"`\"tensorflow\"`, `\"jax\"` or `\"torch\"`. Support for Keras Core is baked into\n",
"This examples uses [Keras 3](https://keras.io/keras_3/) to work in any of\n",
"`\"tensorflow\"`, `\"jax\"` or `\"torch\"`. Support for Keras 3 is baked into\n",
"KerasNLP, simply change the `\"KERAS_BACKEND\"` environment variable to select\n",
"the backend of your choice. We select the JAX backend below."
]
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand All @@ -101,7 +101,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand All @@ -111,10 +111,9 @@
"import time\n",
"\n",
"import keras_nlp\n",
"import keras\n",
"import tensorflow as tf\n",
"import tensorflow_datasets as tfds\n",
"\n",
"import keras_core as keras"
"import tensorflow_datasets as tfds"
]
},
{
Expand All @@ -128,7 +127,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand Down Expand Up @@ -156,7 +155,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand Down Expand Up @@ -187,7 +186,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand Down Expand Up @@ -215,7 +214,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand Down Expand Up @@ -255,7 +254,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand Down Expand Up @@ -285,7 +284,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand Down Expand Up @@ -322,7 +321,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand Down Expand Up @@ -351,7 +350,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand Down Expand Up @@ -399,7 +398,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": null,
"metadata": {
"colab_type": "code"
},
Expand Down Expand Up @@ -454,4 +453,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
9 changes: 4 additions & 5 deletions examples/nlp/md/abstractive_summarization_with_bart.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Author:** [Abheesht Sharma](https://github.com/abheesht17/)<br>
**Date created:** 2023/07/08<br>
**Last modified:** 2023/07/08<br>
**Last modified:** 2024/03/20<br>
**Description:** Use KerasNLP to fine-tune BART on the abstractive summarization task.


Expand Down Expand Up @@ -59,8 +59,8 @@ couple of utility libraries.
```
</div>
This examples uses [Keras Core](https://keras.io/keras_core/) to work in any of
`"tensorflow"`, `"jax"` or `"torch"`. Support for Keras Core is baked into
This examples uses [Keras 3](https://keras.io/keras_3) to work in any of
`"tensorflow"`, `"jax"` or `"torch"`. Support for Keras 3 is baked into
KerasNLP, simply change the `"KERAS_BACKEND"` environment variable to select
the backend of your choice. We select the JAX backend below.

Expand All @@ -79,10 +79,9 @@ import py7zr
import time

import keras_nlp
import keras
import tensorflow as tf
import tensorflow_datasets as tfds

import keras_core as keras
```

<div class="k-default-codeblock">
Expand Down

0 comments on commit c99e77b

Please sign in to comment.