{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "ludwig-bert-Claims",
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "q4qrz9uQaCnA",
        "colab_type": "text"
      },
      "source": [
        "**Goal of this Colab:** Use Bert model in Ludwig Framework to classify fake news.\n",
        "\n",
        "Author: @gatemezing\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "veYwwjw6bEYo",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# testing GPU\n",
        "import tensorflow as tf\n",
        "tf.test.gpu_device_name()"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "nBD61IZ7Uf_p",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Bert avec Ludwig\n",
        "# install ludwig \n",
        "!pip install ludwig[text,viz]"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "aXl3s7o5c3Sz",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# mount drive in Google Drive \n",
        "from google.colab import drive\n",
        "drive.mount('/content/drive')\n"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Csz8eB7gt6or",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "#  Directory set up\n",
        "BERT_DIR = '/content/drive/My Drive/Model/uncased_L-12_H-768_A-12'\n",
        "LUDWIG_DIR ='/content/drive/My Drive/Model/Ludwig'\n",
        "#print(LUDWIG_DIR)\n",
        "#print(BERT_DIR)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "hBp5IEGNig7p",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# run the experiment \n",
        "!ludwig experiment --experiment_name bert-uncaselarge --data_csv /content/claims-spacy-train.csv \\\n",
        "--model_definition_file /content/model_definition_bert.yaml"
      ],
      "execution_count": 0,
      "outputs": []
    }
  ]
}