Customized Positional Encoding to Combine Static and Time-varying Data in Robust Representation Learning for Crop Yield Prediction

Qinqing Liu, Fei Dou, Meijian Yang, Ezana Amdework, Guiling Wang, Jinbo Bi

Abstract

Crop yield prediction is critical for global food security, yet standard Transformer models often struggle to integrate static environmental factors with dynamic weather sequences. This paper introduces Customized Positional Encoding (CPE), a novel architecture that adapts temporal perception based on static "side information" such as soil quality and geographical location. By decoupling positional data and employing a Partially Linearized Attention Module (PLAM), the proposed model achieves significant improvements in robustness, particularly during extreme climate events, reducing prediction error by up to 26% in drought conditions.

Introduction

Predicting agricultural yields is increasingly complex due to climate-driven weather volatility. While Transformers excel at modeling time-series data like daily temperature or rainfall, they typically utilize a "one-size-fits-all" Positional Encoding (PE) mechanism. In agriculture, the impact of weather is highly dependent on static context; for instance, heavy rainfall affects sandy-soil regions differently than clay-heavy ones. Standard models often fail to effectively integrate these non-sequential variables, leading to suboptimal performance when static data is "washed out" by internal normalization layers like softmax.

Methodology

The authors propose two primary innovations to the standard Transformer block: Customized Positional Encoding (CPE) and the Partially Linearized Attention Module (PLAM).

Customized Positional Encoding (CPE)

Instead of a fixed or globally learned position vector, CPE makes positional encoding a function of static side information ($s$). The authors explore two variants to generate this unique "temporal map" for every location:

  1. Pairwise CPE: Utilizes a Multi-Layer Perceptron (MLP) to generate relationships between positions based on the static context.
  2. Explicit CPE: Directly maps static features to a position matrix, allowing the model to learn a unique context-aware positional representation.
Overview of the Attention Module for CPE, including Pairwise and Explicit CPE architectures.

Partially Linearized Attention Module (PLAM)

Standard attention mechanisms use a softmax function that can dilute the specific "bias" introduced by side information. PLAM addresses this by splitting the attention: it applies softmax to weather sequence scores to capture temporal dependencies while adding CPE scores linearly. This ensures that the influence of static factors remains explicit and straightforward rather than being normalized away.

Extracted figure from page 5 of Customized Positional Encoding to Combine Static and Time-varying Data in Robust Representation Learning for Crop Yield Prediction

Experimental Setup and Datasets

The model was evaluated on three large-scale agricultural datasets to test its generalizability and robustness:

  • US Maize (Corn): 20,259 samples (2000–2018) with 97 static and 19 daily weather variables.
  • US Soybean: 25,171 samples (1979–2018) with similar feature sets.
  • Ethiopia (Maize): 7,951 samples (2004–2021), representing a rain-fed system highly vulnerable to climate extremes.

Key Results and Insights

The CPE-Att model consistently outperformed baselines, including Random Forests, XGBoost, LSTMs, and vanilla Transformers (Informer).

Robustness to Extremes

A standout feature of the CPE model is its performance during "black swan" weather years. During the 2012 US drought, the model reduced Mean Absolute Error (MAE) by 26% for Maize compared to the best baseline. In the 2003 soybean crisis, it reduced error by 17%. Standard models often fail when weather deviates wildly from the norm because they haven't properly weighted the underlying static vulnerabilities of the land.

The Role of PLAM

Ablation studies confirmed that the PLAM approach consistently outperformed standard softmax-based integration across all datasets. By keeping the side-information component linear, the model retains the inductive bias of the static data more effectively.

Conclusion and Future Work

CPE provides a robust framework for combining static and dynamic data in crop yield prediction by contextualizing time relative to the environment. While the model showed superior performance in the US, regional gaps in Ethiopia suggest that non-environmental factors like labor and seed quality—currently not captured—play a significant role. Future work will explore more sophisticated methods to decouple special tokens, such as the [CLS] token, from customized positions to further refine how the model summarizes entire growing seasons.

Summary updated

BibTeX
@inproceedings{liu2023customized,
  author = {Qinqing Liu and Fei Dou and Meijian Yang and Ezana Amdework and Guiling Wang and Jinbo Bi},
  title = {{Customized Positional Encoding to Combine Static and Time-varying Data in Robust Representation Learning for Crop Yield Prediction}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2023},
  doi = {10.24963/ijcai.2023/676},
}
Figure