html_url
stringlengths
48
51
title
stringlengths
1
290
comments
sequencelengths
0
30
body
stringlengths
0
228k
βŒ€
number
int64
2
7.08k
https://github.com/huggingface/datasets/issues/4811
Bug in function validate_type for Python >= 3.9
[]
## Describe the bug The function `validate_type` assumes that the type `typing.Optional[str]` is automatically transformed to `typing.Union[str, NoneType]`. ```python In [4]: typing.Optional[str] Out[4]: typing.Union[str, NoneType] ``` However, this is not the case for Python 3.9: ```python In [3]: typing.Optional[str] Out[3]: typing.Optional[str] ```
4,811
https://github.com/huggingface/datasets/issues/4808
Add more information to the dataset card of mlqa dataset
[ "#self-assign", "Fixed by:\r\n- #4809" ]
null
4,808
https://github.com/huggingface/datasets/issues/4805
Wrong example in opus_gnome dataset card
[]
## Describe the bug I found that [the example on opus_gone dataset ](https://github.com/huggingface/datasets/tree/main/datasets/opus_gnome#dataset-summary) doesn't work. ## Steps to reproduce the bug ```python load_dataset("gnome", lang1="it", lang2="pl") ``` `"gnome"` should be `"opus_gnome"` ## Expected results ```bash 100% 1/1 [00:00<00:00, 42.09it/s] DatasetDict({ train: Dataset({ features: ['id', 'translation'], num_rows: 8368 }) }) ``` ## Actual results ```bash Couldn't find 'gnome' on the Hugging Face Hub either: FileNotFoundError: Couldn't find file at https://raw.githubusercontent.com/huggingface/datasets/main/datasets/gnome/gnome.py ``` ## Environment info - `datasets` version: 2.4.0 - Platform: Linux-5.4.0-120-generic-x86_64-with-glibc2.27 - Python version: 3.9.13 - PyArrow version: 9.0.0 - Pandas version: 1.4.3
4,805
https://github.com/huggingface/datasets/issues/4804
streaming dataset with concatenating splits raises an error
[ "Hi! Only the name of a particular split (\"train\", \"test\", ...) is supported as a split pattern if `streaming=True`. We plan to address this limitation soon.", "Hi, have you addressed this yet?", "yes, same error occurs.\r\n```python\r\nfrom datasets import load_dataset\r\n\r\n# error\r\nrepo = \"nateraw/ade20k-tiny\"\r\ndataset = load_dataset(repo, split=\"train+validation\", streaming=True)\r\n```\r\n\r\n```python\r\n---------------------------------------------------------------------------\r\nValueError Traceback (most recent call last)\r\n[<ipython-input-3-a6ae02d63899>](https://localhost:8080/#) in <cell line: 5>()\r\n 3 # error\r\n 4 repo = \"nateraw/ade20k-tiny\"\r\n----> 5 dataset = load_dataset(repo, split=\"train+validation\", streaming=True)\r\n\r\n1 frames\r\n[/usr/local/lib/python3.10/dist-packages/datasets/builder.py](https://localhost:8080/#) in as_streaming_dataset(self, split, base_path)\r\n 1265 splits_generator = splits_generators[split]\r\n 1266 else:\r\n-> 1267 raise ValueError(f\"Bad split: {split}. Available splits: {list(splits_generators)}\")\r\n 1268 \r\n 1269 # Create a dataset for each of the given splits\r\n\r\nValueError: Bad split: train+validation. Available splits: ['train', 'validation']\r\n```\r\n\r\ngoogle colab, `datasets==2.12.0`\r\n```\r\n- huggingface_hub version: 0.14.1\r\n- Platform: Linux-5.10.147+-x86_64-with-glibc2.31\r\n- Python version: 3.10.11\r\n- Running in iPython ?: No\r\n- Running in notebook ?: No\r\n- Running in Google Colab ?: No\r\n- Token path ?: /root/.cache/huggingface/token\r\n- Has saved token ?: False\r\n- Configured git credential helpers: \r\n- FastAI: 2.7.12\r\n- Tensorflow: 2.12.0\r\n- Torch: 2.0.0+cu118\r\n- Jinja2: 3.1.2\r\n- Graphviz: 0.20.1\r\n- Pydot: 1.4.2\r\n- Pillow: 8.4.0\r\n- hf_transfer: N/A\r\n- gradio: N/A\r\n- ENDPOINT: https://huggingface.co/\r\n- HUGGINGFACE_HUB_CACHE: /root/.cache/huggingface/hub\r\n- HUGGINGFACE_ASSETS_CACHE: /root/.cache/huggingface/assets\r\n- HF_TOKEN_PATH: /root/.cache/huggingface/token\r\n- HF_HUB_OFFLINE: False\r\n- HF_HUB_DISABLE_TELEMETRY: False\r\n- HF_HUB_DISABLE_PROGRESS_BARS: None\r\n- HF_HUB_DISABLE_SYMLINKS_WARNING: False\r\n- HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False\r\n- HF_HUB_DISABLE_IMPLICIT_TOKEN: False\r\n- HF_HUB_ENABLE_HF_TRANSFER: False\r\n```\r\n", "Hi!, still not fixed this, the truth is that it is an important update for what we want to train the entire dataset because we want to train fast, also should be enabled the function \"[train:18%]\" for streaming" ]
## Describe the bug streaming dataset with concatenating splits raises an error ## Steps to reproduce the bug ```python from datasets import load_dataset # no error repo = "nateraw/ade20k-tiny" dataset = load_dataset(repo, split="train+validation") ``` ```python from datasets import load_dataset # error repo = "nateraw/ade20k-tiny" dataset = load_dataset(repo, split="train+validation", streaming=True) ``` ```sh --------------------------------------------------------------------------- ValueError Traceback (most recent call last) [<ipython-input-4-a6ae02d63899>](https://localhost:8080/#) in <module>() 3 # error 4 repo = "nateraw/ade20k-tiny" ----> 5 dataset = load_dataset(repo, split="train+validation", streaming=True) 1 frames [/usr/local/lib/python3.7/dist-packages/datasets/builder.py](https://localhost:8080/#) in as_streaming_dataset(self, split, base_path) 1030 splits_generator = splits_generators[split] 1031 else: -> 1032 raise ValueError(f"Bad split: {split}. Available splits: {list(splits_generators)}") 1033 1034 # Create a dataset for each of the given splits ValueError: Bad split: train+validation. Available splits: ['validation', 'train'] ``` [Colab](https://colab.research.google.com/drive/1wMj08_0bym9jnGgByib4lsBPu8NCZBG9?usp=sharing) ## Expected results load successfully or throws an error saying it is not supported. ## Actual results above ## Environment info - `datasets` version: 2.4.0 - Platform: Windows-10-10.0.22000-SP0 (windows11 x64) - Python version: 3.9.13 - PyArrow version: 8.0.0 - Pandas version: 1.4.3
4,804
https://github.com/huggingface/datasets/issues/4803
Support `pipeline` argument in inspect.py functions
[ "Now: the preview (first-rows) works, but not the conversion to parquet. See https://huggingface.co/datasets/wikipedia/viewer/20220301.de/train\r\n\r\n```\r\n_split_generators() missing 1 required positional argument: 'pipeline'\r\n\r\nError code: UnexpectedError\r\n```" ]
**Is your feature request related to a problem? Please describe.** The `wikipedia` dataset requires a `pipeline` argument to build the list of splits: https://huggingface.co/datasets/wikipedia/blob/main/wikipedia.py#L937 But this is currently not supported in `get_dataset_config_info`: https://github.com/huggingface/datasets/blob/main/src/datasets/inspect.py#L373-L375 which is called by other functions, e.g. `get_dataset_split_names`. **Additional context** The dataset viewer is not working out-of-the-box on `wikipedia` for this reason: https://huggingface.co/datasets/wikipedia/viewer <img width="637" alt="Capture d’écran 2022-08-08 aΜ€ 12 01 16" src="https://user-images.githubusercontent.com/1676121/183461838-5330783b-0269-4ba7-a999-314cde2023d8.png">
4,803
https://github.com/huggingface/datasets/issues/4802
`with_format` behavior is inconsistent on different datasets
[ "Hi! You can get a `torch.Tensor` if you do the following:\r\n```python\r\nraw = load_dataset(\"beans\", split=\"train\")\r\nraw = raw.select(range(100))\r\n\r\npreprocessor = AutoFeatureExtractor.from_pretrained(\"nateraw/vit-base-beans\")\r\n\r\nfrom datasets import Array3D\r\nfeatures = raw.features.copy()\r\nfeatures[\"pixel_values\"] = datasets.Array3D(shape=(3, 224, 224), dtype=\"float32\")\r\n\r\ndef preprocess_func(examples):\r\n imgs = [img.convert(\"RGB\") for img in examples[\"image\"]]\r\n return preprocessor(imgs)\r\n\r\ndata = raw.map(preprocess_func, batched=True, features=features)\r\n\r\nprint(type(data[0][\"pixel_values\"]))\r\n\r\ndata = data.with_format(\"torch\", columns=[\"pixel_values\"])\r\n\r\nprint(type(data[0][\"pixel_values\"]))\r\n```\r\n\r\nThe reason for this \"inconsistency\" in the default case is the way PyArrow infers the type of multi-dim arrays (in this case, the `pixel_values` column). If the type is not specified manually, PyArrow assumes it is a dynamic-length sequence (it needs to know the type before writing the first batch to a cache file, and it can't be sure the array is fixed ahead of time; `ArrayXD` is our way of telling that the dims are fixed), so it already fails to convert the corresponding array to NumPy properly (you get an array of `np.object` arrays). And `with_format(\"torch\")` replaces NumPy arrays with Torch tensors, so this bad formatting propagates." ]
## Describe the bug I found a case where `with_format` does not transform the dataset to the requested format. ## Steps to reproduce the bug Run: ```python from transformers import AutoTokenizer, AutoFeatureExtractor from datasets import load_dataset raw = load_dataset("glue", "sst2", split="train") raw = raw.select(range(100)) tokenizer = AutoTokenizer.from_pretrained("philschmid/tiny-bert-sst2-distilled") def preprocess_func(examples): return tokenizer(examples["sentence"], padding=True, max_length=256, truncation=True) data = raw.map(preprocess_func, batched=True) print(type(data[0]["input_ids"])) data = data.with_format("torch", columns=["input_ids"]) print(type(data[0]["input_ids"])) ``` printing as expected: ```python <class 'list'> <class 'torch.Tensor'> ``` Then run: ```python raw = load_dataset("beans", split="train") raw = raw.select(range(100)) preprocessor = AutoFeatureExtractor.from_pretrained("nateraw/vit-base-beans") def preprocess_func(examples): imgs = [img.convert("RGB") for img in examples["image"]] return preprocessor(imgs) data = raw.map(preprocess_func, batched=True) print(type(data[0]["pixel_values"])) data = data.with_format("torch", columns=["pixel_values"]) print(type(data[0]["pixel_values"])) ``` Printing, unexpectedly ```python <class 'list'> <class 'list'> ``` ## Expected results `with_format` should transform into the requested format; it's not the case. ## Actual results `type(data[0]["pixel_values"])` should be `torch.Tensor` in the example above ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: dev version, commit 44af3fafb527302282f6b6507b952de7435f0979 - Platform: Linux - Python version: 3.9.12 - PyArrow version: 7.0.0
4,802
https://github.com/huggingface/datasets/issues/4799
video dataset loader/parser
[ "Hi! We've just started discussing the video support in `datasets` (decoding backends, video feature type, etc.), so I believe we should have something tangible by the end of this year.\r\n\r\nAlso, if you have additional video features in mind that you would like to see, feel free to let us know", "Coool thanks @mariosasko ", "Hey @mariosasko, I was wondering if there's a way to load video data currently in the library? \r\nAlternatively is there a way I could hack it through the dataset.from_dict() method? I tried to hack it, but the issue I run into is that earlier I was doing a `cast_column()` call for the `Image` feature, but now I'm not sure about to do if I want the dataset to have the following keys when I call from_dict on it:\r\n`{\"caption\":[list of text captions], \"video_frames\": [list of image lists with one image list corresponding to one video]}`\r\n\r\nMaybe something like `cast_column(\"video_frames\", List(Image))` ..\r\n(This is assuming I have already extracted frames from video)" ]
you know how you can [use `load_dataset` with any arbitrary csv file](https://huggingface.co/docs/datasets/loading#csv)? and you can also [use it to load a local image dataset](https://huggingface.co/docs/datasets/image_load#local-files)? could you please add functionality to load a video dataset? it would be really cool if i could point it to a bunch of video files and use pytorch to start looping through batches of videos. like if my batch size is 16, each sample in the batch is a frame from a video. i'm competing in the [minerl challenge](https://www.aicrowd.com/challenges/neurips-2022-minerl-basalt-competition), and it would be awesome to use the HF ecosystem.
4,799
https://github.com/huggingface/datasets/issues/4796
ArrowInvalid: Could not convert <PIL.Image.Image image mode=RGB when adding image to Dataset
[ "@mariosasko I'm getting a similar issue when creating a Dataset from a Pandas dataframe, like so:\r\n\r\n```\r\nfrom datasets import Dataset, Features, Image, Value\r\nimport pandas as pd\r\nimport requests\r\nimport PIL\r\n\r\n# we need to define the features ourselves\r\nfeatures = Features({\r\n 'a': Value(dtype='int32'),\r\n 'b': Image(),\r\n})\r\n\r\nurl = \"http://images.cocodataset.org/val2017/000000039769.jpg\"\r\nimage = PIL.Image.open(requests.get(url, stream=True).raw)\r\n\r\ndf = pd.DataFrame({\"a\": [1, 2], \r\n \"b\": [image, image]})\r\n\r\ndataset = Dataset.from_pandas(df, features=features) \r\n```\r\nresults in \r\n\r\n```\r\nArrowInvalid: ('Could not convert <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=640x480 at 0x7F7991A15C10> with type JpegImageFile: did not recognize Python value type when inferring an Arrow data type', 'Conversion failed for column b with type object')\r\n```\r\n\r\nWill the PR linked above also fix that?", "I would expect this to work, but it doesn't. Shouldn't be too hard to fix tho (in a subsequent PR).", "Hi @mariosasko just wanted to check in if there is a PR to follow for this. I was looking to create a demo app using this. If it's not working I can just use byte encoded images in the dataset which are not displayed. ", "Hi @darraghdog! No PR yet, but I plan to fix this before the next release.", "I was just pointed here by @mariosasko, meanwhile I found a workaround using `encode_example` like so:\r\n\r\n```\r\nfrom datasets import load_from_disk, Dataset\r\nDATASET_PATH = \"/hf/m4-master/data/cm4/cm4-10000-v0.1\"\r\nds1 = load_from_disk(DATASET_PATH)\r\nds2 = Dataset.from_dict(mapping={k: [] for k in ds1[99].keys()},\r\n features=ds1.features\r\n)\r\nfor i in range(2):\r\n # could add several representative items here\r\n row = ds1[99]\r\n row_encoded = ds2.features.encode_example(row)\r\n ds2 = ds2.add_item(row_encoded)\r\n```", "Hmm, interesting. If I create the dataset on the fly:\r\n\r\n```\r\nfrom datasets import load_from_disk, Dataset\r\nDATASET_PATH = \"/hf/m4-master/data/cm4/cm4-10000-v0.1\"\r\nds1 = load_from_disk(DATASET_PATH)\r\nds2 = Dataset.from_dict(mapping={k: [v]*2 for k, v in ds1[99].items()},\r\n features=ds1.features)\r\n```\r\n\r\nit doesn't fail with the error in the OP, as `from_dict` performs `encode_batch`.\r\n\r\nHowever if I try to use this dataset it fails now with:\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"/home/stas/anaconda3/envs/py38-pt112/lib/python3.8/site-packages/multiprocess/pool.py\", line 125, in worker\r\n result = (True, func(*args, **kwds))\r\n File \"/home/stas/anaconda3/envs/py38-pt112/lib/python3.8/site-packages/datasets/arrow_dataset.py\", line 557, in wrapper\r\n out: Union[\"Dataset\", \"DatasetDict\"] = func(self, *args, **kwargs)\r\n File \"/home/stas/anaconda3/envs/py38-pt112/lib/python3.8/site-packages/datasets/arrow_dataset.py\", line 524, in wrapper\r\n out: Union[\"Dataset\", \"DatasetDict\"] = func(self, *args, **kwargs)\r\n File \"/home/stas/anaconda3/envs/py38-pt112/lib/python3.8/site-packages/datasets/fingerprint.py\", line 480, in wrapper\r\n out = func(self, *args, **kwargs)\r\n File \"/home/stas/anaconda3/envs/py38-pt112/lib/python3.8/site-packages/datasets/arrow_dataset.py\", line 2775, in _map_single\r\n batch = apply_function_on_filtered_inputs(\r\n File \"/home/stas/anaconda3/envs/py38-pt112/lib/python3.8/site-packages/datasets/arrow_dataset.py\", line 2655, in apply_function_on_filtered_inputs\r\n processed_inputs = function(*fn_args, *additional_args, **fn_kwargs)\r\n File \"/home/stas/anaconda3/envs/py38-pt112/lib/python3.8/site-packages/datasets/arrow_dataset.py\", line 2347, in decorated\r\n result = f(decorated_item, *args, **kwargs)\r\n File \"debug_leak2.py\", line 235, in split_pack_and_pad\r\n images.append(image_transform(image.convert(\"RGB\")))\r\nAttributeError: 'dict' object has no attribute 'convert'\r\n\"\"\"\r\n\r\nThe above exception was the direct cause of the following exception:\r\n\r\nTraceback (most recent call last):\r\n File \"debug_leak2.py\", line 418, in <module>\r\n train_loader, val_loader = get_dataloaders()\r\n File \"debug_leak2.py\", line 348, in get_dataloaders\r\n dataset = dataset.map(mapper, batch_size=32, batched=True, remove_columns=dataset.column_names, num_proc=4)\r\n File \"/home/stas/anaconda3/envs/py38-pt112/lib/python3.8/site-packages/datasets/arrow_dataset.py\", line 2500, in map\r\n transformed_shards[index] = async_result.get()\r\n File \"/home/stas/anaconda3/envs/py38-pt112/lib/python3.8/site-packages/multiprocess/pool.py\", line 771, in get\r\n raise self._value\r\nAttributeError: 'dict' object has no attribute 'convert'\r\n```\r\n\r\nbut if I create that same dataset one item at a time as in the previous comment's code snippet it doesn't fail.\r\n\r\nThe features of this dataset are set to:\r\n\r\n```\r\n{'texts': Sequence(feature=Value(dtype='string', id=None), length=-1, id=None), \r\n'images': Sequence(feature=Image(decode=True, id=None), length=-1, id=None)}\r\n```", "> @mariosasko I'm getting a similar issue when creating a Dataset from a Pandas dataframe, like so:\r\n> \r\n> ```\r\n> from datasets import Dataset, Features, Image, Value\r\n> import pandas as pd\r\n> import requests\r\n> import PIL\r\n> \r\n> # we need to define the features ourselves\r\n> features = Features({\r\n> 'a': Value(dtype='int32'),\r\n> 'b': Image(),\r\n> })\r\n> \r\n> url = \"http://images.cocodataset.org/val2017/000000039769.jpg\"\r\n> image = PIL.Image.open(requests.get(url, stream=True).raw)\r\n> \r\n> df = pd.DataFrame({\"a\": [1, 2], \r\n> \"b\": [image, image]})\r\n> \r\n> dataset = Dataset.from_pandas(df, features=features) \r\n> ```\r\n> \r\n> results in\r\n> \r\n> ```\r\n> ArrowInvalid: ('Could not convert <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=640x480 at 0x7F7991A15C10> with type JpegImageFile: did not recognize Python value type when inferring an Arrow data type', 'Conversion failed for column b with type object')\r\n> ```\r\n> \r\n> Will the PR linked above also fix that?\r\n\r\nIt looks like the problem still exists.\r\nAny news ? Any good workaround ?\r\n\r\nThank you", "There is a workaround: \r\nCreate a loader python scrypt and upload the dataset to huggingface.\r\n\r\nHere is an example how to do that:\r\n\r\nhttps://huggingface.co/datasets/jamescalam/image-text-demo/tree/main\r\n\r\nand Here are videos with explanations:\r\n\r\nhttps://www.youtube.com/watch?v=lqK4ocAKveE and https://www.youtube.com/watch?v=ODdKC30dT8c", "cc @mariosasko gentle ping for a fix :)", "Any update on this? I'm still facing this issure. Any workaround?", "I was facing the same issue. Downgrading datasets from 2.11.0 to 2.4.0 solved the issue. ", "> Any update on this? I'm still facing this issure. Any workaround?\r\n\r\nI was able to resolve my issue with a quick workaround: \r\n\r\n```\r\nfrom collections import defaultdict\r\nfrom datasets import Dataset\r\n \r\ndata = defaultdict(list)\r\nfor idx in tqdm(range( len(dataloader)),desc=\"Captioning...\"):\r\n img = dataloader[idx]\r\n data['image'].append(img)\r\n data['text'].append(f\"{img_{idx}})\r\n \r\ndataset = Dataset.from_dict(data)\r\ndataset = dataset.filter(lambda example: example['image'] is not None)\r\ndataset = dataset.filter(lambda example: example['text'] is not None)\r\n \r\ndataset.push_to_hub(path-to-repo', private=False)\r\n```\r\n\r\nHope it helps!\r\nHappy coding", "> > Any update on this? I'm still facing this issure. Any workaround?\r\n> \r\n> I was able to resolve my issue with a quick workaround:\r\n> \r\n> ```\r\n> from collections import defaultdict\r\n> from datasets import Dataset\r\n> \r\n> data = defaultdict(list)\r\n> for idx in tqdm(range( len(dataloader)),desc=\"Captioning...\"):\r\n> img = dataloader[idx]\r\n> data['image'].append(img)\r\n> data['text'].append(f\"{img_{idx}})\r\n> \r\n> dataset = Dataset.from_dict(data)\r\n> dataset = dataset.filter(lambda example: example['image'] is not None)\r\n> dataset = dataset.filter(lambda example: example['text'] is not None)\r\n> \r\n> dataset.push_to_hub(path-to-repo', private=False)\r\n> ```\r\n> \r\n> Hope it helps! Happy coding\r\n\r\nIt works!! ", "> \r\n\r\nhow did this work, how to use this script or where to paste it?", "I had a similar issue to @NielsRogge where I was unable to create a dataset from a Pandas DataFrame containing PIL.Images.\r\n\r\nI found another workaround that works in this case which involves converting the DataFrame to a python dictionary, and then creating a dataset from said python dictionary.\r\n\r\nThis is a generic example of my workaround. The example assumes that you have your data in a Pandas DataFrame variable called \"dataframe\" plus a dictionary of your data's features in a variable called \"features\".\r\n```\r\nimport datasets\r\n\r\ndictionary = dataframe.to_dict(orient='list')\r\ndataset = datasets.Dataset.from_dict(dictionary, features=features)\r\n```", "cc @mariosasko this issue has been open for 2 years, would be great to resolve it :)", "I have the same issue, my current workaround is saving the dataframe to a csv and then loading the dataset from the csv. Would also appreciate it a fix :)" ]
## Describe the bug When adding a Pillow image to an existing Dataset on the hub, `add_item` fails due to the Pillow image not being automatically converted into the Image feature. ## Steps to reproduce the bug ```python from datasets import load_dataset from PIL import Image dataset = load_dataset("hf-internal-testing/example-documents") # load any random Pillow image image = Image.open("/content/cord_example.png").convert("RGB") new_image = {'image': image} dataset['test'] = dataset['test'].add_item(new_image) ``` ## Expected results The image should be automatically casted to the Image feature when using `add_item`. For now, this can be fixed by using `encode_example`: ``` import datasets feature = datasets.Image(decode=False) new_image = {'image': feature.encode_example(image)} dataset['test'] = dataset['test'].add_item(new_image) ``` ## Actual results ``` ArrowInvalid: Could not convert <PIL.Image.Image image mode=RGB size=576x864 at 0x7F7CCC4589D0> with type Image: did not recognize Python value type when inferring an Arrow data type ```
4,796
https://github.com/huggingface/datasets/issues/4795
Missing MBPP splits
[ "Thanks for reporting this as well, @stadlerb.\r\n\r\nI suggest waiting for the answer of the data owners... ", "@albertvillanova The first author of the paper responded to the upstream issue:\r\n> Task IDs 11-510 are the 500 test problems. We use 90 problems (511-600) for validation and then remaining 374 for fine-tuning (601-974). The other problems can be used as desired, either for training or few-shot prompting (although this should be specified).", "Thanks for the follow-up, @stadlerb.\r\n\r\nWould you be willing to open a Pull Request to address this issue? :wink: ", "Opened a [PR](https://github.com/huggingface/datasets/pull/4943) to implement this--lmk if you have any feedback" ]
(@albertvillanova) The [MBPP dataset on the Hub](https://huggingface.co/datasets/mbpp) has only a test split for both its "full" and its "sanitized" subset, while the [paper](https://arxiv.org/abs/2108.07732) states in subsection 2.1 regarding the full split: > In the experiments described later in the paper, we hold out 10 problems for **few-shot prompting**, another 500 as our **test** dataset (which is used to evaluate both few-shot inference and fine-tuned models), 374 problems for **fine-tuning**, and the rest for **validation**. If the dataset on the Hub should reproduce most closely what the original authors use, I guess this four-way split should be reflected. The paper doesn't explicitly state the task_id ranges of the splits, but the [GitHub readme](https://github.com/google-research/google-research/tree/master/mbpp) referenced in the paper specifies exact task_id ranges, although it misstates the total number of samples: > We specify a train and test split to use for evaluation. Specifically: > > * Task IDs 11-510 are used for evaluation. > * Task IDs 1-10 and 511-1000 are used for training and/or prompting. We typically used 1-10 for few-shot prompting, although you can feel free to use any of the training examples. I.e. the few-shot, train and validation splits are combined into one split, with a soft suggestion of using the first ten for few-shot prompting. It is not explicitly stated whether the 374 fine-tuning samples mentioned in the paper have task_id 511 to 784 or 601 to 974 or are randomly sampled from task_id 511 to 974. Regarding the "sanitized" split the paper states the following: > For evaluations involving the edited dataset, we perform comparisons with 100 problems that appear in both the original and edited dataset, using the same held out 10 problems for few-shot prompting and 374 problems for fine-tuning. The statement doesn't appear to be very precise, as among the 10 few-shot problems, those with task_id 1, 5 and 10 are not even part of the sanitized variant, and many from the task_id range from 511 to 974 are missing (e.g. task_id 511 to 553). I suppose the idea the task_id ranges for each split remain the same, even if some of the task_ids are not present. That would result in 7 few-shot, 257 test, 141 train and 22 validation examples in the sanitized split.
4,795
https://github.com/huggingface/datasets/issues/4792
Add DocVQA
[ "Thanks for proposing, @NielsRogge.\r\n\r\nPlease, note this dataset requires registering in their website and their Terms and Conditions state we cannot distribute their URL:\r\n```\r\n1. You will NOT distribute the download URLs\r\n...\r\n```" ]
## Adding a Dataset - **Name:** DocVQA - **Description:** Document Visual Question Answering (DocVQA) seeks to inspire a β€œpurpose-driven” point of view in Document Analysis and Recognition research, where the document content is extracted and used to respond to high-level tasks defined by the human consumers of this information. - **Paper:** https://arxiv.org/abs/2007.00398 - **Data:** https://www.docvqa.org/datasets/docvqa - **Motivation:** Models like LayoutLM and Donut in the Transformers library are fine-tuned on DocVQA. Would be very handy to directly load this dataset from the hub. Instructions to add a new dataset can be found [here](https://github.com/huggingface/datasets/blob/main/ADD_NEW_DATASET.md).
4,792
https://github.com/huggingface/datasets/issues/4791
Dataset Viewer issue for Team-PIXEL/rendered-wikipedia-english
[ "Thanks for reporting. It's a known issue that should be fixed soon. Meanwhile, I had to manually trigger the dataset viewer. It's OK now.\r\nNote that the extreme aspect ratio of the images generates another issue, that we're inspecting." ]
### Link https://huggingface.co/datasets/Team-PIXEL/rendered-wikipedia-english/viewer/rendered-wikipedia-en/train ### Description The dataset can be loaded fine but the viewer shows this error: ``` Server Error Status code: 400 Exception: Status400Error Message: The dataset does not exist. ``` I'm guessing this is because I recently renamed the dataset. Based on related issues (e.g. https://github.com/huggingface/datasets/issues/4759) , is there something server-side that needs to be refreshed? ### Owner Yes
4,791
https://github.com/huggingface/datasets/issues/4790
Issue with fine classes in trec dataset
[]
## Describe the bug According to their paper, the TREC dataset contains 2 kinds of classes: - 6 coarse classes: TREC-6 - 50 fine classes: TREC-50 However, our implementation only has 47 (instead of 50) fine classes. The reason for this is that we only considered the last segment of the label, which is repeated for several coarse classes: - We have one `desc` fine label instead of 2: - `DESC:desc` - `HUM:desc` - We have one `other` fine label instead of 3: - `ENTY:other` - `LOC:other` - `NUM:other` From their paper: > We define a two-layered taxonomy, which represents a natural semantic classification for typical answers in the TREC task. The hierarchy contains 6 coarse classes and 50 fine classes, > Each coarse class contains a non-overlapping set of fine classes.
4,790
https://github.com/huggingface/datasets/issues/4787
NonMatchingChecksumError in mbpp dataset
[]
## Describe the bug As reported on the Hub [Fix Checksum Mismatch](https://huggingface.co/datasets/mbpp/discussions/1), there is a `NonMatchingChecksumError` when loading mbpp dataset ## Steps to reproduce the bug ```python ds = load_dataset("mbpp", "full") ``` ## Expected results Loading of the dataset without any exception raised. ## Actual results ``` NonMatchingChecksumError Traceback (most recent call last) <ipython-input-1-a3fbdd3ed82e> in <module> ----> 1 ds = load_dataset("mbpp", "full") .../huggingface/datasets/src/datasets/load.py in load_dataset(path, name, data_dir, data_files, split, cache_dir, features, download_config, download_mode, ignore_verifications, keep_in_memory, save_infos, revision, use_auth_token, task, streaming, **config_kwargs) 1791 1792 # Download and prepare data -> 1793 builder_instance.download_and_prepare( 1794 download_config=download_config, 1795 download_mode=download_mode, .../huggingface/datasets/src/datasets/builder.py in download_and_prepare(self, download_config, download_mode, ignore_verifications, try_from_hf_gcs, dl_manager, base_path, use_auth_token, **download_and_prepare_kwargs) 702 logger.warning("HF google storage unreachable. Downloading and preparing it from source") 703 if not downloaded_from_gcs: --> 704 self._download_and_prepare( 705 dl_manager=dl_manager, verify_infos=verify_infos, **download_and_prepare_kwargs 706 ) .../huggingface/datasets/src/datasets/builder.py in _download_and_prepare(self, dl_manager, verify_infos) 1225 1226 def _download_and_prepare(self, dl_manager, verify_infos): -> 1227 super()._download_and_prepare(dl_manager, verify_infos, check_duplicate_keys=verify_infos) 1228 1229 def _get_examples_iterable_for_split(self, split_generator: SplitGenerator) -> ExamplesIterable: .../huggingface/datasets/src/datasets/builder.py in _download_and_prepare(self, dl_manager, verify_infos, **prepare_split_kwargs) 773 # Checksums verification 774 if verify_infos and dl_manager.record_checksums: --> 775 verify_checksums( 776 self.info.download_checksums, dl_manager.get_recorded_sizes_checksums(), "dataset source files" 777 ) .../huggingface/datasets/src/datasets/utils/info_utils.py in verify_checksums(expected_checksums, recorded_checksums, verification_name) 38 if len(bad_urls) > 0: 39 error_msg = "Checksums didn't match" + for_verification_name + ":\n" ---> 40 raise NonMatchingChecksumError(error_msg + str(bad_urls)) 41 logger.info("All the checksums matched successfully" + for_verification_name) 42 NonMatchingChecksumError: Checksums didn't match for dataset source files: ['https://raw.githubusercontent.com/google-research/google-research/master/mbpp/mbpp.jsonl'] ```
4,787
https://github.com/huggingface/datasets/issues/4786
.save_to_disk('path', fs=s3) TypeError
[]
The following code: ```python import datasets train_dataset, test_dataset = load_dataset("imdb", split=["train", "test"]) s3 = datasets.filesystems.S3FileSystem(key=aws_access_key_id, secret=aws_secret_access_key) train_dataset.save_to_disk("s3://datasets/", fs=s3) ``` produces following traceback: ```shell File "C:\Users\Hong Knop\AppData\Local\Programs\Python\Python310\lib\site-packages\botocore\auth.py", line 374, in scope return '/'.join(scope) ``` I invoke print(scope) in <auth.py> (line 373) and find this: ```python [('4VA08VLL3VTKQJKCAI8M',), '20220803', 'us-east-1', 's3', 'aws4_request'] ```
4,786
https://github.com/huggingface/datasets/issues/4784
Add Multiface dataset
[ "Hi @osanseviero I would like to add this dataset.", "Hey @nandwalritik! Thanks for offering to help!\r\n\r\nThis dataset might be somewhat complex and I'm concerned about it being 65 TB, which would be quite expensive to host. @lhoestq @mariosasko I would love your input if you think it's worth adding this dataset.", "Thanks for proposing this interesting dataset, @osanseviero.\r\n\r\nPlease note that the data files are already hosted in a third-party server: e.g. the index of data files for entity \"6795937\" is at https://fb-baas-f32eacb9-8abb-11eb-b2b8-4857dd089e15.s3.amazonaws.com/MugsyDataRelease/v0.0/identities/6795937/index.html \r\n- audio.tar: https://fb-baas-f32eacb9-8abb-11eb-b2b8-4857dd089e15.s3.amazonaws.com/MugsyDataRelease/v0.0/identities/6795937/audio.tar\r\n- ...\r\n\r\nTherefore, in principle, we don't need to host them on our Hub: it would be enough to just implement a loading script in the corresponding Hub dataset repo, e.g. \"facebook/multiface\"..." ]
## Adding a Dataset - **Name:** Multiface dataset - **Description:** f high quality recordings of the faces of 13 identities, each captured in a multi-view capture stage performing various facial expressions. An average of 12,200 (v1 scripts) to 23,000 (v2 scripts) frames per subject with capture rate at 30 fps - **Data:** https://github.com/facebookresearch/multiface The whole dataset is 65TB though, so I'm not sure Instructions to add a new dataset can be found [here](https://github.com/huggingface/datasets/blob/main/ADD_NEW_DATASET.md).
4,784
https://github.com/huggingface/datasets/issues/4782
pyarrow.lib.ArrowCapacityError: array cannot contain more than 2147483646 bytes, have 2147483648
[ "Thanks for reporting @conceptofmind.\r\n\r\nCould you please give details about your environment? \r\n```\r\n## Environment info\r\n<!-- You can run the command `datasets-cli env` and copy-and-paste its output below. -->\r\n- `datasets` version:\r\n- Platform:\r\n- Python version:\r\n- PyArrow version:\r\n```", "Hi @albertvillanova ,\r\n\r\nHere is the environment information:\r\n```\r\n- `datasets` version: 2.3.2\r\n- Platform: Linux-5.4.0-122-generic-x86_64-with-glibc2.27\r\n- Python version: 3.9.12\r\n- PyArrow version: 7.0.0\r\n- Pandas version: 1.4.2\r\n```\r\nThanks,\r\n\r\nEnrico", "I think this issue is solved here https://discuss.huggingface.co/t/minhash-deduplication/19992/12?u=loubnabnl, this only happens for very large datasets we will update it in CodeParrot code", "Hi @loubnabnl,\r\n\r\nYes, the issue is solved in the discussion thread.\r\n\r\nI will close this issue.\r\n\r\nThank you again for all of your help.\r\n\r\nEnrico", "Thanks @loubnabnl for pointing out the solution to this issue." ]
## Describe the bug Following the example in CodeParrot, I receive an array size limitation error when deduplicating larger datasets. ## Steps to reproduce the bug ```python dataset_name = "the_pile" ds = load_dataset(dataset_name, split="train") ds = ds.map(preprocess, num_proc=num_workers) uniques = set(ds.unique("hash")) ``` Gists for minimum reproducible example: https://gist.github.com/conceptofmind/c5804428ea1bd89767815f9cd5f02d9a https://gist.github.com/conceptofmind/feafb07e236f28d79c2d4b28ffbdb6e2 ## Expected results Chunking and writing out a deduplicated dataset. ## Actual results ``` return dataset._data.column(column).unique().to_pylist() File "pyarrow/table.pxi", line 394, in pyarrow.lib.ChunkedArray.unique File "pyarrow/_compute.pyx", line 531, in pyarrow._compute.call_function File "pyarrow/_compute.pyx", line 330, in pyarrow._compute.Function.call File "pyarrow/error.pxi", line 143, in pyarrow.lib.pyarrow_internal_check_status File "pyarrow/error.pxi", line 124, in pyarrow.lib.check_status pyarrow.lib.ArrowCapacityError: array cannot contain more than 2147483646 bytes, have 2147483648 ```
4,782
https://github.com/huggingface/datasets/issues/4779
Loading natural_questions requires apache_beam even with existing preprocessed data
[]
## Describe the bug When loading "natural_questions", the package "apache_beam" is required: ``` ImportError: To be able to use natural_questions, you need to install the following dependency: apache_beam. Please install it using 'pip install apache_beam' for instance' ``` This requirement is unnecessary, once there exists preprocessed data and the script just needs to download it. ## Steps to reproduce the bug ```python load_dataset("natural_questions", "dev", split="validation", revision="main") ``` ## Expected results No ImportError raised. ## Actual results ``` ImportError Traceback (most recent call last) [<ipython-input-3-c938e7c05d02>](https://localhost:8080/#) in <module>() ----> 1 from datasets import load_dataset; ds = load_dataset("natural_questions", "dev", split="validation", revision="main") [/usr/local/lib/python3.7/dist-packages/datasets/load.py](https://localhost:8080/#) in load_dataset(path, name, data_dir, data_files, split, cache_dir, features, download_config, download_mode, ignore_verifications, keep_in_memory, save_infos, revision, use_auth_token, task, streaming, **config_kwargs) 1732 revision=revision, 1733 use_auth_token=use_auth_token, -> 1734 **config_kwargs, 1735 ) 1736 [/usr/local/lib/python3.7/dist-packages/datasets/load.py](https://localhost:8080/#) in load_dataset_builder(path, name, data_dir, data_files, cache_dir, features, download_config, download_mode, revision, use_auth_token, **config_kwargs) 1504 download_mode=download_mode, 1505 data_dir=data_dir, -> 1506 data_files=data_files, 1507 ) 1508 [/usr/local/lib/python3.7/dist-packages/datasets/load.py](https://localhost:8080/#) in dataset_module_factory(path, revision, download_config, download_mode, dynamic_modules_path, data_dir, data_files, **download_kwargs) 1245 f"Couldn't find '{path}' on the Hugging Face Hub either: {type(e1).__name__}: {e1}" 1246 ) from None -> 1247 raise e1 from None 1248 else: 1249 raise FileNotFoundError( [/usr/local/lib/python3.7/dist-packages/datasets/load.py](https://localhost:8080/#) in dataset_module_factory(path, revision, download_config, download_mode, dynamic_modules_path, data_dir, data_files, **download_kwargs) 1180 download_config=download_config, 1181 download_mode=download_mode, -> 1182 dynamic_modules_path=dynamic_modules_path, 1183 ).get_module() 1184 elif path.count("/") == 1: # community dataset on the Hub [/usr/local/lib/python3.7/dist-packages/datasets/load.py](https://localhost:8080/#) in get_module(self) 490 base_path=hf_github_url(path=self.name, name="", revision=revision), 491 imports=imports, --> 492 download_config=self.download_config, 493 ) 494 additional_files = [(config.DATASETDICT_INFOS_FILENAME, dataset_infos_path)] if dataset_infos_path else [] [/usr/local/lib/python3.7/dist-packages/datasets/load.py](https://localhost:8080/#) in _download_additional_modules(name, base_path, imports, download_config) 214 _them_str = "them" if len(needs_to_be_installed) > 1 else "it" 215 raise ImportError( --> 216 f"To be able to use {name}, you need to install the following {_depencencies_str}: " 217 f"{', '.join(needs_to_be_installed)}.\nPlease install {_them_str} using 'pip install " 218 f"{' '.join(needs_to_be_installed.values())}' for instance'" ImportError: To be able to use natural_questions, you need to install the following dependency: apache_beam. Please install it using 'pip install apache_beam' for instance' ``` ## Environment info Colab notebook.
4,779
https://github.com/huggingface/datasets/issues/4776
RuntimeError when using torchaudio 0.12.0 to load MP3 audio file
[ "Requiring torchaudio<0.12.0 isn't really a viable solution because that implies torch<0.12.0 which means no sm_86 CUDA support which means no RTX 3090 support in PyTorch.\r\n\r\nBut in my case, the error only occurs if `_fallback_load` resolves to `_fail_load` inside torchaudio 0.12.0 which is only the case if FFMPEG initialization failed: https://github.com/pytorch/audio/blob/b1f510fa5681e92ee82bdc6b2d1ed896799fc32c/torchaudio/backend/sox_io_backend.py#L36-L47\r\n\r\nThat means the proper solution for torchaudio>=0.12.0 is to check `torchaudio._extension._FFMPEG_INITIALIZED` and if it is False, then we need to remind the user to install a dynamically linked ffmpeg 4.1.8 and then maybe call `torchaudio._extension._init_ffmpeg()` to force a user-visible exception showing the missing ffmpeg dynamic library name.\r\n\r\nOn my system, installing \r\n\r\n- libavcodec.so.58 \r\n- libavdevice.so.58 \r\n- libavfilter.so.7 \r\n- libavformat.so.58 \r\n- libavutil.so.56 \r\n- libswresample.so.3 \r\n- libswscale.so.5\r\n\r\nfrom ffmpeg 4.1.8 made HF datasets 2.3.2 work just fine with torchaudio 0.12.1+cu116:\r\n\r\n```python3\r\nimport sox, torchaudio, datasets\r\nprint('torchaudio', torchaudio.__version__)\r\nprint('datasets', datasets.__version__)\r\ntorchaudio._extension._init_ffmpeg()\r\nprint(torchaudio._extension._FFMPEG_INITIALIZED)\r\nwaveform, sample_rate = torchaudio.load('/workspace/.cache/huggingface/datasets/downloads/extracted/8e5aa88585efa2a4c74c6664b576550d32b7ff9c3d1d17cc04f44f11338c3dc6/cv-corpus-8.0-2022-01-19/en/clips/common_voice_en_100038.mp3', format='mp3')\r\nprint(waveform.shape)\r\n```\r\n\r\n```\r\ntorchaudio 0.12.1+cu116\r\ndatasets 2.3.2\r\nTrue\r\ntorch.Size([1, 369792])\r\n```", "Related: https://github.com/huggingface/datasets/issues/4889", "Closing as we no longer use `torchaudio` for decoding MP3 files." ]
Current version of `torchaudio` (0.12.0) raises a RuntimeError when trying to use `sox_io` backend but non-Python dependency `sox` is not installed: https://github.com/pytorch/audio/blob/2e1388401c434011e9f044b40bc8374f2ddfc414/torchaudio/backend/sox_io_backend.py#L21-L29 ```python def _fail_load( filepath: str, frame_offset: int = 0, num_frames: int = -1, normalize: bool = True, channels_first: bool = True, format: Optional[str] = None, ) -> Tuple[torch.Tensor, int]: raise RuntimeError("Failed to load audio from {}".format(filepath)) ``` Maybe we should raise a more actionable error message so that the user knows how to fix it. UPDATE: - this is an incompatibility of latest torchaudio (0.12.0) and the sox backend TODO: - [x] as a temporary solution, we should recommend installing torchaudio<0.12.0 - #4777 - #4785 - [ ] however, a stable solution must be found for torchaudio>=0.12.0 Related to: - https://github.com/huggingface/transformers/issues/18379
4,776
https://github.com/huggingface/datasets/issues/4775
Streaming not supported in Theivaprakasham/wildreceipt
[ "Thanks for reporting @NitishkKarra.\r\n\r\nThe root source of the issue is that streaming mode is not supported out-of-the-box for that dataset, because it contains a TAR file.\r\n\r\nWe have opened a discussion in the corresponding Hub dataset page, pointing out this issue: https://huggingface.co/datasets/Theivaprakasham/wildreceipt/discussions/1\r\n\r\nI'm closing this issue here, so this discussion is transferred there instead." ]
### Link _No response_ ### Description _No response_ ### Owner _No response_
4,775
https://github.com/huggingface/datasets/issues/4774
Training hangs at the end of epoch, with set_transform/with_transform+multiple workers
[]
## Describe the bug I use load_dataset() (I tried with [wiki](https://huggingface.co/datasets/wikipedia) and my own json data) and use set_transform/with_transform for preprocessing. But it hangs at the end of the 1st epoch if dataloader_num_workers>=1. No problem with single worker. ## Steps to reproduce the bug ```python train_dataset = datasets.load_dataset("wikipedia", "20220301.en", split='train', cache_dir=model_args.cache_dir, streaming=False) train_dataset.set_transform(psg_parse_fn) train_dataloader = DataLoader( train_dataset, batch_size=args.train_batch_size, sampler=DistributedSampler(train_dataset), collate_fn=data_collator, drop_last=args.dataloader_drop_last, num_workers=args.dataloader_num_workers, ) ``` ## Expected results ## Actual results It simply hangs. The ending step is num_example/batch_size (one epoch). ## Environment info - `datasets` version: 2.4.1.dev0 - Platform: Linux-5.4.170+-x86_64-with-glibc2.17 - Python version: 3.8.12 - PyArrow version: 8.0.0 - Pandas version: 1.4.1
4,774
https://github.com/huggingface/datasets/issues/4772
AssertionError when using label_cols in to_tf_dataset
[ "cc @Rocketknight1 ", "Hi @lehrig, this is caused by the data collator renaming \"label\" to \"labels\". If you set `label_cols=[\"labels\"]` in the call it will work correctly. However, I agree that the cause of the bug is not obvious, so I'll see if I can make a PR to clarify things when the collator renames columns.", "Thanks - and wow, that appears like a strange side-effect of the data collator. Is that really needed?\r\n\r\nWhy not make it more explicit? For example, extend `DefaultDataCollator` with an optional property `label_col_name` to be used as label column; only when it is not provided default to `labels` (and document that this happens) for backwards-compatibility? ", "Haha, I honestly have no idea why our data collators rename `\"label\"` (the standard label column name in our datasets) to `\"labels\"` (the standard label column name input to our models). It's been a pain point when I design TF data pipelines, though, because I don't want to hardcode things like that - especially in `datasets`, because the renaming is something that happens purely at the `transformers` end. I don't think I could make the change in the data collators themselves at this point, because it would break backward compatibility for everything in PyTorch as well as TF.\r\n\r\nIn the most recent version of `transformers` we added a [prepare_tf_dataset](https://huggingface.co/docs/transformers/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset) method to our models which takes care of these details for you, and even chooses appropriate columns and labels for the model you're using. In future we might make that the officially recommended way to convert HF datasets to `tf.data.Dataset`.", "Interesting, that'd be great especially for clarity. https://huggingface.co/docs/datasets/use_with_tensorflow#data-loading already improved clarity, yet, all those options will still confuse people. Looking forward to those advances in the hope there'll be only 1 way in the future ;)\r\n\r\nAnyways, I am happy for the time being with the work-around you provided. Thank you!" ]
## Describe the bug An incorrect `AssertionError` is raised when using `label_cols` in `to_tf_dataset` and the label's key name is `label`. The assertion is in this line: https://github.com/huggingface/datasets/blob/2.4.0/src/datasets/arrow_dataset.py#L475 ## Steps to reproduce the bug ```python from datasets import load_dataset from transformers import DefaultDataCollator dataset = load_dataset('glue', 'mrpc', split='train') tf_dataset = dataset.to_tf_dataset( columns=["sentence1", "sentence2", "idx"], label_cols=["label"], batch_size=16, collate_fn=DefaultDataCollator(return_tensors="tf"), ) ``` ## Expected results No assertion error. ## Actual results ``` AssertionError: in user code: File "/opt/conda/lib/python3.8/site-packages/datasets/arrow_dataset.py", line 475, in split_features_and_labels * assert set(features.keys()).union(labels.keys()) == set(input_batch.keys()) ``` ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: 2.4.0 - Platform: Linux-4.18.0-305.45.1.el8_4.ppc64le-ppc64le-with-glibc2.17 - Python version: 3.8.13 - PyArrow version: 7.0.0 - Pandas version: 1.4.3
4,772
https://github.com/huggingface/datasets/issues/4769
Fail to process SQuADv1.1 datasets with max_seq_length=128, doc_stride=96.
[]
## Describe the bug datasets fail to process SQuADv1.1 with max_seq_length=128, doc_stride=96 when calling datasets["train"].train_dataset.map(). ## Steps to reproduce the bug I used huggingface[ TF2 question-answering examples](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/question-answering). And my scripts are as follows: ``` python run_qa.py \ --model_name_or_path $BERT_DIR \ --dataset_name $SQUAD_DIR \ --do_train \ --do_eval \ --per_device_train_batch_size 12 \ --learning_rate 3e-5 \ --num_train_epochs 2 \ --max_seq_length 128 \ --doc_stride 96 \ --output_dir $OUTPUT \ --save_steps 10000 \ --overwrite_cache \ --overwrite_output_dir \ ``` ## Expected results Normally process SQuADv1.1 datasets with max_seq_length=128, doc_stride=96. ## Actual results ``` INFO:__main__:Padding all batches to max length because argument was set or we're on TPU. WARNING:datasets.fingerprint:Parameter 'function'=<function main.<locals>.prepare_train_features at 0x7f15bc2d07a0> of the transform datasets.arrow_dataset.Dataset._map_single couldn't be hashed properly, a random hash was used instead. Make sure your transforms and parameters are serializable with pickle or dill for the dataset fingerprinting and caching to work. If you reuse this transform, the caching mechanism will consider it to be different from the previous calls and recompute everything. This warning is only showed once. Subsequent hashing failures won't be showed. 0%| | 0/88 [00:00<?, ?ba/s]thread '<unnamed>' panicked at 'assertion failed: stride < max_len', /__w/tokenizers/tokenizers/tokenizers/src/tokenizer/encoding.rs:311:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace 0%| | 0/88 [00:00<?, ?ba/s] Traceback (most recent call last): File "run_qa.py", line 743, in <module> main() File "run_qa.py", line 485, in main load_from_cache_file=not data_args.overwrite_cache, File "/anaconda3/envs/py37/lib/python3.7/site-packages/datasets/arrow_dataset.py", line 2394, in map desc=desc, File "/anaconda3/envs/py37/lib/python3.7/site-packages/datasets/arrow_dataset.py", line 551, in wrapper out: Union["Dataset", "DatasetDict"] = func(self, *args, **kwargs) File "/anaconda3/envs/py37/lib/python3.7/site-packages/datasets/arrow_dataset.py", line 518, in wrapper out: Union["Dataset", "DatasetDict"] = func(self, *args, **kwargs) File "/anaconda3/envs/py37/lib/python3.7/site-packages/datasets/fingerprint.py", line 458, in wrapper out = func(self, *args, **kwargs) File "anaconda3/envs/py37/lib/python3.7/site-packages/datasets/arrow_dataset.py", line 2768, in _map_single offset=offset, File "anaconda3/envs/py37/lib/python3.7/site-packages/datasets/arrow_dataset.py", line 2644, in apply_function_on_filtered_inputs processed_inputs = function(*fn_args, *additional_args, **fn_kwargs) File "anaconda3/envs/py37/lib/python3.7/site-packages/datasets/arrow_dataset.py", line 2336, in decorated result = f(decorated_item, *args, **kwargs) File "run_qa.py", line 410, in prepare_train_features padding=padding, File "anaconda3/envs/py37/lib/python3.7/site-packages/transformers/tokenization_utils_base.py", line 2512, in __call__ **kwargs, File "anaconda3/envs/py37/lib/python3.7/site-packages/transformers/tokenization_utils_base.py", line 2703, in batch_encode_plus **kwargs, File "anaconda3/envs/py37/lib/python3.7/site-packages/transformers/tokenization_utils_fast.py", line 429, in _batch_encode_plus is_pretokenized=is_split_into_words, pyo3_runtime.PanicException: assertion failed: stride < max_len Traceback (most recent call last): File "./data/SQuADv1.1/evaluate-v1.1.py", line 92, in <module> with open(args.prediction_file) as prediction_file: FileNotFoundError: [Errno 2] No such file or directory: './output/bert_base_squadv1.1_tf2/eval_predictions.json' ``` ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: 2.3.2 - Platform: Ubuntu, pytorch=1.11.0, tensorflow-gpu=2.9.1 - Python version: 2.7 - PyArrow version: 8.0.0
4,769
https://github.com/huggingface/datasets/issues/4761
parallel searching in multi-gpu setting using faiss
[ "And I don't see any speed up when increasing the number of GPUs while calling `get_nearest_examples_batch`.", "Hi ! Yes search_batch uses FAISS search which happens in parallel across the GPUs\r\n\r\n> And I don't see any speed up when increasing the number of GPUs while calling get_nearest_examples_batch.\r\n\r\nThat's unexpected, can you share the code you're running ?", "here is the code snippet\r\n\r\n```python\r\n\r\n# add faiss index\r\nsource_dataset = load_dataset(source_path)\r\nqueries = load_dataset(query_path)\r\ngpu = [0,1,2,3]\r\nsource_dataset.add_faiss_index(\r\n \"embedding\",\r\n device=gpu,\r\n )\r\n\r\n\r\n# batch query\r\nbatch_size = 32\r\nfor i in tqdm(range(0, len(queries), batch_size)):\r\n if i + batch_size >= len(queries):\r\n batched_queries = queries[i:]\r\n else:\r\n batched_queries = queries[i:i+batch_size]\r\n\r\n batched_query_embeddings = np.stack([i for i in batched_queries['embedding']], axis=0)\r\n scores, candidates = source_dataset.get_nearest_examples_batch(\r\n \"embedding\",\r\n batched_query_embeddings,\r\n k=5\r\n )\r\n```", "My version of datasets is `2.4.1.dev0`.", "The code looks all good to me, do you see all the GPUs being utilized ? What version of faiss are you using ?", "I can see the memory usage of all the GPUs.\r\nMy version of `faiss-gpu` is `1.7.2`", "It looks all good to me then ^^ though you said you didn't experienced speed improvements by adding more GPUs ? What size is your source dataset and what time differences did you experience ?", "query set: 1e6\r\nsource dataset: 1e6\r\nembedding size: 768\r\nindex: Flat\r\ntopk: 20\r\nGPU: V100\r\n\r\nThe time taken to traverse the query set once is about 1.5h, which is almost not influenced by the value of query batch size or the number of GPUs according to my experiments.", "Hmmm the number of GPUs should divide the time, something is going wrong. Can you check that adding more GPU does divide the memory used per GPU ? Maybe it can be worth looking at similar issues in the FAISS repository or create a noew issue over there to understand what's going on", "> Can you check that adding more GPU does divide the memory used per GPU \r\n\r\nThe memory used per GPU is unchanged while adding more GPU. Is this unexpected?\r\n\r\nI used to think that every GPU loads all the source vectors and the data parallelism is at the query level. πŸ˜† ", "> I used to think that every GPU loads all the source vectors and the data parallelism is at the query level. πŸ˜†\r\n\r\nOh indeed that's possible, I wasn't sure. Anyway you can check that calling get_nearest_examples_batch simply calls search under the hood: \r\n\r\nhttps://github.com/huggingface/datasets/blob/f90f71fbbb33889fe75a3ffc101cdf16a88a3453/src/datasets/search.py#L375", "Here is a runnable script. \r\nMulti-GPU searching still does not work in my experiments.\r\n\r\n\r\n```python\r\nimport os\r\nfrom tqdm import tqdm\r\nimport numpy as np\r\nimport datasets\r\nfrom datasets import Dataset\r\n\r\nclass DPRSelector:\r\n\r\n def __init__(self, source, target, index_name, gpu=None):\r\n self.source = source\r\n self.target = target\r\n self.index_name = index_name\r\n\r\n cache_path = 'embedding.faiss'\r\n\r\n if not os.path.exists(cache_path):\r\n self.source.add_faiss_index(\r\n column=\"embedding\",\r\n index_name=index_name,\r\n device=gpu,\r\n )\r\n self.source.save_faiss_index(index_name, cache_path)\r\n else:\r\n self.source.load_faiss_index(\r\n index_name,\r\n cache_path,\r\n device=gpu\r\n )\r\n print('index builded!')\r\n\r\n def build_dataset(self, top_k, batch_size):\r\n print('start search')\r\n\r\n for i in tqdm(range(0, len(self.target), batch_size)):\r\n if i + batch_size >= len(self.target):\r\n batched_queries = self.target[i:]\r\n else:\r\n batched_queries = self.target[i:i+batch_size]\r\n\r\n\r\n batched_query_embeddings = np.stack([i for i in batched_queries['embedding']], axis=0)\r\n search_res = self.source.get_nearest_examples_batch(\r\n self.index_name,\r\n batched_query_embeddings,\r\n k=top_k\r\n )\r\n \r\n print('finish search')\r\n\r\n\r\ndef get_pseudo_dataset():\r\n pseudo_dict = {\"embedding\": np.zeros((1000000, 768), dtype=np.float32)}\r\n print('generate pseudo data')\r\n\r\n dataset = Dataset.from_dict(pseudo_dict)\r\n def list_to_array(data):\r\n return {\"embedding\": [np.array(vector, dtype=np.float32) for vector in data[\"embedding\"]]} \r\n dataset.set_transform(list_to_array, columns='embedding', output_all_columns=True)\r\n\r\n print('build dataset')\r\n return dataset\r\n\r\n\r\n\r\nif __name__==\"__main__\":\r\n\r\n np.random.seed(42)\r\n\r\n\r\n source_dataset = get_pseudo_dataset()\r\n target_dataset = get_pseudo_dataset()\r\n\r\n gpu = [0,1,2,3,4,5,6,7]\r\n selector = DPRSelector(source_dataset, target_dataset, \"embedding\", gpu=gpu)\r\n\r\n selector.build_dataset(top_k=20, batch_size=32)\r\n```", "@lhoestq Hi, could you please test the code above if you have time? πŸ˜„ ", "Maybe @albertvillanova you can take a look ? I won't be available in the following days", "@albertvillanova Hi, can you help with this issue?", "Hi @xwwwwww I'm investigating it, but I'm not an expert in Faiss. In principle, it is weird that your code does not work properly because it seems right...", "Have you tried passing `gpu=-1` and check if there is a speedup?", "> Have you tried passing `gpu=-1` and check if there is a speedup?\r\n\r\nyes, there is a speed up using GPU compared with CPU. ", "When passing `device=-1`, ALL existing GPUs are used (multi GPU): this is the maximum speedup you can get. To know the number of total GPUs:\r\n```\r\nimport faiss\r\n\r\nngpus = faiss.get_num_gpus()\r\nprint(ngpus)\r\n```\r\n\r\nWhen passing a list of integers to `device`, then only that number of GPUs are used (multi GPU as well)\r\n- the speedup should be proportional (more or less) to the ratio of the number of elements passed to `device` over `ngpus`\r\n- if this is not the case, then there is an issue in the implementation of this use case (however, I have reviewed the code and in principle I can't find any evident bug)\r\n\r\nWhen passing a positive integer to `device`, then only a single GPU is used.\r\n- this time should be more or less proportional to the time when passing `device=-1` over `ngpus`", "Thanks for your help!\r\nHave you run the code and replicated the same experimental results (i.e., no speedup while increasing the number of GPUs)?", "@albertvillanova @lhoestq Sorry for the bother, is there any progress on this issue? πŸ˜ƒ ", "I can confirm `add_faiss_index` calls `index = faiss.index_cpu_to_gpus_list(index, gpus=list(device))`.\r\n\r\nCould this be an issue with your environment ? Could you try running with 1 and 8 GPUs with a code similar to[ this one from the FAISS examples](https://github.com/facebookresearch/faiss/blob/main/tutorial/python/5-Multiple-GPUs.py) but using `gpu_index = faiss.index_cpu_to_gpus_list(cpu_index, gpus=list(device))`, and see if the speed changes ?", "Hi, I test the FAISS example and the speed indeed changes. I set `nb=1000000`, `nq=1000000` and `d=64`\r\n\r\n| num GPUS | time cost |\r\n| -------- | --------- |\r\n| 1 | 28.53 |\r\n| 5 | 7.16 |\r\n\r\n\r\n\r\n", "Ok the benchmark is great, not sure why it doesn't speed up the index in your case though. You can try running the benchmark with the same settings as your actual dataset\r\n```\r\nquery set: 1e6\r\nsource dataset: 1e6\r\nembedding size: 768\r\nindex: Flat\r\ntopk: 20\r\nGPU: V100\r\n```\r\n\r\nNote that you can still pass a FAISS index you built yourself to a dataset using https://huggingface.co/docs/datasets/v2.4.0/en/package_reference/main_classes#datasets.Dataset.add_faiss_index_from_external_arrays", "> Here is a runnable script. Multi-GPU searching still does not work in my experiments.\r\n> \r\n> ```python\r\n> import os\r\n> from tqdm import tqdm\r\n> import numpy as np\r\n> import datasets\r\n> from datasets import Dataset\r\n> \r\n> class DPRSelector:\r\n> \r\n> def __init__(self, source, target, index_name, gpu=None):\r\n> self.source = source\r\n> self.target = target\r\n> self.index_name = index_name\r\n> \r\n> cache_path = 'embedding.faiss'\r\n> \r\n> if not os.path.exists(cache_path):\r\n> self.source.add_faiss_index(\r\n> column=\"embedding\",\r\n> index_name=index_name,\r\n> device=gpu,\r\n> )\r\n> self.source.save_faiss_index(index_name, cache_path)\r\n> else:\r\n> self.source.load_faiss_index(\r\n> index_name,\r\n> cache_path,\r\n> device=gpu\r\n> )\r\n> print('index builded!')\r\n> \r\n> def build_dataset(self, top_k, batch_size):\r\n> print('start search')\r\n> \r\n> for i in tqdm(range(0, len(self.target), batch_size)):\r\n> if i + batch_size >= len(self.target):\r\n> batched_queries = self.target[i:]\r\n> else:\r\n> batched_queries = self.target[i:i+batch_size]\r\n> \r\n> \r\n> batched_query_embeddings = np.stack([i for i in batched_queries['embedding']], axis=0)\r\n> search_res = self.source.get_nearest_examples_batch(\r\n> self.index_name,\r\n> batched_query_embeddings,\r\n> k=top_k\r\n> )\r\n> \r\n> print('finish search')\r\n> \r\n> \r\n> def get_pseudo_dataset():\r\n> pseudo_dict = {\"embedding\": np.zeros((1000000, 768), dtype=np.float32)}\r\n> print('generate pseudo data')\r\n> \r\n> dataset = Dataset.from_dict(pseudo_dict)\r\n> def list_to_array(data):\r\n> return {\"embedding\": [np.array(vector, dtype=np.float32) for vector in data[\"embedding\"]]} \r\n> dataset.set_transform(list_to_array, columns='embedding', output_all_columns=True)\r\n> \r\n> print('build dataset')\r\n> return dataset\r\n> \r\n> \r\n> \r\n> if __name__==\"__main__\":\r\n> \r\n> np.random.seed(42)\r\n> \r\n> \r\n> source_dataset = get_pseudo_dataset()\r\n> target_dataset = get_pseudo_dataset()\r\n> \r\n> gpu = [0,1,2,3,4,5,6,7]\r\n> selector = DPRSelector(source_dataset, target_dataset, \"embedding\", gpu=gpu)\r\n> \r\n> selector.build_dataset(top_k=20, batch_size=32)\r\n> ```\r\n\r\nBy the way, have you run this toy example and replicated my experiment results? I think it is a more direct way to figure this out :)", "Hi,\r\n\r\nI have a similar question and would like to know if there's any progress in this issue. \r\n\r\n`dataset.add_faiss_index(column=\"embedding\")`, this takes around 5minutes to add the index.\r\n\r\n`dataset.add_faiss_index(column=\"embedding\", device=-1)`, this ran for more than 10minutes and still didn't complete execution. \r\n\r\nNow, I don't understand why that's the case as I expected for GPU the indexing should be faster" ]
While I notice that `add_faiss_index` has supported assigning multiple GPUs, I am still confused about how it works. Does the `search-batch` function automatically parallelizes the input queries to different gpus?https://github.com/huggingface/datasets/blob/d76599bdd4d186b2e7c4f468b05766016055a0a5/src/datasets/search.py#L360
4,761
https://github.com/huggingface/datasets/issues/4760
Issue with offline mode
[ "Hi @SaulLu, thanks for reporting.\r\n\r\nI think offline mode is not supported for datasets containing only data files (without any loading script). I'm having a look into this...", "Thanks for your feedback! \r\n\r\nTo give you a little more info, if you don't set the offline mode flag, the script will load the cache. I first noticed this behavior with the `evaluate` library, and while trying to understand the downloading flow I realized that I had a similar error with datasets.", "This is an issue we have to fix.", "This is related to https://github.com/huggingface/datasets/issues/3547", "Still not fixed? ......", "#5331 will be helpful to fix this, as it updates the cache directory template to be aligned with the other datasets", "Any updates ?", "I'm facing the same problem", "This issue has been fixed in `datasets` 2.16 by https://github.com/huggingface/datasets/pull/6493. The cache is now working properly :)\r\n\r\nYou just have to update `datasets`:\r\n\r\n```\r\npip install -U datasets\r\n```", "I'm on version 2.17.0, and this exact problem is still persisting.", "Can you share some code to reproduce your issue ?\r\n\r\nAlso make sure your cache was populated with recent versions of `datasets`. Datasets cached with old versions may not be reloadable in offline mode, though we did our best to keep as much backward compatibility as possible.", "I'm not sure if this is related @lhoestq but I am experiencing a similar issue when using offline mode:\r\n\r\n```bash\r\n$ python -c \"from datasets import load_dataset; load_dataset('openai_humaneval', split='test')\"\r\n$ HF_DATASETS_OFFLINE=1 python -c \"from datasets import load_dataset; load_dataset('openai_humaneval', split='test')\"\r\nUsing the latest cached version of the dataset since openai_humaneval couldn't be found on the Hugging Face Hub (offline mode is enabled).\r\nTraceback (most recent call last):\r\n File \"<string>\", line 1, in <module>\r\n File \"/dodrio/scratch/projects/2023_071/alignment-handbook/.venv/lib/python3.10/site-packages/datasets/load.py\", line 2556, in load_dataset\r\n builder_instance = load_dataset_builder(\r\n File \"/dodrio/scratch/projects/2023_071/alignment-handbook/.venv/lib/python3.10/site-packages/datasets/load.py\", line 2265, in load_dataset_builder\r\n builder_instance: DatasetBuilder = builder_cls(\r\n File \"/dodrio/scratch/projects/2023_071/alignment-handbook/.venv/lib/python3.10/site-packages/datasets/packaged_modules/cache/cache.py\", line 122, in __init__\r\n config_name, version, hash = _find_hash_in_cache(\r\n File \"/dodrio/scratch/projects/2023_071/alignment-handbook/.venv/lib/python3.10/site-packages/datasets/packaged_modules/cache/cache.py\", line 48, in _find_hash_in_cache\r\n raise ValueError(\r\nValueError: Couldn't find cache for openai_humaneval for config 'default'\r\nAvailable configs in the cache: ['openai_humaneval']\r\n```", "Thanks for reporting @BramVanroy, I managed to reproduce and I opened a fix here: https://github.com/huggingface/datasets/pull/6741", "Awesome, thanks for the quick fix @lhoestq! Looking forward to update my dependency version list.", "> Thanks for reporting @BramVanroy, I managed to reproduce and I opened a fix here: #6741\r\n\r\nThanks a lot! I have faced the same problem. Can I use your fix code to directly replace the existing version code? I noticed that this fix has not been merged yet. Will it affect other functionalities?\r\n", "I just merged the fix, you can install `datasets` from source or wait for the patch release which will be out in the coming days" ]
## Describe the bug I can't retrieve a cached dataset with offline mode enabled ## Steps to reproduce the bug To reproduce my issue, first, you'll need to run a script that will cache the dataset ```python import os os.environ["HF_DATASETS_OFFLINE"] = "0" import datasets datasets.logging.set_verbosity_info() ds_name = "SaulLu/toy_struc_dataset" ds = datasets.load_dataset(ds_name) print(ds) ``` then, you can try to reload it in offline mode: ```python import os os.environ["HF_DATASETS_OFFLINE"] = "1" import datasets datasets.logging.set_verbosity_info() ds_name = "SaulLu/toy_struc_dataset" ds = datasets.load_dataset(ds_name) print(ds) ``` ## Expected results I would have expected the 2nd snippet not to return any errors ## Actual results The 2nd snippet returns: ``` Traceback (most recent call last): File "/home/lucile_huggingface_co/sandbox/evaluate/test_cache_datasets.py", line 8, in <module> ds = datasets.load_dataset(ds_name) File "/home/lucile_huggingface_co/anaconda3/envs/evaluate-dev/lib/python3.8/site-packages/datasets/load.py", line 1723, in load_dataset builder_instance = load_dataset_builder( File "/home/lucile_huggingface_co/anaconda3/envs/evaluate-dev/lib/python3.8/site-packages/datasets/load.py", line 1500, in load_dataset_builder dataset_module = dataset_module_factory( File "/home/lucile_huggingface_co/anaconda3/envs/evaluate-dev/lib/python3.8/site-packages/datasets/load.py", line 1241, in dataset_module_factory raise ConnectionError(f"Couln't reach the Hugging Face Hub for dataset '{path}': {e1}") from None ConnectionError: Couln't reach the Hugging Face Hub for dataset 'SaulLu/toy_struc_dataset': Offline mode is enabled. ``` ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: 2.4.0 - Platform: Linux-4.19.0-21-cloud-amd64-x86_64-with-glibc2.17 - Python version: 3.8.13 - PyArrow version: 8.0.0 - Pandas version: 1.4.3 Maybe I'm misunderstanding something in the use of the offline mode (see [doc](https://huggingface.co/docs/datasets/v2.4.0/en/loading#offline)), is that the case?
4,760
https://github.com/huggingface/datasets/issues/4759
Dataset Viewer issue for Toygar/turkish-offensive-language-detection
[ "I refreshed the dataset viewer manually, it's fixed now. Sorry for the inconvenience.\r\n<img width=\"1557\" alt=\"Capture d’écran 2022-07-28 aΜ€ 09 17 39\" src=\"https://user-images.githubusercontent.com/1676121/181514666-92d7f8e1-ddc1-4769-84f3-f1edfdb902e8.png\">\r\n\r\n" ]
### Link https://huggingface.co/datasets/Toygar/turkish-offensive-language-detection ### Description Status code: 400 Exception: Status400Error Message: The dataset does not exist. Hi, I provided train.csv, test.csv and valid.csv files. However, viewer says dataset does not exist. Should I need to do anything else? ### Owner Yes
4,759
https://github.com/huggingface/datasets/issues/4757
Document better when relative paths are transformed to URLs
[]
As discussed with @ydshieh, when passing a relative path as `data_dir` to `load_dataset` of a dataset hosted on the Hub, the relative path is transformed to the corresponding URL of the Hub dataset. Currently, we mention this in our docs here: [Create a dataset loading script > Download data files and organize splits](https://huggingface.co/docs/datasets/v2.4.0/en/dataset_script#download-data-files-and-organize-splits) > If the data files live in the same folder or repository of the dataset script, you can just pass the relative paths to the files instead of URLs. Maybe we should document better how relative paths are handled, not only when creating a dataset loading script, but also when passing to `load_dataset`: - `data_dir` - `data_files` CC: @stevhliu
4,757
https://github.com/huggingface/datasets/issues/4755
Datasets.map causes incorrect overflow_to_sample_mapping when used with tokenizers and small batch size
[ "I've built a minimal example that shows this bug without `n_proc`. It seems like it's a problem any way of using **tokenizers, `overflow_to_sample_mapping`, and Dataset.map, with a small batch size**:\r\n\r\n```\r\nimport datasets\r\nimport transformers\r\npretrained = 'deepset/tinyroberta-squad2'\r\ntokenizer = transformers.AutoTokenizer.from_pretrained(pretrained)\r\n\r\nquestions = ['Can you tell me why?', 'What time is it?']\r\ncontexts = ['This is context zero', 'Another paragraph goes here'] \r\n\r\ndef tok(questions, contexts):\r\n return tokenizer(text=questions,\r\n text_pair=contexts,\r\n truncation='only_second',\r\n return_overflowing_tokens=True,\r\n )\r\nprint(tok(questions, contexts)['overflow_to_sample_mapping'])\r\nassert tok(questions, contexts)['overflow_to_sample_mapping'] == [0, 1] # PASSES\r\n\r\ndef tok2(d):\r\n return tok(d['question'], d['context'])\r\n\r\ndef tok2(d):\r\n return tok(d['question'], d['context'])\r\n\r\nds = datasets.Dataset.from_dict({'question': questions, 'context': contexts})\r\ntokens = ds.map(tok2, batched=True, batch_size=1)\r\nprint(tokens['overflow_to_sample_mapping'])\r\nassert tokens['overflow_to_sample_mapping'] == [0, 1] # FAILS produces [0,0]\r\n```\r\n\r\nNote that even if the batch size would be larger, there will be instances where we will not have a lot of data, and end up using small batches. This can occur e.g. if `n_proc` causes batches to be underfill. I imagine it can also occur in other ways, e.g. the final leftover batch at the end.", "A larger batch size does _not_ have this behavior:\r\n\r\n```\r\ndef tok2(d):\r\n return tok(d['question'], d['context'])\r\n\r\nds = datasets.Dataset.from_dict({'question': questions, 'context': contexts})\r\ntokens = ds.map(tok2, batched=True, batch_size=2)\r\nprint(tokens['overflow_to_sample_mapping'])\r\nassert tokens['overflow_to_sample_mapping'] == [0, 1] # PASSES\r\n```", "I was trying the [Question answering](https://huggingface.co/learn/nlp-course/chapter7/7#question-answering) tutorial on Hugging face when i faced the same problem. The preprocessing step is [here](https://huggingface.co/learn/nlp-course/chapter7/7#processing-the-validation-data). i have changed ```max_length=200, stride=50```,\r\n\r\n```\r\nvalidation_dataset = raw_datasets['validation'].select(range(8)).map(\r\n preprocess_validation_examples,\r\n batched=True,\r\n remove_columns=raw_datasets[\"validation\"].column_names,\r\n num_proc=1\r\n)\r\nprint(validation_dataset['overflow_to_sample_mapping'])\r\nprint(validation_dataset['example_id'])\r\n```\r\nresult\r\n\r\n```\r\n[0, 1, 2, 3, 4, 5, 6, 7]\r\n['56be4db0acb8001400a502ec', '56be4db0acb8001400a502ed', '56be4db0acb8001400a502ee', \r\n'56be4db0acb8001400a502ef', '56be4db0acb8001400a502f0', '56be8e613aeaaa14008c90d1', \r\n'56be8e613aeaaa14008c90d2', '56be8e613aeaaa14008c90d3']\r\n```\r\nwhen ```num_proc=2```, result - \r\n\r\n```\r\n[0, 1, 2, 3, 0, 1, 2, 3]\r\n['56be4db0acb8001400a502ec', '56be4db0acb8001400a502ed', '56be4db0acb8001400a502ee', \r\n'56be4db0acb8001400a502ef', '56be4db0acb8001400a502f0', '56be8e613aeaaa14008c90d1', \r\n'56be8e613aeaaa14008c90d2', '56be8e613aeaaa14008c90d3']\r\n```\r\n\r\nwhen ```num_proc=3```, result - \r\n\r\n```\r\n[0, 1, 2, 0, 1, 2, 0, 1]\r\n['56be4db0acb8001400a502ec', '56be4db0acb8001400a502ed', '56be4db0acb8001400a502ee', \r\n'56be4db0acb8001400a502ef', '56be4db0acb8001400a502f0', '56be8e613aeaaa14008c90d1', \r\n'56be8e613aeaaa14008c90d2', '56be8e613aeaaa14008c90d3']\r\n```\r\n\r\nThe```overflow_to_sample_mapping``` changes with ```num_proc```, but ```example_id``` field remains the same . It seems that each process in ```map``` has its own counter for overflow_to_sample_mapping. If you are using ```overflow_to_sample_mapping``` inside the ```preprocess_validation_examples``` function, then there is no issue." ]
## Describe the bug When using `tokenizer`, we can retrieve the field `overflow_to_sample_mapping`, since long samples will be overflown into multiple token sequences. However, when tokenizing is done via `Dataset.map`, with `n_proc > 1`, the `overflow_to_sample_mapping` field is wrong. This seems to be because each tokenizer only looks at its share of the samples, and maps to the index _within its share_, but then `Dataset.map` collates them together. ## Steps to reproduce the bug 1. Make a dataset of 3 strings. 2. Tokenize via Dataset.map with n_proc = 8 3. Inspect the `overflow_to_sample_mapping` field ## Expected results `[0, 1, 2]` ## Actual results `[0, 0, 0]` Notes: 1. I have not yet extracted a minimal example, but the above works reliably 2. If the dataset is large, I've yet to determine if this bug still happens a. not at all b. always c. on the small, leftover batch at the end.
4,755
https://github.com/huggingface/datasets/issues/4752
DatasetInfo issue when testing multiple configs: mixed task_templates
[ "I've narrowed down the issue to the `dataset_module_factory` which already creates a `dataset_infos.json` file down in the `.cache/modules/dataset_modules/..` folder. That JSON file already contains the wrong task_templates for `unfiltered`.", "Ugh. Found the issue: apparently `datasets` was reusing the already existing `dataset_infos.json` that is inside `datasets/datasets/hebban-reviews`! Is this desired behavior?\r\n\r\nPerhaps when `--save_infos` and `--all_configs` are given, an existing `dataset_infos.json` file should first be deleted before continuing with the test? Because that would assume that the user wants to create a new infos file for all configs anyway.", "Hi! I think this is a reasonable solution. Would you be interested in submitting a PR?" ]
## Describe the bug When running the `datasets-cli test` it would seem that some config properties in a DatasetInfo get mangled, leading to issues, e.g., about the ClassLabel. ## Steps to reproduce the bug In summary, what I want to do is create three configs: - unfiltered: no classlabel, no tasks. Gets data from unfiltered.json.gz (I'd want this without splits, just one chunk of data, but that does not seem possible?) - filtered_sentiment: `review_sentiment` as ClassLabel, TextClassification task with `review_sentiment` as label. Gets train/test split from respective json.gz files - filtered_rating: `review_rating0` as ClassLabel, TextClassification task with `review_rating0` as label. Gets train/test split from respective json.gz files This might be a bit tedious to reproduce, so I am sorry, but these are the steps: - Clone datasets -> `datasets/` and install it - Clone `https://huggingface.co/datasets/BramVanroy/hebban-reviews` into `datasets/datasets` so that you have a new folder `datasets/datasets/hebban-reviews/`. - Replace the HebbanReviews class with this new one: ```python class HebbanReviews(datasets.GeneratorBasedBuilder): """The Hebban book reviews dataset.""" BUILDER_CONFIGS = [ HebbanReviewsConfig( name="unfiltered", description=_HEBBAN_REVIEWS_UNFILTERED_DESCRIPTION, version=datasets.Version(_HEBBAN_VERSION) ), HebbanReviewsConfig( name="filtered_sentiment", description=f"This config has the negative, neutral, and positive sentiment scores as ClassLabel in the 'review_sentiment' column.\n{_HEBBAN_REVIEWS_FILTERED_DESCRIPTION}", version=datasets.Version(_HEBBAN_VERSION) ), HebbanReviewsConfig( name="filtered_rating", description=f"This config has the 5-class ratings as ClassLabel in the 'review_rating0' column (which is a variant of 'review_rating' that starts counting from 0 instead of 1).\n{_HEBBAN_REVIEWS_FILTERED_DESCRIPTION}", version=datasets.Version(_HEBBAN_VERSION) ) ] DEFAULT_CONFIG_NAME = "filtered_sentiment" _URLS = { "train": "train.jsonl.gz", "test": "test.jsonl.gz", "unfiltered": "unfiltered.jsonl.gz", } def _info(self): features = { "review_title": datasets.Value("string"), "review_text": datasets.Value("string"), "review_text_without_quotes": datasets.Value("string"), "review_n_quotes": datasets.Value("int32"), "review_n_tokens": datasets.Value("int32"), "review_rating": datasets.Value("int32"), "review_rating0": datasets.Value("int32"), "review_author_url": datasets.Value("string"), "review_author_type": datasets.Value("string"), "review_n_likes": datasets.Value("int32"), "review_n_comments": datasets.Value("int32"), "review_url": datasets.Value("string"), "review_published_date": datasets.Value("string"), "review_crawl_date": datasets.Value("string"), "lid": datasets.Value("string"), "lid_probability": datasets.Value("float32"), "review_sentiment": datasets.features.ClassLabel(names=["negative", "neutral", "positive"]), "review_sentiment_label": datasets.Value("string"), "book_id": datasets.Value("int32"), } if self.config.name == "filtered_sentiment": task_templates = [datasets.TextClassification(text_column="review_text_without_quotes", label_column="review_sentiment")] elif self.config.name == "filtered_rating": # For CrossEntropy, our classes need to start at index 0 -- not 1 features["review_rating0"] = datasets.features.ClassLabel(names=["1", "2", "3", "4", "5"]) features["review_sentiment"] = datasets.Value("int32") task_templates = [datasets.TextClassification(text_column="review_text_without_quotes", label_column="review_rating0")] elif self.config.name == "unfiltered": # no ClassLabels in unfiltered features["review_sentiment"] = datasets.Value("int32") task_templates = None else: raise ValueError(f"Unsupported config {self.config.name}. Expected one of 'filtered_sentiment' (default)," f" 'filtered_rating', or 'unfiltered'") print("AT INFO", self.config.name, task_templates) return datasets.DatasetInfo( description=self.config.description, features=datasets.Features(features), homepage="https://huggingface.co/datasets/BramVanroy/hebban-reviews", citation=_HEBBAN_REVIEWS_CITATION, task_templates=task_templates, license="cc-by-4.0" ) def _split_generators(self, dl_manager): if self.config.name.startswith("filtered"): files = dl_manager.download_and_extract({"train": "train.jsonl.gz", "test": "test.jsonl.gz"}) return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={ "data_file": files["train"] }, ), datasets.SplitGenerator( name=datasets.Split.TEST, gen_kwargs={ "data_file": files["test"] }, ), ] elif self.config.name == "unfiltered": files = dl_manager.download_and_extract({"train": "unfiltered.jsonl.gz"}) return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={ "data_file": files["train"] }, ), ] else: raise ValueError(f"Unsupported config {self.config.name}. Expected one of 'filtered_sentiment' (default)," f" 'filtered_rating', or 'unfiltered'") def _generate_examples(self, data_file): lines = Path(data_file).open(encoding="utf-8").readlines() for line_idx, line in enumerate(lines): row = json.loads(line) yield line_idx, row ``` - finally, run `datasets-cli test ./datasets/hebban-reviews/ --save_infos --all_configs` from within the topmost `datasets` directory ## Expected results Succeeding tests for three different configs. ## Actual results I printed out the values that are given to `DatasetInfo` for config name and task_templates, as you can see. There, as expected, I get `unfiltered None`. I also modified datasets/info.py and added this line [at L.170](https://github.com/huggingface/datasets/blob/f5847a304aa1b38b3a3c54a8318b4df60f1299bc/src/datasets/info.py#L170): ```python print("INTERNALLY AT INFO.PY", self.config_name, self.task_templates) ``` to my surprise, here I get `unfiltered [TextClassification(task='text-classification', text_column='review_text_without_quotes', label_column='review_sentiment')]`. So one way or another, here I suddenly see that `unfiltered` now does have a task_template -- even though that is not what is written in the data loading script, as the first print statement correctly shows. I do not quite understand how, but it seems that the config name and task_templates get mixed. This ultimately leads to the following error, but this trace may not be very useful in itself: ``` Traceback (most recent call last): File "C:\Users\bramv\.virtualenvs\hebban-U6poXNQd\Scripts\datasets-cli-script.py", line 33, in <module> sys.exit(load_entry_point('datasets', 'console_scripts', 'datasets-cli')()) File "c:\dev\python\hebban\datasets\src\datasets\commands\datasets_cli.py", line 39, in main service.run() File "c:\dev\python\hebban\datasets\src\datasets\commands\test.py", line 144, in run builder.as_dataset() File "c:\dev\python\hebban\datasets\src\datasets\builder.py", line 899, in as_dataset datasets = map_nested( File "c:\dev\python\hebban\datasets\src\datasets\utils\py_utils.py", line 393, in map_nested mapped = [ File "c:\dev\python\hebban\datasets\src\datasets\utils\py_utils.py", line 394, in <listcomp> _single_map_nested((function, obj, types, None, True, None)) File "c:\dev\python\hebban\datasets\src\datasets\utils\py_utils.py", line 330, in _single_map_nested return function(data_struct) File "c:\dev\python\hebban\datasets\src\datasets\builder.py", line 930, in _build_single_dataset ds = self._as_dataset( File "c:\dev\python\hebban\datasets\src\datasets\builder.py", line 1006, in _as_dataset return Dataset(fingerprint=fingerprint, **dataset_kwargs) File "c:\dev\python\hebban\datasets\src\datasets\arrow_dataset.py", line 661, in __init__ info = info.copy() if info is not None else DatasetInfo() File "c:\dev\python\hebban\datasets\src\datasets\info.py", line 286, in copy return self.__class__(**{k: copy.deepcopy(v) for k, v in self.__dict__.items()}) File "<string>", line 20, in __init__ File "c:\dev\python\hebban\datasets\src\datasets\info.py", line 176, in __post_init__ self.task_templates = [ File "c:\dev\python\hebban\datasets\src\datasets\info.py", line 177, in <listcomp> template.align_with_features(self.features) for template in (self.task_templates) File "c:\dev\python\hebban\datasets\src\datasets\tasks\text_classification.py", line 22, in align_with_features raise ValueError(f"Column {self.label_column} is not a ClassLabel.") ValueError: Column review_sentiment is not a ClassLabel. ``` ## Environment info - `datasets` version: 2.4.1.dev0 - Platform: Windows-10-10.0.19041-SP0 - Python version: 3.8.8 - PyArrow version: 8.0.0 - Pandas version: 1.4.3
4,752
https://github.com/huggingface/datasets/issues/4750
Easily create loading script for benchmark comprising multiple huggingface datasets
[ "Hi ! I think the simplest is to copy paste the `_split_generators` code from the other datasets and do a bunch of if-else, as in the glue dataset: https://huggingface.co/datasets/glue/blob/main/glue.py#L467", "Ok, I see. Thank you" ]
Hi, I would like to create a loading script for a benchmark comprising multiple huggingface datasets. The function _split_generators needs to return the files for the respective dataset. However, the files are not always in the same location for each dataset. I want to just make a wrapper dataset that provides a single interface to all the underlying datasets. I thought about downloading the files with the load_dataset function and then providing the link to the cached file. But this seems a bit inelegant to me. What approach would you propose to do this? Please let me know if you have any questions. Cheers, Joel
4,750
https://github.com/huggingface/datasets/issues/4746
Dataset Viewer issue for yanekyuk/wikikey
[ "The dataset is empty, as far as I can tell: there are no files in the repository at https://huggingface.co/datasets/yanekyuk/wikikey/tree/main\r\n\r\nMaybe the viewer can display a better message for empty datasets", "OK. Closing as it's not an error. We will work on making the error message a lot clearer." ]
### Link _No response_ ### Description _No response_ ### Owner _No response_
4,746
https://github.com/huggingface/datasets/issues/4745
Allow `list_datasets` to include private datasets
[ "Thanks for opening this issue :)\r\n\r\nIf it can help, I think you can already use `huggingface_hub` to achieve this:\r\n```python\r\n>>> from huggingface_hub import HfApi\r\n>>> [ds_info.id for ds_info in HfApi().list_datasets(use_auth_token=token) if ds_info.private]\r\n['bigscience/xxxx', 'bigscience-catalogue-data/xxxxxxx', ... ]\r\n```\r\n\r\n---------\r\n\r\nThough the latest versions of `huggingface_hub` that contain this feature are not available on python 3.6, so maybe we should first drop support for python 3.6 (see #4460) to update `list_datasets` in `datasets` as well (or we would have to copy/paste some `huggingface_hub` code)", "Great, thanks @lhoestq the workaround works! I think it would be intuitive to have the support directly in `datasets` but it makes sense to wait given that the workaround exists :)", "i also think that going forward we should replace more and more implementations inside datasets with the corresponding ones from `huggingface_hub` (same as we're doing in `transformers`)", "`datasets.list_datasets` is now deprecated in favor of `huggingface_hub.list_datasets` (returns private datasets when `token` is present), so I'm closing this issue." ]
I am working with a large collection of private datasets, it would be convenient for me to be able to list them. I would envision extending the convention of using `use_auth_token` keyword argument to `list_datasets` function, then calling: ``` list_datasets(use_auth_token="my_token") ``` would return the list of all datasets I have permissions to view, including private ones. The only current alternative I see is to use the hub website to manually obtain the list of dataset names - this is in the context of BigScience where respective private spaces contain hundreds of datasets, so not very convenient to list manually.
4,745
https://github.com/huggingface/datasets/issues/4744
Remove instructions to generate dummy data from our docs
[ "Note that for me personally, conceptually all the dummy data (even for \"canonical\" datasets) should be superseded by `datasets-server`, which performs some kind of CI/CD of datasets (including the canonical ones)", "I totally agree: next step should be rethinking if dummy data makes sense for canonical datasets (once we have datasets-server) and eventually remove it.\r\n\r\nBut for now, we could at least start by removing the indication to generate dummy data from our docs." ]
In our docs, we indicate to generate the dummy data: https://huggingface.co/docs/datasets/dataset_script#testing-data-and-checksum-metadata However: - dummy data makes sense only for datasets in our GitHub repo: so that we can test their loading with our CI - for datasets on the Hub: - they do not pass any CI test requiring dummy data - there are no instructions on how they can test their dataset locally using the dummy data - the generation of the dummy data assumes our GitHub directory structure: - the dummy data will be generated under `./datasets/<dataset_name>/dummy` even if locally there is no `./datasets` directory (which is the usual case). See issue: - #4742 CC: @stevhliu
4,744
https://github.com/huggingface/datasets/issues/4742
Dummy data nowhere to be found
[ "Hi @BramVanroy, thanks for reporting.\r\n\r\nFirst of all, please note that you do not need the dummy data: this was the case when we were adding datasets to the `datasets` library (on this GitHub repo), so that we could test the correct loading of all datasets with our CI. However, this is no longer the case for datasets on the Hub.\r\n- We should definitely update our docs.\r\n\r\nSecond, the dummy data is generated locally:\r\n- in your case, the dummy data will be generated inside the directory: `./datasets/hebban-reviews/dummy`\r\n- please note the preceding `./datasets` directory: the reason for this is that the command to generate the dummy data was specifically created for our `datasets` library, and therefore assumes our directory structure: commands are run from the root directory of our GitHub repo, and datasets scripts are under `./datasets` \r\n\r\n\r\n ", "I have opened an Issue to update the instructions on dummy data generation:\r\n- #4744", "Dummy data generation is deprecated now, so I think we can close this issue." ]
## Describe the bug To finalize my dataset, I wanted to create dummy data as per the guide and I ran ```shell datasets-cli dummy_data datasets/hebban-reviews --auto_generate ``` where hebban-reviews is [this repo](https://huggingface.co/datasets/BramVanroy/hebban-reviews). And even though the scripts runs and shows a message at the end that it succeeded, I cannot find the dummy data anywhere. Where is it? ## Expected results To see the dummy data in the datasets' folder or in the folder where I ran the command. ## Actual results I see the following message but I cannot find the dummy data anywhere. ``` Dummy data generation done and dummy data test succeeded for config 'filtered''. Automatic dummy data generation succeeded for all configs of '.\datasets\hebban-reviews\' ``` ## Environment info - `datasets` version: 2.4.1.dev0 - Platform: Windows-10-10.0.19041-SP0 - Python version: 3.8.8 - PyArrow version: 8.0.0 - Pandas version: 1.4.3
4,742
https://github.com/huggingface/datasets/issues/4737
Download error on scene_parse_150
[ "Hi! The server with the data seems to be down. I've reported this issue (https://github.com/CSAILVision/sceneparsing/issues/34) in the dataset repo. ", "The URL seems to work now, and therefore the script as well." ]
``` from datasets import load_dataset dataset = load_dataset("scene_parse_150", "scene_parsing") FileNotFoundError: Couldn't find file at http://data.csail.mit.edu/places/ADEchallenge/ADEChallengeData2016.zip ```
4,737
https://github.com/huggingface/datasets/issues/4736
Dataset Viewer issue for deepklarity/huggingface-spaces-dataset
[ "Thanks for reporting. You're right, workers were under-provisioned due to a manual error, and the job queue was full. It's fixed now." ]
### Link https://huggingface.co/datasets/deepklarity/huggingface-spaces-dataset/viewer/deepklarity--huggingface-spaces-dataset/train ### Description Hi Team, I'm getting the following error on a uploaded dataset. I'm getting the same status for a couple of hours now. The dataset size is `<1MB` and the format is csv, so I'm not sure if it's supposed to take this much time or not. ``` Status code: 400 Exception: Status400Error Message: The split is being processed. Retry later. ``` Is there any explicit step to be taken to get the viewer to work? ### Owner Yes
4,736
https://github.com/huggingface/datasets/issues/4734
Package rouge-score cannot be imported
[ "We have added a comment on an existing issue opened in their repo: https://github.com/google-research/google-research/issues/1212#issuecomment-1192267130\r\n- https://github.com/google-research/google-research/issues/1212" ]
## Describe the bug After the today release of `rouge_score-0.0.7` it seems no longer importable. Our CI fails: https://github.com/huggingface/datasets/runs/7463218591?check_suite_focus=true ``` FAILED tests/test_dataset_common.py::LocalDatasetTest::test_builder_class_bigbench FAILED tests/test_dataset_common.py::LocalDatasetTest::test_builder_configs_bigbench FAILED tests/test_dataset_common.py::LocalDatasetTest::test_load_dataset_bigbench FAILED tests/test_metric_common.py::LocalMetricTest::test_load_metric_rouge ``` with errors: ``` > from rouge_score import rouge_scorer E ModuleNotFoundError: No module named 'rouge_score' ``` ``` E ImportError: To be able to use rouge, you need to install the following dependency: rouge_score. E Please install it using 'pip install rouge_score' for instance' ```
4,734
https://github.com/huggingface/datasets/issues/4733
rouge metric
[ "Fixed by:\r\n- #4735" ]
## Describe the bug A clear and concise description of what the bug is. Loading Rouge metric gives error after latest rouge-score==0.0.7 release. Downgrading rougemetric==0.0.4 works fine. ## Steps to reproduce the bug ```python # Sample code to reproduce the bug ``` ## Expected results A clear and concise description of the expected results. from rouge_score import rouge_scorer, scoring should run ## Actual results Specify the actual results or traceback. File "/root/.cache/huggingface/modules/datasets_modules/metrics/rouge/0ffdb60f436bdb8884d5e4d608d53dbe108e82dac4f494a66f80ef3f647c104f/rouge.py", line 21, in <module> from rouge_score import rouge_scorer, scoring ImportError: cannot import name 'rouge_scorer' from 'rouge_score' (unknown location) ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: - Platform: Linux - Python version:3.9 - PyArrow version:
4,733
https://github.com/huggingface/datasets/issues/4732
Document better that loading a dataset passing its name does not use the local script
[ "Thanks for the feedback!\r\n\r\nI think since this issue is closely related to loading, I can add a clearer explanation under [Load > local loading script](https://huggingface.co/docs/datasets/main/en/loading#local-loading-script).", "That makes sense but I think having a line about it under https://huggingface.co/docs/datasets/installation#source the \"source\" header here would be useful. My mental model of `pip install -e .` does not include the fact that the source files aren't actually being used. ", "Thanks for sharing your perspective. I think the `load_dataset` function is the only one that pulls from GitHub, and since this use-case is very specific, I don't think we need to include such a broad clarification in the Installation section.\r\n\r\nFeel free to check out the linked PR and let me know if it needs any additional explanation 😊" ]
As reported by @TrentBrick here https://github.com/huggingface/datasets/issues/4725#issuecomment-1191858596, it could be more clear that loading a dataset by passing its name does not use the (modified) local script of it. What he did: - he installed `datasets` from source - he modified locally `datasets/the_pile/the_pile.py` loading script - he tried to load it but using `load_dataset("the_pile")` instead of `load_dataset("datasets/the_pile")` - as explained here https://github.com/huggingface/datasets/issues/4725#issuecomment-1191040245: - the former does not use the local script, but instead it downloads a copy of `the_pile.py` from our GitHub, caches it locally (inside `~/.cache/huggingface/modules`) and uses that. He suggests adding a more clear explanation about this. He suggests adding it maybe in [Installation > source](https://huggingface.co/docs/datasets/installation)) CC: @stevhliu
4,732
https://github.com/huggingface/datasets/issues/4730
Loading imagenet-1k validation split takes much more RAM than expected
[ "My bad, `482 * 418 * 50000 * 3 / 1000000 = 30221 MB` ( https://stackoverflow.com/a/42979315 ).\r\n\r\nMeanwhile `256 * 256 * 50000 * 3 / 1000000 = 9830 MB`. We are loading the non-cropped images and that is why we take so much RAM." ]
## Describe the bug Loading into memory the validation split of imagenet-1k takes much more RAM than expected. Assuming ImageNet-1k is 150 GB, split is 50000 validation images and 1,281,167 train images, I would expect only about 6 GB loaded in RAM. ## Steps to reproduce the bug ```python from datasets import load_dataset dataset = load_dataset("imagenet-1k", split="validation") print(dataset) """prints Dataset({ features: ['image', 'label'], num_rows: 50000 }) """ pipe_inputs = dataset["image"] # and wait :-) ``` ## Expected results Use only < 10 GB RAM when loading the images. ## Actual results ![image](https://user-images.githubusercontent.com/9808326/180249183-62f75ca4-d127-402a-9330-f12825a22b0a.png) ``` Using custom data configuration default Reusing dataset imagenet-1k (/home/fxmarty/.cache/huggingface/datasets/imagenet-1k/default/1.0.0/a1e9bfc56c3a7350165007d1176b15e9128fcaf9ab972147840529aed3ae52bc) Killed ``` ## Environment info - `datasets` version: 2.3.3.dev0 - Platform: Linux-5.15.0-41-generic-x86_64-with-glibc2.35 - Python version: 3.9.12 - PyArrow version: 7.0.0 - Pandas version: 1.3.5 - datasets commit: 4e4222f1b6362c2788aec0dd2cd8cede6dd17b80
4,730
https://github.com/huggingface/datasets/issues/4728
load_dataset gives "403" error when using Financial Phrasebank
[ "Hi @rohitvincent, thanks for reporting.\r\n\r\nUnfortunately I'm not able to reproduce your issue:\r\n```python\r\nIn [2]: from datasets import load_dataset, DownloadMode\r\n ...: load_dataset(path='financial_phrasebank',name='sentences_allagree', download_mode=\"force_redownload\")\r\nDownloading builder script: 6.04kB [00:00, 2.87MB/s] \r\nDownloading metadata: 13.7kB [00:00, 7.24MB/s] \r\nDownloading and preparing dataset financial_phrasebank/sentences_allagree (download: 665.91 KiB, generated: 296.26 KiB, post-processed: Unknown size, total: 962.17 KiB) to .../.cache/huggingface/datasets/financial_phrasebank/sentences_allagree/1.0.0/550bde12e6c30e2674da973a55f57edde5181d53f5a5a34c1531c53f93b7e141...\r\nDownloading data: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 682k/682k [00:00<00:00, 7.66MB/s]\r\nDataset financial_phrasebank downloaded and prepared to .../.cache/huggingface/datasets/financial_phrasebank/sentences_allagree/1.0.0/550bde12e6c30e2674da973a55f57edde5181d53f5a5a34c1531c53f93b7e141. Subsequent calls will reuse this data.\r\n100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1/1 [00:00<00:00, 918.80it/s]\r\nOut[2]: \r\nDatasetDict({\r\n train: Dataset({\r\n features: ['sentence', 'label'],\r\n num_rows: 2264\r\n })\r\n})\r\n```\r\n\r\nAre you able to access the link? https://www.researchgate.net/profile/Pekka-Malo/publication/251231364_FinancialPhraseBank-v10/data/0c96051eee4fb1d56e000000/FinancialPhraseBank-v10.zip", "Yes was able to download from the link manually. But still, get the same error when I use load_dataset.", "Fixed once data files are hosted on the Hub:\r\n- #4598" ]
I tried both codes below to download the financial phrasebank dataset (https://huggingface.co/datasets/financial_phrasebank) with the sentences_allagree subset. However, the code gives a 403 error when executed from multiple machines locally or on the cloud. ``` from datasets import load_dataset, DownloadMode load_dataset(path='financial_phrasebank',name='sentences_allagree',download_mode=DownloadMode.FORCE_REDOWNLOAD) ``` ``` from datasets import load_dataset, DownloadMode load_dataset(path='financial_phrasebank',name='sentences_allagree') ``` **Error** ConnectionError: Couldn't reach https://www.researchgate.net/profile/Pekka_Malo/publication/251231364_FinancialPhraseBank-v10/data/0c96051eee4fb1d56e000000/FinancialPhraseBank-v10.zip (error 403)
4,728
https://github.com/huggingface/datasets/issues/4727
Dataset Viewer issue for TheNoob3131/mosquito-data
[ "The preview is working OK:\r\n\r\n![Screenshot from 2022-07-21 09-46-09](https://user-images.githubusercontent.com/8515462/180158929-bd8faad4-6392-4fc1-8d9c-df38aa9f8438.png)\r\n\r\n" ]
### Link https://huggingface.co/datasets/TheNoob3131/mosquito-data/viewer/TheNoob3131--mosquito-data/test ### Description Dataset preview not showing with large files. Says 'split cache is empty' even though there are train and test splits. ### Owner _No response_
4,727
https://github.com/huggingface/datasets/issues/4725
the_pile datasets URL broken.
[ "Thanks for reporting, @TrentBrick. We are addressing the change with their data host server.\r\n\r\nOn the meantime, if you would like to work with your fixed local copy of the_pile script, you should use:\r\n```python\r\nload_dataset(\"path/to/your/local/the_pile/the_pile.py\",...\r\n```\r\ninstead of just `load_dataset(\"the_pile\",...`.\r\n\r\nThe latter downloads a copy of `the_pile.py` from our GitHub, caches it locally (inside `~/.cache/huggingface/modules`) and uses that.", "@TrentBrick, I have checked the URLs and both hosts work, the original (https://the-eye.eu/) and the mirror (https://mystic.the-eye.eu/). See e.g.:\r\n- https://mystic.the-eye.eu/public/AI/pile/\r\n- https://mystic.the-eye.eu/public/AI/pile_preliminary_components/\r\n\r\nPlease, let me know if you still find any issue loading this dataset by using current server URLs.", "Great this is working now. Re the download from GitHub... I'm sure thought went into doing this but could it be made more clear maybe here? https://huggingface.co/docs/datasets/installation for example under installing from source? I spent over an hour questioning my sanity as I kept trying to edit this file, uninstall and reinstall the repo, git reset to previous versions of the file etc.", "Thanks for the quick reply and help too\r\n", "Thanks @TrentBrick for the suggestion about improving our docs: we should definitely do this if you find they are not clear enough.\r\n\r\nCurrently, our docs explain how to load a dataset from a local loading script here: [Load > Local loading script](https://huggingface.co/docs/datasets/loading#local-loading-script)\r\n\r\nI've opened an issue here:\r\n- #4732\r\n\r\nFeel free to comment on it any additional explanation/suggestion/requirement related to this problem." ]
https://github.com/huggingface/datasets/pull/3627 changed the Eleuther AI Pile dataset URL from https://the-eye.eu/ to https://mystic.the-eye.eu/ but the latter is now broken and the former works again. Note that when I git clone the repo and use `pip install -e .` and then edit the URL back the codebase doesn't seem to use this edit so the mystic URL is also cached somewhere else that I can't find?
4,725
https://github.com/huggingface/datasets/issues/4721
PyArrow Dataset error when calling `load_dataset`
[ "Hi ! It looks like a bug in `pyarrow`. If you manage to end up with only one chunk per parquet file it should workaround this issue.\r\n\r\nTo achieve that you can try to lower the value of `max_shard_size` and also don't use `map` before `push_to_hub`.\r\n\r\nDo you have a minimum reproducible example that we can share with the Arrow team for further debugging ?", "> If you manage to end up with only one chunk per parquet file it should workaround this issue.\r\n\r\nYup, I did not encounter this bug when I was testing my script with a slice of <1000 samples for my dataset.\r\n\r\n> Do you have a minimum reproducible example...\r\n\r\nNot sure if I can get more minimal than the script I shared above. Are you asking for a sample json file?\r\nJust generate a random manifest list, I can add that to the above script if that's what you mean?\r\n", "Actually this is probably linked to this open issue: https://issues.apache.org/jira/browse/ARROW-5030.\r\n\r\nsetting `max_shard_size=\"2GB\"` should do the job (or `max_shard_size=\"1GB\"` if you want to be on the safe side, especially given that there can be some variance in the shard sizes if the dataset is not evenly distributed)" ]
## Describe the bug I am fine tuning a wav2vec2 model following the script here using my own dataset: https://github.com/huggingface/transformers/blob/main/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py Loading my Audio dataset from the hub which was originally generated from disk results in the following PyArrow error: ```sh File "/home/ubuntu/w2v2/run_speech_recognition_ctc.py", line 227, in main raw_datasets = load_dataset( File "/home/ubuntu/.virtualenvs/meval/lib/python3.8/site-packages/datasets/load.py", line 1679, in load_dataset builder_instance.download_and_prepare( File "/home/ubuntu/.virtualenvs/meval/lib/python3.8/site-packages/datasets/builder.py", line 704, in download_and_prepare self._download_and_prepare( File "/home/ubuntu/.virtualenvs/meval/lib/python3.8/site-packages/datasets/builder.py", line 793, in _download_and_prepare self._prepare_split(split_generator, **prepare_split_kwargs) File "/home/ubuntu/.virtualenvs/meval/lib/python3.8/site-packages/datasets/builder.py", line 1268, in _prepare_split for key, table in logging.tqdm( File "/home/ubuntu/.virtualenvs/meval/lib/python3.8/site-packages/tqdm/std.py", line 1195, in __iter__ for obj in iterable: File "/home/ubuntu/.virtualenvs/meval/lib/python3.8/site-packages/datasets/packaged_modules/parquet/parquet.py", line 68, in _generate_tables for batch_idx, record_batch in enumerate( File "pyarrow/_parquet.pyx", line 1309, in iter_batches File "pyarrow/error.pxi", line 121, in pyarrow.lib.check_status pyarrow.lib.ArrowNotImplementedError: Nested data conversions not implemented for chunked array outputs ``` ## Steps to reproduce the bug I created a dataset from a JSON lines manifest of `audio_filepath`, `text`, and `duration`. When creating the dataset, I do something like this: ```python import json from datasets import Dataset, Audio # manifest_lines is a list of dicts w/ "audio_filepath", "duration", and "text for line in manifest_lines: line = line.strip() if line: line_dict = json.loads(line) manifest_dict["audio"].append(f"{root_path}/{line_dict['audio_filepath']}") manifest_dict["duration"].append(line_dict["duration"]) manifest_dict["transcription"].append(line_dict["text"]) # Create a HF dataset dataset = Dataset.from_dict(manifest_dict).cast_column( "audio", Audio(sampling_rate=16_000), ) # From the docs for saving to disk # https://huggingface.co/docs/datasets/v2.3.2/en/package_reference/main_classes#datasets.Dataset.save_to_disk def read_audio_file(example): with open(example["audio"]["path"], "rb") as f: return {"audio": {"bytes": f.read()}} dataset = dataset.map(read_audio_file, num_proc=70) dataset.save_to_disk(f"/audio-data/hf/{artifact_name}") dataset.push_to_hub(f"{org-name}/{artifact_name}", max_shard_size="5GB", private=True) ``` Then when I call `load_dataset()` in my training script, with the same dataset I generated above, and download from the huggingface hub I get the above stack trace. I am able to load the dataset fine if I use `load_from_disk()`. ## Expected results `load_dataset()` should behave just like `load_from_disk()` and not cause any errors. ## Actual results See above ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> I am using the `huggingface/transformers-pytorch-gpu:latest` image - `datasets` version: 2.3.0 - Platform: Docker/Ubuntu 20.04 - Python version: 3.8 - PyArrow version: 8.0.0
4,721
https://github.com/huggingface/datasets/issues/4720
Dataset Viewer issue for shamikbose89/lancaster_newsbooks
[ "It seems like the list of splits could not be obtained:\r\n\r\n```python\r\n>>> from datasets import get_dataset_split_names\r\n>>> get_dataset_split_names(\"shamikbose89/lancaster_newsbooks\", \"default\")\r\nUsing custom data configuration default\r\nTraceback (most recent call last):\r\n File \"/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/inspect.py\", line 354, in get_dataset_config_info\r\n for split_generator in builder._split_generators(\r\n File \"/home/slesage/.cache/huggingface/modules/datasets_modules/datasets/shamikbose89--lancaster_newsbooks/2d1c63d269bf7b9342accce0a95960b1710ab4bc774248878bd80eb96c1afaf7/lancaster_newsbooks.py\", line 73, in _split_generators\r\n data_dir = dl_manager.download_and_extract(_URL)\r\n File \"/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/download/streaming_download_manager.py\", line 916, in download_and_extract\r\n return self.extract(self.download(url_or_urls))\r\n File \"/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/download/streaming_download_manager.py\", line 879, in extract\r\n urlpaths = map_nested(self._extract, path_or_paths, map_tuple=True)\r\n File \"/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/utils/py_utils.py\", line 348, in map_nested\r\n return function(data_struct)\r\n File \"/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/download/streaming_download_manager.py\", line 884, in _extract\r\n protocol = _get_extraction_protocol(urlpath, use_auth_token=self.download_config.use_auth_token)\r\n File \"/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/download/streaming_download_manager.py\", line 388, in _get_extraction_protocol\r\n return _get_extraction_protocol_with_magic_number(f)\r\n File \"/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/download/streaming_download_manager.py\", line 354, in _get_extraction_protocol_with_magic_number\r\n f.seek(0)\r\n File \"/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/fsspec/implementations/http.py\", line 684, in seek\r\n raise ValueError(\"Cannot seek streaming HTTP file\")\r\nValueError: Cannot seek streaming HTTP file\r\n\r\nThe above exception was the direct cause of the following exception:\r\n\r\nTraceback (most recent call last):\r\n File \"<stdin>\", line 1, in <module>\r\n File \"/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/inspect.py\", line 404, in get_dataset_split_names\r\n info = get_dataset_config_info(\r\n File \"/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/inspect.py\", line 359, in get_dataset_config_info\r\n raise SplitsNotFoundError(\"The split names could not be parsed from the dataset config.\") from err\r\ndatasets.inspect.SplitsNotFoundError: The split names could not be parsed from the dataset config.\r\n```\r\n\r\nping @huggingface/datasets ", "Oh, I removed the 'split' key from `kwargs`. I put it back in, but there's still the same error", "It looks like the data host doesn't support http range requests, which is necessary to glob inside a ZIP archive in streaming mode. Can you try hosting the dataset elsewhere ? Or download each file separately from https://ota.bodleian.ox.ac.uk/repository/xmlui/handle/20.500.12024/2531 ?", "@lhoestq Thanks! That seems to have solved it. I can get the splits with the `get_dataset_split_names()` function. The dataset viewer is still not loading properly, though. The new error is\r\n```\r\nStatus code: 400\r\nException: BadZipFile\r\nMessage: File is not a zip file\r\n```\r\n\r\nPS. The dataset loads properly and can be accessed" ]
### Link https://huggingface.co/datasets/shamikbose89/lancaster_newsbooks ### Description Status code: 400 Exception: ValueError Message: Cannot seek streaming HTTP file I am able to use the dataset loading script locally and it also runs when I'm using the one from the hub, but the viewer still doesn't load ### Owner Yes
4,720
https://github.com/huggingface/datasets/issues/4719
Issue loading TheNoob3131/mosquito-data dataset
[ "I am also getting a ValueError: 'Couldn't cast' at the bottom. Is this because of some delimiter issue? My dataset is on the Huggingface Hub. If you could look at it, that would be greatly appreciated.", "Hi @thenerd31, thanks for reporting.\r\n\r\nPlease note that your issue is not caused by the Hugging Face Datasets library, but it has to do with the specific implementation of your dataset on the Hub.\r\n\r\nTherefore, I'm transferring this discussion to your own dataset Community tab: https://huggingface.co/datasets/TheNoob3131/mosquito-data/discussions/1" ]
![image](https://user-images.githubusercontent.com/53668030/179815591-d75fa7d3-3122-485f-a852-b06a68909066.png) So my dataset is public in the Huggingface Hub, but when I try to load it using the load_dataset command, it shows that it is downloading the files, but throws a ValueError. When I went to my directory to see if the files were downloaded, the folder was blank. Here is the error below: ValueError Traceback (most recent call last) Input In [8], in <cell line: 3>() 1 from datasets import load_dataset ----> 3 dataset = load_dataset("TheNoob3131/mosquito-data", split="train") File ~\Anaconda3\lib\site-packages\datasets\load.py:1679, in load_dataset(path, name, data_dir, data_files, split, cache_dir, features, download_config, download_mode, ignore_verifications, keep_in_memory, save_infos, revision, use_auth_token, task, streaming, **config_kwargs) 1676 try_from_hf_gcs = path not in _PACKAGED_DATASETS_MODULES 1678 # Download and prepare data -> 1679 builder_instance.download_and_prepare( 1680 download_config=download_config, 1681 download_mode=download_mode, 1682 ignore_verifications=ignore_verifications, 1683 try_from_hf_gcs=try_from_hf_gcs, 1684 use_auth_token=use_auth_token, 1685 ) 1687 # Build dataset for splits 1688 keep_in_memory = ( 1689 keep_in_memory if keep_in_memory is not None else is_small_dataset(builder_instance.info.dataset_size) 1690 ) Is the dataset in the wrong format or is there some security permission that I should enable?
4,719
https://github.com/huggingface/datasets/issues/4717
Dataset Viewer issue for LawalAfeez/englishreview-ds-mini
[ "It's currently working, as far as I understand\r\n\r\nhttps://huggingface.co/datasets/LawalAfeez/englishreview-ds-mini/viewer/LawalAfeez--englishreview-ds-mini/train\r\n\r\n<img width=\"1556\" alt=\"Capture d’écran 2022-07-19 aΜ€ 09 24 01\" src=\"https://user-images.githubusercontent.com/1676121/179761130-2d7980b9-c0f6-4093-8b1d-f0a3872fef3f.png\">\r\n\r\n---\r\n\r\nWhat was your issue?" ]
### Link _No response_ ### Description Unable to view the split data ### Owner _No response_
4,717
https://github.com/huggingface/datasets/issues/4711
Document how to create a dataset loading script for audio/vision
[ "I'm closing this issue as both the Audio and Image sections now have a \"Create dataset\" page that contains the info about writing the loading script version of a dataset." ]
Currently, in our docs for Audio/Vision/Text, we explain how to: - Load data - Process data However we only explain how to *Create a dataset loading script* for text data. I think it would be useful that we add the same for Audio/Vision as these have some specificities different from Text. See, for example: - #4697 - and comment there: https://github.com/huggingface/datasets/issues/4697#issuecomment-1191502492 CC: @stevhliu
4,711
https://github.com/huggingface/datasets/issues/4709
WMT21 & WMT22
[ "Hi ! That would be awesome to have them indeed, thanks for opening this issue\r\n\r\nI just added you to the WMT org on the HF Hub if you're interested in adding those datasets.\r\n\r\nFeel free to create a dataset repository for each dataset and upload the data files there :) preferably in ZIP archives instead of TAR archives (the current WMT scripts don't support streaming TAR archives, so it would break the dataset preview). We've also had issues with the `statmt.org` host (data unavailable, slow download speed), that's why I think it's better if we re-host the files on the Hub.\r\n\r\n`wmt21` (and wmt22) can be added <s>in this GitHub repository I think</s> on the HF Hub under the `WMT` org (we'll move the previous ones to this org soon as well).\r\nTo add it, you can copy paste the code of the previous one (e.g. wmt19), and add the new data:\r\n- in wmt_utils.py, add the new data subsets. You need to provide the download URLs, as well as the target and source languages\r\n- in wmt21.py (renamed from wmt19.py), you can specify the subsets that WMT21 uses (i.e. the one you just added)\r\n- in wmt_utils.py, define the python function that must be used to parse the subsets you added. To do so, you must go in `_generate_examples` and chose the proper `sub_generator` based on the subset name. For example, the `paracrawl_v3` subset uses the `_parse_tmx` function:\r\n\r\nhttps://github.com/huggingface/datasets/blob/ede72d3f9796339701ec59899c7c31d2427046fb/datasets/wmt19/wmt_utils.py#L834-L835\r\n\r\nHopefully the data is in a format that is already supported and there's no need to write a new `_parse_*` function for the new subsets. Let me know if you have questions or if I can help :)", "@Muennighoff , @lhoestq let me know if you want me to look into this. Happy to help bring WMT21 & WMT22 datasets into πŸ€— ! ", "Hi @srhrshr :) Sure, feel free to create a dataset repository on the Hub and start from the implementation of WMT19 if you want. Then we can move the dataset under the WMT org (we'll move the other ones there as well).\r\n\r\nLet me know if you have questions or if I can help", "#self-assign", "Hello @lhoestq ,\r\n\r\nWould it be possible for me to be granted in the WMT organization (on hf ofc) in order to facilitate dataset uploads? I've already initiated the joining process at this link: https://huggingface.co/wmt\r\n\r\nI appreciate your help with this. Thank you!", "Hi ! Cool I just added you" ]
## Adding a Dataset - **Name:** WMT21 & WMT22 - **Description:** We are going to have three tracks: two small tasks and a large task. The small tracks evaluate translation between fairly related languages and English (all pairs). The large track uses 101 languages. - **Paper:** / - **Data:** https://statmt.org/wmt21/large-scale-multilingual-translation-task.html https://statmt.org/wmt22/large-scale-multilingual-translation-task.html - **Motivation:** Many more languages than previous WMT versions - Could be very high impact Instructions to add a new dataset can be found [here](https://github.com/huggingface/datasets/blob/main/ADD_NEW_DATASET.md). I could also tackle this. I saw the existing logic for WMT models is a bit complex (datasets are stored on the wmt account & retrieved in separate wmt datasets afaict). How long do you think it would take me? @lhoestq
4,709
https://github.com/huggingface/datasets/issues/4707
Dataset Viewer issue for TheNoob3131/mosquito-data
[ "Thanks for reporting. I refreshed the dataset viewer and it now works as expected.\r\n\r\nhttps://huggingface.co/datasets/TheNoob3131/mosquito-data\r\n\r\n<img width=\"1135\" alt=\"Capture d’écran 2022-07-18 aΜ€ 13 15 22\" src=\"https://user-images.githubusercontent.com/1676121/179566497-e47f1a27-fd84-4a8d-9d7f-2e0f2da803df.png\">\r\n\r\nWe will investigate why it occurred in the first place\r\n", "By chance, could you provide some details about the operations done on the dataset: was it private? gated?", "Yes, it was a private dataset, and when I made it public, the Dataset Preview did not work. \r\n\r\nHowever, now when I make the dataset private, it says that the Dataset Preview has been disabled. Why is this?", "Thanks for the details. For now, the dataset viewer is always disabled on private datasets (see https://huggingface.co/docs/hub/datasets-viewer for more details)", "Hi, it was working fine for a few hours, but then I can't see the dataset viewer again (public dataset). Why is this still happening?\r\nIt's the same error too:\r\n![image](https://user-images.githubusercontent.com/53668030/179602465-f220f971-d3aa-49ba-a31b-60510f4c2a89.png)\r\n", "OK? This is a bug, thanks for help spotting and reproducing it (it occurs when a dataset is switched to private, then to public). We will be working on it, meanwhile, I've restored the dataset viewer manually again." ]
### Link _No response_ ### Description Getting this error when trying to view dataset preview: Message: 401, message='Unauthorized', url=URL('https://huggingface.co/datasets/TheNoob3131/mosquito-data/resolve/8aceebd6c4a359d216d10ef020868bd9e8c986dd/0_Africa_train.csv') ### Owner _No response_
4,707
https://github.com/huggingface/datasets/issues/4702
Domain specific dataset discovery on the Hugging Face hub
[ "Hi! I added a link to this issue in our internal request for adding keywords/topics to the Hub, which is identical to the `topic tags` solution. The `collections` solution seems too complex (as you point out). Regarding the `domain tags` solution, we primarily focus on machine learning, so I'm not sure if it's a good idea to make our current taxonomy more complex.", "> Hi! I added a link to this issue in our internal request for adding keywords/topics to the Hub, which is identical to the `topic tags` solution. The `collections` solution seems too complex (as you point out). Regarding the `domain tags` solution, we primarily focus on machine learning, so I'm not sure if it's a good idea to make our current taxonomy more complex.\r\n\r\nThanks, for letting me know. Will you allow the topic tags to be user-generated or only chosen from a list?", "Thanks for opening this issue @davanstrien.\r\n\r\nAs we discussed last week, the tag approach would be in principle the simpler to be implemented, either the domain tag (with closed vocabulary: more reliable but also more rigid), or the topic tag (with open vocabulary: more flexible for user needs)", "Hi @davanstrien If i remember correctly this was also discussed inside a hf.co Discussion, would you be able to link it here too?\r\n\r\n(where i suggested using `tags: - foo - bar` IIRC.\r\n\r\nThanks a ton!", "> Hi @davanstrien If i remember correctly this was also discussed inside a hf.co Discussion, would you be able to link it here too?\r\n> \r\n> (where i suggested using `tags: - foo - bar` IIRC.\r\n> \r\n> Thanks a ton!\r\n\r\nThis doesn't ring a bell - I did a quick search of https://discuss.huggingface.co but didn't find anything. \r\n\r\nThe `tags: ` approach sounds like a good option for this. It would be especially nice if these could suggest existing tags, but this probably won't be easily possible through the current interface. \r\n", "I opened a PR to add \"tags\" to the YAML validator:\r\nhttps://github.com/huggingface/datasets/pull/4716\r\n\r\nI also added \"tags\" to the [tagging app](https://huggingface.co/spaces/huggingface/datasets-tagging), with suggestions like \"bio\" or \"newspapers\"", "Thanks @lhoestq for the initiative.\r\n \r\nJust one question: are \"tags\" already supported on the Hub? \r\n\r\nI think they aren't. Thus, the Hub should support them so that they are properly displayed.", "I think they're not displayed, but at least it should enable users to filter by tag in using `huggingface_hub` or using the appropriate query params on the website (not sure if it's possible yet though)", "> I think they're not displayed, but at least it should enable users to filter by tag in using `huggingface_hub` or using the appropriate query params on the website (not sure if it's possible yet though)\r\n\r\nI think this would already be a helpful start. I'm happy to try this out with the datasets added to https://huggingface.co/organizations/biglam and use the `huggingface_hub` to filter those datasets using the tags. ", "Is this abandoned? \r\nI'm looking for a transport logistics dataset; how can I find one?", "@younes-io Full text search is probably your best bet: https://huggingface.co/search/full-text?type=dataset" ]
**Is your feature request related to a problem? Please describe.** ## The problem The datasets hub currently has `8,239` datasets. These datasets span a wide range of different modalities and tasks (currently with a bias towards textual data). There are various ways of identifying datasets that may be relevant for a particular use case: - searching - various filters Currently, however, there isn't an easy way to identify datasets belonging to a specific domain. For example, I want to browse machine learning datasets related to 'social science' or 'climate change research'. The ability to identify datasets relating to a specific domain has come up in discussions around the [BigLA](https://github.com/bigscience-workshop/lam/) datasets hackathon https://github.com/bigscience-workshop/lam/discussions/31#discussioncomment-3123610. As part of the hackathon, we're currently collecting datasets related to Libraries, Archives and Museums and making them available via the hub. We currently do this under a Hugging Face organization (https://huggingface.co/biglam). However, going forward, I can see some of these datasets being migrated to sit under an organization that is the custodian of the dataset (for example, a national library the data was originally from). At this point, it becomes more difficult to quickly identify datasets from this domain without relying on search. This is also related to some existing issues on Github related to metadata on the hub: - https://github.com/huggingface/datasets/issues/3625 - https://github.com/huggingface/datasets/issues/3877 **Describe the solution you'd like** ### Some possible solutions that may help with this: #### Enable domain tags (from a controlled vocabulary) - This would add metadata field to the YAML for the domain a dataset relates to - Advantages: - the list is controlled, allowing it to be more easily integrated into the datasets tag app (https://huggingface.co/space/huggingface/datasets-tagging) - the controlled vocabulary could align with an existing controlled vocabulary - this additional metadata can be used to perform filtering by domain - disadvantages - choosing the best controlled vocab may be difficult - there are many datasets that are likely to fit into the 'machine learning' domain (i.e. there is a long tail of datasets that aren't in more 'generic' machine learning domain #### Enable topic tags (user-generated) Enable 'free form' topic tags for datasets and models. This would be closer to GitHub's repository topics which can be chosen from a controlled list (https://github.com/topics/) but can also be more user/org specific. This could potentially be useful for organizations to also manage their own models and datasets as the number they hold in their org grows. For example, they may create 'topic tags' for a specific project, so it's clearer which datasets /models are related to that project. #### Collections This solution would likely be the biggest shift and may require significant changes in the hub fronted. Collections could work in several different ways but would include: Users can curate particular datasets, models, spaces, etc., into a collection. For example, they may create a collection of 'historic newspapers suitable for training language models'. These collections would not be mutually exclusive, i.e. a dataset can belong to zero, one or many collections. Collections can also potentially be nested under other collections. This is fairly common on other data reposotiores for example the following collections: <img width="293" alt="Screenshot 2022-07-18 at 11 50 44" src="https://user-images.githubusercontent.com/8995957/179496445-963ed122-5e26-4574-96e8-41081bce3e2b.png"> all belong under a higher level collection (https://bl.iro.bl.uk/collections/353c908d-b495-4413-b047-87236d2573e3?locale=en). There are different models one could use for how these collections could be created: - only within an org - for any dataset/model - the owner or a dataset/model has to agree to be added to a collection - a collection owner can have people suggest additions to their collection - other models.... These collections could be thematic, related to particular training approaches, curate models with particular inference properties etc. Whilst some of these features may duplicate current/or future tag filters on the hub, they offer the advantage of being flexible and not having to predict what users will want to do upfront. There is also potential for automating the creation of these collections based on existing metadata. For example, one could collect models trained on a collection of datasets so for example, if we had a collection of 'historic newspapers suitable for training language models' that contained 30 datasets, we could create another collection 'historic newspaper language models' that takes any model on the hub whose metadata says it used one or more of those 30 datasets. There is also the option of exploring ML approaches to suggest models/datasets may be relevant to a particular collection. This approach is likely to be quite difficult to implement well and would require significant thought. There is also likely to be a benefit in doing quite a bit of upfront work in curating useful collections to demonstrate the benefits of collections. **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. It is possible to collate this information externally, i.e. one could link back to the relevant models/datasets from an external platform. **Additional context** Add any other context about the feature request here. I'm cc'ing others involved in the BigLAM hackathon who may also have thoughts @cakiki @clancyoftheoverflow @albertvillanova
4,702
https://github.com/huggingface/datasets/issues/4697
Trouble with streaming frgfm/imagenette vision dataset with TAR archive
[ "Hi @frgfm, thanks for reporting.\r\n\r\nAs the error message says, streaming mode is not supported out of the box when the dataset contains TAR archive files.\r\n\r\nTo make the dataset streamable, you have to use `dl_manager.iter_archive`.\r\n\r\nThere are several examples in other datasets, e.g. food101: https://huggingface.co/datasets/food101/blob/main/food101.py\r\n\r\nAnd yes, as the link you pointed out, for the streaming to be possible, the metadata file must be loaded before all of the images:\r\n- either this is the case when iterating the archive (and you get the metadata file before the images)\r\n- or you have to extract the metadata file by hand and upload it separately to the Hub", "Hi @albertvillanova :wave:\r\n\r\nThanks! Yeah I saw that but since I didn't have any metadata, I wasn't sure whether I should create them myself.\r\n\r\nSo one last question:\r\nWhat is the metadata supposed to be for archives? The relative path of all files in it?\r\n_(Sorry I'm a bit confused since it's quite hard to debug using the single error message from the data preview :sweat_smile: )_", "Hi @frgfm, streaming a dataset that contains a TAR file requires some tweaks because (contrary to ZIP files), tha TAR archive does not allow random access to any of the contained member files. Instead they have to be accessed sequentially (in the order in which they were put into the TAR file when created) and yielded.\r\n\r\nSo when iterating over the TAR file content, when an image file is found, we need to yield it (and not keeping it in memory, which will require huge RAM memory for large datasets). But when yielding an image file, we also need to yield with it what we call \"metadata\": the class label, and other textual information (for example, for audio files, sometimes we also add info such as the speaker ID, their sex, their age,...).\r\n\r\nAll this information usually is stored in what we call the metadata file: either a JSON or a CSV/TSV file.\r\n\r\nBut if this is also inside the TAR archive, we need to find this file in the first place when iterating the TAR archive, so that we already have this information when we find an image file and we can yield the image file and its metadata info.\r\n\r\nTherefore:\r\n- either the TAR archive contains the metadata file as the first member when iterating it (something we cannot change as it is done at the creation of the TAR file)\r\n- or if not, then we need to have the metadata file elsewhere\r\n - in these cases, what we do (if the dataset license allows it) is:\r\n - we download the TAR file locally, we extract the metadata file and we host the metadata on the Hub\r\n - we modify the dataset loading script so that it first downloads the metadata file (and reads it) and only then starts iterating the content of the TAR archive file\r\n\r\nSee an example of this process we recently did for \"google/fleurs\" (their metadata files for \"train\" were at the end of the TAR archives, after all audio files): https://huggingface.co/datasets/google/fleurs/discussions/4\r\n- we uploaded the metadata file to the Hub\r\n- we adapted the loading script to use it", "Hi @albertvillanova :wave: \r\n\r\nThanks, since my last message, I went through the repo of https://huggingface.co/datasets/food101/blob/main/food101.py and managed to get it to work in the end :pray: \r\n\r\nHere it is: https://huggingface.co/datasets/frgfm/imagenette\r\n\r\nI appreciate you opening an issue to document the process, it might help a few!", "Great to see that you manage to make your dataset streamable. :rocket: \r\n\r\nI'm closing this issue, as for the docs update there is another issue opened:\r\n- #4711" ]
### Link https://huggingface.co/datasets/frgfm/imagenette ### Description Hello there :wave: Thanks for the amazing work you've done with HF Datasets! I've just started playing with it, and managed to upload my first dataset. But for the second one, I'm having trouble with the preview since there is some archive extraction involved :sweat_smile: Basically, I get a: ``` Status code: 400 Exception: NotImplementedError Message: Extraction protocol for TAR archives like 'https://s3.amazonaws.com/fast-ai-imageclas/imagenette2.tgz' is not implemented in streaming mode. Please use `dl_manager.iter_archive` instead. ``` I've tried several things and checked this issue https://github.com/huggingface/datasets/issues/4181 as well, but no luck so far! Could you point me in the right direction please? :pray: ### Owner Yes
4,697
https://github.com/huggingface/datasets/issues/4696
Cannot load LinCE dataset
[ "Hi @finiteautomata, thanks for reporting.\r\n\r\nUnfortunately, I'm not able to reproduce your issue:\r\n```python\r\nIn [1]: from datasets import load_dataset\r\n ...: dataset = load_dataset(\"lince\", \"ner_spaeng\")\r\nDownloading builder script: 20.8kB [00:00, 9.09MB/s] \r\nDownloading metadata: 31.2kB [00:00, 13.5MB/s] \r\nDownloading and preparing dataset lince/ner_spaeng (download: 2.93 MiB, generated: 18.45 MiB, post-processed: Unknown size, total: 21.38 MiB) to .../.cache/huggingface/datasets/lince/ner_spaeng/1.0.0/10d41747f55f0849fa84ac579ea1acfa7df49aa2015b60426bc459c111b3d589...\r\nDownloading data: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 3.08M/3.08M [00:01<00:00, 2.73MB/s]\r\nDataset lince downloaded and prepared to .../.cache/huggingface/datasets/lince/ner_spaeng/1.0.0/10d41747f55f0849fa84ac579ea1acfa7df49aa2015b60426bc459c111b3d589. Subsequent calls will reuse this data.\r\n100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 3/3 [00:00<00:00, 630.66it/s]\r\n\r\nIn [2]: dataset\r\nOut[2]: \r\nDatasetDict({\r\n train: Dataset({\r\n features: ['idx', 'words', 'lid', 'ner'],\r\n num_rows: 33611\r\n })\r\n validation: Dataset({\r\n features: ['idx', 'words', 'lid', 'ner'],\r\n num_rows: 10085\r\n })\r\n test: Dataset({\r\n features: ['idx', 'words', 'lid', 'ner'],\r\n num_rows: 23527\r\n })\r\n})\r\n``` \r\n\r\nPlease note that for this dataset, the original data files are not hosted on the Hugging Face Hub, but on https://ritual.uh.edu\r\nAnd sometimes, the server might be temporarily unavailable, as your error message said (trying to connect to the server timed out):\r\n```\r\nConnectionError: Couldn't reach https://ritual.uh.edu/lince/libaccess/eyJ1c2VybmFtZSI6ICJodWdnaW5nZmFjZSBubHAiLCAidXNlcl9pZCI6IDExMSwgImVtYWlsIjogImR1bW15QGVtYWlsLmNvbSJ9/ner_spaeng.zip (ConnectTimeout(MaxRetryError(\"HTTPSConnectionPool(host='ritual.uh.edu', port=443): Max retries exceeded with url: /lince/libaccess/eyJ1c2VybmFtZSI6ICJodWdnaW5nZmFjZSBubHAiLCAidXNlcl9pZCI6IDExMSwgImVtYWlsIjogImR1bW15QGVtYWlsLmNvbSJ9/ner_spaeng.zip (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7feb1c45a690>, 'Connection to ritual.uh.edu timed out. (connect timeout=100)'))\")))\r\n```\r\nIn these cases you could:\r\n- either contact the owners of the data server where the data is hosted to inform them about the issue in their server\r\n- or re-try after waiting some time: usually these issues are just temporary", "Great, thanks for checking out!" ]
## Describe the bug Cannot load LinCE dataset due to a connection error ## Steps to reproduce the bug ```python from datasets import load_dataset dataset = load_dataset("lince", "ner_spaeng") ``` A notebook with this code and corresponding error can be found at https://colab.research.google.com/drive/1pgX3bNB9amuUwAVfPFm-XuMV5fEg-cD2 ## Expected results It should load the dataset ## Actual results ```python --------------------------------------------------------------------------- ConnectionError Traceback (most recent call last) <ipython-input-2-fc551ddcebef> in <module>() 1 from datasets import load_dataset 2 ----> 3 dataset = load_dataset("lince", "ner_spaeng") 10 frames /usr/local/lib/python3.7/dist-packages/datasets/load.py in load_dataset(path, name, data_dir, data_files, split, cache_dir, features, download_config, download_mode, ignore_verifications, keep_in_memory, save_infos, revision, use_auth_token, task, streaming, **config_kwargs) 1682 ignore_verifications=ignore_verifications, 1683 try_from_hf_gcs=try_from_hf_gcs, -> 1684 use_auth_token=use_auth_token, 1685 ) 1686 /usr/local/lib/python3.7/dist-packages/datasets/builder.py in download_and_prepare(self, download_config, download_mode, ignore_verifications, try_from_hf_gcs, dl_manager, base_path, use_auth_token, **download_and_prepare_kwargs) 703 if not downloaded_from_gcs: 704 self._download_and_prepare( --> 705 dl_manager=dl_manager, verify_infos=verify_infos, **download_and_prepare_kwargs 706 ) 707 # Sync info /usr/local/lib/python3.7/dist-packages/datasets/builder.py in _download_and_prepare(self, dl_manager, verify_infos) 1219 1220 def _download_and_prepare(self, dl_manager, verify_infos): -> 1221 super()._download_and_prepare(dl_manager, verify_infos, check_duplicate_keys=verify_infos) 1222 1223 def _get_examples_iterable_for_split(self, split_generator: SplitGenerator) -> ExamplesIterable: /usr/local/lib/python3.7/dist-packages/datasets/builder.py in _download_and_prepare(self, dl_manager, verify_infos, **prepare_split_kwargs) 769 split_dict = SplitDict(dataset_name=self.name) 770 split_generators_kwargs = self._make_split_generators_kwargs(prepare_split_kwargs) --> 771 split_generators = self._split_generators(dl_manager, **split_generators_kwargs) 772 773 # Checksums verification /root/.cache/huggingface/modules/datasets_modules/datasets/lince/10d41747f55f0849fa84ac579ea1acfa7df49aa2015b60426bc459c111b3d589/lince.py in _split_generators(self, dl_manager) 481 def _split_generators(self, dl_manager): 482 """Returns SplitGenerators.""" --> 483 lince_dir = dl_manager.download_and_extract(f"{_LINCE_URL}/{self.config.name}.zip") 484 data_dir = os.path.join(lince_dir, self.config.data_dir) 485 return [ /usr/local/lib/python3.7/dist-packages/datasets/download/download_manager.py in download_and_extract(self, url_or_urls) 429 extracted_path(s): `str`, extracted paths of given URL(s). 430 """ --> 431 return self.extract(self.download(url_or_urls)) 432 433 def get_recorded_sizes_checksums(self): /usr/local/lib/python3.7/dist-packages/datasets/download/download_manager.py in download(self, url_or_urls) 313 num_proc=download_config.num_proc, 314 disable_tqdm=not is_progress_bar_enabled(), --> 315 desc="Downloading data files", 316 ) 317 duration = datetime.now() - start_time /usr/local/lib/python3.7/dist-packages/datasets/utils/py_utils.py in map_nested(function, data_struct, dict_only, map_list, map_tuple, map_numpy, num_proc, types, disable_tqdm, desc) 346 # Singleton 347 if not isinstance(data_struct, dict) and not isinstance(data_struct, types): --> 348 return function(data_struct) 349 350 disable_tqdm = disable_tqdm or not logging.is_progress_bar_enabled() /usr/local/lib/python3.7/dist-packages/datasets/download/download_manager.py in _download(self, url_or_filename, download_config) 333 # append the relative path to the base_path 334 url_or_filename = url_or_path_join(self._base_path, url_or_filename) --> 335 return cached_path(url_or_filename, download_config=download_config) 336 337 def iter_archive(self, path_or_buf: Union[str, io.BufferedReader]): /usr/local/lib/python3.7/dist-packages/datasets/utils/file_utils.py in cached_path(url_or_filename, download_config, **download_kwargs) 195 use_auth_token=download_config.use_auth_token, 196 ignore_url_params=download_config.ignore_url_params, --> 197 download_desc=download_config.download_desc, 198 ) 199 elif os.path.exists(url_or_filename): /usr/local/lib/python3.7/dist-packages/datasets/utils/file_utils.py in get_from_cache(url, cache_dir, force_download, proxies, etag_timeout, resume_download, user_agent, local_files_only, use_etag, max_retries, use_auth_token, ignore_url_params, download_desc) 531 _raise_if_offline_mode_is_enabled(f"Tried to reach {url}") 532 if head_error is not None: --> 533 raise ConnectionError(f"Couldn't reach {url} ({repr(head_error)})") 534 elif response is not None: 535 raise ConnectionError(f"Couldn't reach {url} (error {response.status_code})") ConnectionError: Couldn't reach https://ritual.uh.edu/lince/libaccess/eyJ1c2VybmFtZSI6ICJodWdnaW5nZmFjZSBubHAiLCAidXNlcl9pZCI6IDExMSwgImVtYWlsIjogImR1bW15QGVtYWlsLmNvbSJ9/ner_spaeng.zip (ConnectTimeout(MaxRetryError("HTTPSConnectionPool(host='ritual.uh.edu', port=443): Max retries exceeded with url: /lince/libaccess/eyJ1c2VybmFtZSI6ICJodWdnaW5nZmFjZSBubHAiLCAidXNlcl9pZCI6IDExMSwgImVtYWlsIjogImR1bW15QGVtYWlsLmNvbSJ9/ner_spaeng.zip (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7feb1c45a690>, 'Connection to ritual.uh.edu timed out. (connect timeout=100)'))"))) ``` ## Environment info - `datasets` version: 2.3.2 - Platform: Linux-5.4.188+-x86_64-with-Ubuntu-18.04-bionic - Python version: 3.7.13 - PyArrow version: 6.0.1 - Pandas version: 1.3.5
4,696
https://github.com/huggingface/datasets/issues/4694
Distributed data parallel training for streaming datasets
[ "Hi ! According to https://huggingface.co/docs/datasets/use_with_pytorch#stream-data you can use the pytorch DataLoader with `num_workers>0` to distribute the shards across your workers (it uses `torch.utils.data.get_worker_info()` to get the worker ID and select the right subsets of shards to use)\r\n\r\n<s> EDIT: here is a code example </s>\r\n```python\r\n# ds = ds.with_format(\"torch\")\r\n# dataloader = DataLoader(ds, num_workers=num_workers)\r\n```\r\n\r\nEDIT: `with_format(\"torch\")` is not required, now you can just do\r\n```python\r\ndataloader = DataLoader(ds, num_workers=num_workers)\r\n```", "@cyk1337 does streaming datasets with multi-gpu works for you? I am testing on one node with multiple gpus, but this is freezing, https://github.com/huggingface/datasets/issues/5123 \r\nIn case you could make this work, could you share with me your data-loading codes?\r\nthank you", "+1", "This has been implemented in `datasets` 2.8:\r\n```python\r\nfrom datasets.distributed import split_dataset_by_node\r\n\r\nds = split_dataset_by_node(ds, rank=rank, world_size=world_size)\r\n```\r\n\r\ndocs: https://huggingface.co/docs/datasets/use_with_pytorch#distributed", "i'm having hanging issues with this when using DDP and allocating the datasets with `split_dataset_by_node` πŸ€”\r\n\r\n--- \r\n### edit\r\nI don't want to pollute this thread, but for the sake of following up, I observed hanging close to the final iteration of the dataloader. I think this was happening on the final shard. First, I removed the final shard and things worked. Then (including all shards), I reordered the list of shards: `load_dataset('json', data_files=reordered, streaming=True)` and no hang. \r\n\r\nI won't open an issue yet bc I am not quite sure about this observation.", "@wconnell would you mind opening a different bug issue and giving more details?\r\nhttps://github.com/huggingface/datasets/issues/new?assignees=&labels=&template=bug-report.yml\r\n\r\nThanks." ]
### Feature request Any documentations for the the `load_dataset(streaming=True)` for (multi-node multi-GPU) DDP training? ### Motivation Given a bunch of data files, it is expected to split them onto different GPUs. Is there a guide or documentation? ### Your contribution Does it requires manually split on data files for each worker in `DatasetBuilder._split_generator()`? What is`IterableDatasetShard` expected to do?
4,694
https://github.com/huggingface/datasets/issues/4692
Unable to cast a column with `Image()` by using the `cast_column()` feature
[ "Hi, thanks for reporting! A PR (https://github.com/huggingface/datasets/pull/4614) has already been opened to address this issue." ]
## Describe the bug A clear and concise description of what the bug is. When I create a dataset, then add a column to the created dataset through the `dataset.add_column` feature and then try to cast a column of the dataset (this column contains image paths) with `Image()` by using the `cast_column()` feature, I get the following error - ``` TypeError: Couldn't cast array of type string to {'bytes': Value(dtype='binary', id=None), 'path': Value(dtype='string', id=None)} ``` When I try and cast the same column, but without doing the `add_column` in the previous step, it works as expected. ## Steps to reproduce the bug ```python from datasets import Dataset, Image data_dict = { "img_path": ["https://picsum.photos/200/300"] } dataset = Dataset.from_dict(data_dict) #NOTE Comment out this line and use cast_column and it works properly dataset = dataset.add_column("yeet", [1]) #NOTE This line fails to execute properly if `add_column` is called before dataset = dataset.cast_column("img_path", Image()) # #NOTE This is my current workaround. This seems to work fine with/without `add_column`. While # # running this, make sure to comment out the `cast_column` line # new_features = dataset.features.copy() # new_features["img_path"] = Image() # dataset = dataset.cast(new_features) print(dataset) print(dataset.features) print(dataset[0]) ``` ## Expected results A clear and concise description of the expected results. Able to successfully use `cast_column` to cast a column containing img_paths to now be Image() features after modifying the dataset using `add_column` in a previous step ## Actual results Specify the actual results or traceback. ``` Traceback (most recent call last): File "/home/surya/Desktop/hf_bug_test.py", line 14, in <module> dataset = dataset.cast_column("img_path", Image()) File "/home/surya/anaconda3/envs/snap_test/lib/python3.9/site-packages/datasets/fingerprint.py", line 458, in wrapper out = func(self, *args, **kwargs) File "/home/surya/anaconda3/envs/snap_test/lib/python3.9/site-packages/datasets/arrow_dataset.py", line 1580, in cast_column dataset._data = dataset._data.cast(dataset.features.arrow_schema) File "/home/surya/anaconda3/envs/snap_test/lib/python3.9/site-packages/datasets/table.py", line 1487, in cast new_tables.append(subtable.cast(subschema, *args, **kwargs)) File "/home/surya/anaconda3/envs/snap_test/lib/python3.9/site-packages/datasets/table.py", line 834, in cast return InMemoryTable(table_cast(self.table, *args, **kwargs)) File "/home/surya/anaconda3/envs/snap_test/lib/python3.9/site-packages/datasets/table.py", line 1897, in table_cast return cast_table_to_schema(table, schema) File "/home/surya/anaconda3/envs/snap_test/lib/python3.9/site-packages/datasets/table.py", line 1880, in cast_table_to_schema arrays = [cast_array_to_feature(table[name], feature) for name, feature in features.items()] File "/home/surya/anaconda3/envs/snap_test/lib/python3.9/site-packages/datasets/table.py", line 1880, in <listcomp> arrays = [cast_array_to_feature(table[name], feature) for name, feature in features.items()] File "/home/surya/anaconda3/envs/snap_test/lib/python3.9/site-packages/datasets/table.py", line 1673, in wrapper return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks]) File "/home/surya/anaconda3/envs/snap_test/lib/python3.9/site-packages/datasets/table.py", line 1673, in <listcomp> return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks]) File "/home/surya/anaconda3/envs/snap_test/lib/python3.9/site-packages/datasets/table.py", line 1846, in cast_array_to_feature raise TypeError(f"Couldn't cast array of type\n{array.type}\nto\n{feature}") TypeError: Couldn't cast array of type string to {'bytes': Value(dtype='binary', id=None), 'path': Value(dtype='string', id=None)} ``` ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: 2.3.2 - Platform: Ubuntu 20.04.3 LTS - Python version: 3.9.7 - PyArrow version: 7.0.0
4,692
https://github.com/huggingface/datasets/issues/4691
Dataset Viewer issue for rajistics/indian_food_images
[ "Hi, thanks for reporting. I triggered a refresh of the preview for this dataset, and it works now. I'm not sure what occurred.\r\n<img width=\"1019\" alt=\"Capture d’écran 2022-07-18 aΜ€ 11 01 52\" src=\"https://user-images.githubusercontent.com/1676121/179541327-f62ecd5e-a18a-4d91-b316-9e2ebde77a28.png\">\r\n\r\n" ]
### Link https://huggingface.co/datasets/rajistics/indian_food_images/viewer/rajistics--indian_food_images/train ### Description I have a train/test split in my dataset <img width="410" alt="Screen Shot 2022-07-15 at 11 44 42 AM" src="https://user-images.githubusercontent.com/6808012/179293215-7b419ec3-3527-46f2-8dad-adbc5568cfa0.png"> t The dataset viewer works for the test split (images of indian food), but does not show my train split. My guess is maybe there is some corrupt image file that is guessing this. But I have no idea. The original dataset was pulled from here: https://www.kaggle.com/datasets/l33tc0d3r/indian-food-classification?resource=download-directory ### Owner Yes
4,691
https://github.com/huggingface/datasets/issues/4684
How to assign new values to Dataset?
[ "Hi! One option is use `map` with a function that overwrites the labels (`dset = dset.map(lamba _: {\"label\": 0}, features=dset.features`)). Or you can use the `remove_column` + `add_column` combination (`dset = dset.remove_columns(\"label\").add_column(\"label\", [0]*len(data)).cast(dset.features)`, but note that this approach creates an in-memory table for the added column instead of writing to disk, which could be problematic for large datasets.", "Hi! I tried your proposed solution, but it does not solve my problem unfortunately. I am working with a set of protein sequences that have been tokenized with ESM, but some sequences are longer than `max_length`, they have been truncated in the tokenization. So now I want to truncate my labels as well, but that does not work with a mapping (e.g. `dset.map` as you suggested). Specifically, what I did was the following:\r\n\r\n```\r\ndef postprocess_tokenize(tokenized_data):\r\n \"\"\"\r\n adjust label lengths if they dont match.\r\n \"\"\"\r\n if len(tokenized_data['input_ids']) < len(tokenized_data['labels']):\r\n new_labels = tokenized_data['labels'][:len(tokenized_data['input_ids'])]\r\n tokenized_data[\"labels\"] = new_labels\r\n return tokenized_data\r\n\r\ntokenized_data = tokenized_data.map(postprocess_tokenize, batched=True) # this does not adjust the labels...\r\n```\r\n\r\nAny tips on how to do this properly?\r\n\r\nMore generally, I am wondering why the DataCollator supports padding but does not support truncation? Seems odd to me.\r\n\r\nThanks in advance!" ]
![image](https://user-images.githubusercontent.com/37113676/179149159-bbbda0c8-a661-403c-87ed-dc2b4219cd68.png) Hi, if I want to change some values of the dataset, or add new columns to it, how can I do it? For example, I want to change all the labels of the SST2 dataset to `0`: ```python from datasets import load_dataset data = load_dataset('glue','sst2') data['train']['label'] = [0]*len(data) ``` I will get the error: ``` TypeError: 'Dataset' object does not support item assignment ```
4,684
https://github.com/huggingface/datasets/issues/4682
weird issue/bug with columns (dataset iterable/stream mode)
[]
I have a dataset online (CloverSearch/cc-news-mutlilingual) that has a bunch of columns, two of which are "score_title_maintext" and "score_title_description". the original files are jsonl formatted. I was trying to iterate through via streaming mode and grab all "score_title_description" values, but I kept getting key not found after a certain point of iteration. I found that some json objects in the file don't have "score_title_description". And in SOME cases, this returns a NONE and in others it just gets a key error. Why is there an inconsistency here and how can I fix it?
4,682
https://github.com/huggingface/datasets/issues/4681
IndexError when loading ImageFolder
[ "Hi, thanks for reporting! If there are no examples in ImageFolder, the `label` column is of type `ClassLabel(names=[])`, which leads to an error in [this line](https://github.com/huggingface/datasets/blob/c15b391942764152f6060b59921b09cacc5f22a6/src/datasets/arrow_writer.py#L387) as `asdict(info)` calls `Features({..., \"label\": {'num_classes': 0, 'names': [], 'id': None, '_type': 'ClassLabel'}})`, which then calls `require_decoding` [here](https://github.com/huggingface/datasets/blob/c15b391942764152f6060b59921b09cacc5f22a6/src/datasets/features/features.py#L1516) on the dict value it does not expect.\r\n\r\nI see two ways to fix this:\r\n* custom `asdict` where `dict_factory` is also applied on the `dict` object itself besides dataclasses (the built-in implementation calls `type(dict_obj)` - this means we also need to fix `Features.to_dict` btw) \r\n* implement `DatasetInfo.to_dict` (though adding `to_dict` to a data class is a bit weird IMO)\r\n\r\n@lhoestq Which one of these approaches do you like more?\r\n", "Small pref for the first option, it feels weird to know that `Features()` can be called with a dictionary of types defined as dictionaries instead of type instances." ]
## Describe the bug Loading an image dataset with `imagefolder` throws `IndexError: list index out of range` when the given folder contains a non-image file (like a csv). ## Steps to reproduce the bug Put a csv file in a folder with images and load it: ```python import datasets datasets.load_dataset("imagefolder", data_dir=path/to/folder) ``` ## Expected results I would expect a better error message, like `Unsupported file` or even the dataset loader just ignoring every file that is not an image in that case. ## Actual results Here is the whole traceback: ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: 2.3.2 - Platform: Linux-5.11.0-051100-generic-x86_64-with-glibc2.27 - Python version: 3.9.9 - PyArrow version: 8.0.0 - Pandas version: 1.4.3
4,681
https://github.com/huggingface/datasets/issues/4680
Dataset Viewer issue for codeparrot/xlcost-text-to-code
[ "There seems to be an issue with the `C++-snippet-level` config:\r\n\r\n```python\r\n>>> from datasets import get_dataset_split_names\r\n>>> get_dataset_split_names(\"codeparrot/xlcost-text-to-code\", \"C++-snippet-level\")\r\nTraceback (most recent call last):\r\n File \"/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/inspect.py\", line 352, in get_dataset_config_info\r\n info.splits = {\r\nTypeError: 'NoneType' object is not iterable\r\n\r\nThe above exception was the direct cause of the following exception:\r\n\r\nTraceback (most recent call last):\r\n File \"<stdin>\", line 1, in <module>\r\n File \"/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/inspect.py\", line 404, in get_dataset_split_names\r\n info = get_dataset_config_info(\r\n File \"/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/inspect.py\", line 359, in get_dataset_config_info\r\n raise SplitsNotFoundError(\"The split names could not be parsed from the dataset config.\") from err\r\ndatasets.inspect.SplitsNotFoundError: The split names could not be parsed from the dataset config.\r\n```\r\n\r\nI remove the dataset-viewer tag since it's not directly related.\r\n\r\nPinging @huggingface/datasets ", "Thanks I found that this subset wasn't properly defined the the config, I fixed it. Now I can see the subsets but I get this error for the viewer\r\n````\r\nStatus code: 400\r\nException: Status400Error\r\nMessage: The split cache is empty.\r\n```", "Yes, the cache is being refreshed, hopefully, it will work in some minutes for all the splits. Some are already here:\r\n\r\nhttps://huggingface.co/datasets/codeparrot/xlcost-text-to-code/viewer/Python-snippet-level/train\r\n\r\n<img width=\"1533\" alt=\"Capture d’écran 2022-07-18 aΜ€ 12 04 06\" src=\"https://user-images.githubusercontent.com/1676121/179553933-64d874fa-ada9-4b82-900e-082619523c20.png\">\r\n", "I think all the splits are working as expected now", "Perfect, thank you!" ]
### Link https://huggingface.co/datasets/codeparrot/xlcost-text-to-code ### Description Error ``` Server Error Status code: 400 Exception: TypeError Message: 'NoneType' object is not iterable ``` Before I did a minor change in the dataset script (removing some comments), the viewer was working but not properely, it wasn't showing the dataset subsets. But the data can be loaded successfully. Thanks! ### Owner Yes
4,680
https://github.com/huggingface/datasets/issues/4678
Cant pass streaming dataset to dataloader after take()
[ "Hi! Calling `take` on an iterable/streamable dataset makes it not possible to shard the dataset, which in turn disables multi-process loading (attempts to split the workload over the shards), so to go past this limitation, you can either use single-process loading in `DataLoader` (`num_workers=None`) or fetch the first `50_000/batch_size` batches in the loop." ]
## Describe the bug I am trying to pass a streaming version of c4 to a dataloader, but it can't be passed after I call `dataset.take(n)`. Some functions such as `shuffle()` can be applied without breaking the dataloader but not take. ## Steps to reproduce the bug ```python import datasets import torch dset = datasets.load_dataset(path='c4', name='en', split="train", streaming=True) dset = dset.take(50_000) dset = dset.with_format("torch") num_workers = 8 batch_size = 512 loader = torch.utils.data.DataLoader(dataset=dset, batch_size=batch_size, num_workers=num_workers) for batch in loader: ... ``` ## Expected results No error thrown when iterating over the dataloader ## Actual results Original Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop data = fetcher.fetch(index) File "/usr/local/lib/python3.9/dist-packages/torch/utils/data/_utils/fetch.py", line 32, in fetch data.append(next(self.dataset_iter)) File "/root/.local/lib/python3.9/site-packages/datasets/formatting/dataset_wrappers/torch_iterable_dataset.py", line 48, in __iter__ for key, example in self._iter_shard(shard_idx): File "/root/.local/lib/python3.9/site-packages/datasets/iterable_dataset.py", line 586, in _iter_shard yield from ex_iterable.shard_data_sources(shard_idx) File "/root/.local/lib/python3.9/site-packages/datasets/iterable_dataset.py", line 60, in shard_data_sources raise NotImplementedError(f"{type(self)} doesn't implement shard_data_sources yet") NotImplementedError: <class 'datasets.iterable_dataset.TakeExamplesIterable'> doesn't implement shard_data_sources yet ## Environment info - `datasets` version: 2.3.2 - Platform: Linux-5.4.0-120-generic-x86_64-with-glibc2.31 - Python version: 3.9.13 - PyArrow version: 8.0.0 - Pandas version: 1.4.3
4,678
https://github.com/huggingface/datasets/issues/4677
Random 400 Client Error when pushing dataset
[ "did you ever fix this? I'm experiencing the same", "I am having the same issue. Even the simple example from the documentation gives me the 400 Error\r\n\r\n\r\n> from datasets import load_dataset\r\n> \r\n> dataset = load_dataset(\"stevhliu/demo\")\r\n> dataset.push_to_hub(\"processed_demo\")\r\n\r\n\r\n`requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://huggingface.co/api/datasets/REDACTED/commit/main (Request ID: e-tPnYTiCdB5KPmSL86dQ)`\r\n\r\nI \"fixed\" it by initializing a new virtual environment with only datasets==2.5.2 installed.\r\n\r\nThe workaround consists of saving to disk then loading from disk and pushing to hub but from the new clean virtual environment." ]
## Describe the bug When pushing a dataset, the client errors randomly with `Bad Request for url:...`. At the next call, a new parquet file is created for each shard. The client may fail at any random shard. ## Steps to reproduce the bug ```python dataset.push_to_hub("ORG/DATASET", private=True, branch="main") ``` ## Expected results Push all the dataset to the Hub with no duplicates. If it fails, it should retry or fail, but continue from the last failed shard. ## Actual results ``` --------------------------------------------------------------------------- HTTPError Traceback (most recent call last) testing.ipynb Cell 29 in <cell line: 1>() ----> [1](testing.ipynb?line=0) dataset.push_to_hub("ORG/DATASET", private=True, branch="main") File ~/.local/lib/python3.9/site-packages/datasets/arrow_dataset.py:4297, in Dataset.push_to_hub(self, repo_id, split, private, token, branch, max_shard_size, shard_size, embed_external_files) 4291 warnings.warn( 4292 "'shard_size' was renamed to 'max_shard_size' in version 2.1.1 and will be removed in 2.4.0.", 4293 FutureWarning, 4294 ) 4295 max_shard_size = shard_size -> 4297 repo_id, split, uploaded_size, dataset_nbytes, repo_files, deleted_size = self._push_parquet_shards_to_hub( 4298 repo_id=repo_id, 4299 split=split, 4300 private=private, 4301 token=token, 4302 branch=branch, 4303 max_shard_size=max_shard_size, 4304 embed_external_files=embed_external_files, 4305 ) 4306 organization, dataset_name = repo_id.split("/") 4307 info_to_dump = self.info.copy() File ~/.local/lib/python3.9/site-packages/datasets/arrow_dataset.py:4195, in Dataset._push_parquet_shards_to_hub(self, repo_id, split, private, token, branch, max_shard_size, embed_external_files) 4193 shard.to_parquet(buffer) 4194 uploaded_size += buffer.tell() -> 4195 _retry( 4196 api.upload_file, 4197 func_kwargs=dict( 4198 path_or_fileobj=buffer.getvalue(), 4199 path_in_repo=shard_path_in_repo, 4200 repo_id=repo_id, 4201 token=token, 4202 repo_type="dataset", 4203 revision=branch, 4204 identical_ok=False, 4205 ), 4206 exceptions=HTTPError, 4207 status_codes=[504], 4208 base_wait_time=2.0, 4209 max_retries=5, 4210 max_wait_time=20.0, 4211 ) 4212 shards_path_in_repo.append(shard_path_in_repo) 4214 # Cleanup to remove unused files File ~/.local/lib/python3.9/site-packages/datasets/utils/file_utils.py:284, in _retry(func, func_args, func_kwargs, exceptions, status_codes, max_retries, base_wait_time, max_wait_time) 282 except exceptions as err: 283 if retry >= max_retries or (status_codes and err.response.status_code not in status_codes): --> 284 raise err 285 else: 286 sleep_time = min(max_wait_time, base_wait_time * 2**retry) # Exponential backoff File ~/.local/lib/python3.9/site-packages/datasets/utils/file_utils.py:281, in _retry(func, func_args, func_kwargs, exceptions, status_codes, max_retries, base_wait_time, max_wait_time) 279 while True: 280 try: --> 281 return func(*func_args, **func_kwargs) 282 except exceptions as err: 283 if retry >= max_retries or (status_codes and err.response.status_code not in status_codes): File ~/.local/lib/python3.9/site-packages/huggingface_hub/hf_api.py:1967, in HfApi.upload_file(self, path_or_fileobj, path_in_repo, repo_id, token, repo_type, revision, identical_ok, commit_message, commit_description, create_pr) 1957 commit_message = ( 1958 commit_message 1959 if commit_message is not None 1960 else f"Upload {path_in_repo} with huggingface_hub" 1961 ) 1962 operation = CommitOperationAdd( 1963 path_or_fileobj=path_or_fileobj, 1964 path_in_repo=path_in_repo, 1965 ) -> 1967 pr_url = self.create_commit( 1968 repo_id=repo_id, 1969 repo_type=repo_type, 1970 operations=[operation], 1971 commit_message=commit_message, 1972 commit_description=commit_description, 1973 token=token, 1974 revision=revision, 1975 create_pr=create_pr, 1976 ) 1977 if pr_url is not None: 1978 re_match = re.match(REGEX_DISCUSSION_URL, pr_url) File ~/.local/lib/python3.9/site-packages/huggingface_hub/hf_api.py:1844, in HfApi.create_commit(self, repo_id, operations, commit_message, commit_description, token, repo_type, revision, create_pr, num_threads) 1836 commit_url = f"{self.endpoint}/api/{repo_type}s/{repo_id}/commit/{revision}" 1838 commit_resp = requests.post( 1839 url=commit_url, 1840 headers={"Authorization": f"Bearer {token}"}, 1841 json=commit_payload, 1842 params={"create_pr": 1} if create_pr else None, 1843 ) -> 1844 _raise_for_status(commit_resp) 1845 return commit_resp.json().get("pullRequestUrl", None) File ~/.local/lib/python3.9/site-packages/huggingface_hub/utils/_errors.py:84, in _raise_for_status(request) 76 if request.status_code == 401: 77 # The repo was not found and the user is not Authenticated 78 raise RepositoryNotFoundError( 79 f"401 Client Error: Repository Not Found for url: {request.url}. If the" 80 " repo is private, make sure you are authenticated. (Request ID:" 81 f" {request_id})" 82 ) ---> 84 _raise_with_request_id(request) File ~/.local/lib/python3.9/site-packages/huggingface_hub/utils/_errors.py:95, in _raise_with_request_id(request) 92 if request_id is not None and len(e.args) > 0 and isinstance(e.args[0], str): 93 e.args = (e.args[0] + f" (Request ID: {request_id})",) + e.args[1:] ---> 95 raise e File ~/.local/lib/python3.9/site-packages/huggingface_hub/utils/_errors.py:90, in _raise_with_request_id(request) 88 request_id = request.headers.get("X-Request-Id") 89 try: ---> 90 request.raise_for_status() 91 except Exception as e: 92 if request_id is not None and len(e.args) > 0 and isinstance(e.args[0], str): File ~/.local/lib/python3.9/site-packages/requests/models.py:1021, in Response.raise_for_status(self) 1016 http_error_msg = ( 1017 f"{self.status_code} Server Error: {reason} for url: {self.url}" 1018 ) 1020 if http_error_msg: -> 1021 raise HTTPError(http_error_msg, response=self) HTTPError: 400 Client Error: Bad Request for url: https://huggingface.co/api/datasets/ORG/DATASET/commit/main (Request ID: a_F0IQAHJdxGKVRYyu1cF) ``` ## Environment info - `datasets` version: 2.3.2 - Platform: Linux-5.13.0-1025-aws-x86_64-with-glibc2.31 - Python version: 3.9.4 - PyArrow version: 8.0.0 - Pandas version: 1.4.3
4,677
https://github.com/huggingface/datasets/issues/4676
Dataset.map gets stuck on _cast_to_python_objects
[ "Are you able to reproduce this? My example is small enough that it should be easy to try.", "Hi! Thanks for reporting and providing a reproducible example. Indeed, by default, `datasets` performs an expensive cast on the values returned by `map` to convert them to one of the types supported by PyArrow (the underlying storage format used by `datasets`). This cast is not needed on NumPy arrays as PyArrow supports them natively, so one way to make this transform faster is to add `return_tensors=\"np\"` to the tokenizer call. \r\n\r\nI think we should mention this in the docs (cc @stevhliu)", "I tested this tokenize function and indeed noticed a casting. However it seems to only concerns the `offset_mapping` field, which contains a list of tuples, that is converted to a list of lists. Since `pyarrow` also supports tuples, we actually don't need to convert the tuples to lists. \r\n\r\nI think this can be changed here: \r\n\r\nhttps://github.com/huggingface/datasets/blob/ede72d3f9796339701ec59899c7c31d2427046fb/src/datasets/features/features.py#L382-L383\r\n\r\n```diff\r\n- if isinstance(obj, list): \r\n+ if isinstance(obj, (list, tuple)): \r\n```\r\n\r\nand here: \r\n\r\nhttps://github.com/huggingface/datasets/blob/ede72d3f9796339701ec59899c7c31d2427046fb/src/datasets/features/features.py#L386-L387\r\n\r\n```diff\r\n- return obj if isinstance(obj, list) else [], isinstance(obj, tuple)\r\n+ return obj, False\r\n```\r\n\r\n@srobertjames can you try applying these changes and let us know if it helps ? If so, feel free to open a Pull Request to contribute this improvement if you want :)", "Wow, adding `return_tensors=\"np\"` sped up my example by a **factor 17x** of and completely eliminated the casting! I'd recommend not only to document it, but to make that the default.\r\n\r\nThe code at https://github.com/huggingface/notebooks/blob/main/examples/question_answering.ipynb does not specify `return_tensors=\"np\"` but yet avoids the casting penalty. How does it do that? (The ntbk seems to do `return_overflowing_tokens=True, return_offsets_mapping=True,`).\r\n\r\nAlso, surprisingly enough, using `return_tensors=\"pt\"` (which is my eventual application) yields this error:\r\n```\r\nTypeError: Provided `function` which is applied to all elements of table returns a `dict` of types \r\n[<class 'torch.Tensor'>, <class 'torch.Tensor'>, <class 'torch.Tensor'>, <class 'torch.Tensor'>]. \r\nWhen using `batched=True`, make sure provided `function` returns a `dict` of types like \r\n`(<class 'list'>, <class 'numpy.ndarray'>)`.\r\n```", "Setting the output to `\"np\"` makes the whole pipeline fast because it moves the data buffers from rust to python to arrow using zero-copy, and also because it does eliminate the casting completely ;)\r\n\r\nHave you had a chance to try eliminating the tuple casting using the trick above ?", "@lhoestq I just benchmarked the two edits to `features.py` above, and they appear to solve the problem, bringing my original example to within 20% the speed of the output `\"np\"` example. Nice!\r\n\r\nFor a pull request, do you suggest simply following https://github.com/huggingface/datasets/blob/main/CONTRIBUTING.md ?", "Cool ! Sure feel free to follow these instructions to open a PR :) thanks !", "#take", "Resolved via https://github.com/huggingface/datasets/pull/4993." ]
## Describe the bug `Dataset.map`, when fed a Huggingface Tokenizer as its map func, can sometimes spend huge amounts of time doing casts. A minimal example follows. Not all usages suffer from this. For example, I profiled the preprocessor at https://github.com/huggingface/notebooks/blob/main/examples/question_answering.ipynb , and it did _not_ have this problem. However, I'm at a loss to figure out how it avoids it, as the example below is simple and minimal and still has this problem. This casting, where it occurs, causes the `Dataset.map` to run approximately 7x slower than it runs for code which does not cause this casting. This may be related to https://github.com/huggingface/datasets/issues/1046 . However, the tokenizer is _not_ set to return Tensors. ## Steps to reproduce the bug A minimal, self-contained example to reproduce is below: ```python import transformers from transformers import AutoTokenizer from datasets import load_dataset import torch import cProfile pretrained = 'distilbert-base-uncased' tokenizer = AutoTokenizer.from_pretrained(pretrained) squad = load_dataset('squad') squad_train = squad['train'] squad_tiny = squad_train.select(range(5000)) assert isinstance(tokenizer, transformers.PreTrainedTokenizerFast) def tokenize(ds): tokens = tokenizer(text=ds['question'], text_pair=ds['context'], add_special_tokens=True, padding='max_length', truncation='only_second', max_length=160, stride=32, return_overflowing_tokens=True, return_offsets_mapping=True, ) return tokens cmd = 'squad_tiny.map(tokenize, batched=True, remove_columns=squad_tiny.column_names)' cProfile.run(cmd, sort='tottime') ``` ## Actual results The code works, but takes 10-25 sec per batch (about 7x slower than non-casting code), with the following profile. Note that `_cast_to_python_objects` is the culprit. ``` 63524075 function calls (58206482 primitive calls) in 121.836 seconds Ordered by: internal time ncalls tottime percall cumtime percall filename:lineno(function) 5274034/40 68.751 0.000 111.060 2.776 features.py:262(_cast_to_python_objects) 42223832 24.077 0.000 33.310 0.000 {built-in method builtins.isinstance} 16338/20 5.121 0.000 111.053 5.553 features.py:361(<listcomp>) 5274135 4.747 0.000 4.749 0.000 {built-in method _abc._abc_instancecheck} 80/40 4.731 0.059 116.292 2.907 {pyarrow.lib.array} 5274135 4.485 0.000 9.234 0.000 abc.py:96(__instancecheck__) 2661564/2645196 2.959 0.000 4.298 0.000 features.py:1081(_check_non_null_non_empty_recursive) 5 2.786 0.557 2.786 0.557 {method 'encode_batch' of 'tokenizers.Tokenizer' objects} 2668052 0.930 0.000 0.930 0.000 {built-in method builtins.len} 5000 0.930 0.000 0.938 0.000 tokenization_utils_fast.py:187(_convert_encoding) 5 0.750 0.150 0.808 0.162 {method 'to_pydict' of 'pyarrow.lib.Table' objects} 1 0.444 0.444 121.749 121.749 arrow_dataset.py:2501(_map_single) 40 0.375 0.009 116.291 2.907 arrow_writer.py:151(__arrow_array__) 10 0.066 0.007 0.066 0.007 {method 'write_batch' of 'pyarrow.lib._CRecordBatchWriter' objects} 1 0.060 0.060 121.835 121.835 fingerprint.py:409(wrapper) 11387/5715 0.049 0.000 0.175 0.000 {built-in method builtins.getattr} 36 0.049 0.001 0.049 0.001 {pyarrow._compute.call_function} 15000 0.040 0.000 0.040 0.000 _collections_abc.py:719(__iter__) 3 0.023 0.008 0.023 0.008 {built-in method _imp.create_dynamic} 77 0.020 0.000 0.020 0.000 {built-in method builtins.dir} 37 0.019 0.001 0.019 0.001 socket.py:543(send) 15 0.017 0.001 0.017 0.001 tokenization_utils_fast.py:460(<listcomp>) 432/421 0.015 0.000 0.024 0.000 traitlets.py:1388(_notify_observers) 5000 0.015 0.000 0.018 0.000 _collections_abc.py:672(keys) 51 0.014 0.000 0.042 0.001 traitlets.py:276(getmembers) 5 0.014 0.003 3.775 0.755 tokenization_utils_fast.py:392(_batch_encode_plus) 3/1 0.014 0.005 0.035 0.035 {built-in method _imp.exec_dynamic} 5 0.012 0.002 0.950 0.190 tokenization_utils_fast.py:438(<listcomp>) 31626 0.012 0.000 0.012 0.000 {method 'append' of 'list' objects} 1532/1001 0.011 0.000 0.189 0.000 traitlets.py:643(get) 5 0.009 0.002 3.796 0.759 arrow_dataset.py:2631(apply_function_on_filtered_inputs) 51 0.009 0.000 0.062 0.001 traitlets.py:1766(traits) 5 0.008 0.002 3.784 0.757 tokenization_utils_base.py:2632(batch_encode_plus) 368 0.007 0.000 0.044 0.000 traitlets.py:1715(_get_trait_default_generator) 26 0.007 0.000 0.022 0.001 traitlets.py:1186(setup_instance) 51 0.006 0.000 0.010 0.000 traitlets.py:1781(<listcomp>) 80/32 0.006 0.000 0.052 0.002 table.py:1758(cast_array_to_feature) 684 0.006 0.000 0.007 0.000 {method 'items' of 'dict' objects} 4344/1794 0.006 0.000 0.192 0.000 traitlets.py:675(__get__) ... ``` ## Environment info I observed this on both Google colab and my local workstation: ### Google colab - `datasets` version: 2.3.2 - Platform: Linux-5.4.188+-x86_64-with-Ubuntu-18.04-bionic - Python version: 3.7.13 - PyArrow version: 6.0.1 - Pandas version: 1.3.5 ### Local - `datasets` version: 2.3.2 - Platform: Windows-7-6.1.7601-SP1 - Python version: 3.8.10 - PyArrow version: 8.0.0 - Pandas version: 1.4.3
4,676
https://github.com/huggingface/datasets/issues/4675
Unable to use dataset with PyTorch dataloader
[ "Hi! `para_crawl` has a single column of type `Translation`, which stores translation dictionaries. These dictionaries can be stored in a NumPy array but not in a PyTorch tensor since PyTorch only supports numeric types. In `datasets`, the conversion to `torch` works as follows: \r\n1. convert PyArrow table to NumPy arrays \r\n2. convert NumPy arrays to Torch tensors. \r\n\r\nThe 2nd step is problematic for your case as `datasets` attempts to convert the array of dictionaries to a PyTorch tensor. One way to fix this is to use the [preprocessing logic](https://github.com/huggingface/transformers/blob/8581a798c0a48fca07b29ce2ca2ef55adcae8c7e/examples/pytorch/translation/run_translation.py#L440-L458) from the Transformers translation script. And on our side, I think we can replace a NumPy array of dicts with a dict of NumPy array if the feature type is `Translation`/`TranslationVariableLanguages` (one array for each language) to get the official PyTorch error message for strings in such case." ]
## Describe the bug When using `.with_format("torch")`, an arrow table is returned and I am unable to use it by passing it to a PyTorch DataLoader: please see the code below. ## Steps to reproduce the bug ```python from datasets import load_dataset from torch.utils.data import DataLoader ds = load_dataset( "para_crawl", name="enfr", cache_dir="/tmp/test/", split="train", keep_in_memory=True, ) dataloader = DataLoader(ds.with_format("torch"), num_workers=32) print(next(iter(dataloader))) ``` Is there something I am doing wrong? The documentation does not say much about the behavior of `.with_format()` so I feel like I am a bit stuck here :-/ Thanks in advance for your help! ## Expected results The code should run with no error ## Actual results ``` AttributeError: 'str' object has no attribute 'dtype' ``` ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: 2.3.2 - Platform: Linux-4.18.0-348.el8.x86_64-x86_64-with-glibc2.28 - Python version: 3.10.4 - PyArrow version: 8.0.0 - Pandas version: 1.4.3
4,675
https://github.com/huggingface/datasets/issues/4674
Issue loading datasets -- pyarrow.lib has no attribute
[ "Hi @margotwagner, thanks for reporting.\r\n\r\nUnfortunately, I'm not able to reproduce your bug: in an environment with datasets-2.3.2 and pyarrow-8.0.0, I can load the datasets without any problem:\r\n```python\r\n>>> ds = load_dataset(\"glue\", \"cola\")\r\n>>> ds\r\nDatasetDict({\r\n train: Dataset({\r\n features: ['sentence', 'label', 'idx'],\r\n num_rows: 8551\r\n })\r\n validation: Dataset({\r\n features: ['sentence', 'label', 'idx'],\r\n num_rows: 1043\r\n })\r\n test: Dataset({\r\n features: ['sentence', 'label', 'idx'],\r\n num_rows: 1063\r\n })\r\n})\r\n\r\n>>> import pyarrow\r\n>>> pyarrow.__version__\r\n8.0.0\r\n>>> from pyarrow.lib import IpcReadOptions\r\n>>> IpcReadOptions\r\npyarrow.lib.IpcReadOptions\r\n```\r\n\r\nI think you may have a problem in your Python environment: maybe you have also an old version of pyarrow that has precedence when importing it.\r\n\r\nCould you please check this (just after you tried to load the dataset and got the error)?\r\n```python\r\n>>> import pyarrow\r\n>>> pyarrow.__version__\r\n``` " ]
## Describe the bug I am trying to load sentiment analysis datasets from huggingface, but any dataset I try to use via load_dataset, I get the same error: `AttributeError: module 'pyarrow.lib' has no attribute 'IpcReadOptions'` ## Steps to reproduce the bug ```python dataset = load_dataset("glue", "cola") ``` ## Expected results Download datasets without issue. ## Actual results `AttributeError: module 'pyarrow.lib' has no attribute 'IpcReadOptions'` ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: 2.3.2 - Platform: macOS-10.15.7-x86_64-i386-64bit - Python version: 3.8.5 - PyArrow version: 8.0.0 - Pandas version: 1.1.0
4,674
https://github.com/huggingface/datasets/issues/4673
load_datasets on csv returns everything as a string
[ "Hi @courtneysprouse, thanks for reporting.\r\n\r\nYes, you are right: by default the \"csv\" loader loads all columns as strings. \r\n\r\nYou could tweak this behavior by passing the `feature` argument to `load_dataset`, but it is also true that currently it is not possible to perform some kind of casts, due to lacking of implementation in PyArrow. For example:\r\n```python\r\nimport datasets\r\n\r\nfeatures = datasets.Features(\r\n {\r\n \"tokens\": datasets.Sequence(datasets.Value(\"string\")),\r\n \"ner_tags\": datasets.Sequence(datasets.Value(\"int32\")),\r\n }\r\n)\r\n\r\nnew_conll = datasets.load_dataset(\"csv\", data_files=\"ner_conll.csv\", features=features)\r\n```\r\ngives `ArrowNotImplementedError` error:\r\n```\r\n/usr/local/lib/python3.7/dist-packages/pyarrow/error.pxi in pyarrow.lib.check_status()\r\n\r\nArrowNotImplementedError: Unsupported cast from string to list using function cast_list\r\n```\r\n\r\nOn the other hand, if you just would like to save and afterwards load your dataset, you could use `save_to_disk` and `load_from_disk` instead. These functions preserve all data types.\r\n```python\r\n>>> orig_conll.save_to_disk(\"ner_conll\")\r\n\r\n>>> from datasets import load_from_disk\r\n\r\n>>> new_conll = load_from_disk(\"ner_conll\")\r\n>>> new_conll\r\nDatasetDict({\r\n train: Dataset({\r\n features: ['id', 'tokens', 'pos_tags', 'chunk_tags', 'ner_tags'],\r\n num_rows: 14042\r\n })\r\n validation: Dataset({\r\n features: ['id', 'tokens', 'pos_tags', 'chunk_tags', 'ner_tags'],\r\n num_rows: 3251\r\n })\r\n test: Dataset({\r\n features: ['id', 'tokens', 'pos_tags', 'chunk_tags', 'ner_tags'],\r\n num_rows: 3454\r\n })\r\n})\r\n>>> new_conll[\"train\"][0]\r\n{'chunk_tags': [11, 21, 11, 12, 21, 22, 11, 12, 0],\r\n 'id': '0',\r\n 'ner_tags': [3, 0, 7, 0, 0, 0, 7, 0, 0],\r\n 'pos_tags': [22, 42, 16, 21, 35, 37, 16, 21, 7],\r\n 'tokens': ['EU',\r\n 'rejects',\r\n 'German',\r\n 'call',\r\n 'to',\r\n 'boycott',\r\n 'British',\r\n 'lamb',\r\n '.']}\r\n>>> new_conll[\"train\"].features\r\n{'chunk_tags': Sequence(feature=ClassLabel(num_classes=23, names=['O', 'B-ADJP', 'I-ADJP', 'B-ADVP', 'I-ADVP', 'B-CONJP', 'I-CONJP', 'B-INTJ', 'I-INTJ', 'B-LST', 'I-LST', 'B-NP', 'I-NP', 'B-PP', 'I-PP', 'B-PRT', 'I-PRT', 'B-SBAR', 'I-SBAR', 'B-UCP', 'I-UCP', 'B-VP', 'I-VP'], id=None), length=-1, id=None),\r\n 'id': Value(dtype='string', id=None),\r\n 'ner_tags': Sequence(feature=ClassLabel(num_classes=9, names=['O', 'B-PER', 'I-PER', 'B-ORG', 'I-ORG', 'B-LOC', 'I-LOC', 'B-MISC', 'I-MISC'], id=None), length=-1, id=None),\r\n 'pos_tags': Sequence(feature=ClassLabel(num_classes=47, names=['\"', \"''\", '#', '$', '(', ')', ',', '.', ':', '``', 'CC', 'CD', 'DT', 'EX', 'FW', 'IN', 'JJ', 'JJR', 'JJS', 'LS', 'MD', 'NN', 'NNP', 'NNPS', 'NNS', 'NN|SYM', 'PDT', 'POS', 'PRP', 'PRP$', 'RB', 'RBR', 'RBS', 'RP', 'SYM', 'TO', 'UH', 'VB', 'VBD', 'VBG', 'VBN', 'VBP', 'VBZ', 'WDT', 'WP', 'WP$', 'WRB'], id=None), length=-1, id=None),\r\n 'tokens': Sequence(feature=Value(dtype='string', id=None), length=-1, id=None)}\r\n```", "Hi @albertvillanova!\r\n\r\nThanks so much for your suggestions! That worked! " ]
## Describe the bug If you use: `conll_dataset.to_csv("ner_conll.csv")` It will create a csv file with all of your data as expected, however when you load it with: `conll_dataset = load_dataset("csv", data_files="ner_conll.csv")` everything is read in as a string. For example if I look at everything in 'ner_tags' I get back `['[3 0 7 0 0 0 7 0 0]', '[1 2]', '[5 0]']` instead of what I originally saved which was `[[3, 0, 7, 0, 0, 0, 7, 0, 0], [1, 2], [5, 0]]` I think maybe there is something funky going on with the csv delimiter ## Steps to reproduce the bug ```python # Sample code to reproduce the bug #load original conll dataset orig_conll = load_dataset("conll2003") #save original conll as a csv orig_conll.to_csv("ner_conll.csv") #reload conll data as a csv new_conll = load_dataset("csv", data_files="ner_conll.csv")` ``` ## Expected results A clear and concise description of the expected results. I would expect the data be returned as the data type I saved it as. I.e. if I save a list of ints [[3, 0, 7, 0, 0, 0, 7, 0, 0]], I shouldnt get back a string ['[3 0 7 0 0 0 7 0 0]'] I also get back a string when I pass a list of strings ['EU', 'rejects', 'German', 'call', 'to', 'boycott', 'British', 'lamb', '.'] ## Actual results A list of strings `['[3 0 7 0 0 0 7 0 0]', '[1 2]', '[5 0]']` A string "['EU' 'rejects' 'German' 'call' 'to' 'boycott' 'British' 'lamb' '.']" ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: 1.18.3 - Platform: Linux-5.4.0-121-generic-x86_64-with-glibc2.17 - Python version: 3.8.13 - PyArrow version: 8.0.0
4,673
https://github.com/huggingface/datasets/issues/4671
Dataset Viewer issue for wmt16
[ "Thanks for reporting, @lewtun.\r\n\r\n~We can't load the dataset locally, so I think this is an issue with the loading script (not the viewer).~\r\n\r\n We are investigating...", "Recently, there was a merged PR related to this dataset:\r\n- #4554\r\n\r\nWe are looking at this...", "Indeed, the above mentioned PR fixed the loading script (it was not working before).\r\n\r\nI'm forcing the refresh of the Viewer.", "Please note that the above mentioned PR also made an enhancement in the `datasets` library, required by this loading script. This enhancement will only be available to the Viewer once we make our next release.", "OK, it's working now.\r\n\r\nhttps://huggingface.co/datasets/wmt16/viewer/ro-en/test\r\n\r\n<img width=\"1434\" alt=\"Capture d’écran 2022-09-08 aΜ€ 10 15 55\" src=\"https://user-images.githubusercontent.com/1676121/189071665-17d2d149-9b22-42bf-93ac-1a966c3f637a.png\">\r\n", "Thank you @severo !!" ]
### Link https://huggingface.co/datasets/wmt16 ### Description [Reported](https://huggingface.co/spaces/autoevaluate/model-evaluator/discussions/12#62cb83f14c7f35284e796f9c) by a user of AutoTrain Evaluate. AFAIK this dataset was working 1-2 weeks ago, and I'm not sure how to interpret this error. ``` Status code: 400 Exception: NotImplementedError Message: This is a abstract method ``` Thanks! ### Owner No
4,671
https://github.com/huggingface/datasets/issues/4670
Can't extract files from `.7z` zipfile using `download_and_extract`
[ "Hi @bhavitvyamalik, thanks for reporting.\r\n\r\nYes, currently we do not support 7zip archive compression: I think we should.\r\n\r\nAs a workaround, you could uncompress it explicitly, like done in e.g. `samsum` dataset: \r\n\r\nhttps://github.com/huggingface/datasets/blob/fedf891a08bfc77041d575fad6c26091bc0fce52/datasets/samsum/samsum.py#L106-L110\r\n", "Related to this issue: https://github.com/huggingface/datasets/issues/3541", "Sure, let me look into and check what can be done. Will keep you guys updated here!", "Initially, I thought of solving this without any external dependency. Almost everywhere I saw `lzma` can be used for this but there is a caveat that lzma doesn’t work with 7z archives but only single files. In my case the 7z archive has multiple files so it didn't work. Is it fine to use external library here?", "Hi @bhavitvyamalik, thanks for your investigation.\r\n\r\nOn Monday, I started a PR that will eventually close this issue as well: I'm linking it to this.\r\n- #4672\r\n\r\nLet me know what you think. " ]
## Describe the bug I'm adding a new dataset which is a `.7z` zip file in Google drive and contains 3 json files inside. I'm able to download the data files using `download_and_extract` but after downloading it throws this error: ``` >>> dataset = load_dataset("./datasets/mantis/") Using custom data configuration default Downloading and preparing dataset mantis/default to /Users/bhavitvyamalik/.cache/huggingface/datasets/mantis/default/1.1.0/611affa804ec53e2055a335cc1b8b213bb5a0b5142d919967729d5ee23c6bab4... Downloading data: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 77.2M/77.2M [00:23<00:00, 3.28MB/s] /Users/bhavitvyamalik/.cache/huggingface/datasets/downloads/fc3d70123c9de8407587a59aa426c37819cf2bf016795d33270e8a1d558a34e6 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/bhavitvyamalik/Desktop/work/hf/datasets/src/datasets/load.py", line 1745, in load_dataset use_auth_token=use_auth_token, File "/Users/bhavitvyamalik/Desktop/work/hf/datasets/src/datasets/builder.py", line 595, in download_and_prepare dl_manager=dl_manager, verify_infos=verify_infos, **download_and_prepare_kwargs File "/Users/bhavitvyamalik/Desktop/work/hf/datasets/src/datasets/builder.py", line 690, in _download_and_prepare ) from None OSError: Cannot find data file. Original error: [Errno 20] Not a directory: '/Users/bhavitvyamalik/.cache/huggingface/datasets/downloads/fc3d70123c9de8407587a59aa426c37819cf2bf016795d33270e8a1d558a34e6/merged_train.json' ``` just before generating the splits. I checked `fc3d70123c9de8407587a59aa426c37819cf2bf016795d33270e8a1d558a34e6` file and it's `7z` zip file (similar to downloaded Google drive file) which means it didn't get unzip. Do I need to unzip it separately and then pass the paths for train,dev,test files in `SplitGenerator`? ## Environment info - `datasets` version: 1.18.4.dev0 - Platform: Darwin-19.6.0-x86_64-i386-64bit - Python version: 3.7.8 - PyArrow version: 5.0.0
4,670
https://github.com/huggingface/datasets/issues/4669
loading oscar-corpus/OSCAR-2201 raises an error
[ "I had to use the appropriate token for use_auth_token. Thank you." ]
## Describe the bug load_dataset('oscar-2201', 'af') raises an error: Traceback (most recent call last): File "/usr/lib/python3.8/code.py", line 90, in runcode exec(code, self.locals) File "<input>", line 1, in <module> File "..python3.8/site-packages/datasets/load.py", line 1656, in load_dataset builder_instance = load_dataset_builder( File ".../lib/python3.8/site-packages/datasets/load.py", line 1439, in load_dataset_builder dataset_module = dataset_module_factory( File ".../lib/python3.8/site-packages/datasets/load.py", line 1189, in dataset_module_factory raise FileNotFoundError( FileNotFoundError: Couldn't find a dataset script at .../oscar-2201/oscar-2201.py or any data file in the same directory. Couldn't find 'oscar-2201' on the Hugging Face Hub either: FileNotFoundError: Couldn't find file at https://raw.githubusercontent.com/huggingface/datasets/master/datasets/oscar-2201/oscar-2201.py I've tried other permutations such as : oscar_22 = load_dataset('oscar-2201', 'af',use_auth_token=True) oscar_22 = load_dataset('oscar-corpus/OSCAR-2201', 'af',use_auth_token=True) oscar_22 = load_dataset('oscar-2201', 'af') oscar_22 = load_dataset('oscar-corpus/OSCAR-2201') with the same unfortunate result. ## Steps to reproduce the bug oscar_22 = load_dataset('oscar-2201', 'af',use_auth_token=True) oscar_22 = load_dataset('oscar-corpus/OSCAR-2201', 'af',use_auth_token=True) oscar_22 = load_dataset('oscar-2201', 'af') oscar_22 = load_dataset('oscar-corpus/OSCAR-2201') # Sample code to reproduce the bug ``` ## Expected results loaded data ## Actual results Traceback (most recent call last): File "/usr/lib/python3.8/code.py", line 90, in runcode exec(code, self.locals) File "<input>", line 1, in <module> File "..python3.8/site-packages/datasets/load.py", line 1656, in load_dataset builder_instance = load_dataset_builder( File ".../lib/python3.8/site-packages/datasets/load.py", line 1439, in load_dataset_builder dataset_module = dataset_module_factory( File ".../lib/python3.8/site-packages/datasets/load.py", line 1189, in dataset_module_factory raise FileNotFoundError( FileNotFoundError: Couldn't find a dataset script at .../oscar-2201/oscar-2201.py or any data file in the same directory. Couldn't find 'oscar-2201' on the Hugging Face Hub either: FileNotFoundError: Couldn't find file at https://raw.githubusercontent.com/huggingface/datasets/master/datasets/oscar-2201/oscar-2201.py ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: 2.3.2 - Platform: Linux-5.13.0-37-generic-x86_64-with-glibc2.29 - Python version: 3.8.10 - PyArrow version: 8.0.0 - Pandas version: 1.4.3
4,669
https://github.com/huggingface/datasets/issues/4668
Dataset Viewer issue for hungnm/multilingual-amazon-review-sentiment-processed
[ "It seems like a private dataset. The viewer is currently not supported on the private datasets." ]
### Link https://huggingface.co/hungnm/multilingual-amazon-review-sentiment ### Description _No response_ ### Owner Yes
4,668
https://github.com/huggingface/datasets/issues/4667
Dataset Viewer issue for hungnm/multilingual-amazon-review-sentiment-processed
[]
### Link _No response_ ### Description _No response_ ### Owner _No response_
4,667
https://github.com/huggingface/datasets/issues/4666
Issues with concatenating datasets
[ "Hi! I agree we should improve the features equality checks to account for this particular case. However, your code fails due to `answer_start` having the dtype `int64` instead of `int32` after loading from JSON (it's not possible to embed type precision info into a JSON file; `save_to_disk` does that for arrow files), which would lead to the concatenation error as PyArrow does not support this sort of type promotion. This can be fixed as follows:\r\n```python\r\ntemp = load_dataset(\"json\", data_files={\"train\": \"output.jsonl\"}, features=squad[\"train\"].features)\r\n``` ", "That makes sense. I totally missed the `int64` and `int32` part. Thanks for pointing it out! Will close this issue for now." ]
## Describe the bug It is impossible to concatenate datasets if a feature is sequence of dict in one dataset and a dict of sequence in another. But based on the document, it should be automatically converted. > A [datasets.Sequence](https://huggingface.co/docs/datasets/v2.3.2/en/package_reference/main_classes#datasets.Sequence) with a internal dictionary feature will be automatically converted into a dictionary of lists. This behavior is implemented to have a compatilbity layer with the TensorFlow Datasets library but may be un-wanted in some cases. If you don’t want this behavior, you can use a python list instead of the [datasets.Sequence](https://huggingface.co/docs/datasets/v2.3.2/en/package_reference/main_classes#datasets.Sequence). ## Steps to reproduce the bug ```python from datasets import concatenate_datasets, load_dataset squad = load_dataset("squad_v2") squad["train"].to_json("output.jsonl", lines=True) temp = load_dataset("json", data_files={"train": "output.jsonl"}) concatenate_datasets([temp["train"], squad["train"]]) ``` ## Expected results No error executing that code ## Actual results ``` ValueError: The features can't be aligned because the key answers of features {'id': Value(dtype='string', id=None), 'title': Value(dtype='string', id=None), 'context': Value(dtype='string', id=None), 'question': Value(dtype='string', id=None), 'answers': Sequence(feature={'text': Value(dtype='string', id=None), 'answer_start': Value(dtype='int32', id=None)}, length=-1, id=None)} has unexpected type - Sequence(feature={'text': Value(dtype='string', id=None), 'answer_start': Value(dtype='int32', id=None)}, length=-1, id=None) (expected either {'text': Sequence(feature=Value(dtype='string', id=None), length=-1, id=None), 'answer_start': Sequence(feature=Value(dtype='int64', id=None), length=-1, id=None)} or Value("null"). ``` ## Environment info - `datasets` version: 2.3.2 - Platform: macOS-12.4-arm64-arm-64bit - Python version: 3.8.11 - PyArrow version: 6.0.1 - Pandas version: 1.3.5
4,666
https://github.com/huggingface/datasets/issues/4665
Unable to create dataset having Python dataset script only
[ "Hi @aleSuglia, thanks for reporting.\r\n\r\nWe are having a look at it. \r\n\r\nWe transfer this issue to the Community tab of the corresponding Hub dataset: https://huggingface.co/datasets/Heriot-WattUniversity/dialog-babi/discussions" ]
## Describe the bug Hi there, I'm trying to add the following dataset to Huggingface datasets: https://huggingface.co/datasets/Heriot-WattUniversity/dialog-babi/blob/ I'm trying to do so using the CLI commands but seems that this command generates the wrong `dataset_info.json` file (you can find it in the repo already): ``` datasets-cli test Heriot-WattUniversity/dialog-babi/dialog_babi.py --save_infos --all-configs ``` while it errors when I remove the python script: ``` datasets-cli test Heriot-WattUniversity/dialog-babi/ --save_infos --all-configs ``` The error message is the following: ``` FileNotFoundError: Unable to resolve any data file that matches '['**']' at /Users/as2180/workspace/Heriot-WattUniversity/dialog-babi with any supported extension ['csv', 'tsv', 'json', 'jsonl', 'parquet', 'txt', 'blp', 'bmp', 'dib', 'bufr', 'cur', 'pcx', 'dcx', 'dds', 'ps', 'eps', 'fit', 'fits', 'fli', 'flc', 'ftc', 'ftu', 'gbr', 'gif', 'grib', 'h5', 'hdf', 'png', 'apng', 'jp2', 'j2k', 'jpc', 'jpf', 'jpx', 'j2c', 'icns', 'ico', 'im', 'iim', 'tif', 'tiff', 'jfif', 'jpe', 'jpg', 'jpeg', 'mpg', 'mpeg', 'msp', 'pcd', 'pxr', 'pbm', 'pgm', 'ppm', 'pnm', 'psd', 'bw', 'rgb', 'rgba', 'sgi', 'ras', 'tga', 'icb', 'vda', 'vst', 'webp', 'wmf', 'emf', 'xbm', 'xpm', 'zip'] ``` ## Environment info - `datasets` version: 2.3.2 - Platform: macOS-12.4-arm64-arm-64bit - Python version: 3.9.9 - PyArrow version: 8.0.0 - Pandas version: 1.4.3
4,665
https://github.com/huggingface/datasets/issues/4661
Concurrency bug when using same cache among several jobs
[ "I can confirm that if I run one job first that processes the dataset, then I can run any jobs in parallel with no problem (no write-concurrency anymore...). ", "Hi! That's weird. It seems like the error points to the `mkstemp` function, but the official docs state the following:\r\n```\r\nThere are no race conditions in the file’s creation, assuming that the platform properly implements the [os.O_EXCL](https://docs.python.org/3/library/os.html#os.O_EXCL) flag for [os.open()](https://docs.python.org/3/library/os.html#os.open)\r\n```\r\nSo this could mean your platform doesn't support that flag.\r\n\r\n~~Can you please check if wrapping the temp file creation (the line `tmp_file = tempfile.NamedTemporaryFile(\"wb\", dir=os.path.dirname(cache_file_name), delete=False)` in `_map_single`) with the `multiprocess.Lock` fixes the issue?~~\r\nPerhaps wrapping the temp file creation in `_map_single` with `filelock` could work:\r\n```python\r\nwith FileLock(lock_path):\r\n tmp_file = tempfile.NamedTemporaryFile(\"wb\", dir=os.path.dirname(cache_file_name), delete=False)\r\n```\r\nCan you please check if that helps?" ]
## Describe the bug I used to see this bug with an older version of the datasets. It seems to persist. This is my concrete scenario: I launch several evaluation jobs on a cluster in which I share the file system and I share the cache directory used by huggingface libraries. The evaluation jobs read the same *.csv files. If my jobs get all scheduled pretty much at the same time, there are all kinds of weird concurrency errors. Sometime it crashes silently. This time I got lucky that it crashed with a stack trace that I can share and maybe you get to the bottom of this. If you don't have a similar setup available, it may be hard to reproduce as you really need two jobs accessing the same file at the same time to see this type of bug. ## Steps to reproduce the bug I'm running a modified version of `run_glue.py` script adapted to my use case. I've seen the same problem when running some glue datasets as well (so it's not specific to loading the datasets from csv files). ## Expected results No crash, concurrent access to the (intermediate) files just fine. ## Actual results Crashes due to races/concurrency bugs. ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: 2.3.2 - Platform: Linux-4.18.0-348.23.1.el8_5.x86_64-x86_64-with-glibc2.10 - Python version: 3.8.5 - PyArrow version: 8.0.0 - Pandas version: 1.1.0 Stack trace that I just got with the crash (I've obfuscated some names, it should still be quite informative): ``` Running tokenizer on dataset: 0%| | 0/3 [00:00<?, ?ba/s] Traceback (most recent call last): File "../../src/models//run_*******.py", line 600, in <module> main() File "../../src/models//run_*******.py", line 444, in main raw_datasets = raw_datasets.map( File "/*******//envs/tr-crt/lib/python3.8/site-packages/datasets/dataset_dict.py", line 770, in map { File "/*******//envs/tr-crt/lib/python3.8/site-packages/datasets/dataset_dict.py", line 771, in <dictcomp> k: dataset.map( File "/*******//envs/tr-crt/lib/python3.8/site-packages/datasets/arrow_dataset.py", line 2376, in map return self._map_single( File "/*******/envs/tr-crt/lib/python3.8/site-packages/datasets/arrow_dataset.py", line 551, in wrapper out: Union["Dataset", "DatasetDict"] = func(self, *args, **kwargs) File "/*******//envs/tr-crt/lib/python3.8/site-packages/datasets/arrow_dataset.py", line 518, in wrapper out: Union["Dataset", "DatasetDict"] = func(self, *args, **kwargs) File "/*******/envs/tr-crt/lib/python3.8/site-packages/datasets/fingerprint.py", line 458, in wrapper out = func(self, *args, **kwargs) File "/*******//envs/tr-crt/lib/python3.8/site-packages/datasets/arrow_dataset.py", line 2776, in _map_single buf_writer, writer, tmp_file = init_buffer_and_writer() File "/*******//envs/tr-crt/lib/python3.8/site-packages/datasets/arrow_dataset.py", line 2696, in init_buffer_and_writer tmp_file = tempfile.NamedTemporaryFile("wb", dir=os.path.dirname(cache_file_name), delete=False) File "/*******//envs/tr-crt/lib/python3.8/tempfile.py", line 541, in NamedTemporaryFile (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type) File "/*******//envs/tr-crt/lib/python3.8/tempfile.py", line 250, in _mkstemp_inner fd = _os.open(file, flags, 0o600) FileNotFoundError: [Errno 2] No such file or directory: '/*******/cache-transformers//transformers/csv/default-ef9cd184210742a7/0.0.0/51cce309a08df9c4d82ffd9363bbe090bf173197fc01a71b034e8594995a1a58/tmps8l6j5yc' ``` As I ran 100s of experiments last year for an empirical paper, I ran into this type of bugs several times. I found several bandaid/work-arounds, e.g., run one job first that caches the dataset => eliminate concurrency; OR use unique caches => eliminate concurrency (but increase storage space), etc. and it all works fine. I'd like to help you fixing this bug as it's really annoying to always apply the work arounds. Let me know what other info from my side could help you figure out the issue. Thanks for your help!
4,661
https://github.com/huggingface/datasets/issues/4658
Transfer CI tests to GitHub Actions
[]
Let's try CI tests using GitHub Actions to see if they are more stable than on CircleCI.
4,658
https://github.com/huggingface/datasets/issues/4657
Add SQuAD2.0 Dataset
[ "Hey, It's already present [here](https://huggingface.co/datasets/squad_v2) ", "Hi! This dataset is indeed already available on the Hub. Closing." ]
## Adding a Dataset - **Name:** *SQuAD2.0* - **Description:** *Stanford Question Answering Dataset (SQuAD) is a reading comprehension dataset, consisting of questions posed by crowdworkers on a set of Wikipedia articles, where the answer to every question is a segment of text, or span, from the corresponding reading passage, or the question might be unanswerable.* - **Paper:** *https://aclanthology.org/P18-2124.pdf* - **Data:** *https://rajpurkar.github.io/SQuAD-explorer/* - **Motivation:** *Dataset for training and evaluating models of conversational response*
4,657
https://github.com/huggingface/datasets/issues/4656
Add Amazon-QA Dataset
[ "uploaded dataset [here](https://huggingface.co/datasets/embedding-data/Amazon-QA)." ]
## Adding a Dataset - **Name:** *Amazon-QA* - **Description:** *The dataset is .jsonl format, where each line in the file is a json string that corresponds to a question, existing answers to the question and the extracted review snippets (relevant to the question).* - **Paper:** *https://github.com/amazonqa/amazonqa/tree/master/paper* - **Data:** *https://huggingface.co/datasets/sentence-transformers/embedding-training-data/resolve/main/amazon-qa.jsonl.gz* - **Motivation:** *Dataset for training and evaluating models of conversational response*
4,656
https://github.com/huggingface/datasets/issues/4655
Simple Wikipedia
[ "uploaded dataset [here](https://huggingface.co/datasets/embedding-data/simple-wiki)." ]
## Adding a Dataset - **Name:** *Simple Wikipedia* - **Description:** *Two different versions of the data set now exist. Both were generated by aligning Simple English Wikipedia and English Wikipedia. A complete description of the extraction process can be found in "Simple English Wikipedia: A New Simplification Task", William Coster and David Kauchak (2011).* - **Paper:** *https://aclanthology.org/P11-2117/* - **Data:** *https://huggingface.co/datasets/sentence-transformers/embedding-training-data/resolve/main/SimpleWiki.jsonl.gz* - **Motivation:** *Dataset for training and evaluating models of conversational response*
4,655
https://github.com/huggingface/datasets/issues/4654
Add Quora Question Triplets Dataset
[ "uploaded dataset [here](https://huggingface.co/datasets/embedding-data/QQP_triplets)." ]
## Adding a Dataset - **Name:** *Quora Question Triplets* - **Description:** *This dataset consists of over 400,000 lines of potential question duplicate pairs. Each line contains IDs for each question in the pair, the full text for each question, and a binary value that indicates whether the line truly contains a duplicate pair.* - **Paper:** - **Data:** *https://huggingface.co/datasets/sentence-transformers/embedding-training-data/resolve/main/quora_duplicates_triplets.jsonl.gz* - **Motivation:** *Dataset for training and evaluating models of conversational response*
4,654
https://github.com/huggingface/datasets/issues/4653
Add Altlex dataset
[ "uploaded dataset [here](https://huggingface.co/datasets/embedding-data/altlex)." ]
## Adding a Dataset - **Name:** *Altlex* - **Description:** *Git repository for software associated with the 2016 ACL paper "Identifying Causal Relations Using Parallel Wikipedia Articles.”* - **Paper:** *https://aclanthology.org/P16-1135.pdf* - **Data:** *https://huggingface.co/datasets/sentence-transformers/embedding-training-data/resolve/main/altlex.jsonl.gz* - **Motivation:** *Dataset for training and evaluating models of conversational response*
4,653
https://github.com/huggingface/datasets/issues/4652
Add Sentence Compression Dataset
[ "uploaded dataset [here](https://huggingface.co/datasets/embedding-data/sentence-compression)." ]
## Adding a Dataset - **Name:** *Sentence Compression* - **Description:** *Large corpus of uncompressed and compressed sentences from news articles.* - **Paper:** *https://www.aclweb.org/anthology/D13-1155/* - **Data:** *https://github.com/google-research-datasets/sentence-compression/tree/master/data* - **Motivation:** *Dataset for training and evaluating models of conversational response*
4,652
https://github.com/huggingface/datasets/issues/4651
Add Flickr 30k Dataset
[ "uploaded dataset [here](https://huggingface.co/datasets/embedding-data/flickr30k-captions)." ]
## Adding a Dataset - **Name:** *Flickr 30k* - **Description:** *To produce the denotation graph, we have created an image caption corpus consisting of 158,915 crowd-sourced captions describing 31,783 images. This is an extension of our previous Flickr 8k Dataset. The new images and captions focus on people involved in everyday activities and events.* - **Paper:** *https://transacl.org/ojs/index.php/tacl/article/view/229/33* - **Data:** *https://huggingface.co/datasets/sentence-transformers/embedding-training-data/resolve/main/flickr30k_captions.jsonl.gz* - **Motivation:** *Dataset for training and evaluating models of conversational response*
4,651
https://github.com/huggingface/datasets/issues/4650
Add SPECTER dataset
[ "uploaded dataset [here](https://huggingface.co/datasets/embedding-data/SPECTER)" ]
## Adding a Dataset - **Name:** *SPECTER* - **Description:** *SPECTER: Document-level Representation Learning using Citation-informed Transformers* - **Paper:** *https://doi.org/10.18653/v1/2020.acl-main.207* - **Data:** *https://huggingface.co/datasets/sentence-transformers/embedding-training-data/resolve/main/specter_train_triples.jsonl.gz* - **Motivation:** *Dataset for training and evaluating models of conversational response*
4,650
https://github.com/huggingface/datasets/issues/4649
Add PAQ dataset
[ "uploaded dataset [here](https://huggingface.co/datasets/embedding-data/PAQ_pairs)" ]
## Adding a Dataset - **Name:** *PAQ* - **Description:** *This repository contains code and models to support the research paperΒ PAQ: 65 Million Probably-Asked Questions and What You Can Do With Them* - **Paper:** *https://arxiv.org/abs/2102.07033* - **Data:** *https://huggingface.co/datasets/sentence-transformers/embedding-training-data/resolve/main/PAQ_pairs.jsonl.gz* - **Motivation:** *Dataset for training and evaluating models of conversational response*
4,649
https://github.com/huggingface/datasets/issues/4648
Add WikiAnswers dataset
[ "uploaded dataset [here](https://huggingface.co/datasets/embedding-data/WikiAnswers)" ]
## Adding a Dataset - **Name:** *WikiAnswers* - **Description:** *The WikiAnswers corpus contains clusters of questions tagged by WikiAnswers users as paraphrases. Each cluster optionally contains an answer provided by WikiAnswers users.* - **Paper:** *https://dl.acm.org/doi/10.1145/2623330.2623677* - **Data:** *https://github.com/afader/oqa#wikianswers-corpus* - **Motivation:** *Dataset for training and evaluating models of conversational response*
4,648
https://github.com/huggingface/datasets/issues/4647
Add Reddit dataset
[]
## Adding a Dataset - **Name:** *Reddit comments (2015-2018)* - **Description:** *Reddit is an American social news aggregation website, where users can post links, and take part in discussions on these posts. These threaded discussions provide a large corpus, which is converted into a conversational dataset using the tools in this directory.* - **Paper:** *https://arxiv.org/abs/1904.06472* - **Data:** *https://github.com/PolyAI-LDN/conversational-datasets/tree/master/reddit* - **Motivation:** *Dataset for training and evaluating models of conversational response*
4,647
https://github.com/huggingface/datasets/issues/4642
Streaming issue for ccdv/pubmed-summarization
[ "Thanks for reporting @lewtun.\r\n\r\nI confirm there is an issue with streaming: it does not stream locally. ", "Oh, after investigation, the source of the issue is in the Hub dataset loading script.\r\n\r\nI'm opening a PR on the Hub dataset.", "I've opened a PR on their Hub dataset to support streaming: https://huggingface.co/datasets/ccdv/pubmed-summarization/discussions/2" ]
### Link https://huggingface.co/datasets/ccdv/pubmed-summarization ### Description This was reported by a [user of AutoTrain Evaluate](https://huggingface.co/spaces/autoevaluate/model-evaluator/discussions/7). It seems like streaming doesn't work due to the way the dataset loading script is defined? ``` Status code: 400 Exception: FileNotFoundError Message: https://huggingface.co/datasets/ccdv/pubmed-summarization/resolve/main/train.zip/train.txt ``` ### Owner No
4,642
https://github.com/huggingface/datasets/issues/4641
Dataset Viewer issue for kmfoda/booksum
[ "Thanks for reporting, @lewtun.\r\n\r\nIt works locally in streaming mode:\r\n```\r\n{'bid': 27681,\r\n 'is_aggregate': True,\r\n 'source': 'cliffnotes',\r\n 'chapter_path': 'all_chapterized_books/27681-chapters/chapters_1_to_2.txt',\r\n 'summary_path': 'finished_summaries/cliffnotes/The Last of the Mohicans/section_1_part_0.txt',\r\n 'book_id': 'The Last of the Mohicans.chapters 1-2',\r\n 'summary_id': 'chapters 1-2',\r\n 'content': None,\r\n 'summary': '{\"name\": \"Chapters 1-2\", \"url\": \"https://web.archive.org/web/20201101053205/https://www.cliffsnotes.com/literature/l/the-last-of-the-mohicans/summary-and-analysis/chapters-12\", \"summary\": \"Before any characters appear, the time and geography are made clear. Though it is the last war that England and France waged for a country that neither would retain, the wilderness between the forces still has to be...\r\n```\r\n\r\nI'm forcing the refresh of the preview. ", "The preview appears as expected once the refresh forced.", "Thank you @albertvillanova πŸ€— !" ]
### Link https://huggingface.co/datasets/kmfoda/booksum ### Description A [user of AutoTrain Evaluate](https://huggingface.co/spaces/autoevaluate/model-evaluator/discussions/9) discovered this dataset cannot be streamed due to: ``` Status code: 400 Exception: ClientResponseError Message: 401, message='Unauthorized', url=URL('https://huggingface.co/datasets/kmfoda/booksum/resolve/47953f583d6967f086cb16a2f4d2346e9834024d/test.csv') ``` I'm not sure why it says "Unauthorized" since it's just a bunch of CSV files in a repo ### Owner No
4,641
https://github.com/huggingface/datasets/issues/4639
Add HaGRID -- HAnd Gesture Recognition Image Dataset
[]
## Adding a Dataset - **Name:** HaGRID -- HAnd Gesture Recognition Image Dataset - **Description:** We introduce a large image dataset HaGRID (HAnd Gesture Recognition Image Dataset) for hand gesture recognition (HGR) systems. You can use it for image classification or image detection tasks. Proposed dataset allows to build HGR systems, which can be used in video conferencing services (Zoom, Skype, Discord, Jazz etc.), home automation systems, the automotive sector, etc. - **Paper:** https://arxiv.org/abs/2206.08219 - **Data:** https://github.com/hukenovs/hagrid Instructions to add a new dataset can be found [here](https://github.com/huggingface/datasets/blob/master/ADD_NEW_DATASET.md).
4,639
https://github.com/huggingface/datasets/issues/4637
The "all" split breaks streaming
[ "Thanks for reporting @cakiki.\r\n\r\nYes, this is a bug. We are investigating it.", "@albertvillanova Nice! Let me know if it's something I can fix my self; would love to contribtue!", "@cakiki I was working on this but if you would like to contribute, go ahead. I will close my PR. ;)\r\n\r\nFor the moment I just pushed the test (to see if it impacts other tests).", "It impacted the test `test_generator_based_download_and_prepare` and I have fixed this.\r\n\r\nSo that you can copy the test I implemented in my PR and then implement a fix for this issue that passes the test `tests/test_builder.py::test_builder_as_streaming_dataset`.", "Hi @cakiki are you still interested in working on this? Are you planning to open a PR?", "Hi @albertvillanova ! Sorry it took so long; I wanted to spend this weekend working on it." ]
## Describe the bug Not sure if this is a bug or just the way streaming works, but setting `streaming=True` did not work when setting `split="all"` ## Steps to reproduce the bug The following works: ```python ds = load_dataset('super_glue', 'wsc.fixed', split='all') ``` The following throws `ValueError: Bad split: all. Available splits: ['train', 'validation', 'test']`: ```python ds = load_dataset('super_glue', 'wsc.fixed', split='all', streaming=True) ``` ## Expected results An iterator over all splits. ## Actual results I had to do the following to achieve the desired result: ```python from itertools import chain ds = load_dataset('super_glue', 'wsc.fixed', streaming=True) it = chain.from_iterable(ds.values()) ``` ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: 2.3.2 - Platform: Linux-4.15.0-176-generic-x86_64-with-glibc2.31 - Python version: 3.10.5 - PyArrow version: 8.0.0 - Pandas version: 1.4.3
4,637
https://github.com/huggingface/datasets/issues/4636
Add info in docs about behavior of download_config.num_proc
[]
**Is your feature request related to a problem? Please describe.** I went to override `download_config.num_proc` and was confused about what was happening under the hood. It would be nice to have the behavior documented a bit better so folks know what's happening when they use it. **Describe the solution you'd like** - Add note about how the default number of workers is 16. Related code: https://github.com/huggingface/datasets/blob/7bcac0a6a0fc367cc068f184fa132b8de8dfa11d/src/datasets/download/download_manager.py#L299-L302 - Add note that if the number of workers is higher than the number of files to download, it won't use multiprocessing. **Describe alternatives you've considered** maybe it would also be nice to set `num_proc` = `num_files` when `num_proc` > `num_files`. **Additional context** ...
4,636
https://github.com/huggingface/datasets/issues/4635
Dataset Viewer issue for vadis/sv-ident
[ "Thanks for reporting, @e-tornike \r\n\r\nSome context:\r\n- #4527 \r\n\r\nThe dataset loads locally in streaming mode:\r\n```python\r\nIn [2]: from datasets import load_dataset; ds = load_dataset(\"vadis/sv-ident\", split=\"validation\", streaming=True); item = next(iter(ds)); item\r\nUsing custom data configuration default\r\nOut[2]: \r\n{'sentence': 'Im Falle von Umweltbelastungen kann selten eindeutig entschieden werden, ob Unbedenklichkeitswerte bereits erreicht oder ΓΌberschritten sind, die die menschliche Gesundheit oder andere WohlfahrtsΒ»gΓΌterΒ« beeintrΓ€chtigen.',\r\n 'is_variable': 0,\r\n 'variable': [],\r\n 'research_data': [],\r\n 'doc_id': '51971',\r\n 'uuid': 'ee3d7f88-1a3e-4a59-997f-e986b544a604',\r\n 'lang': 'de'}\r\n```", "~~I have forced the refresh of the split in the preview without success.~~\r\n\r\nI have forced the refresh of the split in the preview, and now it works.", "Preview seems to work now. \r\n\r\nhttps://huggingface.co/datasets/vadis/sv-ident/viewer/default/validation", "OK, thank you @e-tornike.\r\n\r\nApparently, after forcing the refresh, we just had to wait a little until it is effectively refreshed. ", "I'm closing this issue as it was solved after forcing the refresh of the split in the preview.", "Thanks a lot! :)" ]
### Link https://huggingface.co/datasets/vadis/sv-ident/viewer/default/validation ### Description Error message when loading validation split in the viewer: ``` Status code: 400 Exception: Status400Error Message: The split cache is empty. ``` ### Owner _No response_
4,635
https://github.com/huggingface/datasets/issues/4634
Can't load the Hausa audio dataset
[ "Could you provide the error details. It is difficult to debug otherwise. Also try other config. `ha` is not a valid." ]
common_voice_train = load_dataset("common_voice", "ha", split="train+validation")
4,634
https://github.com/huggingface/datasets/issues/4632
'sort' method sorts one column only
[ "Hi ! `ds.sort()` does sort the full dataset, not just one column:\r\n```python\r\nfrom datasets import *\r\n\r\nds = Dataset.from_dict({\"foo\": [3, 2, 1], \"bar\": [\"c\", \"b\", \"a\"]})\r\nprint(d.sort(\"foo\").to_pandas()\r\n# foo bar\r\n# 0 1 a\r\n# 1 2 b\r\n# 2 3 c\r\n```\r\n\r\nWhat made you think it was not the case ? Did you experience a situation where it was only sorting one column ?", "Hi! thank you for your quick reply!\r\nI wanted to sort the `cnn_dailymail` dataset by the length of the labels (num of characters). I added a new column to the dataset (`ds.add_column`) with the lengths and then sorted by this new column. Only the new length column was sorted, the reset left in their original order. ", "That's unexpected, can you share the code you used to get this ?" ]
The 'sort' method changes the order of one column only (the one defined by the argument 'column'), thus creating a mismatch between a sample fields. I would expect it to change the order of the samples as a whole, based on the 'column' order.
4,632
https://github.com/huggingface/datasets/issues/4629
Rename repo default branch to main
[]
Rename repository default branch to `main` (instead of current `master`). Once renamed, users will have to manually update their local repos: - [ ] Upstream: ``` git branch -m master main git fetch upstream main git branch -u upstream/main main git remote set-head upstream -a ``` - [ ] Origin: Rename fork default branch as well at: https://github.com/USERNAME/lam/settings/branches Then: ``` git fetch origin main git remote set-head origin -a ``` CC: @sgugger
4,629
https://github.com/huggingface/datasets/issues/4626
Add non-commercial licensing info for datasets for which we removed tags
[ "yep plus `license_details` also makes sense for this IMO" ]
We removed several YAML tags saying that certain datasets can't be used for commercial purposes: https://github.com/huggingface/datasets/pull/4613#discussion_r911919753 Reason for this is that we only allow tags that are part of our [supported list of licenses](https://github.com/huggingface/datasets/blob/84fc3ad73c85de4eda5d152dfede7671491449cb/src/datasets/utils/resources/standard_licenses.tsv) We should update the Licensing Information section of the concerned dataset cards, now that the non-commercial tag doesn't exist anymore for certain datasets
4,626
https://github.com/huggingface/datasets/issues/4623
Loading MNIST as Pytorch Dataset
[ "Hi ! We haven't implemented the conversion from images data to PyTorch tensors yet I think\r\n\r\ncc @mariosasko ", "So I understand:\r\n\r\nset_format() does not properly do the conversion to pytorch tensors from PIL images.\r\n\r\nSo that someone who stumbles on this can use the package:\r\n\r\n```python\r\ndataset = load_dataset(\"mnist\", split=\"train\")\r\ndef transform_func(examples):\r\n examples[\"image\"] = [np.array(img) for img in examples[\"image\"]]\r\n return examples\r\ndataset = dataset.with_transform(transform_func)\r\ndataset[0]\r\n``` ", "This then appears to work with pytorch dataloaders as:\r\n```\r\ndataloader=torch.utils.data.DataLoader(dataset,batch_size=1)\r\n```\r\n\r\nand tensorflow as:\r\n```\r\ndataset=dataset.to_tf_dataset(batch_size=1)\r\n```", "Hi! `set_transform`/`with_transform` is indeed the correct solution for the conversion. Improving this part of the API is one of the things I'm working on currently, so stay tuned!" ]
## Describe the bug Conversion of MNIST dataset to pytorch fails with bug ## Steps to reproduce the bug ```python from datasets import load_dataset dataset = load_dataset("mnist", split="train") dataset.set_format('torch') dataset[0] print() ``` ## Expected results Expect to see torch tensors image and label ## Actual results Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm 2020.3.3\plugins\python\helpers\pydev\pydevd.py", line 1491, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Program Files\JetBrains\PyCharm 2020.3.3\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:/Users/chapm/PycharmProjects/multiviewdata/multiviewdata/huggingface/mnist.py", line 13, in <module> dataset[0] File "C:\Users\chapm\PycharmProjects\multiviewdata\venv\lib\site-packages\datasets\arrow_dataset.py", line 2154, in __getitem__ return self._getitem( File "C:\Users\chapm\PycharmProjects\multiviewdata\venv\lib\site-packages\datasets\arrow_dataset.py", line 2139, in _getitem formatted_output = format_table( File "C:\Users\chapm\PycharmProjects\multiviewdata\venv\lib\site-packages\datasets\formatting\formatting.py", line 532, in format_table return formatter(pa_table, query_type=query_type) File "C:\Users\chapm\PycharmProjects\multiviewdata\venv\lib\site-packages\datasets\formatting\formatting.py", line 281, in __call__ return self.format_row(pa_table) File "C:\Users\chapm\PycharmProjects\multiviewdata\venv\lib\site-packages\datasets\formatting\torch_formatter.py", line 58, in format_row return self.recursive_tensorize(row) File "C:\Users\chapm\PycharmProjects\multiviewdata\venv\lib\site-packages\datasets\formatting\torch_formatter.py", line 54, in recursive_tensorize return map_nested(self._recursive_tensorize, data_struct, map_list=False) File "C:\Users\chapm\PycharmProjects\multiviewdata\venv\lib\site-packages\datasets\utils\py_utils.py", line 356, in map_nested mapped = [ File "C:\Users\chapm\PycharmProjects\multiviewdata\venv\lib\site-packages\datasets\utils\py_utils.py", line 357, in <listcomp> _single_map_nested((function, obj, types, None, True, None)) File "C:\Users\chapm\PycharmProjects\multiviewdata\venv\lib\site-packages\datasets\utils\py_utils.py", line 309, in _single_map_nested return {k: _single_map_nested((function, v, types, None, True, None)) for k, v in pbar} File "C:\Users\chapm\PycharmProjects\multiviewdata\venv\lib\site-packages\datasets\utils\py_utils.py", line 309, in <dictcomp> return {k: _single_map_nested((function, v, types, None, True, None)) for k, v in pbar} File "C:\Users\chapm\PycharmProjects\multiviewdata\venv\lib\site-packages\datasets\utils\py_utils.py", line 293, in _single_map_nested return function(data_struct) File "C:\Users\chapm\PycharmProjects\multiviewdata\venv\lib\site-packages\datasets\formatting\torch_formatter.py", line 51, in _recursive_tensorize return self._tensorize(data_struct) File "C:\Users\chapm\PycharmProjects\multiviewdata\venv\lib\site-packages\datasets\formatting\torch_formatter.py", line 38, in _tensorize if np.issubdtype(value.dtype, np.integer): AttributeError: 'bytes' object has no attribute 'dtype' python-BaseException ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: 2.3.2 - Platform: Windows-10-10.0.22579-SP0 - Python version: 3.9.2 - PyArrow version: 8.0.0 - Pandas version: 1.4.1
4,623
https://github.com/huggingface/datasets/issues/4621
ImageFolder raises an error with parameters drop_metadata=True and drop_labels=False when metadata.jsonl is present
[]
## Describe the bug If you pass `drop_metadata=True` and `drop_labels=False` when a `data_dir` contains at least one `matadata.jsonl` file, you will get a KeyError. This is probably not a very useful case but we shouldn't get an error anyway. Asking users to move metadata files manually outside `data_dir` or pass features manually (when there is a tool that can infer them automatically) don't look like a good idea to me either. ## Steps to reproduce the bug ### Clone an example dataset from the Hub ```bash git clone https://huggingface.co/datasets/nateraw/test-imagefolder-metadata ``` ### Try to load it ```python from datasets import load_dataset ds = load_dataset("test-imagefolder-metadata", drop_metadata=True, drop_labels=False) ``` or even just ```python ds = load_dataset("test-imagefolder-metadata", drop_metadata=True) ``` as `drop_labels=False` is a default value. ## Expected results A DatasetDict object with two features: `"image"` and `"label"`. ## Actual results ``` Traceback (most recent call last): File "/home/polina/workspace/datasets/debug.py", line 18, in <module> ds = load_dataset( File "/home/polina/workspace/datasets/src/datasets/load.py", line 1732, in load_dataset builder_instance.download_and_prepare( File "/home/polina/workspace/datasets/src/datasets/builder.py", line 704, in download_and_prepare self._download_and_prepare( File "/home/polina/workspace/datasets/src/datasets/builder.py", line 1227, in _download_and_prepare super()._download_and_prepare(dl_manager, verify_infos, check_duplicate_keys=verify_infos) File "/home/polina/workspace/datasets/src/datasets/builder.py", line 793, in _download_and_prepare self._prepare_split(split_generator, **prepare_split_kwargs) File "/home/polina/workspace/datasets/src/datasets/builder.py", line 1218, in _prepare_split example = self.info.features.encode_example(record) File "/home/polina/workspace/datasets/src/datasets/features/features.py", line 1596, in encode_example return encode_nested_example(self, example) File "/home/polina/workspace/datasets/src/datasets/features/features.py", line 1165, in encode_nested_example { File "/home/polina/workspace/datasets/src/datasets/features/features.py", line 1165, in <dictcomp> { File "/home/polina/workspace/datasets/src/datasets/utils/py_utils.py", line 249, in zip_dict yield key, tuple(d[key] for d in dicts) File "/home/polina/workspace/datasets/src/datasets/utils/py_utils.py", line 249, in <genexpr> yield key, tuple(d[key] for d in dicts) KeyError: 'label' ``` ## Environment info `datasets` master branch - `datasets` version: 2.3.3.dev0 - Platform: Linux-5.14.0-1042-oem-x86_64-with-glibc2.17 - Python version: 3.8.12 - PyArrow version: 6.0.1 - Pandas version: 1.4.1
4,621
https://github.com/huggingface/datasets/issues/4620
Data type is not recognized when using datetime.time
[ "cc @mariosasko ", "Hi, thanks for reporting! I'm investigating the issue." ]
## Describe the bug Creating a dataset from a pandas dataframe with `datetime.time` format generates an error. ## Steps to reproduce the bug ```python import pandas as pd from datetime import time from datasets import Dataset df = pd.DataFrame({"feature_name": [time(1, 1, 1)]}) dataset = Dataset.from_pandas(df) ``` ## Expected results The dataset should be created. ## Actual results ``` Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_dataset.py", line 823, in from_pandas return cls(table, info=info, split=split) File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_dataset.py", line 679, in __init__ inferred_features = Features.from_arrow_schema(arrow_table.schema) File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/features/features.py", line 1551, in from_arrow_schema obj = {field.name: generate_from_arrow_type(field.type) for field in pa_schema} File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/features/features.py", line 1551, in <dictcomp> obj = {field.name: generate_from_arrow_type(field.type) for field in pa_schema} File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/features/features.py", line 1315, in generate_from_arrow_type return Value(dtype=_arrow_to_datasets_dtype(pa_type)) File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/features/features.py", line 83, in _arrow_to_datasets_dtype return f"time64[{arrow_type.unit}]" AttributeError: 'pyarrow.lib.DataType' object has no attribute 'unit' ``` ## Environment info - `datasets` version: 2.3.3.dev0 - Platform: Linux-5.13.0-1031-aws-x86_64-with-glibc2.31 - Python version: 3.9.6 - PyArrow version: 7.0.0 - Pandas version: 1.4.2
4,620
https://github.com/huggingface/datasets/issues/4619
np arrays get turned into native lists
[ "If you add the line `dataset2.set_format('np')` before calling `dataset2[0]['tmp']` it should return `np.ndarray`.\r\nI believe internally it will not store it as a list, it is only returning a list when you index it.\r\n\r\n```\r\nIn [1]: import datasets, numpy as np\r\nIn [2]: dataset = datasets.load_dataset(\"glue\", \"mrpc\")[\"validation\"]\r\nIn [3]: dataset2 = dataset.map(lambda x: {\"tmp\": np.array([0.5])}, batched=False)\r\nIn [4]: dataset2[0][\"tmp\"]\r\nOut[4]: [0.5]\r\n\r\nIn [5]: dataset2.set_format('np')\r\n\r\nIn [6]: dataset2[0][\"tmp\"]\r\nOut[6]: array([0.5])\r\n```", "I see, thanks! Any idea if the default numpy β†’ list conversion might cause precision loss?", "I'm not super familiar with our datasets works internally, but I think your `np` array will be stored in a `pyarrow` format, and then you take a view of this as a python array. In which case, I think the precision should be preserved." ]
## Describe the bug When attaching an `np.array` field, it seems that it automatically gets turned into a list (see below). Why is this happening? Could it lose precision? Is there a way to make sure this doesn't happen? ## Steps to reproduce the bug ```python >>> import datasets, numpy as np >>> dataset = datasets.load_dataset("glue", "mrpc")["validation"] Reusing dataset glue (...) 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 3/3 [00:00<00:00, 1360.61it/s] >>> dataset2 = dataset.map(lambda x: {"tmp": np.array([0.5])}, batched=False) 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 408/408 [00:00<00:00, 10819.97ex/s] >>> dataset2[0]["tmp"] [0.5] >>> type(dataset2[0]["tmp"]) <class 'list'> ``` ## Expected results `dataset2[0]["tmp"]` should be an `np.ndarray`. ## Actual results It's a list. ## Environment info <!-- You can run the command `datasets-cli env` and copy-and-paste its output below. --> - `datasets` version: 2.3.2 - Platform: mac, though I'm pretty sure it happens on a linux machine too - Python version: 3.9.7 - PyArrow version: 6.0.1
4,619
https://github.com/huggingface/datasets/issues/4618
contribute data loading for object detection datasets with yolo data format
[ "Hi! The `imagefolder` script is already quite complex, so a standalone script sounds better. Also, I suggest we create an org on the Hub (e.g. `hf-loaders`) and store such scripts there for easier maintenance rather than having them as packaged modules (IMO only very generic loaders should be packaged). WDYT @lhoestq @albertvillanova @polinaeterna?", "@mariosasko sounds good to me!\r\n", "Thank you for the suggestion @mariosasko . I agree with the point, but I have a few doubts\r\n\r\n1. How would the user access the script if it's not a part of the core codebase?\r\n2. Could you direct me as to what will be the tasks I have to do to contribute to the code? As per my understanding, it would be like\r\n 1. Create a new org \"hf-loaders\" and add you (and more HF people) to the org\r\n 2. Add data loader script as a (model?)\r\n 3. Test it with a dataset on HF hub\r\n3. We should maybe brainstorm as to which public datasets have this format (YOLO type) and are the most important ones to test the script with. We can even add the datasets on HF Hub alongside the script", "1. Like this: `load_dataset(\"hf-loaders/yolo\", data_files=...)`\r\n2. The steps would be:\r\n 1. Create a new org `hf-community-loaders` (IMO a better name than \"hf-loaders\") and add me (as an admin)\r\n 2. Create a new dataset repo `yolo` and add the loading script to it (`yolo.py`)\r\n 3. Open a discussion to request our review\r\n4. I like this idea. Another option is to add snippets that describe how to load such datasets using the `yolo` loader." ]
**Is your feature request related to a problem? Please describe.** At the moment, HF datasets loads [image classification datasets](https://huggingface.co/docs/datasets/image_process) out-of-the-box. There could be a data loader for loading standard object detection datasets ([original discussion here](https://huggingface.co/datasets/jalFaizy/detect_chess_pieces/discussions/2)) **Describe the solution you'd like** I wrote a [custom script](https://huggingface.co/datasets/jalFaizy/detect_chess_pieces/blob/main/detect_chess_pieces.py) to load dataset which has YOLO data format. **Describe alternatives you've considered** The script can either be a standalone dataset builder, or a modified version of `ImageFolder` **Additional context** I would be happy to contribute to this, but I would do it at a very slow pace (maybe a month or two) as I have my exams approaching πŸ˜„
4,618