Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #424 | Add Dataloader Bactrian-X #552

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

akhdanfadh
Copy link
Collaborator

Closes #424

I implemented one config per language/subset. Thus, configs will look like this: bactrian_x_id_source, bactrian_x_km_seacrowd_t2t, etc. When testing, pass bactrian_x_<subset> to the --subset_id parameter.

As there is one more variable for the input response in the source schema, I added that manually as Instruction: {instruction}\nInput: {input}" in text_1 of seacrowd_t2t schema. I don't know if that is allowed, so let's discuss.

Note that for Khmer subset, the loaded data will look as follows:

INFO:__main__:Dataset sample [source]
{'instruction': 'តើ\u200bស៊ុម\u200bក្រិត\u200bក្នុង\u200bការ\u200bថត\u200bរូប\u200bតារាសាស្ត្រ\u200bមាន\u200bអ្វីខ្លះ?', 'input': '', 'id': 'dolly-10828', 'output': 'ស៊ុម\u200bក្រិត\u200bក្នុង\u200bការ\u200bថត\u200bរូប\u200bតារាសាស្ត្រ\u200bវាប្រកាស\u200bពី\u200bប្រភេទ\u200bនិង\u200bលក្ខណៈ\u200bរបស់\u200bរូបភាព\u200b។ វាតម្រូវ\u200bឲ្យ\u200bទៅ\u200bដល់\u200bលក្ខណៈ\u200bប្រូបាបនៃ\u200bរូបភាព\u200bដែល\u200bប្រើ\u200bដើម្បី\u200bថត\u200bបន្ទាត់\u200bស្មើ\u200bនឹង\u200bតម្លៃ\u200bមួយ\u200bចំនួន\u200b។ ក្នុង\u200bបំណង\u200bនេះ\u200bនៃ\u200bការថត\u200bរូប\u200bតារាសាស្ត្រ\u200bមាន\u200bករណី\u200bដូចជា\u200bប្រូបាប\u200bពណ៌\u200bរូបភាព\u200bក្បែរ\u200bតែ\u200bមិន\u200bត្រូវ\u200bបាន\u200bប្រាកដ\u200bនៅពេលដែល\u200bវា\u200bល្អបំផុត\u200bទេ\u200b។ គុណភាព\u200bរូបភាព\u200bមាន\u200bតម្លៃ\u200bបំផុត\u200bនៅ\u200bពេល\u200bដែល\u200bវា\u200bអាច\u200bប្រើ\u200bបាន\u200bទៅ\u200bនឹង\u200bប្រិតប្រយ័ត្ន\u200bនៃ\u200bវាល\u200bផ្សេងទៀត\u200bដែល\u200bវា\u200bត្រូវ\u200bបានផ្ដល់។'}
INFO:__main__:Dataset sample [seacrowd_t2t]
{'id': 'dolly-10828', 'text_1': 'Instruction: តើ\u200bស៊ុម\u200bក្រិត\u200bក្នុង\u200bការ\u200bថត\u200bរូប\u200bតារាសាស្ត្រ\u200bមាន\u200bអ្វីខ្លះ?\nInput: ', 'text_2': 'ស៊ុម\u200bក្រិត\u200bក្នុង\u200bការ\u200bថត\u200bរូប\u200bតារាសាស្ត្រ\u200bវាប្រកាស\u200bពី\u200bប្រភេទ\u200bនិង\u200bលក្ខណៈ\u200bរបស់\u200bរូបភាព\u200b។ វាតម្រូវ\u200bឲ្យ\u200bទៅ\u200bដល់\u200bលក្ខណៈ\u200bប្រូបាបនៃ\u200bរូបភាព\u200bដែល\u200bប្រើ\u200bដើម្បី\u200bថត\u200bបន្ទាត់\u200bស្មើ\u200bនឹង\u200bតម្លៃ\u200bមួយ\u200bចំនួន\u200b។ ក្នុង\u200bបំណង\u200bនេះ\u200bនៃ\u200bការថត\u200bរូប\u200bតារាសាស្ត្រ\u200bមាន\u200bករណី\u200bដូចជា\u200bប្រូបាប\u200bពណ៌\u200bរូបភាព\u200bក្បែរ\u200bតែ\u200bមិន\u200bត្រូវ\u200bបាន\u200bប្រាកដ\u200bនៅពេលដែល\u200bវា\u200bល្អបំផុត\u200bទេ\u200b។ គុណភាព\u200bរូបភាព\u200bមាន\u200bតម្លៃ\u200bបំផុត\u200bនៅ\u200bពេល\u200bដែល\u200bវា\u200bអាច\u200bប្រើ\u200bបាន\u200bទៅ\u200bនឹង\u200bប្រិតប្រយ័ត្ន\u200bនៃ\u200bវាល\u200bផ្សេងទៀត\u200bដែល\u200bវា\u200bត្រូវ\u200bបានផ្ដល់។', 'text_1_name': 'instruction + input', 'text_2_name': 'output'}

At first, I thought this should be an encoding problem and need to be solved. But turns out I also get the same result when loading from HF directly as follows:

from datasets import load_dataset

data = load_dataset("MBZUAI/Bactrian-X", "km")
print(data['train'][0])
# {'instruction': 'តើ\u200bស៊ុម\u200bក្រិត\u200bក្នុង\u200bការ\u200bថត\u200bរូប\u200bតារាសាស្ត្រ\u200bមាន\u200bអ្វីខ្លះ?', 'input': '', 'id': 'dolly-10828', 'output': 'ស៊ុម\u200bក្រិត\u200bក្នុង\u200bការ\u200bថត\u200bរូប\u200bតារាសាស្ត្រ\u200bវាប្រកាស\u200bពី\u200bប្រភេទ\u200bនិង\u200bលក្ខណៈ\u200bរបស់\u200bរូបភាព\u200b។ វាតម្រូវ\u200bឲ្យ\u200bទៅ\u200bដល់\u200bលក្ខណៈ\u200bប្រូបាបនៃ\u200bរូបភាព\u200bដែល\u200bប្រើ\u200bដើម្បី\u200bថត\u200bបន្ទាត់\u200bស្មើ\u200bនឹង\u200bតម្លៃ\u200bមួយ\u200bចំនួន\u200b។ ក្នុង\u200bបំណង\u200bនេះ\u200bនៃ\u200bការថត\u200bរូប\u200bតារាសាស្ត្រ\u200bមាន\u200bករណី\u200bដូចជា\u200bប្រូបាប\u200bពណ៌\u200bរូបភាព\u200bក្បែរ\u200bតែ\u200bមិន\u200bត្រូវ\u200bបាន\u200bប្រាកដ\u200bនៅពេលដែល\u200bវា\u200bល្អបំផុត\u200bទេ\u200b។ គុណភាព\u200bរូបភាព\u200bមាន\u200bតម្លៃ\u200bបំផុត\u200bនៅ\u200bពេល\u200bដែល\u200bវា\u200bអាច\u200bប្រើ\u200bបាន\u200bទៅ\u200bនឹង\u200bប្រិតប្រយ័ត្ន\u200bនៃ\u200bវាល\u200bផ្សេងទៀត\u200bដែល\u200bវា\u200bត្រូវ\u200bបានផ្ដល់។'}

Checkbox

  • Confirm that this PR is linked to the dataset issue.
  • Create the dataloader script seacrowd/sea_datasets/{my_dataset}/{my_dataset}.py (please use only lowercase and underscore for dataset folder naming, as mentioned in dataset issue) and its __init__.py within {my_dataset} folder.
  • Provide values for the _CITATION, _DATASETNAME, _DESCRIPTION, _HOMEPAGE, _LICENSE, _LOCAL, _URLs, _SUPPORTED_TASKS, _SOURCE_VERSION, and _SEACROWD_VERSION variables.
  • Implement _info(), _split_generators() and _generate_examples() in dataloader script.
  • Make sure that the BUILDER_CONFIGS class attribute is a list with at least one SEACrowdConfig for the source schema and one for a seacrowd schema.
  • Confirm dataloader script works with datasets.load_dataset function.
  • Confirm that your dataloader script passes the test suite run with python -m tests.test_seacrowd seacrowd/sea_datasets/<my_dataset>/<my_dataset>.py or python -m tests.test_seacrowd seacrowd/sea_datasets/<my_dataset>/<my_dataset>.py --subset_id {subset_name_without_source_or_seacrowd_suffix}.
  • If my dataset is local, I have provided an output of the unit-tests in the PR (please copy paste). This is OPTIONAL for public datasets, as we can test these without access to the data files.

Copy link
Collaborator

@ljvmiranda921 ljvmiranda921 left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +26 to +33
@misc{li2023bactrianx,
title={Bactrian-X : A Multilingual Replicable Instruction-Following Model with Low-Rank Adaptation},
author={Haonan Li and Fajri Koto and Minghao Wu and Alham Fikri Aji and Timothy Baldwin},
year={2023},
eprint={2305.15011},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unsure if we should follow this and cite the other papers (seem unrelated to the dataset)

image

Copy link
Collaborator

@raileymontalan raileymontalan left a comment

Choose a reason for hiding this comment

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

Reviewed and tested. LGTM, thanks @akhdanfadh :)

@ljvmiranda921
Copy link
Collaborator

Merging in a few

Copy link
Collaborator

@ljvmiranda921 ljvmiranda921 left a comment

Choose a reason for hiding this comment

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

LGTM

@ljvmiranda921 ljvmiranda921 merged commit 7fd3466 into SEACrowd:master Apr 12, 2024
1 check passed
@akhdanfadh akhdanfadh deleted the bactrian_x branch May 6, 2024 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create dataset loader for Bactrian-X
3 participants