Sample by paragraph in the Viewer

#2
by lhoestq HF staff - opened

Added sample_by: paragraph in the YAML configuration so that the dataset is sampled by paragraph in the Viewer and also in load_dataset, instead of line by line

OpenLLM France org

Thanks a lot @lhoestq !
I could not find out how to configure the viewer.
And your fix goes even further (it change the default behavior of the dataset, to encourage correct use)

Just one thing: can we please let the example code as it is?
even if "sample_by" is now not required with "load_dataset", it cannot be harmful to let it here (so that people can think of other ways of loading the dataset, speech turn by speech turn, for instance).

lhoestq changed pull request title from Samply by paragraph in the Viewer to Sample by paragraph in the Viewer

I could not find out how to configure the viewer.

We added the documentation about it quite recently ;)
https://huggingface.co/docs/hub/datasets-viewer

Just one thing: can we please let the example code as it is?
even if "sample_by" is now not required with "load_dataset", it cannot be harmful to let it here (so that people can think of other ways of loading the dataset, speech turn by speech turn, for instance).

Sure, I just reverted the code snippet change.
You can also document the other sampling strategies if you think they can be useful (possible values are "line", "paragraph" and "document")

OpenLLM France org

Thanks a lot

Jeronymous changed pull request status to merged

I forgot to specify the data_files in the configs, sorry. Another PR here to fix this: https://huggingface.co/datasets/OpenLLM-France/Claire-Dialogue-French-0.1/discussions/3

OpenLLM France org

@lhoestq
I tested after this fix (and having cleaned my ~/.cache/huggingface/datasets just in case):
If "sample_by" is not specified, it seems to iterates on lines (i.e. speech turns) not on paragraphs (i.e. full conversations):

In [1]: from datasets import load_dataset

In [2]: dataset = load_dataset("OpenLLM-France/Claire-Dialogue-French-0.1")

In [3]: len(dataset["train"])
Out[3]: 2934084

I expected it to be 36731 after your modification (I understood it would modify the default value of sample_by option):

In [4]: dataset = load_dataset("OpenLLM-France/Claire-Dialogue-French-0.1", sample_by="paragraph")

In [5]: len(dataset["train"])
Out[5]: 36731

Where is it wrong?

OpenLLM France org

... and I have:

In [8]: datasets.__version__
Out[8]: '2.8.0'

Which version of datasets are you using ?
It seems to work fine on my side and in the Viewer

>>> load_dataset("OpenLLM-France/Claire-Dialogue-French-0.1")
DatasetDict({
    train: Dataset({
        features: ['text'],
        num_rows: 36731
    })
    test: Dataset({
        features: ['text'],
        num_rows: 284
    })
})

You should update datasets then ;)

Sign up or log in to comment