Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SyncOne Agriculture

An offline-first Gemma 4 multimodal copilot for agricultural extension workers.

SyncOne Agriculture adapts the existing SyncOne local-first platform into a focused Kaggle Gemma 4 Good Hackathon demo for field extension workers. It keeps the real SyncOne foundation: Android offline workflows, local Gemma 4 E4B inference through LiteRT-LM with on-device vision encoding, SMS/MMS handling, encrypted local storage, sync-ready backend APIs, domain-configured agents, and RAG services.

The public demo is intentionally narrow: a field worker captures a crop photo, records or types a note, adds structured field observations, runs Gemma 4 multimodal locally on the device — image and text together — to produce a structured case summary, reviews retrieved agronomy evidence, drafts a farmer-friendly SMS, and escalates low-confidence cases to a supervisor. Everything runs without a network connection.

Why It Matters

Agricultural extension workers often support farmers in low-connectivity settings where cloud-only AI is unreliable. SyncOne Agriculture is designed around local assistance, transparent evidence, and human review. It does not provide autonomous diagnosis or guaranteed treatment advice.

Why Gemma 4

The original SyncOne app used a Gemma 3n E4B local baseline. This demo upgrades the preferred edge tier toward Gemma 4 E4B while preserving Gemma 4 E2B and legacy Gemma 3n fallback paths for device compatibility.

Google positions Gemma 4 for advanced reasoning and agentic workflows, with E2B/E4B built for multimodal, low-latency edge use. That matches this demo better than a generic chatbot: the model supports field-case structuring, evidence-aware drafting, and escalation decisions on-device.

Official reference: Gemma 4 announcement.

Hero Workflow

  1. Capture a crop photo with the Android camera or import one from the gallery.
  2. Record an audio note, use Android speech recognition when available, or enter an editable transcript/text note.
  3. Add field observations such as crop, stage, affected area, weather, and visible symptoms.
  4. Run local Gemma 4 E4B inference for structured case extraction and summary.
  5. Show retrieved agronomy evidence cards from public-source agronomy summaries or indexed local RAG chunks.
  6. Draft a farmer-friendly SMS with cautious language.
  7. Escalate low-confidence or high-risk cases to a supervisor.

Repo Structure

syncone-agriculture/
  mobile/        Android app adapted from SyncOne Platform
  backend/       ASP.NET Core APIs, orchestration, sync, domain agents, RAG services
  retrieval/     Agriculture ingestion, chunking, metadata, and eval scaffolding
  prompts/       Agriculture-specific prompt contracts
  sample-data/   Demo farmer cases and public source manifest
  benchmarks/    Gemma 3n E4B vs Gemma 4 E4B comparison templates
  docs/          Architecture, migration, evaluation, compliance, demo script
  demo/          Storyboard, screenshots, and video support placeholders
  deployment/    Local demo setup notes

Run The Demo

Android

cd mobile
./gradlew :app:assembleDebug

Deploy a compatible local model outside the repo:

adb push /path/to/gemma-4-E4B-it.litertlm /sdcard/Android/data/com.syncone.agriculture/files/models/

Gemma 4 E2B and legacy Gemma 3n model names remain supported as fallbacks in the local model selector.

Backend

cd backend
dotnet restore SyncOne.sln
dotnet run --project SyncOne.Backend

The backend defaults to the agriculture domain config at backend/SyncOne.Backend/domains/agriculture.json.

Submission Links

These are the artifacts judges should consult, in priority order. Anything still being rendered or rebuilt at final-submission time is noted explicitly so judges aren't left guessing.

  • Live demo site: https://telli.github.io/syncone-agriculture/ — single-page landing built from docs/index.html. Contains the embedded video, the screenshot gallery, the architecture pointers, and links into every other artifact below. Free, no-install, no login.
  • Live demo (Android APK): the offline-first APK is published with each tagged release on GitHub Releases. Setup instructions in deployment/local-demo.md. The app boots into a model-detection splash that walks the viewer through finding the .litertlm file, allocating the engine, and confirming the vision backend before any other UI loads.
  • Kaggle writeup: docs/kaggle-writeup.md. The same content is attached to the Kaggle submission Writeup field.
  • YouTube video: linked from the Kaggle submission Media Gallery and from the live demo site. The shot-level recording script lives at docs/demo-script.md.
  • Demo screenshots: demo/storyboard/ and demo/screenshots/ (populated from the on-device recording session).

