Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
  • Loading branch information
lhoestq and stevhliu committed Dec 3, 2021
1 parent 6d8d2c7 commit 520e9ff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/source/stream.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ Remove columns on-the-fly with :func:`datasets.IterableDataset.remove_columns`.
``Map``
^^^^^^^

As for regular map-style :class:`datasets.Dataset`, 馃 Datasets features :func:`datasets.IterableDataset.map` to process your dataset.
Unlike a map-style dataset though, the processing is applied on-the-fly when the examples are streamed.
Similar to the :func:`datasets.Dataset.map` function for a regular :class:`datasets.Dataset`, 馃 Datasets features :func:`datasets.IterableDataset.map` for processing :class:`datasets.IterableDataset`s.
:func:`datasets.IterableDataset.map` applies processing on-the-fly when examples are streamed.

It allows you to apply a processing function to each example in a dataset, independently or in batches. This function can even create new rows and columns.

In the following example, you will apply tokenization to the dataset. The function needs to accept and output a ``dict``:
The following example demonstrates how to tokenize a :class:`datasets.IterableDataset`. The function needs to accept and output a ``dict``:


.. code-block::
Expand All @@ -146,7 +146,7 @@ In the following example, you will apply tokenization to the dataset. The functi
In a training loop
^^^^^^^^^^^^^^^^^^

First let's shuffle the dataset:
:class:`datasets.IterableDataset`s can be integrated into a training loop. First, shuffle the dataset:
.. code-block::
Expand Down

1 comment on commit 520e9ff

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show benchmarks

PyArrow==3.0.0

Show updated benchmarks!

Benchmark: benchmark_array_xd.json

metric read_batch_formatted_as_numpy after write_array2d read_batch_formatted_as_numpy after write_flattened_sequence read_batch_formatted_as_numpy after write_nested_sequence read_batch_unformated after write_array2d read_batch_unformated after write_flattened_sequence read_batch_unformated after write_nested_sequence read_col_formatted_as_numpy after write_array2d read_col_formatted_as_numpy after write_flattened_sequence read_col_formatted_as_numpy after write_nested_sequence read_col_unformated after write_array2d read_col_unformated after write_flattened_sequence read_col_unformated after write_nested_sequence read_formatted_as_numpy after write_array2d read_formatted_as_numpy after write_flattened_sequence read_formatted_as_numpy after write_nested_sequence read_unformated after write_array2d read_unformated after write_flattened_sequence read_unformated after write_nested_sequence write_array2d write_flattened_sequence write_nested_sequence
new / old (diff) 0.077876 / 0.011353 (0.066523) 0.005573 / 0.011008 (-0.005435) 0.037663 / 0.038508 (-0.000845) 0.038690 / 0.023109 (0.015581) 0.349724 / 0.275898 (0.073826) 0.395958 / 0.323480 (0.072479) 0.089919 / 0.007986 (0.081933) 0.005793 / 0.004328 (0.001465) 0.009999 / 0.004250 (0.005749) 0.042795 / 0.037052 (0.005743) 0.365292 / 0.258489 (0.106803) 0.389113 / 0.293841 (0.095272) 0.105309 / 0.128546 (-0.023237) 0.014625 / 0.075646 (-0.061021) 0.315537 / 0.419271 (-0.103735) 0.060101 / 0.043533 (0.016568) 0.358861 / 0.255139 (0.103722) 0.400470 / 0.283200 (0.117271) 0.093063 / 0.141683 (-0.048620) 2.077854 / 1.452155 (0.625700) 2.095019 / 1.492716 (0.602303)

Benchmark: benchmark_getitem_100B.json

metric get_batch_of_1024_random_rows get_batch_of_1024_rows get_first_row get_last_row
new / old (diff) 0.282702 / 0.018006 (0.264696) 0.548567 / 0.000490 (0.548077) 0.005205 / 0.000200 (0.005005) 0.000133 / 0.000054 (0.000078)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.041501 / 0.037411 (0.004089) 0.026761 / 0.014526 (0.012235) 0.031359 / 0.176557 (-0.145198) 0.225997 / 0.737135 (-0.511138) 0.032542 / 0.296338 (-0.263797)

Benchmark: benchmark_iterating.json

metric read 5000 read 50000 read_batch 50000 10 read_batch 50000 100 read_batch 50000 1000 read_formatted numpy 5000 read_formatted pandas 5000 read_formatted tensorflow 5000 read_formatted torch 5000 read_formatted_batch numpy 5000 10 read_formatted_batch numpy 5000 1000 shuffled read 5000 shuffled read 50000 shuffled read_batch 50000 10 shuffled read_batch 50000 100 shuffled read_batch 50000 1000 shuffled read_formatted numpy 5000 shuffled read_formatted_batch numpy 5000 10 shuffled read_formatted_batch numpy 5000 1000
new / old (diff) 0.601502 / 0.215209 (0.386293) 6.047025 / 2.077655 (3.969371) 2.390464 / 1.504120 (0.886345) 2.040539 / 1.541195 (0.499344) 2.083782 / 1.468490 (0.615291) 0.717032 / 4.584777 (-3.867745) 6.601752 / 3.745712 (2.856040) 2.984733 / 5.269862 (-2.285128) 1.460315 / 4.565676 (-3.105362) 0.079455 / 0.424275 (-0.344820) 0.013163 / 0.007607 (0.005556) 0.784700 / 0.226044 (0.558656) 7.749624 / 2.268929 (5.480696) 3.125989 / 55.444624 (-52.318635) 2.420608 / 6.876477 (-4.455869) 2.509420 / 2.142072 (0.367348) 0.925242 / 4.805227 (-3.879985) 0.180788 / 6.500664 (-6.319876) 0.071421 / 0.075469 (-0.004048)

