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

Mixer validator #215

Merged
merged 24 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b724d5f
Adding script that validates if mixer config is well formated and has…
Sep 10, 2024
1954932
Add S3 path validation with boto3 existence check
Sep 13, 2024
9ebe5f1
Adding check of the files, trying to run jq expressions on them and s…
Sep 16, 2024
67adadf
Add S3 path validation, sampling, and doc-attribute alignment checks
Sep 25, 2024
4391805
adding logic to split jsonpath expressions into pieces and check them
Sep 25, 2024
2885e7e
Added JsonPath syntax evaluation, started working on sampling docs an…
Sep 25, 2024
82920f8
Adding logic to check if all doc and corresponding attributes files c…
Sep 27, 2024
8745c8d
Adding functionality to check if filters in config and attribute file…
Oct 3, 2024
564cee6
updating filter checking logic to focus on filters missing from the m…
Oct 3, 2024
5e7e3d4
adding ligic to run jq and jsonpath filters on small set of docs to s…
Oct 7, 2024
445bfef
refactored to use smart open and added logic to download sample files…
Oct 9, 2024
83481ac
added logic to sample lines from doc and apply filters to it, refacto…
Oct 11, 2024
890de88
Adding clean up logic to delete sample files after the run
Oct 11, 2024
50763bd
Merge branch 'main' of https://github.com/allenai/dolma into mixer-va…
Oct 11, 2024
001fd04
adding test configs for mixer validator
Oct 14, 2024
15a7104
fixing bug in test configs
Oct 14, 2024
b740e45
addressing comments, spliting script into smaller files, moving test …
Oct 16, 2024
c1708e2
adding --verbose method, support of .env variables
Oct 17, 2024
2aca6a3
supporting != operator
Oct 17, 2024
d10de44
updating types in function definitions, updating Readme
Oct 21, 2024
e59c64b
fixing a bug in readme
Oct 21, 2024
07c2367
adding more error handlers
Oct 21, 2024
6941ac6
deleting the initial version of the script
Oct 21, 2024
f019fef
Merge branch 'main' into mixer-validator
mariia-iureva Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions configs/test/test_config_jq.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
streams:
- name: cc_tiny_subset
documents:
- s3://ai2-oe-data/mashai/tiny-DCLM-pool-subset-october/documents/**/*.jsonl.gz

attributes:
- cc_tiny_subset_analysis_october
- bff_duplicate_paragraph_spans_new

output:
path: s3://ai2-oe-data/mashai/tiny-DCLM-pool-subset-october/mixed-output-exclude-bff
max_size_in_bytes: 4294967296
discard_fields:
- attributes

filter:
syntax: jq
include: []
exclude:
# Language filter (using both cld2 and fasttext)
- (.attributes.cc_tiny_subset_analysis_october__cld2_en_paragraph_with_doc_score_v2__doc_en | if type == "array" and length > 0 and .[0] != null and .[0][2] != null then .[0][2] < 0.8 else false end)
- (.attributes.cc_tiny_subset_analysis_october__ft_lang_id_en_paragraph_with_doc_score_v2__doc_en | if type == "array" and length > 0 and .[0] != null and .[0][2] != null then .[0][2] < 0.8 else false end)
# Document length filter
- (.attributes.cc_tiny_subset_analysis_october__char_length_with_paragraphs_v1__document | if type == "array" and length > 0 and .[0] != null and .[0][2] != null then .[0][2] < 100 else false end)
# NSFW content filter
- (.attributes.cc_tiny_subset_analysis_october__jigsaw_nsfw_document_v1____label__nsfw | if type == "array" and length > 0 and .[0] != null and .[0][2] != null then .[0][2] > 0.5 else false end)
# Gopher quality filter
- (.attributes.cc_tiny_subset_analysis_october__gopher_v2__word_count | if type == "array" and length > 0 and .[0] != null and .[0][2] != null then .[0][2] < 50 else false end)
- (.attributes.cc_tiny_subset_analysis_october__gopher_v2__symbol_to_word_ratio | if type == "array" and length > 0 and .[0] != null and .[0][2] != null then .[0][2] > 0.1 else false end)
# Deduplication filter (BFF)
- (.attributes.bff_duplicate_paragraph_spans_new | if type == "array" and length > 0 and .[0] != null and .[0][2] != null then .[0][2] >= 1.0 else false end)
# C4 quality filter
- (.attributes.cc_tiny_subset_analysis_october__c4_v2__line_bullets | if type == "array" and length > 0 and .[0] != null and .[0][2] != null then .[0][2] > 0.5 else false end)
- (.attributes.cc_tiny_subset_analysis_october__c4_v2__phrase_repeat | if type == "array" and length > 0 and .[0] != null and .[0][2] != null then .[0][2] > 0.3 else false end)

span_replacement:
- span: "$.attributes.cc_tiny_subset_analysis_october__pii_regex_with_counts_fast_v2__EMAIL_ADDRESS"
min_score: 0.5
replacement: " |||EMAIL_ADDRESS||| "
- span: "$.attributes.cc_tiny_subset_analysis_october__pii_regex_with_counts_fast_v2__PHONE_NUMBER"
min_score: 0.5
replacement: " |||PHONE_NUMBER||| "
- span: "$.attributes.cc_tiny_subset_analysis_october__pii_regex_with_counts_fast_v2__IP_ADDRESS"
min_score: 0.5
replacement: " |||IP_ADDRESS||| "

