DistilBERT Model for Crop Recommendation Based on Environmental Parameters
This repository contains a fine-tuned DistilBERT model trained for crop recommendation using structured agricultural data. By converting numerical environmental features into text format, the model leverages transformer-based NLP techniques to classify the most suitable crop type.
🌾 Problem Statement
The goal is to recommend the best crop to cultivate based on parameters such as soil nutrients and weather conditions. Traditional ML models handle this as a tabular classification problem. Here, we explore the innovative approach of using NLP models (DistilBERT) on serialized tabular data.
📊 Dataset
Source:
Crop Recommendation Dataset
Features:
N: Nitrogen content in soil
P: Phosphorus content in soil
K: Potassium content in soil
Temperature: in Celsius
Humidity: %
pH: Acidity of soil
Rainfall: mm
Target:
Crop label (22 crop types)
The dataset is preprocessed by concatenating all numeric features into a single space-separated string, making it suitable for transformer-based tokenization.
The dataset is sourced from the publicly available
Crop Recommendation Dataset
. It consists of structured features such as:
Nitrogen (N)
Phosphorus (P)
Potassium (K)
Temperature (°C)
Humidity (%)
pH
Rainfall (mm)
All numerical features were converted into a single textual input string to be used with the DistilBERT tokenizer. Labels were factorized into class indices for training.
The dataset was split using an 80/20 ratio for training and testing.
🔧 Training Configuration
Epochs:
3
Batch size:
8
Learning rate:
2e-5
Evaluation strategy:
epoch
Model Base:
DistilBERT (
distilbert-base-uncased
)
Framework:
Hugging Face Transformers + PyTorch
🔄 Quantization
Post-training quantization was applied using PyTorch’s
half()
precision (FP16).
This reduces the model size and speeds up inference with minimal impact on performance.
The quantized model can be loaded with:
model = DistilBertForSequenceClassification.from_pretrained("quantized_model_fp16", torch_dtype=torch.float16)
Repository Structure
.
├── quantized-model/ # Contains the quantized model files
│ ├── config.json
│ ├── model.safetensors
│ ├── tokenizer_config.json
│ ├── vocab.txt
│ └── special_tokens_map.json
├── README.md # Model documentation
Limitations
Uses text conversion of tabular data, which may miss deeper feature interactions.
Trained on a specific dataset; may not generalize to different regions or conditions.
FP16 quantization may slightly reduce accuracy in rare cases.
Contributing
Feel free to open issues or submit pull requests to improve the model or documentation.
Runs of AventIQ-AI Crop_Recommendation on huggingface.co
11
Total runs
0
24-hour runs
4
3-day runs
3
7-day runs
-9
30-day runs
More Information About Crop_Recommendation huggingface.co Model
Crop_Recommendation huggingface.co
Crop_Recommendation huggingface.co is an AI model on huggingface.co that provides Crop_Recommendation's model effect (), which can be used instantly with this AventIQ-AI Crop_Recommendation model. huggingface.co supports a free trial of the Crop_Recommendation model, and also provides paid use of the Crop_Recommendation. Support call Crop_Recommendation model through api, including Node.js, Python, http.
Crop_Recommendation huggingface.co is an online trial and call api platform, which integrates Crop_Recommendation's modeling effects, including api services, and provides a free online trial of Crop_Recommendation, you can try Crop_Recommendation online for free by clicking the link below.
AventIQ-AI Crop_Recommendation online free url in huggingface.co:
Crop_Recommendation is an open source model from GitHub that offers a free installation service, and any user can find Crop_Recommendation on GitHub to install. At the same time, huggingface.co provides the effect of Crop_Recommendation install, users can directly use Crop_Recommendation installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
Crop_Recommendation install url in huggingface.co: