-
Notifications
You must be signed in to change notification settings - Fork 55
Closes #536 | Add/Update Dataloader Onto4All #635
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
Open
patrickamadeus
wants to merge
6
commits into
SEACrowd:master
Choose a base branch
from
patrickamadeus:onto4all
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9e6036d
feat: add Onto4All dataloader
patrickamadeus 0b97c0b
Merge branch 'master' into onto4all
patrickamadeus 97c34d6
fix: torubleshooting seacrowd_qa
patrickamadeus d59b656
Merge remote-tracking branch 'upstream/master' into onto4all
patrickamadeus 30a7a69
nitpick
patrickamadeus efa8d51
feat: chat agent schema
patrickamadeus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| # coding=utf-8 | ||
| # Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """ | ||
| Onto4All is a subsample of other open source performant conversational datasets. We start with a carefully curated subset of the OpenHermes-2.5-Viet dataset, co-created by @qnguyen3 and @Teknium. This dataset is specifically designed to support the training and evaluation of Multilingual language models, such as Vistral-7B-chat and VinaLlama-7B-chat, and is derived from our Supervised Fine-Tuning (SFT) data. We have included Vietnamese here, but will add more languages. | ||
| """ | ||
| from pathlib import Path | ||
| from typing import Dict, List, Tuple | ||
|
|
||
| import datasets | ||
| import pandas as pd | ||
|
|
||
| from seacrowd.utils import schemas | ||
| from seacrowd.utils.configs import SEACrowdConfig | ||
| from seacrowd.utils.constants import Tasks, Licenses | ||
|
|
||
| _CITATION = """\ | ||
| @article{Onto4All2024, | ||
| title={Onto4All: Enhancing Multilingual Conversational AI}, | ||
| author={Nguyen, Q., }, | ||
| journal={GitHub repository}, | ||
| year={2024}, | ||
| publisher={HuggingFace Datasets} | ||
| } | ||
| """ | ||
|
|
||
| _DATASETNAME = "onto4all" | ||
|
|
||
| _DESCRIPTION = """\ | ||
| Onto4All is a subsample of other open source performant conversational datasets. We start with a carefully curated subset of the OpenHermes-2.5-Viet dataset, co-created by @qnguyen3 and @Teknium. This dataset is specifically designed to support the training and evaluation of Multilingual language models, such as Vistral-7B-chat and VinaLlama-7B-chat, and is derived from our Supervised Fine-Tuning (SFT) data. We have included Vietnamese here, but will add more languages. | ||
| """ | ||
|
|
||
| _HOMEPAGE = "https://huggingface.co/datasets/ontocord/onto4all" | ||
|
|
||
| _LANGUAGES = ["vie"] | ||
|
|
||
| _LICENSE = Licenses.CC0_1_0.value | ||
|
|
||
| _LOCAL = False | ||
|
|
||
| _URLS = "https://huggingface.co/datasets/ontocord/onto4all/resolve/main/data/train-00000-of-00001.parquet?download=true" | ||
|
|
||
| _SUPPORTED_TASKS = [Tasks.QUESTION_ANSWERING] | ||
|
|
||
| _SOURCE_VERSION = "1.0.0" | ||
|
|
||
| _SEACROWD_VERSION = "1.0.0" | ||
|
|
||
| class Onto4AllDataset(datasets.GeneratorBasedBuilder): | ||
| """Onto4All is a subsample of other open source performant conversational datasets. We start with a carefully curated subset of the OpenHermes-2.5-Viet dataset, co-created by @qnguyen3 and @Teknium. This dataset is specifically designed to support the training and evaluation of Multilingual language models, such as Vistral-7B-chat and VinaLlama-7B-chat, and is derived from our Supervised Fine-Tuning (SFT) data. We have included Vietnamese here, but will add more languages.""" | ||
|
|
||
| SOURCE_VERSION = datasets.Version(_SOURCE_VERSION) | ||
| SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION) | ||
|
|
||
| BUILDER_CONFIGS = [ | ||
| SEACrowdConfig( | ||
| name=f"{_DATASETNAME}_source", | ||
| version=SOURCE_VERSION, | ||
| description=f"{_DATASETNAME} source schema", | ||
| schema="source", | ||
| subset_id=f"{_DATASETNAME}", | ||
| ), | ||
| SEACrowdConfig( | ||
| name=f"{_DATASETNAME}_seacrowd_qa", | ||
| version=SEACROWD_VERSION, | ||
| description=f"{_DATASETNAME} SEACrowd schema", | ||
| schema="seacrowd_qa", | ||
| subset_id=f"{_DATASETNAME}", | ||
| ), | ||
| ] | ||
|
|
||
| DEFAULT_CONFIG_NAME = f"{_DATASETNAME}_source" | ||
|
|
||
| def _info(self) -> datasets.DatasetInfo: | ||
|
|
||
| if self.config.schema == "source": | ||
| features = datasets.Features( | ||
| { | ||
| "id": datasets.Value("int32"), | ||
| "type": datasets.Value("string"), | ||
| "conversation": datasets.Sequence({ | ||
| "from": datasets.Value("string"), | ||
| "value": datasets.Value("string"), | ||
| "weight": datasets.Value("int32"), | ||
| }) | ||
| } | ||
| ) | ||
|
|
||
| elif self.config.schema == "seacrowd_qa": | ||
| features = schemas.qa_features | ||
|
|
||
| return datasets.DatasetInfo( | ||
| description=_DESCRIPTION, | ||
| features=features, | ||
| homepage=_HOMEPAGE, | ||
| license=_LICENSE, | ||
| citation=_CITATION, | ||
| ) | ||
|
|
||
| def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]: | ||
| """Returns SplitGenerators.""" | ||
| data_dir = dl_manager.download_and_extract(_URLS) | ||
|
|
||
| return [ | ||
| datasets.SplitGenerator( | ||
| name=datasets.Split.TRAIN, | ||
| gen_kwargs={ | ||
| "filepath": data_dir, | ||
| }, | ||
| ), | ||
| ] | ||
|
|
||
| def _generate_examples(self, filepath: Path) -> Tuple[int, Dict]: | ||
| """Yields examples as (key, example) tuples.""" | ||
| df = pd.read_parquet(filepath) | ||
|
|
||
| if self.config.schema == "source": | ||
| for i, row in df.iterrows(): | ||
| yield i, { | ||
| "id": row["id"], | ||
| "type": row["type"], | ||
| "conversation": row["conversation"], | ||
| } | ||
|
|
||
| elif self.config.schema == "seacrowd_qa": | ||
| for i, row in df.iterrows(): | ||
| context = "" | ||
| question = "" | ||
| answer = "" | ||
|
|
||
| for item in row["conversation"]: | ||
| for k,v in item.items(): | ||
| if k == "system": | ||
| context = v | ||
| elif k == "human": | ||
| question = v | ||
| elif k == "gpt": | ||
| answer = v | ||
|
|
||
| yield i, { | ||
| "id": row["id"], | ||
| "question_id": row["id"], | ||
| "document_id": "", | ||
| "question": question, | ||
| "type": row["type"], | ||
| "choices": [], | ||
| "context": context, | ||
| "answer": [answer], | ||
| "meta": {}, | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.