Agronexus: Agricultural Recommendation Model for Kenya
Model Details
- Developed by: William Obino
- Model Type: Causal Language Model
- Language(s): English
- Base Model: unsloth/llama-2-7b-bnb-4bit
- License: Apache 2.0
- Finetuned with: Unsloth and Hugging Face's TRL library
- Model Size: 7B parameters
- Quantization: Q4_K_M
- Ollama Model: https://ollama.com/Cloudsurfer/agronexus
- Contacts:
- LinkedIn: https://www.linkedin.com/in/williamobino/
- X: https://x.com/ObinoWilliam
- Instagram: https://www.instagram.com/cloudsurfer./
- Github: https://github.com/andomeder
Model Description
Agronexus is a specialized AI model designed to provide agricultural recommendations for Kenya. It takes into account specific weather conditions, soil properties, and local agricultural knowledge to suggest suitable crops and farming practices.
Intended Uses & Limitations
Intended Uses
- Provide crop recommendations for specific locations in Kenya based on current weather and soil conditions.
- Offer detailed farming advice including planting dates, harvesting times, and care methods.
- Suggest cost-cutting measures and environmental considerations for Kenyan agriculture.
- Assist in crop rotation planning and pest management strategies.
Limitations
- The model's knowledge is based on its training data and may not reflect very recent changes in agricultural practices or climate conditions in Kenya.
- Recommendations should be validated by local agricultural experts before implementation.
- The model may not account for all possible local variations in soil and microclimate conditions.
- The model is specifically tailored for Kenyan agriculture and may not be suitable for other regions.
Training Data
- Source: The training data was compiled from a variety of publicly available sources:
- Historical weather data: Sourced from the Open-Meteo Historical Weather API and [OpenWeather API] (https://openweathermap.org/api).
- Soil composition data: Sourced from ISRIC – World Soil Information's SoilGrids.
- Crop recommendations and farming practices: Compiled from resources gotten from the Ministry of Agriculture, Livestock, Fisheries and Cooperatives (MoALFC), Food and Agriculture Organization of the United Nations (FAO), and various agricultural extension publications.
- Expert recommendations: Gathered from interviews with experienced agricultural advisors in Kenya.
- Content: Proprietary dataset containing 118 entries of detailed agricultural scenarios in Kenya. See a sample here.
- Preprocessing:
- Consistent formatting of weather and soil information.
- Standardization of location names.
- Categorization of climate types.
- Normalization of numerical values for weather and soil properties.
Training Procedure
- Library: trl and unsloth were used for training.
- Base Model: meta-llama/Llama-2-7b-hf
- Fine-tuned Model Name: Agronexus-4bit
- Training Hyperparameters:
- Learning rate: 2e-4
- Batch size per device: 2
- Gradient accumulation steps: 4 (effective batch size of 8)
- Number of epochs: 25
- Optimizer: adamw_8bit
- Weight decay: 0.01
- Learning rate scheduler: linear
- Seed: 42
- Max sequence length: 2048
- Data type: torch.float16
- 4-bit quantization: True
- LoRA parameters:
- r: 16
- lora_alpha: 16
- lora_dropout: 0
- bias: "none"
- target_modules: ["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"]
- Gradient checkpointing: True
- Mixed precision training (FP16 or BF16): Automatically selected based on GPU support.
Evaluation Results
- Training Loss: Decreased consistently over 25 epochs, reaching ~0.2946. This indicates successful learning and model improvement.
- Further evaluation metrics: Need to be calculated using a separate evaluation dataset to assess performance on unseen data. This could include accuracy, F1 score, and other metrics relevant for agricultural recommendation tasks.
Environmental Impact
- Hardware Type: Tesla T4 GPU
- Cloud Provider: Google Colab.
- Hours used: Training took approximately 1 hour and 46 minutes (1.77 hours).
- Carbon Emitted: Not calculated. This depends on the cloud provider's energy sources and data center carbon intensity.
Model Quantization
Quantized using the "q4_k_m" method for size reduction, resulting in a final model size of ~3.89 GB.
Input Format
The model expects input in the following format:
You are an expert agricultural advisor specializing in Kenyan agriculture. It is [current date]. Given the following weather and soil conditions for [location], Kenya, provide a recommendation for one (1) distinct crop suitable for growing. The location has a [climate type] climate.
Weather:
- Current Description: [weather description]
- Current Temperature: [temperature]°C
- Average Annual Temperature (5-year): [average temp]°C
- Average Annual Precipitation (5-year): [average precipitation] mm
- 14-Day Forecast:
- Average Max Temperature: [max temp]°C
- Average Min Temperature: [min temp]°C
- Total Precipitation: [precipitation] mm
Soil Properties:
- clay: [percentage]%
- sand: [percentage]%
- silt: [percentage]%
- phh2o: [pH level]
- cec: [CEC value] cmol/kg
Consider the specific Kenyan climate, local soil composition, and pH level when selecting the crop and providing advice. Ensure the recommendation is tailored to the given conditions. Output the recommendation in the following JSON format ONLY!
Output Format
The model will return a JSON object with the following structure:
{
"Crop": "Recommended crop name",
"Planting Date": "Specific months based on Kenyan growing seasons",
"Harvesting Time": "Estimated number of months after planting",
"Farm Inputs": [
{"Type": "Input type", "Description": "Detailed description of input"}
],
"Best Care Methods": "Detailed care tips tailored to Kenyan weather patterns",
"Cost Cutting Measures": "Detailed cost-saving measures relevant to Kenyan agriculture",
"Expected Yield": "Estimated yield per hectare",
"Market Potential": "Brief overview of market demand and potential profit",
"Environmental Impact": "Brief description of the crop's environmental impact",
"Crop Rotation Suggestions": "Suggestions for crop rotation to maintain soil health",
"Pest and Disease Management": "Common pests/diseases and management strategies",
"Water Management": "Irrigation requirements and water conservation techniques",
"Soil Management": "Techniques to maintain or improve soil quality for this crop"
}
Bias, Risks, and Limitations
- The model's recommendations are based on historical data and may not account for recent climate changes or agricultural innovations
- There may be biases in the training data that could affect the diversity of crop recommendations
- The model does not consider socio-economic factors or individual farmer preferences in its recommendations
Ethical Considerations
- Users should be aware that the model's recommendations are based on general patterns and may not be suitable for all specific local conditions.
- The model's output should be used as a starting point for agricultural planning, not as a definitive guide.
- Care should be taken to ensure that the use of this model does not exacerbate existing inequalities in access to agricultural information and resources.
How to Use
To use this model with the Hugging Face Transformers library:
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "Cloudsurfer48902/agronexus"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
prompt = "You are an expert agricultural advisor specializing in Kenyan agriculture. It is 30 August 2024. Given the following weather and soil conditions for Nairobi, Kenya, provide a recommendation for one (1) distinct crop suitable for growing. The location has a semi-arid climate. Weather: - Current Description: partly cloudy - Current Temperature: 22°C - Average Annual Temperature (5-year): 19°C - Average Annual Precipitation (5-year): 850 mm - 14-Day Forecast: - Average Max Temperature: 25°C - Average Min Temperature: 14°C - Total Precipitation: 20 mm Soil Properties: - clay: 35% - sand: 40% - silt: 25% - phh2o: 6.2 - cec: 18 cmol/kg Consider the specific Kenyan climate, local soil composition, and pH level when selecting the crop and providing advice. Ensure the recommendation is tailored to the given conditions. Output the recommendation in the following JSON format ONLY!"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=1000, temperature=0.7)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
Note: Adjust the max_length
and temperature
parameters as needed for your specific use case.
Model Card Authors
William Obino
Model Card Contact
See "Model Details" section for contact information.
- Downloads last month
- 42
Model tree for Cloudsurfer48902/Agronexus-4bit
Base model
unsloth/llama-2-7b-bnb-4bit