What's actually running on Gemma 4

This is the technical claim the judges should verify against the code, not just the writeup:

  • On-device inference: mobile/.../LocalGemmaClient.kt wires Gemma 4 E4B / E2B .litertlm through Google AI Edge LiteRT-LM 0.11.0 with GPU vision backend, Multi-Token Prediction enabled where supported, and a system instruction tailored to extension-worker constraints.
  • Live engine state on app start. A new model-detection splash (ModelSplashScreen, LocalEngineState) observes LocalGemmaClient.engineState: StateFlow<LocalEngineState> and walks the user from "Searching for Gemma 4 model file…" through "Found gemma-4-E4B-it.litertlm (4.2 GB)" → "Backend: GPU · Vision: GPU · Speculative decoding: on" → "Ready · loaded in 4.8 s." If the model file isn't on disk, the splash shows the actual search paths so the user can adb push to one of them without leaving the screen.
  • Multimodal grounding: the captured crop photo is attached to the user Message as a Content.ImageFile alongside the prompt, so Gemma 4's vision encoder receives the actual pixels. The imageAnalyzedByModel flag in GenerationResult is set from the engine's response, not hard-coded — the UI never claims image analysis that didn't run.
  • Structured output as a contract: the model is asked to return a fixed JSON schema (case summary, likely issue, next steps, risk flags, source ids, confidence, supervisor-review flag, SMS draft) which is parsed and validated client-side; parse failures route the case to the supervisor queue.
  • RAG-grounded evidence cards: local vector search against bundled agronomy summaries; source_ids returned by the model must match retrieved source ids before a card is shown.
  • Composite, evidence-derived confidence. The value behind the confidence chip and the escalation gate is no longer "trust whatever the model said." computeCompositeConfidence blends 0.4 · modelConfidence + 0.4 · avg(cosine of cited sources) + max(0, 0.20 − 0.05 · riskFlagCount). Uncited model output cannot exceed 0.60, which sits below the 0.70 supervisor-review threshold — so a hallucinated answer with no cited sources auto-escalates.
  • One-tap Krio SMS. Same Gemma 4 call, same English structured summary for the supervisor packet, but the farmer-facing sms_draft shifts into Sierra Leone's working lingua franca. Contract in prompts/sms-drafting.prompt.md; appended to the structured prompt by AgricultureCaseRepository.appendSmsLanguageBlock.
  • Cloud fallback: when the device is online, cases above the local model's complexity threshold are routed to the hosted Gemma 4 26B/31B endpoint via the backend's GemmaService (see backend/SyncOne.Infrastructure/Services/GemmaService.cs). The default demo path is fully local.

Current Status

Implemented end-to-end: agriculture domain config, Room-backed field cases, app-private camera/gallery media storage, app-private audio recording with reviewed transcript provenance, Gemma 4 multimodal (image + text) on-device inference via LiteRT-LM, structured JSON output contract, RAG-backed evidence cards with source attribution, confidence/escalation state machine, supervisor packet preview, farmer SMS review panel, offline/sync status UI and WorkManager sync, backend agriculture case/review endpoints, source-pack summaries, benchmark export/validator, and public docs.

What ships with the final submission: a debug APK (built from this repo), the bundled agronomy source pack, the demo storyboard and screenshots from a real device run, and the recorded benchmark numbers in benchmarks/. Crop sample images are not redistributed in the repo for licensing reasons — supply your own JPEGs at the paths declared in sample-data/demo-cases.json, or capture live with the camera flow.

See docs/demo-limitations.md for the explicit demo boundary (what we don't claim) and docs/benchmarking.md for the Gemma 3n E4B vs. Gemma 4 E4B comparison plan.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages