-
Notifications
You must be signed in to change notification settings - Fork 110
Add normalization and tokenization for starcoder2-extras #4626
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
6 commits
Select commit
Hold shift + click to select a range
847e48b
Add starcoder2data-extras download and tokenization
Helw150 d285899
Add normalization, record splitting, and configurable batch size for …
ravwojdyla 29bcf0b
Revert max_record_size from normalize step
ravwojdyla 943dfab
Expose resources and worker_resources on default_tokenize; bump docum…
ravwojdyla 031e3bc
Clean up redundant resources override for documentation subset
ravwojdyla daf2a49
Validate levanter_batch_size is positive
ravwojdyla 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Copyright The Marin Authors | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """StarCoder2 data extras: download and tokenize ir_cpp, ir_python, ir_rust, ir_low_resource, documentation.""" | ||
|
|
||
| from experiments.defaults import default_tokenize | ||
| from experiments.marin_models import marin_tokenizer | ||
| from fray.v2 import ResourceConfig | ||
| from levanter.data.text.formats import TextLmDatasetFormat | ||
| from marin.datakit.download.starcoder2_extras import ( | ||
| SUBSETS, | ||
| download_starcoder2_extras_step, | ||
| ) | ||
| from marin.datakit.normalize import normalize_step | ||
| from marin.execution.executor import executor_main | ||
| from marin.processing.tokenize.data_configs import TokenizerStep | ||
|
|
||
|
|
||
| def tokenize_starcoder2_extras(*, tokenizer: str = marin_tokenizer) -> list[TokenizerStep]: | ||
| """Download, normalize, and tokenize all selected starcoder2data-extras subsets.""" | ||
| steps = [] | ||
| for subset in SUBSETS: | ||
| download = download_starcoder2_extras_step(subset) | ||
| normalized = normalize_step( | ||
| name=f"normalized/starcoder2_extras/{subset}", | ||
| download=download, | ||
| text_field="content", | ||
| file_extensions=(".parquet",), | ||
| ) | ||
| # documentation contains a single 64MB OpenJDK record that peaks at ~9GB RSS | ||
| # during tokenization; bump memory to 32GB for that subset | ||
| doc_resources = ResourceConfig(ram="32g", disk="10g") if subset == "documentation" else None | ||
| steps.append( | ||
| default_tokenize( | ||
| name=f"starcoder2_extras/{subset}", | ||
| dataset=normalized.as_executor_step(), | ||
| tokenizer=tokenizer, | ||
| format=TextLmDatasetFormat(text_key="text"), | ||
| levanter_batch_size=128, | ||
| worker_resources=doc_resources, | ||
| ) | ||
| ) | ||
| return steps | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| executor_main(steps=tokenize_starcoder2_extras()) |
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,31 @@ | ||
| # Copyright The Marin Authors | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Download subsets of the bigcode/starcoder2data-extras dataset from HuggingFace. | ||
|
|
||
| Subsets: ir_cpp, ir_python, ir_rust, ir_low_resource, documentation, kaggle. | ||
| """ | ||
|
|
||
| from marin.datakit.download.huggingface import download_hf_step | ||
| from marin.execution.step_spec import StepSpec | ||
|
|
||
| HF_DATASET_ID = "bigcode/starcoder2data-extras" | ||
| HF_REVISION = "1ba0d4f" | ||
|
|
||
| SUBSETS = ["ir_cpp", "ir_python", "ir_rust", "ir_low_resource", "documentation", "kaggle"] | ||
|
|
||
|
|
||
| def download_starcoder2_extras_step(subset: str) -> StepSpec: | ||
| """Download a single subset of the starcoder2data-extras dataset.""" | ||
| return download_hf_step( | ||
| f"raw/starcoder2_extras/{subset}", | ||
| hf_dataset_id=HF_DATASET_ID, | ||
| revision=HF_REVISION, | ||
| hf_urls_glob=[f"{subset}/*.parquet"], | ||
| override_output_path=f"raw/starcoder2_extras-{HF_REVISION}/{subset}", | ||
| ) | ||
|
|
||
|
|
||
| def download_all_starcoder2_extras_steps() -> list[StepSpec]: | ||
| """Download all selected subsets of starcoder2data-extras.""" | ||
| return [download_starcoder2_extras_step(subset) for subset in SUBSETS] |
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
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.