Preprocess Command Guide¶
The sequifier preprocess command transforms raw tabular data (CSV or Parquet) into the specific sequence format required for training transformer sequence models. It handles windowing, data splitting (train/validation/test), categorical encoding, and optional numerical standardization.
Usage¶
sequifier preprocess --config-path configs/preprocess.yaml
CLI Overrides¶
Values passed on the command line override the YAML before validation.
Flag |
Overrides / Action |
|---|---|
|
Generates a random |
|
Overrides |
|
Overrides |
Composable Configuration Files¶
A preprocessing entry config may set additional_config_paths to one
non-empty string, a list of non-empty strings, or null. Relative paths
resolve against the entry config’s project_root; absolute paths are used
directly. Fragments are direct only and cannot include further fragments. They
may share nested containers when their child fields are disjoint, but duplicate
fields are errors. CLI values override the completed file composition.
Configuration Fields¶
The configuration is defined in a YAML file (e.g., preprocess.yaml). Below are the available fields, their requirements, and their functions.
1. File System & Input/Output¶
Field |
Type |
Mandatory |
Default |
Description |
|---|---|---|---|---|
|
|
Yes |
- |
The root directory of your Sequifier project. Usually |
|
|
No |
|
Direct complementary YAML fragments. Relative paths resolve against |
|
|
Yes |
- |
Path to the raw input file or folder. |
|
|
No |
|
Format of input data ( |
|
|
No |
|
Format of output data ( |
|
|
No |
|
Whether to merge split files into single files or keep them sharded. |
|
|
No |
|
If |
Important Constraint on
write_format:
If
write_formatispt(PyTorch tensors),merge_outputmust befalse.If
write_formatisparquet,merge_outputcan befalseortrue.If
write_formatiscsv,merge_outputmust betrue. For distributed training,merge_outputmust be set tofalse.
2. Column Selection & Filtering¶
Field |
Type |
Mandatory |
Default |
Description |
|---|---|---|---|---|
|
|
No |
|
A specific list of columns to process. If |
|
|
No |
|
Optional output dtype map for processed columns, such as |
|
|
No |
|
If |
|
|
No |
|
Limits processing to the first N rows. Useful for rapid debugging. |
|
|
No |
|
Use a preexisting metadata config for tokenizing discrete columns and, when enabled, standardizing real-valued columns. |
|
|
No |
|
Optional input column used as a row-level mask. If set, |
|
|
No |
|
If not |
3. Sequence Logic & Splitting¶
Field |
Type |
Mandatory |
Default |
Description |
|---|---|---|---|---|
|
|
Yes |
- |
The physical serialized window width written to preprocessed data. |
|
|
No |
|
Number of future items retained after the model input window. Use |
|
|
Yes |
- |
Ordered train/validation/test proportions. Must sum to 1.0. |
|
|
No |
|
How rows are assigned to splits ( |
|
|
No |
|
Window stride for each split; entry |
|
|
No |
|
Strategy for selecting start indices ( |
|
|
No |
|
If |
4. Performance & System¶
Field |
Type |
Mandatory |
Default |
Description |
|---|---|---|---|---|
|
|
No |
|
Random seed for reproducibility. |
|
|
No |
Max Cores |
Number of CPU cores to use for parallel processing. |
|
|
No |
|
Only used when |
|
|
No |
|
Memory optimization. If |
Key Trade-offs and Decisions¶
1. write_format: parquet vs. pt¶
Choose
parquet(default): Unless you have a specific reason, useparquet. Note: If you are doing distributed training, Parquet support is currently in Beta.Choose
pt: Useptdata loading if speed and CPU overhead are your primary bottlenecks, or if you are running multi-GPU distributed training. This format is the most stable choice for high-throughput scaling.
2. window_strides configuration¶
window_length: non-overlapping windows and less data.1: maximum overlap, coverage, storage, and training time.A common compromise is a larger train/validation stride and test stride
1, for examplewindow_strides: [24, 24, 1].
3. window_placement: distribute vs exact¶
distribute(Default): The algorithm adjusts the start indices slightly to minimize the overlap of the final subsequence with the previous one, ensuring the data covers the full sequence length as evenly as possible. Recommended for most use cases.exact: Strictly enforces the stride. If the sequence length minus the window size isn’t perfectly divisible by the stride, this will raise an error. Use this only if mathematical precision of the sliding window is strictly required by your downstream application or evaluation code.
4. Advanced: Static Vocabularies (Custom ID Maps)¶
By default, Sequifier dynamically builds ID maps from the data found in the input file. However, in production systems, you often need a fixed vocabulary to ensure that ID “105” always maps to “Item_X”, regardless of the daily training batch.
To use a static vocabulary:
Create a folder
configs/id_maps/in your project root.Add JSON files named
{COLUMN_NAME}.json.The format must be a dictionary mapping ordinary data values to integers starting at 3. Reserved labels may be included only with their fixed IDs.
Reserved Indices:
0: Reserved for
[unknown](padding/missing).1: Reserved for
[other](unseen values not in your map).2: Reserved for
[mask].3+: Your data.
Example configs/id_maps/itemId.json:
{
"apple": 3,
"banana": 4,
"cherry": 5
}
Outputs¶
After running preprocess, the following are generated:
Data Files: Located in
data/. Depending on your configuration, these will be merged files such as[NAME]-split0.parquet(Training),[NAME]-split1.parquet(Validation), etc., or split folders such as[NAME]-split0/containing.ptor.parquetshards.Metadata Config: Located in
configs/metadata_configs/[NAME].json.Crucial: This file contains the integer mappings for categorical variables (
id_maps), statistics for real variables (selected_columns_statistics), and whether those variables were normalized (normalize_real_columns).Next Step: Reference this file from
dataset.part.metadata_config_pathin a singleton training config, or fromdataset_training.<dataset>.parts.<part>.metadata_config_pathin a named training config. In inference, eitherpreprocessing_data_pathormetadata_config_pathcan locate the metadata and its split paths.
Named depth layouts¶
Repeated rows can describe one outer item with a fixed-capacity child collection.
Depth behavior is explicit; a column named subItemPosition alone remains an
ordinary flat feature.
project_root: .
preprocessing_data_path: data/raw-items
read_format: parquet
write_format: pt
merge_output: false
selected_columns: [accountType, subitemType, subitemAmount, nextAction]
depth_layouts:
subitems:
position_column: subItemPosition
columns: [subitemType, subitemAmount]
context_length: 16
position_base: 0
allow_gaps: false
window_length: 129
max_target_offset: 1
split_ratios: [0.8, 0.1, 0.1]
window_strides: [128, 128, 128]
Every file must contain the position column, which is read automatically and
excluded from feature statistics and output types. Configure at most one raw
layout, use PT output without merging, and omit mask_column. Reused metadata
must have the same complete layout definition, output types, and normalization
policy. String identifiers must be convertible to signed Int64; item and depth
positions must have integer source types.
The adapter indexes raw fragments on disk before grouping them. max_rows
counts complete outer items ordered by (sequenceId, itemPosition), including
children found in later files. Shallow features must agree across every child
row before casting or mapping. Shallow statistics count each item once; deep
statistics count occupied child slots. Both populations are selected before
split extraction. Materialization uses bounded windows and output batches;
batches_per_file bounds the number of windows accumulated per split on this
path. This adapter is currently sequential; n_cores does not parallelize it.
Child positions map to physical slots by subtracting position_base. Without
allow_gaps, occupied slots must be a prefix starting at zero. Tail padding is
always allowed. With gaps enabled, physical slots remain unchanged. Outer item
positions must be continuous within each selected sequence. An item in this raw
format must have at least one child; null child rows do not encode emptiness.
Flat PT files retain the five-element tuple. Depth files use version 2 of
sequifier_tensor_batch, with shallow [N,W], deep [N,W,D], and boolean masks
under metadata.depth_valid_masks.<layout>. Metadata records depth_layouts
and tensor_payload_version, separately from the stored window version.
Categorical padding is the existing unknown-token ID (zero); real padding is
finite zero after normalization. Temporal padding has false depth masks.
External tensor payloads may contain several layouts with different capacities
and independently empty collections. Use StoredTensorBatch, save_pt_payload,
and load_pt_payload in sequifier.io.pt_payload, supplying the complete layout
registry and categorical vocabulary sizes. All stored feature values, including
masked slots, must have legal categorical indices and finite real values. Empty
collections use an all-false mask. Missing masks and forbidden internal gaps are
errors. Selected interfaces compare only relevant layout feature membership and
layout properties, so unused stored layouts/features can be added independently.
To consume a named layout during training, configure a depth_transformer
ingestion branch whose layout names this entry and whose columns are selected
features from it. See the training guide.