|
20 | 20 |
|
21 | 21 | ## Summary and Objective |
22 | 22 |
|
23 | | -The reason for motivating datapreprocessor design for fms-hf-tuning is to have a unified interface which supports many type of data formats, streaming and non streaming data, weight based data mixing and many others. |
| 23 | +<!--> |
| 24 | +Context goes here. |
| 25 | +Describe the forces at play, including technological, political, social, and project local. These forces are likely in tension, and should be called out as such. The language in this section is value-neutral. It is simply describing facts. |
| 26 | +<--> |
24 | 27 |
|
25 | | -1. Support for different formats of data → Arrow, Parquet, CSV, etc. |
| 28 | +The primary objective of the `DataPreProcessor` design for fms-hf-tuning is to provide a unified yet powerful interface for handling diverse data formats and configurations. |
| 29 | +This interface should cater to various user expertise levels, enabling basic users to easily load and process data, while allowing advanced users to customize their data handling through pre-defined configuration files. |
26 | 30 |
|
27 | | -1. Support for multiple files in a dataset. |
| 31 | +### Key Goals: |
| 32 | +1. **Broad Data Format Support**: Allow datasets in formats such as Arrow, Parquet, and CSV. |
| 33 | +1. **Compatibility with Multiple Datasets and Files**: Enable multiple files per dataset and interleaving or mixing of datasets. |
| 34 | +1. **Support for Different Data Modalities**: Include images, audio, and text data, along with modality-specific preprocessing options. |
| 35 | +1. **User-Focused Configurations**: Provide simple data loading for regular users, while enabling advanced configurations for expert users. |
| 36 | +1. **Template-Based Preprocessing**: Support chat templates and masking, where necessary, for chat-based or other template-dependent preprocesing requirements. |
28 | 37 |
|
29 | | -1. Support for multiple datasets. |
| 38 | +### Motivation |
30 | 39 |
|
31 | | -1. Support for different modalities of data -> Images, Audio etc. |
| 40 | +<!--> |
| 41 | +Why this is a valuable problem to solve? What background information is needed to show how this design addresses the problem? |
| 42 | +Which users are affected by the problem? Why is it a problem? What data supports this? What related work exists? |
| 43 | +<--> |
32 | 44 |
|
33 | | -1. Support for mixing datasets based on static weights. |
| 45 | +The main motivation for this ADR stems from the fact that fms-hf-tuning is being used by many teams for a diverse set of use cases which are not currently supported in the library. |
34 | 46 |
|
35 | | -1. Support for streaming datasets (or Iterable Datasets in HuggingFace) |
| 47 | +In the library for data preposssing we currently take two primary arguments `training_data_path` and `validataion_data_path` which take in a single file location for a dataset. Current library supports only `Json` data but can handle both pretokenised or non tokenised data by performing `input` masking and custom data formatting. |
36 | 48 |
|
37 | | -1. Support for chat template based masking |
| 49 | +The first motivation for a change is the requirements from users asking for multiple datasets and even multiple data files in a dataset. Also there are teams which are training using |
| 50 | +Parquet and Arrow format data so they require support for additional data formats in the code. |
| 51 | +Futher requirements from teams is to have a way to interleave datasets at run time by specifying static weights to mix different datasets which is also not supported by the code yet. |
| 52 | +Finally other requirements are to have preprocesing support for multiple modalities of data (starting with Image first) and have support for custom preprocesing like jinja based template rendering of the dataset before consumption. |
38 | 53 |
|
39 | | -1. Tool Usage - for example using jinja templates in the datasets which require preprocessing of the data. |
| 54 | +All these requirements are new and are currently not supported by the library which motivated us to propose a change in the design of data preprocesing in this library to incorporate these and potentially any new changes in one go. |
40 | 55 |
|
41 | | -### Motivation |
| 56 | +### User Benefit |
42 | 57 |
|
43 | | -The current design of the data processing in fms-hf-tuning contains predefined use cases and support for a simple interface |
44 | | -to the users. While the simple interface provides ease of use over HuggingFace APIs it doesn't provide users any interface to define custom data preprocessing for e.g. in case of multi modal support. |
| 58 | +<!-- How will users (or other contributors) benefit from this work? What would be the headline in the release notes or blog post? --> |
45 | 59 |
|
46 | | -Ths motivation for this design is to implement the data preprocessor in a flexible way and expose to the users a powerful API which can allow them custom processing of data however they want, and at the same time have backwards compatibility retaining the simple interface of the existing API. |
| 60 | +Users will benefit from the additional argument which allows users to pass a single `data_config` file specifying how to preprocess their dataset. |
| 61 | +In the config, users will be able to pass multiple data files and multiple datasets and specify static weights in the configuration to interleave datasets. |
| 62 | +In the config, users will also be able to define which preprocessing routines to apply on the data and in which order making the process of handling custom datasets |
| 63 | +which might require rendering jinja template or processing image data in a custom way much easier. |
| 64 | + |
| 65 | +Its not mandatory for users to learn the specification of the additional `data_config` as the existing arguments to process data as present in the code `tuning.config.configs.DataArguments` will not be deprecated and users can keep using the same data arguments for use cases being served by the library currently. |
| 66 | + |
| 67 | +## Decision |
| 68 | + |
| 69 | +<!--> |
| 70 | +This is the meat of the document, where you explain the decision. If you have multiple alternatives, be sure to use sub-sections for better separation of the idea, and list pros/cons to each approach. If there are alternatives that you have eliminated, you should also list those here, and explain why you believe your chosen approach is superior. Make sure you’ve thought through and addressed the following sections. If a section is not relevant to your specific proposal, please explain why, e.g. your ADR addresses a convention or process, not an API. |
| 71 | +<--> |
| 72 | + |
| 73 | +The primary decision at our hand for this ADR is to consider how to handle the incoming use cases. The current code as explained above handles limited data format (only `json`) and limited preprocessing `custom data formatting` with or without a data template, `tokenization and input masking`. |
| 74 | + |
| 75 | +One way to handle a set number of usecases is to have use case specific implementation of data pre processing and let users choose which preprocessing to utilise via |
| 76 | +existing or new commandline arguments. |
| 77 | + |
| 78 | +### Alternatives Considered |
| 79 | +<!--> |
| 80 | + |
| 81 | +Make sure to discuss the relative merits of alternatives to your proposal. |
| 82 | +<--> |
| 83 | + |
| 84 | +## Consequences |
| 85 | + |
| 86 | +<!--> |
| 87 | +Describe the resulting context, after applying the decision. All consequences should be listed here, not just the "positive" ones. A particular decision may have positive, negative, and neutral consequences, but all of them affect the team and project in the future. |
| 88 | +<--> |
47 | 89 |
|
48 | | -### User Benefit |
49 | 90 |
|
50 | 91 | ### Simple User Perspective |
51 | 92 |
|
@@ -111,34 +152,12 @@ datasets: |
111 | 152 | Our perspective is that the advanced users will create config files for data preprocessing and the intermediate users can use these existing configs and modify them according to their preference to get the desired result. |
112 | 153 |
|
113 | 154 | ## Detailed Design |
| 155 | +<!--> |
| 156 | +This section is optional. Elaborate on details if they're important to understanding the design, but would make it hard to read the proposal section above. |
| 157 | +<--> |
114 | 158 |
|
115 | 159 | ### The proposed design to implement support for this spec is follows, |
116 | 160 |
|
117 | | -Config Representation in code. |
118 | | - |
119 | | -``` |
120 | | -@dataclass |
121 | | -class DataHandlerConfig: |
122 | | - name: str |
123 | | - arguments: Optional[Dict] |
124 | | -
|
125 | | -@dataclass |
126 | | -class DatasetConfig: |
127 | | - name: str |
128 | | - sampling: Optional[Dict] = None |
129 | | - data_paths: List[str] |
130 | | - data_handlers: List[DataHandlerConfig] = None |
131 | | -
|
132 | | -@dataclass |
133 | | -class DataPreProcessorConfig: |
134 | | - streaming: Optional[bool] = None |
135 | | -
|
136 | | -@dataclass |
137 | | -class DataConfig: |
138 | | - datapreprocessor: Optional[DataPreProcessorConfig] |
139 | | - datasets: List[DatasetConfig] |
140 | | -``` |
141 | | - |
142 | 161 | Data Pre Processor abstract class |
143 | 162 |
|
144 | 163 | ``` |
@@ -226,17 +245,7 @@ The functionality listed by HF in implementing the use of image and audio datase |
226 | 245 |
|
227 | 246 | This means the image and audio multi modal datasets will be compatible with our data handler routines. Once we implement the data handler routine processing, we will allow users to train with multi modal datasets too. |
228 | 247 |
|
229 | | -### Alternatives Considered |
230 | | - |
231 | | -## Consequences |
232 | | - |
233 | | -### Advantages |
234 | | - |
235 | | -### Impact on performance |
236 | | - |
237 | | - |
238 | 248 | # Implementing stages. |
239 | | - |
240 | 249 | 1. Stage 1: |
241 | 250 | * Refactoring the code in `fms-hf-tuning` into the abstract data class and adding support for preliminery data handling routines. |
242 | 251 | This will automatically enable support for multi modal data which is our priority. |
|
0 commit comments