-
Notifications
You must be signed in to change notification settings - Fork 163
MT datasets FLORES200 and WMT24pp #892
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
53c1ec8
initial commit for flores200, wmt24pp datasets and bleu metrics
AlexGrinch 0856d8f
added docs
AlexGrinch 7985a85
added dependencies
AlexGrinch 342674e
fixed requirements
AlexGrinch 868f91a
Merge branch 'main' into ohrinchuk/mt_datasets
AlexGrinch f22814e
pre commit passed
AlexGrinch b9d9ac4
Merge branch 'ohrinchuk/mt_datasets' of https://github.com/NVIDIA/NeM…
AlexGrinch 54b60a1
docstring corrected
AlexGrinch e7b23bd
better docs for multilingual, todo for mt metrics
AlexGrinch ba14f6f
Merge branch 'main' into ohrinchuk/mt_datasets
Kipok 1f848d7
Merge branch 'main' into ohrinchuk/mt_datasets
AlexGrinch 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
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
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
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
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
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
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,22 @@ | ||
| # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # | ||
| # 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. | ||
|
|
||
|
|
||
| # settings that define how evaluation should be done by default (all can be changed from cmdline) | ||
|
|
||
| PROMPT_CONFIG = "multilingual/segment-translation" | ||
| DATASET_GROUP = "chat" | ||
| METRICS_TYPE = "translation" | ||
| EVAL_ARGS = "++eval_type=no-op" | ||
| GENERATION_ARGS = "" |
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,73 @@ | ||
| # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # | ||
| # 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. | ||
|
|
||
| import argparse | ||
| import json | ||
| from pathlib import Path | ||
|
|
||
| from datasets import load_dataset | ||
| from langcodes import Language | ||
|
|
||
|
|
||
| def write_data_to_file(output_file, datasets, src_languages, tgt_languages): | ||
| with open(output_file, "wt", encoding="utf-8") as fout: | ||
| for src_lang in src_languages: | ||
| for tgt_lang in tgt_languages: | ||
| if src_lang != tgt_lang: | ||
| for src, tgt in zip(datasets[src_lang], datasets[tgt_lang], strict=True): | ||
| json_dict = { | ||
| "text": src, | ||
| "translation": tgt, | ||
| "source_language": src_lang, | ||
| "target_language": tgt_lang, | ||
| "source_lang_name": Language(src_lang).display_name(), | ||
| "target_lang_name": Language(tgt_lang).display_name(), | ||
| } | ||
| json.dump(json_dict, fout) | ||
| fout.write("\n") | ||
|
|
||
|
|
||
| def main(args): | ||
| all_languages = list(set(args.source_languages).union(set(args.target_languages))) | ||
|
|
||
| datasets = {} | ||
| for lang in all_languages: | ||
| iso_639_3 = Language(lang).to_alpha3() | ||
| iso_15924 = Language(lang).maximize().script | ||
| lang_code = f"{iso_639_3}_{iso_15924}" | ||
| datasets[lang] = load_dataset("openlanguagedata/flores_plus", lang_code, split=args.split)["text"] | ||
|
|
||
| data_dir = Path(__file__).absolute().parent | ||
| data_dir.mkdir(exist_ok=True) | ||
| output_file = data_dir / f"{args.split}.jsonl" | ||
| write_data_to_file(output_file, datasets, src_languages=args.source_languages, tgt_languages=args.target_languages) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument("--split", default="dev", choices=("dev", "devtest"), help="Dataset split to process.") | ||
| parser.add_argument( | ||
| "--source_languages", | ||
| default=["en", "de", "es", "fr", "it", "ja"], | ||
| nargs="+", | ||
| help="Languages to translate from.", | ||
| ) | ||
| parser.add_argument( | ||
| "--target_languages", | ||
| default=["en", "de", "es", "fr", "it", "ja"], | ||
| nargs="+", | ||
| help="Languages to translate to.", | ||
| ) | ||
| args = parser.parse_args() | ||
| main(args) |
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,22 @@ | ||
| # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # | ||
| # 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. | ||
|
|
||
|
|
||
| # settings that define how evaluation should be done by default (all can be changed from cmdline) | ||
|
|
||
| PROMPT_CONFIG = "multilingual/segment-translation" | ||
| DATASET_GROUP = "chat" | ||
| METRICS_TYPE = "translation" | ||
| EVAL_ARGS = "++eval_type=no-op" | ||
| GENERATION_ARGS = "" |
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,60 @@ | ||
| # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # | ||
| # 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. | ||
|
|
||
| import argparse | ||
| import json | ||
| from pathlib import Path | ||
|
|
||
| from datasets import load_dataset | ||
| from langcodes import Language | ||
|
|
||
|
|
||
| def write_data_to_file(output_file, datasets, tgt_languages): | ||
| with open(output_file, "wt", encoding="utf-8") as fout: | ||
| for tgt_lang in tgt_languages: | ||
| for src, tgt in zip(datasets[tgt_lang]["source"], datasets[tgt_lang]["target"], strict=True): | ||
| json_dict = { | ||
| "text": src, | ||
| "translation": tgt, | ||
| "source_language": "en", | ||
| "target_language": tgt_lang, | ||
| "source_lang_name": "English", | ||
| "target_lang_name": Language(tgt_lang[:2]).display_name(), | ||
| } | ||
| json.dump(json_dict, fout) | ||
| fout.write("\n") | ||
|
|
||
|
|
||
| def main(args): | ||
| datasets = {} | ||
| for lang in args.target_languages: | ||
| datasets[lang] = load_dataset("google/wmt24pp", f"en-{lang}")["train"] | ||
|
|
||
| data_dir = Path(__file__).absolute().parent | ||
| data_dir.mkdir(exist_ok=True) | ||
| output_file = data_dir / f"{args.split}.jsonl" | ||
| write_data_to_file(output_file, datasets, tgt_languages=args.target_languages) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument("--split", default="test", choices=("test",), help="Dataset split to process.") | ||
| parser.add_argument( | ||
| "--target_languages", | ||
| default=["de_DE", "es_MX", "fr_FR", "it_IT", "ja_JP"], | ||
| nargs="+", | ||
| help="Languages to translate to.", | ||
| ) | ||
| args = parser.parse_args() | ||
| main(args) |
Oops, something went wrong.
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.