Skip to main content

On This Page

Engineering Shamba-MedCare: Structured Prompt Design for Accurate Plant Disease Diagnosis

2 min read
Share

These articles are AI-generated summaries. Please check the original sources for full details.

The Architecture

Shamba-MedCare, an AI-powered plant disease diagnosis tool, faced critical failures with naive prompts that generated 2,000-word essays instead of actionable insights for farmers. Iterative refinement of system prompts and structured JSON output resolved these issues.

Why This Matters

LLMs like Claude excel at generating verbose responses but struggle with structured, budget-aware outputs. Early versions of Shamba-MedCare returned unactionable data, risking misdiagnosis for farmers with limited resources. Parsing errors and vague location descriptions added to the technical debt, costing time and accuracy until explicit formatting and cost-tiered treatments were enforced.

Key Insights

  • “JSON parsing failure in 20% of cases despite explicit instructions”: The system required backend parsing to extract valid JSON from markdown-enclosed responses.
  • “Structured prompts with cost tiers improve farmer accessibility”: Explicit ordering of treatments by cost ensured free remedies were prioritized.
  • “Shamba persona enforces traditional remedies”: The system prompt’s mandate for free treatments shifted outputs from commercial products to accessible solutions.

Working Example

# System Prompt (Shamba Persona)
You are Shamba, an expert agricultural pathologist. You analyze
plant images to identify diseases, pests, and nutrient deficiencies.
Your expertise includes:
- 50+ crop types worldwide
- Fungal, bacterial, viral, and physiological disorders
- Traditional and modern treatment methods
- Practical advice for resource-limited farmers
Guidelines:
1. Always include at least one FREE/traditional treatment
2. Describe WHERE symptoms appear (for visual mapping)
3. Be honest about uncertainty—use confidence scores
4. Recommend professional help for severe cases
// Example JSON Output Schema
{
  "disease": "Early Blight",
  "confidence": 0.85,
  "affected_regions": [
    {
      "location": "lower-left",
      "coverage": 15,
      "severity": "severe",
      "description": "Dark brown lesions with concentric rings"
    }
  ],
  "treatments": [
    {
      "method": "Wood ash paste",
      "cost_tier": "free",
      "estimated_cost": "$0",
      "application": "Apply directly to affected areas"
    }
  ]
}

Practical Applications

  • Use Case: Shamba-MedCare diagnoses tomato blight with heatmaps and cost-tiered treatments for smallholder farmers.
  • Pitfall: Overlooking input quality (e.g., blurry photos) leads to inaccurate symptom detection and treatment recommendations.

References:

Continue reading

Next article

How AI is Changing DevOps Careers: A Reality Check with Bret Fisher

Related Content