Dynamic Tokenization via Reinforcement Patching: End-to-end Training and Zero-shot Transfer
Organizations: Capital One · University of Texas, Austin
Abstract
Efficiently aggregating spatial or temporal horizons to acquire compact representations has become a unifying principle in modern deep learning models, yet learning data-adaptive representations for long-horizon sequence data, especially continuous sequences like time series, remains an open challenge. While fixed-size patching has improved scalability and performance, discovering variable-sized, data-driven patches end-to-end often forces models to rely on soft discretization, specific backbones, or heuristic rules. In this work, we propose Reinforcement Patching (ReinPatch), the first framework to jointly optimize a sequence patching policy and its downstream sequence backbone model using reinforcement learning. By formulating patch boundary placement as a discrete decision process optimized via Group Relative Policy Gradient (GRPG), ReinPatch bypasses the need for continuous relaxations and performs dynamic patching policy optimization in a natural manner. Moreover, our method allows strict enforcement of a desired compression rate, freeing the downstream backbone to scale efficiently, and naturally supports multi-level hierarchical modeling. We evaluate ReinPatch on time-series forecasting datasets, where it demonstrates compelling performance compared to state-of-the-art data-driven patching strategies. Furthermore, our detached design allows the patching module to be extracted as a standalone foundation patcher, providing the community with visual and empirical insights into the segmentation behaviors preferred by a purely performance-driven neural patching strategy.
Figures & tables
| Method | Data- driven | Variable size | Model- based | End-to- end | Backbone- agnostic | Continuous. exploration | Inductive bias | Data type- specific | Hierarchical modeling |
|---|---|---|---|---|---|---|---|---|---|
| Static Patching [ 14 ] | ✗ | ✗ | ✗ | ✗ | ✓ | n/a | ✗ | ✗ | ✓ |
| Entropy Patching [ 15 ] | ✓ | ✓ | ✓ | ✗ | ✓ | n/a | ✓ | ✓ | ✗ |
| TimeSqueeze’s Compression [ 2 ] | ✓ | ✓ | ✗ | ✗ | ✓ | n/a | ✓ | ✓ | ✗ |
| H-Net’s Chunking [ 8 ] | ✓ | ✓ | ✓ | ✓ | ✗ | ✓ | ✓ | ✗ | ✓ |
| Periodic Patching [ 21 ] | ✓ | ✗ | ✗ | ✗ | ✓ | n/a | ✓ | ✓ | ✗ |
| Selective Patching [ 24 ] | ✓ | ✗ | ✓ | ✓/✗ | ✗ | ✓ | ✓ | ✗ | ✗ |
| Datasets | ETTh1 | ETTh2 | ETTm1 | ETTm2 | Weather | Electricity | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Metrics | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE |
| Static Patching [ 14 ] | 0.415 | 0.434 | 0.337 | 0.385 | 0.357 | 0.388 | 0.272 | 0.326 | 0.230 | 0.268 | 0.192 | 0.299 |
| Selective Patching [ 24 ] | 0.416 | 0.433 | 0.331 | 0.384 | 0.361 | 0.391 | 0.269 | 0.326 | 0.232 | 0.271 | 0.191 | 0.298 |
| Periodic Patching [ 21 ] | 0.408 | 0.431 | 0.338 | 0.387 | 0.362 | 0.392 | 0.274 | 0.327 | 0.230 | 0.268 | 0.187 | 0.292 |
| Entropy Patching [ 1 ] | 0.430 | 0.438 | 0.339 | 0.389 | 0.359 | 0.387 | 0.283 | 0.334 | 0.231 | 0.269 | 0.170 | 0.268 |
| TimeSqueeze’s Compression [ 2 ] | 0.422 | 0.438 | 0.338 | 0.388 | 0.362 | 0.385 | 0.272 | 0.329 | 0.230 | 0.268 | 0.176 | 0.277 |
Appendix figures & tables4 assets
Supplementary material from the paper’s appendix.
Appendix
| Dataset | Domain | Frequency | Lengths | Dim | Split | Description |
|---|---|---|---|---|---|---|
| ETTh1 | Electricity | 1 hour | 14,400 | 7 | 6:2:2 | Power transformer 1, comprising seven indicators such as oil temperature and useful load |
| ETTh2 | Electricity | 1 hour | 14,400 | 7 | 6:2:2 | Power transformer 2, comprising seven indicators such as oil temperature and useful load |
| ETTm1 | Electricity | 15 mins | 57,600 | 7 | 6:2:2 | Power transformer 1, comprising seven indicators such as oil temperature and useful load |
| ETTm2 | Electricity | 15 mins | 57,600 | 7 | 6:2:2 | Power transformer 2, comprising seven indicators such as oil temperature and useful load |
| Weather | Environment | 10 mins | 52,696 | 21 | 7:1:2 | Recorded every day for the whole year 2020, which contains 21 meteorological indicators |
| Electricity | Electricity | 1 hour | 26,304 | 321 | 7:1:2 | Electricity records the electricity consumption in kWh every 1 hour from 2012 to 2014 |
| Method | Encoder ( levels) | Decoder ( levels) | Forecasting Backbone |
|---|---|---|---|
| Static Patching | Transformer | Transformer | Transformer |
| Selective Patching | Transformer | Transformer | Transformer |
| Periodic Patching | Transformer | Transformer | Transformer |
| Entropy Patching | Transformer | Transformer | Transformer |
| TimeSqueeze’s Compression | SSM | SSM | Transformer |
| H-Net’s Chunking | SSM | SSM | Transformer |
| Models | ReinPatch (foundation) [Ours] | ReinPatch (end-to-end) [Ours] | Static Patching [ 14 ] | Selective Patching [ 24 ] | Periodic Patching [ 21 ] | Entropy Patching [ 1 ] | TimeSqueeze’s Compression [ 2 ] | H-Net’s Chunking [ 8 ] | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Metrics | H | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE | MSE | MAE |
| ETTh1 | 96 | 0.360 0.008 | 0.400 0.006 | 0.374 0.007 | 0.405 0.006 | 0.367 | 0.404 | 0.368 | 0.403 | 0.365 | 0.403 | 0.382 | 0.405 | 0.378 | 0.405 | 0.391 | 0.409 |
| 192 | 0.394 0.003 | 0.419 0.004 | 0.410 0.016 | 0.423 0.009 | 0.416 | 0.428 | 0.416 | 0.428 | 0.421 | 0.432 | 0.435 | 0.434 | 0.423 | 0.429 | 0.436 | 0.437 | |
| 336 | 0.395 0.007 | 0.423 0.005 | 0.397 0.007 | 0.424 0.006 | 0.416 | 0.431 | 0.419 | 0.434 | 0.399 | 0.424 | 0.430 | 0.443 | 0.417 | 0.438 | 0.439 | 0.450 | |
| 720 | 0.440 0.019 | 0.455 0.010 | 0.441 0.016 | 0.461 0.011 | 0.462 | 0.473 | 0.460 | 0.467 | 0.449 | 0.465 | 0.471 | 0.470 | 0.467 | 0.478 | 0.485 | 0.483 | |
| Avg. | 0.397 0.008 | 0.424 0.005 | 0.405 0.008 | 0.428 0.004 | 0.415 | 0.434 | 0.416 | 0.433 | 0.408 | 0.431 | 0.430 | 0.438 | 0.422 | 0.438 | 0.438 | 0.445 | |