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

Fix DAPT tutorial #503

Merged
merged 5 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
1 change: 1 addition & 0 deletions nemo_curator/modules/semantic_dedup/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def __call__(self, dataset: DocumentDataset) -> DocumentDataset:
)
)
else:
embedding_ddf = self.create_embeddings(dataset.df, self.input_column)
ddf = DocumentDataset(embedding_ddf)

self.logger.info(
Expand Down
2 changes: 2 additions & 0 deletions nemo_curator/modules/semantic_dedup/semdedup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(
input_column: str = "text",
id_column: str = "id",
id_column_type: str = "int",
write_embeddings_to_disk: bool = True,
logger: Union[logging.Logger, str] = "./",
) -> None:
"""
Expand All @@ -50,6 +51,7 @@ def __init__(
embedding_batch_size=config.embedding_batch_size,
input_column=input_column,
embedding_output_dir=os.path.join(cache_dir, config.embeddings_save_loc),
write_embeddings_to_disk=write_embeddings_to_disk,
logger=logger,
profile_dir=self.config.profile_dir,
)
Expand Down
5 changes: 3 additions & 2 deletions tutorials/dapt-curation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ The tutorial follows the steps below:<br>
After installing the NeMo Curator package, install the dependencies and run:

```bash
pip install -r code/requirements.txt
cd code
pip install -r requirements.txt
python main.py
# or python main.py --device "gpu"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it an or here , should this by the default ?

```

This will download chip-design related datasets and begin the data curation pipeline.
This will download chip-design related datasets and begin the data curation pipeline. Please use `--device "gpu"` to enable semantic and fuzzy deduplication, which require the GPU.
7 changes: 2 additions & 5 deletions tutorials/dapt-curation/code/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@
)

import nemo_curator as nc
from nemo_curator import ExactDuplicates, Modify, ScoreFilter, Sequential
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @sarahyurick - Is it possible to revert these sections that are deleted from the DAPT tutorial?

from nemo_curator import ScoreFilter, Sequential
from nemo_curator.datasets import DocumentDataset
from nemo_curator.filters import RepeatingTopNGramsFilter, WordCountFilter
from nemo_curator.modifiers.pii_modifier import PiiModifier
from nemo_curator.modifiers.unicode_reformatter import UnicodeReformatter
from nemo_curator.utils.distributed_utils import get_client
from nemo_curator.utils.file_utils import (
get_all_files_paths_under,
Expand Down Expand Up @@ -191,7 +188,7 @@ def run_curation_pipeline(args: Any, text_files: str, code_files: str) -> None:
duplicates = semantic_dedupe(
dataset=gpu_dataset_text,
sem_dedupe_config_yaml_path=sem_dedupe_config_yaml_path,
cache=CACHE_DIR,
cache_dir=CACHE_DIR,
)
unique_ids = duplicates.df.to_backend("pandas").compute()["id"]
semantic_dataset_text = DocumentDataset(
Expand Down
20 changes: 6 additions & 14 deletions tutorials/dapt-curation/code/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import os
import re

import dask.dataframe as dd
import pandas as pd
import yaml

from nemo_curator import (
ExactDuplicates,
Expand All @@ -33,7 +27,6 @@
from nemo_curator.datasets import DocumentDataset
from nemo_curator.filters import (
DocumentFilter,
RepeatedLinesFilter,
RepeatedParagraphsFilter,
RepeatingTopNGramsFilter,
UrlsFilter,
Expand All @@ -46,12 +39,7 @@
from nemo_curator.modifiers import DocumentModifier
from nemo_curator.modifiers.pii_modifier import PiiModifier
from nemo_curator.modifiers.unicode_reformatter import UnicodeReformatter
from nemo_curator.pii.constants import DEFAULT_LANGUAGE, DEFAULT_MAX_DOC_SIZE
from nemo_curator.utils.distributed_utils import get_client
from nemo_curator.utils.file_utils import (
expand_outdir_and_mkdir,
get_all_files_paths_under,
)
from nemo_curator.utils.file_utils import expand_outdir_and_mkdir


class QuotationUnifier(DocumentModifier):
Expand Down Expand Up @@ -356,7 +344,11 @@ def semantic_dedupe(

semdedup_config = SemDedupConfig.from_yaml(sem_dedupe_config_yaml_path)
expand_outdir_and_mkdir(semdedup_config.cache_dir)
semdup = SemDedup(config=semdedup_config, id_column_type="str")
semdup = SemDedup(
config=semdedup_config,
id_column_type="str",
write_embeddings_to_disk=False,
)
duplicates = semdup(dataset)
return duplicates

Expand Down