Inspiration

Smallholder farmers across rural Africa face critical gaps in agricultural advisory services. Reliable internet connectivity is often non-existent in remote farmlands, and conventional extension services are understaffed. Standard cloud-based AI solutions fail in these environments due to latency, connectivity dependencies, and recurring API costs.

We were inspired to build a 100% offline, localized, and privacy-first AI advisory engine designed to run efficiently on low-spec edge hardware (such as 8 GB RAM consumer laptops). By bringing agronomic intelligence directly to the edge, our assistant provides immediate, context-aware agricultural guidance without sending a single byte over the internet.

What it does

The ADTC Pan-African Agriculture Assistant is an offline, terminal-based AI assistant equipped with a localized Retrieval-Augmented Generation (RAG) knowledge base. Key capabilities include:

  • Context Interception & Guardrails: Automatically intercepts queries lacking spatial context and prompts users for regional details (e.g., location, crop type) before enriching the prompt.
  • Localized Agronomic Guidance: Provides concrete, actionable farming recommendations—including planting windows, spacing, fertilizer application rates, and pest management strategies tailored to African regional micro-climates.
  • Smart In-Memory Caching: Instant sub-millisecond response retrieval for repeated or canonical agronomic queries.
  • Flicker-Free TTY Streaming: Custom token batching rendering multi-line Markdown smoothly without terminal scrollback duplication.

How we built it

  • Inference Engine: Powered by llama.cpp (llama-cpp-python) executing Qwen2.5-3B-Instruct in GGUF Q4_K_M 4-bit quantization, strictly keeping RAM usage under ~2.3 GB.
  • Retrieval-Augmented Generation (RAG): Built an in-memory vector search engine (rag_engine.py) backed by SQLite and SentenceTransformers (all-MiniLM-L6-v2) to retrieve localized extension manuals.
  • Query Interceptor: Implemented a stateful guardrail (query_interceptor.py) to manage session history and inject missing geographic parameters.
  • Terminal UI: Constructed an interactive CLI using Python's rich library with dynamic live-display updates every 3 tokens.
  • Offline Enforcement: Configured strict local_files_only loading to guarantee 100% zero-network cold starts.

Challenges we ran into

  • Offline Weight Initialization: Sentence Transformers initially attempted to contact Hugging Face APIs during cold starts. We resolved this by embedding strict local environment flags (HF_HUB_OFFLINE=1) to force zero-network execution.
  • Terminal Scrollback Glitches: Real-time token streaming in Docker TTY containers often duplicated text lines when rendering complex Rich Markdown blocks. We solved this with controlled refresh batching via rich.live.Live(auto_refresh=False).

Accomplishments that we're proud of

  • Rock-Solid Audit Metrics: Verified via the official competition suite (audit.json), achieving 4.05 tokens/sec generation throughput, a 2.27 GB peak RAM footprint, and an ARC-Easy accuracy score of 0.78 on target hardware (Intel i7-3840QM, 8GB RAM).
  • True Edge Operability: Built a fully operational, localized agricultural advisory system that runs completely offline on decade-old budget laptops.

What's next for ADTC Agriculture Assistant

  • SQLite-backed Vector Indexing: Implementing sqlite-vss / sqlite-vec binary extensions for sub-second vector retrieval at scale.
  • Voice-Based Edge Interface: Integrating lightweight offline speech-to-text engines (whisper.cpp) to support local spoken languages for low-literacy rural farmers.

Built With

Share this project:

Updates

Submission history