Repository: gradsflow/gradsflow-automl (language: python)

Issue:
Add support for text summarisation
#### Is your feature request related to a problem? Please describe.
We currently have support for image and text classification it would be good to have support for summarisation too


Discussion / hints:
👋 @gagan3012! Thank you for opening your first issue in this repo.  We are so happy that you have decided to contribute and value your contribution. Please read these materials before proceeding: [Contributing Guide](https://github.com/fastai/fastai/blob/master/CONTRIBUTING.md) and [Code of Conduct](https://github.com/aniketmaurya/chitra/blob/master/CODE_OF_CONDUCT.md).
Thank you for raising the issue @gagan3012 😀
Would you like to raise a PR for this?
Hi yes I will add it very soon

Fix patch:
diff --git a/README.md b/README.md
index 8ff39380..cbf4d344 100644
--- a/README.md
+++ b/README.md
@@ -101,6 +101,47 @@ model.hp_tune()
 
 </details>
 
+### Auto Text Summarization
+
+<details>
+
+```python
+from gradsflow.autoclassifier import AutoSummarization
+
+from flash.core.data.utils import download_data
+from flash.text import SummarizationData
+
+# 1. Download the data
+download_data("https://pl-flash-data.s3.amazonaws.com/xsum.zip", "data/")
+
+# 2. Load the data
+datamodule = SummarizationData.from_csv(
+    "input",
+    "target",
+    train_file="data/xsum/train.csv",
+    val_file="data/xsum/valid.csv",
+    test_file="data/xsum/test.csv",
+)
+
+suggested_conf = dict(
+    optimizers=["adam"],
+    lr=(5e-4, 1e-3),
+)
+
+model = AutoSummarization(
+        datamodule,
+        max_epochs=1,
+        timeout=5,
+        suggested_backbones="sshleifer/distilbart-cnn-12-6",
+        n_trials=1,
+    )
+
+print("AutoSummarization initialised!")
+model.hp_tune()
+```
+
+</details>
+
 📑 For detailed usage examples please visit our [documentation page](https://docs.gradsflow.com).
 
 💬 Join the [Slack](https://join.slack.com/t/gradsflow/shared_invite/zt-ulc0m0ef-xstzyowuTgYceVmFbJlBmg) group to chat with us.
diff --git a/docs/gradsflow/autoclassifier.md b/docs/gradsflow/autoclassifier.md
index 81e99589..2a92712a 100644
--- a/docs/gradsflow/autoclassifier.md
+++ b/docs/gradsflow/autoclassifier.md
@@ -1,3 +1,5 @@
 ::: gradsflow.autoclassifier.image
 
 ::: gradsflow.autoclassifier.text
+
+::: gradsflow.autoclassifier.summarization
diff --git a/gradsflow/autoclassifier/__init__.py b/gradsflow/autoclassifier/__init__.py
index 0b4dbdf8..f8393257 100644
--- a/gradsflow/autoclassifier/__init__.py
+++ b/gradsflow/autoclassifier/__init__.py
@@ -1,2 +1,3 @@
 from .image import AutoImageClassifier
 from .text import AutoTextClassifier
+from .summarization import AutoSummarization
diff --git a/gradsflow/autoclassifier/summarization.py b/gradsflow/autoclassifier/summarization.py
new file mode 100644
index 00000000..3a57b702
--- /dev/null
+++ b/gradsflow/autoclassifier/summarization.py
@@ -0,0 +1,52 @@
+import torch
+from flash.text.seq2seq import SummarizationTask
+
+from gradsflow.autoclassifier.base import AutoClassifier
+
+
+# noinspection PyTypeChecker
+class AutoSummarization(AutoClassifier):
+    """
+    Automatically finds Text Summarization Model
+
+    Args:
+        datamodule: PL Lightning DataModule with `num_classes` property.
+        max_epochs: default=10.
+        n_trials: default=100.
+        optimization_metric: Optional[str] = None.
+        suggested_backbones: Union[List, str, None] = None.
+        suggested_conf [Optional[dict] = None]: This sets Trial suggestions for optimizer,
+            learning rate, and all the hyperparameters.
+        timeout: Hyperparameter search will stop after timeout.
+
+    Example:
+        ```python
+            suggested_conf = dict(
+                optimizers=["adam"],
+                lr=(5e-4, 1e-3),
+            )
+            model = AutoSummarisation(datamodule,
+                                       suggested_backbones='sshleifer/distilbart-cnn-12-6',
+                                       suggested_conf=suggested_conf,
+                                       max_epochs=1,
+                                       optimization_metric="train_loss",
+                                       timeout=30)
+            model.hp_tune()
+        ```
+    """
+
+    DEFAULT_BACKBONES = [
+        "sshleifer/distilbart-cnn-12-6",
+        "sshleifer/distilbart-xsum-12-3",
+    ]
+
+    def build_model(self, **kwargs) -> torch.nn.Module:
+        backbone = kwargs["backbone"]
+        optimizer = kwargs["optimizer"]
+        learning_rate = kwargs["lr"]
+
+        return SummarizationTask(
+            backbone=backbone,
+            optimizer=self.OPTIMIZER_INDEX[optimizer],
+            learning_rate=learning_rate,
+        )


Test patch:
diff --git a/tests/autoclassifier/test_sum.py b/tests/autoclassifier/test_sum.py
new file mode 100644
index 00000000..340eb5a2
--- /dev/null
+++ b/tests/autoclassifier/test_sum.py
@@ -0,0 +1,15 @@
+from gradsflow.autoclassifier import AutoSummarization
+
+from unittest.mock import MagicMock
+
+
+def test_model():
+    datamodule = MagicMock()
+    model = AutoSummarization(
+        datamodule,
+        max_epochs=1,
+        timeout=5,
+        suggested_backbones="sshleifer/distilbart-cnn-12-6",
+        n_trials=1,
+    )
+    assert model.model is None