work_dir:
input: "/tmp/cc_tiny_subset_mix/input"
output: "/tmp/cc_tiny_subset_mix/output"

processes: 16
50 changes: 50 additions & 0 deletions configs/test/test_config_jsonpath.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
streams:
- name: cc_tiny_subset
documents:
- s3://ai2-oe-data/mashai/tiny-DCLM-pool-subset-october/documents/**/*.jsonl.gz

attributes:
- cc_tiny_subset_analysis_october
- bff_duplicate_paragraph_spans_new

output:
path: s3://ai2-oe-data/mashai/tiny-DCLM-pool-subset-october/mixed-output
max_size_in_bytes: 4294967296
discard_fields:
- attributes

filter:
include: []
exclude:
# Language filter (using both cld2 and fasttext)
- "$.attributes[?(@.cc_tiny_subset_analysis_october__cld2_en_paragraph_with_doc_score_v2__doc_en && @.cc_tiny_subset_analysis_october__cld2_en_paragraph_with_doc_score_v2__doc_en[0] && @.cc_tiny_subset_analysis_october__cld2_en_paragraph_with_doc_score_v2__doc_en[0][2] < 0.8)]"
- "$.attributes[?(@.cc_tiny_subset_analysis_october__ft_lang_id_en_paragraph_with_doc_score_v2__doc_en && @.cc_tiny_subset_analysis_october__ft_lang_id_en_paragraph_with_doc_score_v2__doc_en[0] && @.cc_tiny_subset_analysis_october__ft_lang_id_en_paragraph_with_doc_score_v2__doc_en[0][2] < 0.8)]"
# Document length filter
- "$.attributes[?(@.cc_tiny_subset_analysis_october__char_length_with_paragraphs_v1__document && @.cc_tiny_subset_analysis_october__char_length_with_paragraphs_v1__document[0] && @.cc_tiny_subset_analysis_october__char_length_with_paragraphs_v1__document[0][2] < 100)]"
# Deduplication filter
- "[email protected][?(@.bff_duplicate_paragraph_spans_new && @.bff_duplicate_paragraph_spans_new[0] && @.bff_duplicate_paragraph_spans_new[0][2] >= 1.0)]"
# NSFW content filter
- "$.attributes[?(@.cc_tiny_subset_analysis_october__jigsaw_nsfw_document_v1____label__nsfw && @.cc_tiny_subset_analysis_october__jigsaw_nsfw_document_v1____label__nsfw[0] && @.cc_tiny_subset_analysis_october__jigsaw_nsfw_document_v1____label__nsfw[0][2] > 0.5)]"
# Gopher quality filter (example, adjust threshold as needed)
- "$.attributes[?(@.cc_tiny_subset_analysis_october__gopher_v2__word_count && @.cc_tiny_subset_analysis_october__gopher_v2__word_count[0] && @.cc_tiny_subset_analysis_october__gopher_v2__word_count[0][2] < 50)]"
- "$.attributes[?(@.cc_tiny_subset_analysis_october__gopher_v2__symbol_to_word_ratio && @.cc_tiny_subset_analysis_october__gopher_v2__symbol_to_word_ratio[0] && @.cc_tiny_subset_analysis_october__gopher_v2__symbol_to_word_ratio[0][2] > 0.1)]"
# C4 quality filter (example, adjust threshold as needed)
- "$.attributes[?(@.cc_tiny_subset_analysis_october__c4_v2__line_bullets && @.cc_tiny_subset_analysis_october__c4_v2__line_bullets[0] && @.cc_tiny_subset_analysis_october__c4_v2__line_bullets[0][2] > 0.5)]"
- "$.attributes[?(@.cc_tiny_subset_analysis_october__c4_v2__phrase_repeat && @.cc_tiny_subset_analysis_october__c4_v2__phrase_repeat[0] && @.cc_tiny_subset_analysis_october__c4_v2__phrase_repeat[0][2] > 0.3)]"

span_replacement:
- span: "$.attributes.cc_tiny_subset_analysis_october__pii_regex_with_counts_fast_v2__EMAIL_ADDRESS"
min_score: 0.5
replacement: " |||EMAIL_ADDRESS||| "
- span: "$.attributes.cc_tiny_subset_analysis_october__pii_regex_with_counts_fast_v2__PHONE_NUMBER"
min_score: 0.5
replacement: " |||PHONE_NUMBER||| "
- span: "$.attributes.cc_tiny_subset_analysis_october__pii_regex_with_counts_fast_v2__IP_ADDRESS"
min_score: 0.5
replacement: " |||IP_ADDRESS||| "

work_dir:
input: "/tmp/cc_tiny_subset_mix/input"
output: "/tmp/cc_tiny_subset_mix/output"

processes: 16
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ dependencies = [
# "fasttext==0.9.2", # broken with new version of setuptools; using fasttext-wheel instead
"fasttext-wheel==0.9.2",
"fsspec>=2023.6.0",
"jsonpath-ng",
"jq",
"msgspec>=0.14.2",
"nltk>=3.9.1",
"omegaconf>=2.3.0",
Expand Down
Loading
Loading