Benchmark: benchmark_map_filter.json

metric filter map fast-tokenizer batched map identity map identity batched map no-op batched map no-op batched numpy map no-op batched pandas map no-op batched pytorch map no-op batched tensorflow
new / old (diff) 1.913182 / 1.841788 (0.071395) 14.252775 / 8.074308 (6.178466) 41.562968 / 10.191392 (31.371576) 0.985523 / 0.680424 (0.305099) 0.667599 / 0.534201 (0.133398) 0.471078 / 0.579283 (-0.108205) 0.696860 / 0.434364 (0.262496) 0.328382 / 0.540337 (-0.211956) 0.337953 / 1.386936 (-1.048983)
PyArrow==latest
Show updated benchmarks!

Benchmark: benchmark_array_xd.json

metric read_batch_formatted_as_numpy after write_array2d read_batch_formatted_as_numpy after write_flattened_sequence read_batch_formatted_as_numpy after write_nested_sequence read_batch_unformated after write_array2d read_batch_unformated after write_flattened_sequence read_batch_unformated after write_nested_sequence read_col_formatted_as_numpy after write_array2d read_col_formatted_as_numpy after write_flattened_sequence read_col_formatted_as_numpy after write_nested_sequence read_col_unformated after write_array2d read_col_unformated after write_flattened_sequence read_col_unformated after write_nested_sequence read_formatted_as_numpy after write_array2d read_formatted_as_numpy after write_flattened_sequence read_formatted_as_numpy after write_nested_sequence read_unformated after write_array2d read_unformated after write_flattened_sequence read_unformated after write_nested_sequence write_array2d write_flattened_sequence write_nested_sequence
new / old (diff) 0.074162 / 0.011353 (0.062809) 0.004854 / 0.011008 (-0.006154) 0.035919 / 0.038508 (-0.002589) 0.036984 / 0.023109 (0.013875) 0.369220 / 0.275898 (0.093322) 0.411589 / 0.323480 (0.088109) 0.090690 / 0.007986 (0.082704) 0.004917 / 0.004328 (0.000589) 0.008021 / 0.004250 (0.003771) 0.041092 / 0.037052 (0.004040) 0.363158 / 0.258489 (0.104669) 0.418912 / 0.293841 (0.125071) 0.105777 / 0.128546 (-0.022769) 0.013764 / 0.075646 (-0.061882) 0.325679 / 0.419271 (-0.093592) 0.057508 / 0.043533 (0.013975) 0.400769 / 0.255139 (0.145630) 0.408444 / 0.283200 (0.125244) 0.086644 / 0.141683 (-0.055039) 2.083951 / 1.452155 (0.631797) 2.146807 / 1.492716 (0.654091)

Benchmark: benchmark_getitem_100B.json

metric get_batch_of_1024_random_rows get_batch_of_1024_rows get_first_row get_last_row
new / old (diff) 0.288347 / 0.018006 (0.270341) 0.562154 / 0.000490 (0.561664) 0.001278 / 0.000200 (0.001078) 0.000104 / 0.000054 (0.000050)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.036669 / 0.037411 (-0.000742) 0.025304 / 0.014526 (0.010778) 0.029478 / 0.176557 (-0.147078) 0.238412 / 0.737135 (-0.498723) 0.034759 / 0.296338 (-0.261580)

Benchmark: benchmark_iterating.json

metric read 5000 read 50000 read_batch 50000 10 read_batch 50000 100 read_batch 50000 1000 read_formatted numpy 5000 read_formatted pandas 5000 read_formatted tensorflow 5000 read_formatted torch 5000 read_formatted_batch numpy 5000 10 read_formatted_batch numpy 5000 1000 shuffled read 5000 shuffled read 50000 shuffled read_batch 50000 10 shuffled read_batch 50000 100 shuffled read_batch 50000 1000 shuffled read_formatted numpy 5000 shuffled read_formatted_batch numpy 5000 10 shuffled read_formatted_batch numpy 5000 1000
new / old (diff) 0.638791 / 0.215209 (0.423582) 6.217863 / 2.077655 (4.140208) 2.381836 / 1.504120 (0.877716) 2.009365 / 1.541195 (0.468170) 2.011184 / 1.468490 (0.542694) 0.729865 / 4.584777 (-3.854912) 6.714923 / 3.745712 (2.969211) 4.869422 / 5.269862 (-0.400440) 1.482012 / 4.565676 (-3.083665) 0.084447 / 0.424275 (-0.339828) 0.012724 / 0.007607 (0.005117) 0.810386 / 0.226044 (0.584342) 8.182435 / 2.268929 (5.913507) 3.116205 / 55.444624 (-52.328420) 2.392967 / 6.876477 (-4.483510) 2.459678 / 2.142072 (0.317605) 0.956542 / 4.805227 (-3.848685) 0.196441 / 6.500664 (-6.304223) 0.076708 / 0.075469 (0.001239)

Benchmark: benchmark_map_filter.json

metric filter map fast-tokenizer batched map identity map identity batched map no-op batched map no-op batched numpy map no-op batched pandas map no-op batched pytorch map no-op batched tensorflow
new / old (diff) 1.897244 / 1.841788 (0.055457) 13.944640 / 8.074308 (5.870332) 41.243842 / 10.191392 (31.052450) 0.945355 / 0.680424 (0.264931) 0.645874 / 0.534201 (0.111673) 0.459477 / 0.579283 (-0.119806) 0.687470 / 0.434364 (0.253106) 0.327565 / 0.540337 (-0.212772) 0.338090 / 1.386936 (-1.048846)

CML watermark

Please sign in to comment.