Text Classification
Transformers
Safetensors
yield-weather-soil
crop-yield
multi-temporal
regression
yield-estimation
custom_code
Instructions to use ICICLE-AI/yield-estimation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ICICLE-AI/yield-estimation with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="ICICLE-AI/yield-estimation", trust_remote_code=True)# Load model directly from transformers import AutoModelForSequenceClassification model = AutoModelForSequenceClassification.from_pretrained("ICICLE-AI/yield-estimation", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
pipeline_tag:
|
| 3 |
library_name: transformers
|
| 4 |
tags:
|
| 5 |
- transformers
|
|
@@ -7,267 +7,348 @@ tags:
|
|
| 7 |
- multi-temporal
|
| 8 |
- regression
|
| 9 |
- yield-estimation
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
# Yield Estimation Transformer
|
| 13 |
|
| 14 |
-
A Hugging Face Transformers model for
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
--
|
| 19 |
|
| 20 |
-
#
|
| 21 |
|
| 22 |
-
-
|
| 23 |
-
-
|
| 24 |
-
-
|
| 25 |
-
-
|
| 26 |
-
-
|
| 27 |
-
-
|
| 28 |
-
-
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
| 35 |
-
import json
|
| 36 |
-
from transformers import pipeline
|
| 37 |
|
| 38 |
-
|
| 39 |
-
"yield-estimation",
|
| 40 |
-
model="Sarikaa-Sridhar/yield-estimation-transformer",
|
| 41 |
-
trust_remote_code=True,
|
| 42 |
-
)
|
| 43 |
|
| 44 |
-
|
| 45 |
-
sample = json.load(f)
|
| 46 |
-
|
| 47 |
-
prediction = pipe(sample)
|
| 48 |
-
|
| 49 |
-
print(prediction)
|
| 50 |
-
````
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
|
| 55 |
-
{
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
| 61 |
}
|
|
|
|
| 62 |
```
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
---
|
| 65 |
|
| 66 |
-
#
|
| 67 |
|
| 68 |
-
|
| 69 |
|
| 70 |
-
|
| 71 |
-
git clone https://huggingface.co/Sarikaa-Sridhar/yield-estimation-transformer
|
| 72 |
-
cd yield-estimation-transformer
|
| 73 |
-
```
|
| 74 |
|
| 75 |
-
|
| 76 |
|
| 77 |
-
``
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
```
|
| 81 |
|
| 82 |
-
|
| 83 |
|
| 84 |
-
``
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
```
|
| 87 |
|
| 88 |
---
|
| 89 |
|
| 90 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
```text
|
| 93 |
.
|
|
|
|
| 94 |
├── config.json
|
| 95 |
-
├── model.safetensors
|
| 96 |
├── configuration_yield.py
|
|
|
|
| 97 |
├── modeling_yield.py
|
| 98 |
-
├── pipeline_yield.py
|
| 99 |
-
├── yield_transformer.py
|
| 100 |
-
├── sample_input_daily.json
|
| 101 |
├── requirements.txt
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
| 103 |
```
|
| 104 |
|
| 105 |
-
|
| 106 |
|
| 107 |
-
|
|
|
|
|
|
|
| 108 |
|
| 109 |
-
|
| 110 |
|
| 111 |
-
|
| 112 |
-
from transformers import AutoModel
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
)
|
| 118 |
```
|
| 119 |
|
| 120 |
-
|
| 121 |
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
-
|
| 125 |
|
| 126 |
-
|
|
|
|
|
|
|
| 127 |
|
| 128 |
-
##
|
| 129 |
|
| 130 |
-
|
| 131 |
-
* `weather`
|
| 132 |
-
* `soil`
|
| 133 |
|
| 134 |
-
|
| 135 |
|
| 136 |
-
|
| 137 |
-
|
|
|
|
| 138 |
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
-
|
| 142 |
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
```json
|
| 148 |
{
|
| 149 |
"crop": "corn",
|
| 150 |
-
"weather_format": "
|
| 151 |
-
"cutoff":
|
| 152 |
"weather": {
|
| 153 |
-
"
|
| 154 |
-
"
|
| 155 |
-
"
|
| 156 |
-
"tmax": [
|
| 157 |
-
"
|
| 158 |
-
"
|
| 159 |
-
"vp": [...],
|
| 160 |
-
"tmean": [...],
|
| 161 |
-
"precip_3day_avg_perday": [...],
|
| 162 |
-
"precip_7day_avg_perday": [...],
|
| 163 |
-
"precip_14day_avg_perday": [...]
|
| 164 |
},
|
| 165 |
"soil": {
|
| 166 |
-
"
|
| 167 |
-
"
|
| 168 |
-
"cec": 15.0,
|
| 169 |
-
"awc": 0.18,
|
| 170 |
-
"clay": 25.0,
|
| 171 |
-
"p_ppm": 30.0,
|
| 172 |
-
"k_ppm": 150.0,
|
| 173 |
-
"mg_ppm": 220.0,
|
| 174 |
-
"ca_ppm": 1800.0,
|
| 175 |
-
"k_te": 3.0,
|
| 176 |
-
"mg_te": 12.0,
|
| 177 |
-
"ca_te": 70.0,
|
| 178 |
-
"s_ppm": 15.0,
|
| 179 |
-
"zn_ppm": 1.2,
|
| 180 |
-
"fe_ppm": 50.0,
|
| 181 |
-
"mn_ppm": 20.0,
|
| 182 |
-
"cu_ppm": 0.8,
|
| 183 |
-
"b_ppm": 0.5,
|
| 184 |
-
"na_ppm": 10.0,
|
| 185 |
-
"sand": 40.0,
|
| 186 |
-
"silt": 35.0,
|
| 187 |
-
"bd": 1.3,
|
| 188 |
-
"elevation": 280.0,
|
| 189 |
-
"slope": 2.0
|
| 190 |
}
|
| 191 |
}
|
| 192 |
```
|
| 193 |
|
| 194 |
-
The
|
| 195 |
|
| 196 |
-
|
| 197 |
-
* applies the normalization statistics stored with the model
|
| 198 |
-
* performs inference
|
| 199 |
-
* returns the predicted crop yield
|
| 200 |
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
|
| 205 |
-
|
| 206 |
|
| 207 |
-
|
| 208 |
|
| 209 |
-
|
| 210 |
-
* `maize`
|
| 211 |
-
* `soy`
|
| 212 |
-
* `soybean`
|
| 213 |
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
| 215 |
|
| 216 |
-
|
| 217 |
|
| 218 |
-
|
| 219 |
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
-
|
| 223 |
-
from transformers import pipeline
|
| 224 |
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
|
|
|
| 231 |
```
|
| 232 |
|
| 233 |
-
|
| 234 |
|
| 235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
from transformers import pipeline
|
| 237 |
|
|
|
|
|
|
|
|
|
|
| 238 |
pipe = pipeline(
|
| 239 |
-
"
|
| 240 |
-
model="
|
| 241 |
-
|
| 242 |
trust_remote_code=True,
|
| 243 |
)
|
| 244 |
-
```
|
| 245 |
-
|
| 246 |
-
---
|
| 247 |
-
|
| 248 |
-
# Pipeline Output
|
| 249 |
|
| 250 |
-
|
|
|
|
|
|
|
| 251 |
|
| 252 |
-
|
| 253 |
|
| 254 |
-
```
|
| 255 |
-
{
|
| 256 |
-
"predicted_yield": 182.28,
|
| 257 |
-
"cutoff": 16,
|
| 258 |
-
"effective_cutoff": 16,
|
| 259 |
-
"crop": "corn",
|
| 260 |
-
"weather_format": "daily"
|
| 261 |
-
}
|
| 262 |
```
|
| 263 |
|
| 264 |
---
|
| 265 |
|
| 266 |
-
#
|
| 267 |
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
*National Science Foundation (NSF) AI Institute for Intelligent Cyberinfrastructure with Computational Learning in the Environment (ICICLE), Award OAC-2112606.*
|
| 271 |
|
| 272 |
-
|
| 273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
pipeline_tag: text-classification
|
| 3 |
library_name: transformers
|
| 4 |
tags:
|
| 5 |
- transformers
|
|
|
|
| 7 |
- multi-temporal
|
| 8 |
- regression
|
| 9 |
- yield-estimation
|
| 10 |
+
- yield-weather-soil
|
| 11 |
+
license: mit
|
| 12 |
---
|
| 13 |
|
| 14 |
# Yield Estimation Transformer
|
| 15 |
|
| 16 |
+
A Hugging Face Transformers model for county-level corn yield estimation using multi-temporal weather observations and static soil properties.
|
| 17 |
|
| 18 |
+
The model combines weekly weather time-series with static soil features to estimate corn yield in bushels per acre (`bu/acre`). It is packaged for inference using Hugging Face Transformers and has been tested for deployment through FlexServ.
|
| 19 |
|
| 20 |
+
The Hugging Face `text-classification` task is used as the FlexServ-compatible serving interface. The underlying model performs scalar regression, and the returned `score` represents predicted corn yield in `bu/acre`.
|
| 21 |
|
| 22 |
+
### Tags
|
| 23 |
|
| 24 |
+
- Crop Yield Estimation
|
| 25 |
+
- Digital Agriculture
|
| 26 |
+
- Transformers
|
| 27 |
+
- Multi-Temporal Modeling
|
| 28 |
+
- Regression
|
| 29 |
+
- Hugging Face Transformers
|
| 30 |
+
- FlexServ
|
| 31 |
|
| 32 |
+
### License
|
| 33 |
|
| 34 |
+
- [](https://opensource.org/licenses/MIT)
|
| 35 |
|
| 36 |
+
## References
|
|
|
|
|
|
|
| 37 |
|
| 38 |
+
### USA County Level Crop Yield Dataset
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
This model uses the USA County Level Crop Yield Dataset.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
```bibtex
|
| 43 |
+
@inproceedings{hasan2026vita,
|
| 44 |
+
title={VITA: Variational Pretraining of Transformers for Climate-Robust Crop Yield Forecasting},
|
| 45 |
+
author={Adib Hasan and Mardavij Roozbehani and Munther Dahleh},
|
| 46 |
+
booktitle={Proceedings of the 40th AAAI Conference on Artificial Intelligence},
|
| 47 |
+
year={2026},
|
| 48 |
+
url={https://arxiv.org/abs/2508.03589},
|
| 49 |
+
}
|
| 50 |
|
| 51 |
+
@article{Khaki2020CNNRNN,
|
| 52 |
+
author = {Khaki, Saeed and Wang, Liang and Archontoulis, Sotirios V.},
|
| 53 |
+
title = {A CNN-RNN Framework for Crop Yield Prediction},
|
| 54 |
+
journal = {Frontiers in Plant Science},
|
| 55 |
+
volume = {10},
|
| 56 |
+
pages = {1750},
|
| 57 |
+
year = {2020},
|
| 58 |
+
doi = {10.3389/fpls.2019.01750},
|
| 59 |
+
publisher = {Frontiers Media SA}
|
| 60 |
}
|
| 61 |
+
|
| 62 |
```
|
| 63 |
|
| 64 |
+
### FlexServ
|
| 65 |
+
|
| 66 |
+
The model is packaged and validated for deployment with FlexServ.
|
| 67 |
+
|
| 68 |
+
FlexServ documentation: https://zhangwei217245.github.io/FlexServ/
|
| 69 |
+
|
| 70 |
+
## Acknowledgements
|
| 71 |
+
|
| 72 |
+
This work was developed as part of the ICICLE AI Institute.
|
| 73 |
+
|
| 74 |
+
*National Science Foundation (NSF) AI Institute for Intelligent Cyberinfrastructure with Computational Learning in the Environment (ICICLE), Award OAC-2112606.*
|
| 75 |
+
|
| 76 |
+
## Issue reporting
|
| 77 |
+
|
| 78 |
+
Contact:
|
| 79 |
+
|
| 80 |
+
For questions or support:
|
| 81 |
+
|
| 82 |
+
Sarikaa Sridhar: sridhar.86@buckeyemail.osu.edu
|
| 83 |
+
|
| 84 |
---
|
| 85 |
|
| 86 |
+
# Tutorials
|
| 87 |
|
| 88 |
+
### Overview
|
| 89 |
|
| 90 |
+
The Yield Estimation Transformer is a pretrained model for county-level corn yield estimation. It combines multi-temporal weekly weather observations with static soil properties and produces a scalar yield prediction in bushels per acre.
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
+
The model accepts six weekly weather variables:
|
| 93 |
|
| 94 |
+
- `prcp`
|
| 95 |
+
- `srad`
|
| 96 |
+
- `swe`
|
| 97 |
+
- `tmax`
|
| 98 |
+
- `tmin`
|
| 99 |
+
- `vp`
|
| 100 |
+
|
| 101 |
+
It also uses 66 static soil features defined in `config.json`.
|
| 102 |
+
|
| 103 |
+
The model supports prediction cutoffs at:
|
| 104 |
+
|
| 105 |
+
```text
|
| 106 |
+
20, 24, 28, 32, 36, 40, 44, 48, 52
|
| 107 |
```
|
| 108 |
|
| 109 |
+
A cutoff determines how many weeks of weather information are available to the model. A cutoff of `52` represents full-season inference.
|
| 110 |
|
| 111 |
+
For deployment through FlexServ, the model uses the Hugging Face `text-classification` pipeline as its serving interface. This is an interface choice for inference compatibility; the underlying prediction task remains regression.
|
| 112 |
+
|
| 113 |
+
### Prerequisites
|
| 114 |
+
|
| 115 |
+
- Python 3.10+
|
| 116 |
+
- PyTorch
|
| 117 |
+
- Hugging Face Transformers
|
| 118 |
+
- Dependencies listed in `requirements.txt`
|
| 119 |
+
- FlexServ environment for service deployment
|
| 120 |
+
|
| 121 |
+
Because the repository provides custom model configuration, tokenizer, and architecture code, Hugging Face loading requires:
|
| 122 |
+
|
| 123 |
+
```python
|
| 124 |
+
trust_remote_code=True
|
| 125 |
```
|
| 126 |
|
| 127 |
---
|
| 128 |
|
| 129 |
+
# How-To Guides
|
| 130 |
+
|
| 131 |
+
### Problem Description
|
| 132 |
+
|
| 133 |
+
The model estimates county-level corn yield from weather and soil information.
|
| 134 |
+
|
| 135 |
+
The pretrained architecture expects structured numerical inputs rather than natural-language text. To make the model deployable through FlexServ's supported pipeline tasks, the model is exposed through the Hugging Face `text-classification` interface.
|
| 136 |
+
|
| 137 |
+
The structured yield input is serialized as a JSON string. The custom tokenizer parses this string and converts the weather, soil, crop, and cutoff information into the tensors expected by the pretrained model.
|
| 138 |
+
|
| 139 |
+
The resulting inference path is:
|
| 140 |
+
|
| 141 |
+
```text
|
| 142 |
+
JSON-formatted input string
|
| 143 |
+
↓
|
| 144 |
+
YieldTokenizer
|
| 145 |
+
↓
|
| 146 |
+
weather + soil + crop + cutoff tensors
|
| 147 |
+
↓
|
| 148 |
+
Yield Estimation Transformer
|
| 149 |
+
↓
|
| 150 |
+
scalar yield prediction
|
| 151 |
+
↓
|
| 152 |
+
YIELD_BU_ACRE score
|
| 153 |
+
```
|
| 154 |
+
|
| 155 |
+
The `score` returned by the pipeline is therefore a yield estimate in `bu/acre`, not a classification probability.
|
| 156 |
+
|
| 157 |
+
### Getting Started
|
| 158 |
+
|
| 159 |
+
The repository contains the files required for standalone Hugging Face and FlexServ inference:
|
| 160 |
|
| 161 |
```text
|
| 162 |
.
|
| 163 |
+
├── README.md
|
| 164 |
├── config.json
|
|
|
|
| 165 |
├── configuration_yield.py
|
| 166 |
+
├── model.safetensors
|
| 167 |
├── modeling_yield.py
|
|
|
|
|
|
|
|
|
|
| 168 |
├── requirements.txt
|
| 169 |
+
├── sample_input_weekly.json
|
| 170 |
+
├── tokenization_yield.py
|
| 171 |
+
├── tokenizer_config.json
|
| 172 |
+
└── yield_transformer.py
|
| 173 |
```
|
| 174 |
|
| 175 |
+
A complete inference example is provided in:
|
| 176 |
|
| 177 |
+
```text
|
| 178 |
+
sample_input_weekly.json
|
| 179 |
+
```
|
| 180 |
|
| 181 |
+
### Installation
|
| 182 |
|
| 183 |
+
Clone the model repository:
|
|
|
|
| 184 |
|
| 185 |
+
```bash
|
| 186 |
+
git clone https://huggingface.co/Sarikaa-Sridhar/yield-estimation-transformer
|
| 187 |
+
cd yield-estimation-transformer
|
|
|
|
| 188 |
```
|
| 189 |
|
| 190 |
+
Create and activate a Python environment:
|
| 191 |
|
| 192 |
+
```bash
|
| 193 |
+
conda create -n yield_hf python=3.10
|
| 194 |
+
conda activate yield_hf
|
| 195 |
+
```
|
| 196 |
|
| 197 |
+
Install the required dependencies:
|
| 198 |
|
| 199 |
+
```bash
|
| 200 |
+
pip install -r requirements.txt
|
| 201 |
+
```
|
| 202 |
|
| 203 |
+
### Usage
|
| 204 |
|
| 205 |
+
#### Local Hugging Face Inference
|
|
|
|
|
|
|
| 206 |
|
| 207 |
+
Load the model through the Hugging Face `text-classification` pipeline:
|
| 208 |
|
| 209 |
+
```python
|
| 210 |
+
import json
|
| 211 |
+
from transformers import pipeline
|
| 212 |
|
| 213 |
+
pipe = pipeline(
|
| 214 |
+
"text-classification",
|
| 215 |
+
model="Sarikaa-Sridhar/yield-estimation-transformer",
|
| 216 |
+
tokenizer="Sarikaa-Sridhar/yield-estimation-transformer",
|
| 217 |
+
trust_remote_code=True,
|
| 218 |
+
)
|
| 219 |
+
|
| 220 |
+
with open("sample_input_weekly.json") as f:
|
| 221 |
+
sample = json.load(f)
|
| 222 |
|
| 223 |
+
prediction = pipe(json.dumps(sample))
|
| 224 |
|
| 225 |
+
print(prediction)
|
| 226 |
+
```
|
| 227 |
+
|
| 228 |
+
Example output:
|
| 229 |
+
|
| 230 |
+
```python
|
| 231 |
+
[
|
| 232 |
+
{
|
| 233 |
+
"label": "YIELD_BU_ACRE",
|
| 234 |
+
"score": 165.1769561767578
|
| 235 |
+
}
|
| 236 |
+
]
|
| 237 |
+
```
|
| 238 |
|
| 239 |
+
The `score` is the predicted corn yield in bushels per acre.
|
| 240 |
+
|
| 241 |
+
#### Input Format
|
| 242 |
+
|
| 243 |
+
The structured input contains:
|
| 244 |
|
| 245 |
```json
|
| 246 |
{
|
| 247 |
"crop": "corn",
|
| 248 |
+
"weather_format": "weekly",
|
| 249 |
+
"cutoff": 52,
|
| 250 |
"weather": {
|
| 251 |
+
"prcp": ["52 weekly values"],
|
| 252 |
+
"srad": ["52 weekly values"],
|
| 253 |
+
"swe": ["52 weekly values"],
|
| 254 |
+
"tmax": ["52 weekly values"],
|
| 255 |
+
"tmin": ["52 weekly values"],
|
| 256 |
+
"vp": ["52 weekly values"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
},
|
| 258 |
"soil": {
|
| 259 |
+
"bdod_mean_0-5cm": 0.0,
|
| 260 |
+
"...": "remaining soil features"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
}
|
| 262 |
}
|
| 263 |
```
|
| 264 |
|
| 265 |
+
The complete set of 66 soil variables and their expected ordering are stored in `config.json`.
|
| 266 |
|
| 267 |
+
The tokenizer:
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
+
1. parses the JSON-formatted string,
|
| 270 |
+
2. validates the expected input fields,
|
| 271 |
+
3. constructs the weather, soil, crop, and cutoff tensors.
|
| 272 |
|
| 273 |
+
The Hugging Face pipeline then passes these tensors to the pretrained model for inference.
|
| 274 |
|
| 275 |
+
#### FlexServ Inference
|
| 276 |
|
| 277 |
+
The model has been tested for inference through FlexServ using:
|
|
|
|
|
|
|
|
|
|
| 278 |
|
| 279 |
+
```text
|
| 280 |
+
Task: text-classification
|
| 281 |
+
Model: Sarikaa-Sridhar/yield-estimation-transformer
|
| 282 |
+
```
|
| 283 |
|
| 284 |
+
FlexServ's `inputs` field expects a string. Therefore, the structured yield input must be supplied as a **JSON-formatted string**, rather than directly as a nested JSON object.
|
| 285 |
|
| 286 |
+
Conceptually, a FlexServ request has the following form:
|
| 287 |
|
| 288 |
+
```json
|
| 289 |
+
{
|
| 290 |
+
"task": "text-classification",
|
| 291 |
+
"inputs": "{\"crop\":\"corn\",\"weather_format\":\"weekly\",\"cutoff\":52,\"weather\":{...},\"soil\":{...}}",
|
| 292 |
+
"parameters": {},
|
| 293 |
+
"model": "Sarikaa-Sridhar/yield-estimation-transformer"
|
| 294 |
+
}
|
| 295 |
+
```
|
| 296 |
|
| 297 |
+
A successful response has the form:
|
|
|
|
| 298 |
|
| 299 |
+
```json
|
| 300 |
+
[
|
| 301 |
+
{
|
| 302 |
+
"label": "YIELD_BU_ACRE",
|
| 303 |
+
"score": 165.1769561767578
|
| 304 |
+
}
|
| 305 |
+
]
|
| 306 |
```
|
| 307 |
|
| 308 |
+
The returned `score` is the estimated yield in `bu/acre`.
|
| 309 |
|
| 310 |
+
#### Validation
|
| 311 |
+
|
| 312 |
+
The packaged model can be validated locally against the included sample:
|
| 313 |
+
|
| 314 |
+
```bash
|
| 315 |
+
python - <<'PY'
|
| 316 |
+
import json
|
| 317 |
from transformers import pipeline
|
| 318 |
|
| 319 |
+
with open("sample_input_weekly.json") as f:
|
| 320 |
+
sample = json.load(f)
|
| 321 |
+
|
| 322 |
pipe = pipeline(
|
| 323 |
+
"text-classification",
|
| 324 |
+
model=".",
|
| 325 |
+
tokenizer=".",
|
| 326 |
trust_remote_code=True,
|
| 327 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
|
| 329 |
+
print(pipe(json.dumps(sample)))
|
| 330 |
+
PY
|
| 331 |
+
```
|
| 332 |
|
| 333 |
+
Expected output for the included sample is approximately:
|
| 334 |
|
| 335 |
+
```text
|
| 336 |
+
[{'label': 'YIELD_BU_ACRE', 'score': 165.1769561767578}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
```
|
| 338 |
|
| 339 |
---
|
| 340 |
|
| 341 |
+
# Explanation
|
| 342 |
|
| 343 |
+
### Features
|
|
|
|
|
|
|
| 344 |
|
| 345 |
+
- **Transformer-Based Yield Estimation:** Uses a transformer architecture to model temporal weather information for corn yield prediction.
|
| 346 |
+
- **Weather and Soil Integration:** Combines six weekly weather variables with 66 static soil properties.
|
| 347 |
+
- **Multi-Temporal Inference:** Supports yield estimation at multiple seasonal cutoffs from week 20 through week 52.
|
| 348 |
+
- **Automatic Preprocessing:** The custom tokenizer converts JSON-formatted structured inputs into the tensors expected by the pretrained model.
|
| 349 |
+
- **Automatic Normalization:** Weather and soil features are normalized using statistics stored with the model configuration.
|
| 350 |
+
- **Regression Output:** Produces a scalar corn yield estimate in bushels per acre.
|
| 351 |
+
- **Hugging Face Integration:** Uses the standard Transformers pipeline interface with repository-provided model and tokenizer code.
|
| 352 |
+
- **FlexServ Deployment:** Uses the supported `text-classification` task to expose the regression model as a FlexServ inference service.
|
| 353 |
+
- **CPU and GPU Support:** Supports PyTorch inference on CPU and compatible CUDA GPUs.
|
| 354 |
+
- **Safetensors Weights:** Model weights are distributed using the Safetensors format.
|