{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "d78b2b50-9c54-441e-a835-b28cb0f8e096", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2024-11-29 23:21:49.836344: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.\n", "2024-11-29 23:21:49.836729: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.\n", "2024-11-29 23:21:49.838569: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.\n", "2024-11-29 23:21:49.843832: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:477] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n", "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n", "E0000 00:00:1732918909.852690 10769 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n", "E0000 00:00:1732918909.855335 10769 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n", "2024-11-29 23:21:49.864609: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n", "To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n" ] } ], "source": [ "import flair\n", "\n", "from flair.datasets import ClassificationCorpus\n", "\n", "from huggingface_hub import hf_hub_download\n", "\n", "from pathlib import Path\n", "from typing import Optional, Union" ] }, { "cell_type": "code", "execution_count": 2, "id": "404f1a80-5dcd-44cf-a37c-731553bebafc", "metadata": {}, "outputs": [], "source": [ "class SENTI_ANNO(ClassificationCorpus):\n", " def __init__(\n", " self,\n", " base_path: Optional[Union[str, Path]] = None,\n", " in_memory: bool = True,\n", " **corpusargs,\n", " ) -> None:\n", " base_path = flair.cache_root / \"datasets\" if not base_path else Path(base_path)\n", " dataset_name = self.__class__.__name__.lower()\n", " data_folder = base_path / dataset_name\n", " data_path = flair.cache_root / \"datasets\" / dataset_name\n", "\n", " for split in [\"train\", \"dev\", \"test\"]:\n", " hf_hub_download(repo_id=\"stefan-it/senti-anno\", repo_type=\"dataset\",\n", " filename=f\"{split}.txt\", token=True, local_dir=data_folder)\n", "\n", " super().__init__(\n", " data_path,\n", " **corpusargs,\n", " )" ] }, { "cell_type": "code", "execution_count": 3, "id": "146baf74-5208-4a46-bb1f-0b652bae92c0", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "cfb52f4fd9bd47d496df3c39a460aac3", "version_major": 2, "version_minor": 0 }, "text/plain": [ "train.txt: 0%| | 0.00/210k [00:00