Skip to content

[FEATURE] organize preprocessing module - #3

Merged
inclinedadarsh merged 55 commits into
mainfrom
preprocessing
Jul 9, 2025
Merged

inclinedadarsh merged 55 commits into
mainfrom
preprocessing

Conversation

@inclinedadarsh

Copy link
Copy Markdown
Contributor

No description provided.

supreme-gg-gg and others added 4 commits June 16, 2025 00:33
- divide original class into multiple classes
- create GCSStorage for gcs based file storage
- create LocalStorage for local file storage
- remove original file

NOTE: This commit was made for organization purpose, code doesn't work at this commit because the changes aren't implemented in other related modules
as the two dataset classes (DataHandler and DataPreprocessor) had multiple overlapping functionality, I divided into smaller submodule for better handling and maintainance

- introduce DataAnalyzer for analyzing the dataset
- introduce DataLoader for loading the dataset (it loads the dataset from local file storage, hugging face or a demo one)
- introduce DataUploader (handles uploading of local dataset)
- introduce FormatConverter for converting processing the dataset
- introduce DatasetService which utilizes all above classes (this one is used in the fastapi app)

NOTE: Please note that the app doesn't work at this commit, it was made for the purpose of organization. Other modules that use the changed one haven't been edited yet.
this commit uses all the previous changes, and the app should be usable now

@supreme-gg-gg supreme-gg-gg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm overall

Comment thread preprocessing/schema.py Resolved
Comment thread preprocessing/schema.py Resolved
…ation

- Updated the preview and processing endpoints to include comprehensive documentation on field mappings.
- Refined the configuration structure to support field mappings with types and values, allowing for more flexible data handling.
- Adjusted the format converter to accommodate the new field mapping structure, ensuring proper extraction and formatting of user and system messages.

@supreme-gg-gg supreme-gg-gg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

splitting logic looks good

@supreme-gg-gg

supreme-gg-gg commented Jun 21, 2025 •

Copy link
Copy Markdown
Contributor

Not necessary to implement right now but it seems to me like hugging face also allows you to specify data_files and data_dir and these are useful for very large and sophisticatedly organised datasets, I've copied the section from their documentation here:

You can also load a specific subset of the files with the data_files or data_dir parameter. These parameters can accept a relative path which resolves to the base path corresponding to where the dataset is loaded from.

from datasets import load_dataset

# load files that match the grep pattern
c4_subset = load_dataset("allenai/c4", data_files="en/c4-train.0000*-of-01024.json.gz")

# load dataset from the en directory on the Hub
c4_subset = load_dataset("allenai/c4", data_dir="en")
The split parameter can also map a data file to a specific split:

data_files = {"validation": "en/c4-validation.*.json.gz"}
c4_validation = load_dataset("allenai/c4", data_files=data_files, split="validation")

I believe this is one example dataset of where this is useful: https://huggingface.co/datasets/allenai/c4

@supreme-gg-gg

Copy link
Copy Markdown
Contributor

Also I believe the first version of prototype uses dataset.map instead of for loop because you can batch them:

augmented_dataset = dataset.map(function, batched=True, remove_columns=dataset.column_names, batch_size=8)

I also believe it has better built in support to convert to pytorch tensor types if we ever run into an incompatibility in the future

Source

Comment thread preprocessing/schema.py Resolved
@supreme-gg-gg

Copy link
Copy Markdown
Contributor

It seems like I accidentally overwritten the Dockerfile to not use uv, i will find out which commit and revert it soon

Comment thread preprocessing/storage/gcs_storage.py Resolved

@supreme-gg-gg supreme-gg-gg left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM overall, feel free to merge but make sure:

  1. Check preprocess/README.md to update the API docs and usage
  2. Test the modules (especially integration) if needed by just running locally and with GCS (the bucket is gemma-dataset-bucket on the gcp project
  3. If you can test the integration with augmentation as well (just the Gemini synthesis is fine), if you run into package issues let me know but unlikely if you're running locally

Won't recommend building to cloud yet because there's a Dockerfile and update from the other branch, you can deploy it after the other branch is merged 😄

Comment thread preprocessing/storage/base.py Resolved
@inclinedadarsh

Copy link
Copy Markdown
Contributor Author

@supreme-gg-gg I have tested the GCS data storage, and it works perfectly. I have also made few necessary changes and updated the README file.

I wasn't able to test the augmentation integration; I need your help with it. It'll be great if you could test it out, or getting on a meet to discuss it would be better.

Otherwise, I believe this PR is ready to be merged.

@supreme-gg-gg

Copy link
Copy Markdown
Contributor

@supreme-gg-gg I have tested the GCS data storage, and it works perfectly. I have also made few necessary changes and updated the README file.

I wasn't able to test the augmentation integration; I need your help with it. It'll be great if you could test it out, or getting on a meet to discuss it would be better.

Otherwise, I believe this PR is ready to be merged.

Great, I will test the augmentation and get back to you

@inclinedadarsh

Copy link
Copy Markdown
Contributor Author

This PR looks good. Merging it now.

@inclinedadarsh
inclinedadarsh merged commit fa22504 into main Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants