{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "X4cRE8IbIrIV" }, "source": [ "If you're opening this Notebook on colab, you will probably need to install đ¤ Transformers and đ¤ Datasets as well as other dependencies. Uncomment the following cell and run it." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "MOsHUjgdIrIW", "outputId": "d4af45da-df5e-49d5-e0d6-be54e0f9ad1f" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Requirement already satisfied: datasets in /usr/local/lib/python3.10/dist-packages (2.13.1)\n", "Requirement already satisfied: evaluate in /usr/local/lib/python3.10/dist-packages (0.4.0)\n", "Requirement already satisfied: transformers in /usr/local/lib/python3.10/dist-packages (4.30.2)\n", "Requirement already satisfied: rouge-score in /usr/local/lib/python3.10/dist-packages (0.1.2)\n", "Requirement already satisfied: nltk in /usr/local/lib/python3.10/dist-packages (3.8.1)\n", "Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from datasets) (1.22.4)\n", "Requirement already satisfied: pyarrow>=8.0.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (9.0.0)\n", "Requirement already satisfied: dill<0.3.7,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (0.3.6)\n", "Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from datasets) (1.5.3)\n", "Requirement already satisfied: requests>=2.19.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (2.27.1)\n", "Requirement already satisfied: tqdm>=4.62.1 in /usr/local/lib/python3.10/dist-packages (from datasets) (4.65.0)\n", "Requirement already satisfied: xxhash in /usr/local/lib/python3.10/dist-packages (from datasets) (3.2.0)\n", "Requirement already satisfied: multiprocess in /usr/local/lib/python3.10/dist-packages (from datasets) (0.70.14)\n", "Requirement already satisfied: fsspec[http]>=2021.11.1 in /usr/local/lib/python3.10/dist-packages (from datasets) (2023.6.0)\n", "Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from datasets) (3.8.4)\n", "Requirement already satisfied: huggingface-hub<1.0.0,>=0.11.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (0.16.3)\n", "Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from datasets) (23.1)\n", "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from datasets) (6.0)\n", "Requirement already satisfied: responses<0.19 in /usr/local/lib/python3.10/dist-packages (from evaluate) (0.18.0)\n", "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from transformers) (3.12.2)\n", "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers) (2022.10.31)\n", "Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.13.3)\n", "Requirement already satisfied: safetensors>=0.3.1 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.3.1)\n", "Requirement already satisfied: absl-py in /usr/local/lib/python3.10/dist-packages (from rouge-score) (1.4.0)\n", "Requirement already satisfied: six>=1.14.0 in /usr/local/lib/python3.10/dist-packages (from rouge-score) (1.16.0)\n", "Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages (from nltk) (8.1.3)\n", "Requirement already satisfied: joblib in /usr/local/lib/python3.10/dist-packages (from nltk) (1.2.0)\n", "Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (23.1.0)\n", "Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (2.0.12)\n", "Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (6.0.4)\n", "Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (4.0.2)\n", "Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.9.2)\n", "Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.3.3)\n", "Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.3.1)\n", "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0.0,>=0.11.0->datasets) (4.6.3)\n", "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets) (1.26.16)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets) (2023.5.7)\n", "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets) (3.4)\n", "Requirement already satisfied: python-dateutil>=2.8.1 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets) (2.8.2)\n", "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets) (2022.7.1)\n" ] } ], "source": [ "! pip install datasets evaluate transformers rouge-score nltk" ] }, { "cell_type": "code", "source": [ "! pip install huggingface_hub" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "mRzDQvi2SWxZ", "outputId": "831331b8-4020-40f3-bbdd-1c373652862d" }, "execution_count": 3, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Requirement already satisfied: huggingface_hub in /usr/local/lib/python3.10/dist-packages (0.16.3)\n", "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface_hub) (3.12.2)\n", "Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from huggingface_hub) (2023.6.0)\n", "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface_hub) (2.27.1)\n", "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/dist-packages (from huggingface_hub) (4.65.0)\n", "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from huggingface_hub) (6.0)\n", "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface_hub) (4.6.3)\n", "Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.10/dist-packages (from huggingface_hub) (23.1)\n", "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface_hub) (1.26.16)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface_hub) (2023.5.7)\n", "Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface_hub) (2.0.12)\n", "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface_hub) (3.4)\n" ] } ] }, { "cell_type": "markdown", "metadata": { "id": "t4_p3GTW1wfY" }, "source": [ "If you're opening this notebook locally, make sure your environment has an install from the last version of those libraries.\n", "\n", "To be able to share your model with the community and generate results like the one shown in the picture below via the inference API, there are a few more steps to follow.\n", "\n", "First you have to store your authentication token from the Hugging Face website (sign up [here](https://huggingface.co/join) if you haven't already!) then execute the following cell and input your username and password:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 162, "referenced_widgets": [ "9c59ace7d7414de39bd9089106d40b61", "b6c0102a743a4dc6a8f0d31a8782fc3a", "5a5362b4027f47519979c90f378ed3f8", "8662568bfce34d2daa3667930e9149bb", "5fd77d6f9da048bb89ff4404a432bc8d", "bf4cb6dd78bc49739a154bd5eace0845", "56d6e462c2d646f2b105f097516042a9", "35dd514732cf40a3ac05f7318eba5554", "32244a1998c743ae8247816d43898b03", "04cdfd25912b4019ab62fe2dcad9daa0", "e2600a5469ed421ca2c55ad4f2df45c5", "aa30bb4feb3c48f59730e9860efec395", "21d7542ea2eb4b7c9d2a3cc44c61db08", "6f9d30b9189b4e5ea5afce58a82975b2", "32fdad1696134a67a1166db3c24b3afc", "70cb135100be4181a347ec64cc8d4964", "5a80a61eea6343eabb6d895afaf4184a", "23c71a29a5644ce39f503f440c950c4d", "46e519b3a1dd41fa84a8195985040c52", "c412910f38f34e50b9c8d8853b516864", "67cc4396a3294d8382dc50cff50fe4b2", "ccca9f0e47ae42ee9a66de68f4776374", "e0a18363d20448b899b205fc7cca40cb", "801da6de33c94c42a8abf3d43472be87", "222bfc5456184d9ebf59c6e223c16b9b", "c22465dd6ad54749bf20dd2f2d9ae325", "4cf75ce535f74ff39ec7e6d5fb92dbef", "9ce113695cc34621b95c97df5276a3d7", "bc70c29aca694266b90c71415e8cd086", "3b66ed358dca41149c1679d5ddabe9d2", "a7a1bf64fb7347f2b997abff3068d0aa", "fc0f6ef8302d4d91bc1e240ba1ead27e" ] }, "id": "x6KMIohU1wfZ", "outputId": "71895d8a-b082-48ff-c16d-3a7ed503f2e0" }, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "VBox(children=(HTML(value='
Epoch | \n", "Training Loss | \n", "Validation Loss | \n", "Rouge1 | \n", "Rouge2 | \n", "Rougel | \n", "Rougelsum | \n", "Gen Len | \n", "
---|---|---|---|---|---|---|---|
1 | \n", "2.710200 | \n", "2.478330 | \n", "28.317100 | \n", "7.737800 | \n", "22.249200 | \n", "22.248900 | \n", "18.825500 | \n", "
"
]
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"Several commits (28) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (28) will be pushed upstream.\n",
"Several commits (29) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (29) will be pushed upstream.\n",
"Several commits (30) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (30) will be pushed upstream.\n",
"Several commits (31) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (31) will be pushed upstream.\n",
"Several commits (32) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (32) will be pushed upstream.\n",
"Several commits (33) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (33) will be pushed upstream.\n",
"Several commits (34) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (34) will be pushed upstream.\n",
"Several commits (35) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (35) will be pushed upstream.\n",
"Several commits (36) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (36) will be pushed upstream.\n",
"Several commits (37) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (37) will be pushed upstream.\n",
"Several commits (38) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (38) will be pushed upstream.\n",
"Several commits (39) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (39) will be pushed upstream.\n",
"Several commits (40) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (40) will be pushed upstream.\n",
"Several commits (41) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (41) will be pushed upstream.\n",
"Several commits (42) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (42) will be pushed upstream.\n",
"Several commits (43) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (43) will be pushed upstream.\n",
"Several commits (44) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (44) will be pushed upstream.\n",
"Several commits (45) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (45) will be pushed upstream.\n",
"Several commits (46) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (46) will be pushed upstream.\n",
"Several commits (47) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (47) will be pushed upstream.\n",
"Several commits (48) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (48) will be pushed upstream.\n",
"Several commits (49) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (49) will be pushed upstream.\n",
"Several commits (50) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (50) will be pushed upstream.\n",
"Several commits (51) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (51) will be pushed upstream.\n",
"Several commits (52) will be pushed upstream.\n",
"WARNING:huggingface_hub.repository:Several commits (52) will be pushed upstream.\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
" \n",
" \n",
" \n",
"
\n",
" \n",
" \n",
" \n",
" \n",
"Epoch \n",
" Training Loss \n",
" Validation Loss \n",
" ââââââââââââââââââââââââââââââââ Traceback (most recent call last) âââââââââââââââââââââââââââââââââŽ\n",
"â /usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_errors.py:261 in â\n",
"â hf_raise_for_status â\n",
"â â\n",
"â 258 â </Tip> â\n",
"â 259 â \"\"\" â\n",
"â 260 â try: â\n",
"â âą 261 â â response.raise_for_status() â\n",
"â 262 â except HTTPError as e: â\n",
"â 263 â â error_code = response.headers.get(\"X-Error-Code\") â\n",
"â 264 â\n",
"â â\n",
"â /usr/local/lib/python3.10/dist-packages/requests/models.py:960 in raise_for_status â\n",
"â â\n",
"â 957 â â â http_error_msg = u'%s Server Error: %s for url: %s' % (self.status_code, rea â\n",
"â 958 â â â\n",
"â 959 â â if http_error_msg: â\n",
"â âą 960 â â â raise HTTPError(http_error_msg, response=self) â\n",
"â 961 â â\n",
"â 962 â def close(self): â\n",
"â 963 â â \"\"\"Releases the connection back to the pool. Once this method has been â\n",
"â°âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââŻ\n",
"HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/JeffGuo/my_model/resolve/main/config.json\n",
"\n",
"The above exception was the direct cause of the following exception:\n",
"\n",
"ââââââââââââââââââââââââââââââââ Traceback (most recent call last) âââââââââââââââââââââââââââââââââŽ\n",
"â /usr/local/lib/python3.10/dist-packages/transformers/utils/hub.py:417 in cached_file â\n",
"â â\n",
"â 414 â user_agent = http_user_agent(user_agent) â\n",
"â 415 â try: â\n",
"â 416 â â # Load from URL or cache if already cached â\n",
"â âą 417 â â resolved_file = hf_hub_download( â\n",
"â 418 â â â path_or_repo_id, â\n",
"â 419 â â â filename, â\n",
"â 420 â â â subfolder=None if len(subfolder) == 0 else subfolder, â\n",
"â â\n",
"â /usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py:118 in _inner_fn â\n",
"â â\n",
"â 115 â â if check_use_auth_token: â\n",
"â 116 â â â kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=ha â\n",
"â 117 â â â\n",
"â âą 118 â â return fn(*args, **kwargs) â\n",
"â 119 â â\n",
"â 120 â return _inner_fn # type: ignore â\n",
"â 121 â\n",
"â â\n",
"â /usr/local/lib/python3.10/dist-packages/huggingface_hub/file_download.py:1195 in hf_hub_download â\n",
"â â\n",
"â 1192 â if not local_files_only: â\n",
"â 1193 â â try: â\n",
"â 1194 â â â try: â\n",
"â âą 1195 â â â â metadata = get_hf_file_metadata( â\n",
"â 1196 â â â â â url=url, â\n",
"â 1197 â â â â â token=token, â\n",
"â 1198 â â â â â proxies=proxies, â\n",
"â â\n",
"â /usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py:118 in _inner_fn â\n",
"â â\n",
"â 115 â â if check_use_auth_token: â\n",
"â 116 â â â kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=ha â\n",
"â 117 â â â\n",
"â âą 118 â â return fn(*args, **kwargs) â\n",
"â 119 â â\n",
"â 120 â return _inner_fn # type: ignore â\n",
"â 121 â\n",
"â â\n",
"â /usr/local/lib/python3.10/dist-packages/huggingface_hub/file_download.py:1541 in â\n",
"â get_hf_file_metadata â\n",
"â â\n",
"â 1538 â â proxies=proxies, â\n",
"â 1539 â â timeout=timeout, â\n",
"â 1540 â ) â\n",
"â âą 1541 â hf_raise_for_status(r) â\n",
"â 1542 â â\n",
"â 1543 â # Return â\n",
"â 1544 â return HfFileMetadata( â\n",
"â â\n",
"â /usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_errors.py:293 in â\n",
"â hf_raise_for_status â\n",
"â â\n",
"â 290 â â â â \" `repo_type`.\\nIf you are trying to access a private or gated repo,\" â\n",
"â 291 â â â â \" make sure you are authenticated.\" â\n",
"â 292 â â â ) â\n",
"â âą 293 â â â raise RepositoryNotFoundError(message, response) from e â\n",
"â 294 â â â\n",
"â 295 â â elif response.status_code == 400: â\n",
"â 296 â â â message = ( â\n",
"â°âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââŻ\n",
"RepositoryNotFoundError: 404 Client Error. (Request ID: \n",
"Root=1-64a83bdb-77e81da43b5d28ea6d550569;efcc0ac0-0ddb-49f0-9746-8fc12c5b5565)\n",
"\n",
"Repository Not Found for url: https://huggingface.co/JeffGuo/my_model/resolve/main/config.json.\n",
"Please make sure you specified the correct `repo_id` and `repo_type`.\n",
"If you are trying to access a private or gated repo, make sure you are authenticated.\n",
"\n",
"During handling of the above exception, another exception occurred:\n",
"\n",
"ââââââââââââââââââââââââââââââââ Traceback (most recent call last) âââââââââââââââââââââââââââââââââŽ\n",
"â in <cell line: 3>:3 â\n",
"â â\n",
"â /usr/local/lib/python3.10/dist-packages/transformers/models/auto/auto_factory.py:456 in â\n",
"â from_pretrained â\n",
"â â\n",
"â 453 â â â if kwargs.get(\"torch_dtype\", None) == \"auto\": â\n",
"â 454 â â â â _ = kwargs.pop(\"torch_dtype\") â\n",
"â 455 â â â â\n",
"â âą 456 â â â config, kwargs = AutoConfig.from_pretrained( â\n",
"â 457 â â â â pretrained_model_name_or_path, â\n",
"â 458 â â â â return_unused_kwargs=True, â\n",
"â 459 â â â â trust_remote_code=trust_remote_code, â\n",
"â â\n",
"â /usr/local/lib/python3.10/dist-packages/transformers/models/auto/configuration_auto.py:944 in â\n",
"â from_pretrained â\n",
"â â\n",
"â 941 â â kwargs[\"_from_auto\"] = True â\n",
"â 942 â â kwargs[\"name_or_path\"] = pretrained_model_name_or_path â\n",
"â 943 â â trust_remote_code = kwargs.pop(\"trust_remote_code\", None) â\n",
"â âą 944 â â config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_n â\n",
"â 945 â â has_remote_code = \"auto_map\" in config_dict and \"AutoConfig\" in config_dict[\"aut â\n",
"â 946 â â has_local_code = \"model_type\" in config_dict and config_dict[\"model_type\"] in CO â\n",
"â 947 â â trust_remote_code = resolve_trust_remote_code( â\n",
"â â\n",
"â /usr/local/lib/python3.10/dist-packages/transformers/configuration_utils.py:574 in â\n",
"â get_config_dict â\n",
"â â\n",
"â 571 â â \"\"\" â\n",
"â 572 â â original_kwargs = copy.deepcopy(kwargs) â\n",
"â 573 â â # Get config dict associated with the base config file â\n",
"â âą 574 â â config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwar â\n",
"â 575 â â if \"_commit_hash\" in config_dict: â\n",
"â 576 â â â original_kwargs[\"_commit_hash\"] = config_dict[\"_commit_hash\"] â\n",
"â 577 â\n",
"â â\n",
"â /usr/local/lib/python3.10/dist-packages/transformers/configuration_utils.py:629 in â\n",
"â _get_config_dict â\n",
"â â\n",
"â 626 â â â â\n",
"â 627 â â â try: â\n",
"â 628 â â â â # Load from local folder or from cache or download from model Hub and ca â\n",
"â âą 629 â â â â resolved_config_file = cached_file( â\n",
"â 630 â â â â â pretrained_model_name_or_path, â\n",
"â 631 â â â â â configuration_file, â\n",
"â 632 â â â â â cache_dir=cache_dir, â\n",
"â â\n",
"â /usr/local/lib/python3.10/dist-packages/transformers/utils/hub.py:433 in cached_file â\n",
"â â\n",
"â 430 â â ) â\n",
"â 431 â â\n",
"â 432 â except RepositoryNotFoundError: â\n",
"â âą 433 â â raise EnvironmentError( â\n",
"â 434 â â â f\"{path_or_repo_id} is not a local folder and is not a valid model identifie â\n",
"â 435 â â â \"listed on 'https://huggingface.co/models'\\nIf this is a private repository, â\n",
"â 436 â â â \"pass a token having permission to this repo with `use_auth_token` or log in â\n",
"â°âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââŻ\n",
"OSError: JeffGuo/my_model is not a local folder and is not a valid model identifier listed on \n",
"'https://huggingface.co/models'\n",
"If this is a private repository, make sure to pass a token having permission to this repo with `use_auth_token` or \n",
"log in with `huggingface-cli login` and pass `use_auth_token=True`.\n",
"
\n"
]
},
"metadata": {}
}
],
"source": [
"from transformers import AutoModelForSeq2SeqLM\n",
"\n",
"model = AutoModelForSeq2SeqLM.from_pretrained(\"JeffGuo/my_model\")"
]
},
{
"cell_type": "code",
"source": [
"from transformers import AutoModelForSeq2SeqLM\n",
"model = AutoModelForSeq2SeqLM.from_pretrained(\"/content/t5-small-finetuned-xsum/checkpoint-12500\")"
],
"metadata": {
"id": "0PQsyHmw_M3Y"
},
"execution_count": 64,
"outputs": []
},
{
"cell_type": "code",
"source": [
"from transformers import pipeline\n",
"from random import randrange\n",
"\n",
"# load model and tokenizer from huggingface hub with pipeline\n",
"summarizer = pipeline(\"summarization\", model=\"/content/t5-small-finetuned-xsum/checkpoint-12500\", device=0)\n",
"\n",
"# select a random test sample\n",
"sample = raw_datasets['test'][randrange(len(raw_datasets[\"test\"]))]\n",
"print(f\"document: \\n{sample['document']}\\n---------------\")\n",
"\n",
"# summarize dialogue\n",
"#summarizer(\"A household name in China, the Hong-Kong born American singer was remembered for her electrifying energy and megawatt smile on stage and in front of the public. And many people were in disbelief after the news broke late at night on Wednesday. Hashtags such as \"how close depression is near you\", \"symptoms of depression\" have been trending on different online platforms, state media outlets like CCTV, People's Daily and China Daily have put out content to raise people's awareness of depression and mental illness.\")\n",
"print(type(sample[\"document\"]))\n",
"res = summarizer(sample[\"document\"])\n",
"\n",
"\n",
"print(f\"flan-t5-base summary:\\n{res[0]['summary_text']}\")\n",
"\n",
"#summarizer([\"\"])"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "_JeFYSQ7L2Ck",
"outputId": "bf90d9d0-0145-4e50-acf1-3984d92e67f7"
},
"execution_count": 83,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"document: \n",
"Second-year scholars Callum Pritchard-Ellis, James Ballie, Callum Saunders, James Jones, Fraser Murdock and Perry Ng have all been offered senior deals.\n",
"Davis told BBC Radio Stoke: \"We're delighted to have another strong group.\n",
"\"Producing our own younger players is going to be more important. It only bodes well for the future of the club.\"\n",
"Additionally, three under-16s have also signed first-year scholar contracts.\n",
"Crewe's under-21s have enjoyed success again this season, reaching the Professional Development League Two final thanks to a 4-0 win against Cardiff on Wednesday.\n",
"Crewe will now play Queens Park Rangers in the final at Loftus Road.\n",
"\"The secondary scholars have all been fairly strong,\" Davis added. \"It took a lot of meetings to decide which of the players we would take.\n",
"\"The future, at the moment, looks very healthy.\n",
"\"It's harder to recruit players now, because of the demands of some of the players and the agents.\n",
"\"Experienced players are more or less a 'no, no' for us, particularly names that people know. Financially, they're always out of our domain. Our own players can give us a better style of playing.\"\n",
"---------------\n",
"
Copy a token from your Hugging Face\ntokens page and paste it below.
Immediately click login after copying\nyour token or it might be stored in plain text in this notebook file.