-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from allenai/soldni/tok_improve
Added falcon dataset
- Loading branch information
Showing
5 changed files
with
157 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
24 changes: 24 additions & 0 deletions
24
pretrain_data/mixer/config/ablations/dedupers/abl-cc-v2-dedup.json
This file contains 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,24 @@ | ||
{ | ||
"documents": [ | ||
"pretraining-data/sources/common-crawl/v2-small/documents/*" | ||
], | ||
"work_dir": { | ||
"input": "/data2/abl-cc-v2-dedup/deduper/input", | ||
"output": "/data2/abl-cc-v2-dedup/deduper/output" | ||
}, | ||
"dedupe": { | ||
"name": "decontamination", | ||
"paragraphs": { | ||
"attribute_name": "bff_duplicate_paragraph_spans" | ||
}, | ||
"skip_empty": true | ||
}, | ||
"bloom_filter": { | ||
"file": "/tmp/decontamination/deduper_decontamination_lucas_20230525.bin", | ||
"size_in_bytes": 8388608, | ||
"read_only": true, | ||
"estimated_doc_count": 3898706, | ||
"desired_false_positive_rate": 0.001 | ||
}, | ||
"processes": 120 | ||
} |
26 changes: 26 additions & 0 deletions
26
pretrain_data/mixer/config/ablations/mixers/abl-cc-v1-dedup.json
This file contains 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,26 @@ | ||
{ | ||
"streams": [ | ||
{ | ||
"name": "abl-cc-v1-dedup", | ||
"documents": [ | ||
"pretraining-data/sources/common-crawl/v1-small/documents/*" | ||
], | ||
"output": { | ||
"path": "pretraining-data/sources/common-crawl/abl-cc-v1-dedup/documents", | ||
"max_size_in_bytes": 4294967296 | ||
}, | ||
"attributes": ["decontamination"], | ||
"filter": { | ||
"include": [], | ||
"exclude": [ | ||
"$@.attributes[?(@.bff_duplicate_paragraph_spans && @.bff_duplicate_paragraph_spans[0] && @.bff_duplicate_paragraph_spans[0][2] >= 1.0)]" | ||
] | ||
} | ||
} | ||
], | ||
"work_dir": { | ||
"input": "/data2/abl-cc-v1-dedup/mixer/input", | ||
"output": "/data2/abl-cc-v1-dedup/mixer/output" | ||
}, | ||
"processes": 120 | ||
} |
26 changes: 26 additions & 0 deletions
26
pretrain_data/mixer/config/ablations/mixers/abl-cc-v2-dedup.json
This file contains 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,26 @@ | ||
{ | ||
"streams": [ | ||
{ | ||
"name": "abl-cc-v2-dedup", | ||
"documents": [ | ||
"pretraining-data/sources/common-crawl/v2-small/documents/*" | ||
], | ||
"output": { | ||
"path": "pretraining-data/sources/common-crawl/abl-cc-v2-dedup/documents", | ||
"max_size_in_bytes": 4294967296 | ||
}, | ||
"attributes": ["decontamination"], | ||
"filter": { | ||
"include": [], | ||
"exclude": [ | ||
"$@.attributes[?(@.bff_duplicate_paragraph_spans && @.bff_duplicate_paragraph_spans[0] && @.bff_duplicate_paragraph_spans[0][2] >= 1.0)]" | ||
] | ||
} | ||
} | ||
], | ||
"work_dir": { | ||
"input": "/data2/abl-cc-v2-dedup/mixer/input", | ||
"output": "/data2/abl-cc-v2-dedup/mixer/output" | ||
}, | ||
"processes": 120 | ||
} |
This file contains 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,66 @@ | ||
""" | ||
Split gzipped files into smaller gzipped files. | ||
Author: @soldni | ||
""" | ||
|
||
import concurrent.futures | ||
import gzip | ||
import os | ||
from contextlib import ExitStack | ||
|
||
import click | ||
|
||
MAX_SIZE_4_GB = 4 * 1024 * 1024 * 1024 | ||
|
||
|
||
@click.command() | ||
@click.option("--input_dir", required=True, help="Path to input directory containing gzip files") | ||
@click.option("--input_ext", default=".gz", help="Extension of the input files") | ||
@click.option("--output_dir", required=True, help="Path to output directory for the split files") | ||
@click.option("--output_ext", default=".gz", help="Extension of the output files") | ||
@click.option("--size_limit", default=MAX_SIZE_4_GB, help="Size limit for each split file in bytes") | ||
def main(input_dir: str, input_ext: str, output_dir: str, output_ext: str, size_limit: int): | ||
os.makedirs(output_dir, exist_ok=True) | ||
|
||
def split_gzip_file(input_file, output_base, size_limit=size_limit, output_ext=output_ext): | ||
print(f"Splitting {input_file} into {output_base} with size limit {size_limit:,}") | ||
with ExitStack() as stack, gzip.open(input_file, "rt") as f: | ||
count = 0 | ||
path = f"{output_base}_{count:04d}{output_ext}" | ||
output = stack.enter_context(gzip.open(path, "wt")) | ||
current_size = 0 | ||
for line in f: | ||
line_size = len(line) | ||
if current_size + line_size > size_limit: | ||
stack.pop_all().close() | ||
count += 1 | ||
print(f"Wrote {path}") | ||
path = f"{output_base}_{count:04d}{output_ext}" | ||
output = stack.enter_context(gzip.open(path, "wt")) | ||
current_size = 0 | ||
output.write(str(line)) | ||
current_size += line_size | ||
print(f"Wrote {path}") | ||
stack.pop_all().close() | ||
print(f"Finished splitting {input_file} into {count + 1:,} files") | ||
|
||
def process_file(file_name, input_ext=input_ext, input_dir=input_dir, output_dir=output_dir): | ||
input_file = os.path.join(input_dir, file_name) | ||
if file_name.endswith(input_ext) and os.path.isfile(input_file): | ||
base_name = file_name.rstrip(input_ext) | ||
output_base = os.path.join(output_dir, base_name) | ||
split_gzip_file(input_file, output_base) | ||
|
||
files_to_process = [ | ||
file_name | ||
for file_name in os.listdir(input_dir) | ||
if file_name.endswith(input_ext) and os.path.isfile(os.path.join(input_dir, file_name)) | ||
] | ||
|
||
with concurrent.futures.ThreadPoolExecutor() as executor: | ||
executor.map(process_file, files_to_process) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |