Organic AI (Gemma 4 12B — SFT + DPO)
Made by Ishaan Dalvi (ishaan.dalvigroup.co.in)
Important Disclaimer — Heavily Built by AI & Not Human-Verified: This model, its training datasets, and the companion skill/MCP tooling were heavily built using AI and have not been human-verified by an agronomist or agricultural scientist. Do not treat outputs as verified agronomic prescriptions—always confirm rates and treatments with a laboratory soil test and a local KVK / certified agronomy specialist.
- GitHub (Organic AI Skill, MCP Server & Training Code): https://github.com/MCGlitch1001/Organic-AI
- Curated Dataset: https://huggingface.co/datasets/MCGlitch/organic-ai-dataset
Organic AI (Gemma 4 12B) is a domain-adapted local language model trained for chemical-aware, strictly organic-first agronomy, soil microbiology, composting, water harvesting, organic IPM, and tropical monsoon / Deccan black cotton (Vertisol) & Western Ghats farming.
Recommendation: If you have internet/tool access or want live SoilGrids, Open-Meteo, and strict guardrail adherence, prefer the Organic AI Gemini Skill + MCP Server in the companion GitHub repository: https://github.com/MCGlitch1001/Organic-AI (one-click skill download:
organic-ai-skill.zip). This local 12B model is provided as an offline/local prototype and research release.
Repository Contents
This single repository packages all three formats of the Organic AI Gemma 4 12B (v2 SFT+DPO) checkpoint:
| Folder | Format | Size (approx.) | Best For |
|---|---|---|---|
adapter/ | PEFT LoRA (r=16, lora_alpha=16) | ~281 MB | Merging or further fine-tuning on unsloth/gemma-4-12b-it |
gguf/ | gemma-4-12b-it.Q4_K_M.gguf + F16-mmproj.gguf + Modelfile | ~7.0 GB | Ollama, llama.cpp, LM Studio (Linux/Windows/macOS) |
mlx/ | Fused 4-bit MLX model (chat_template.jinja with thinking disabled by default) | ~6.3 GB | Apple Silicon (mlx-lm) |
Quick Start
1. Ollama (using gguf/)
Download the gguf/ directory, then create and run the Ollama model from inside gguf/:
cd gguf
ollama create organic-ai-gemma4 -f Modelfile
ollama run organic-ai-gemma4
2. Apple Silicon MLX (using mlx/)
pip install mlx-lm
python -m mlx_lm.generate \
--model MCGlitch/organic-ai-gemma4-12b/mlx \
--prompt "How do arbuscular mycorrhizal fungi help crops, and what practices harm them?" \
--max-tokens 512
(If downloading locally first, point --model to your local mlx/ folder.)
3. Transformers + PEFT (using adapter/)
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
base_id = "unsloth/gemma-4-12b-it"
adapter_id = "MCGlitch/organic-ai-gemma4-12b"
tokenizer = AutoTokenizer.from_pretrained(base_id)
base_model = AutoModelForCausalLM.from_pretrained(
base_id, torch_dtype=torch.bfloat16, device_map="auto"
)
model = PeftModel.from_pretrained(base_model, adapter_id, subfolder="adapter")
messages = [
{
"role": "system",
"content": (
"You are a chemical-aware, strictly organic-first agronomy specialist with deep expertise "
"in soil microbiology, composting, water harvesting, no-till/cover cropping, organic IPM, "
"general crop science, and tropical monsoon / black cotton (vertisol) farming."
),
},
{"role": "user", "content": "How many kg of urea per acre should I apply to rice at tillering?"},
]
inputs = tokenizer.apply_chat_template(
messages, tokenize=True, add_generation_prompt=True, return_tensors="pt", enable_thinking=False
).to(model.device)
outputs = model.generate(inputs, max_new_tokens=384, temperature=1.0, top_p=0.95, top_k=64)
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
Training Summary
- Base Model:
unsloth/gemma-4-12b-it(text-only LoRA:r=16,lora_alpha=16,lora_dropout=0, language attention + MLP layers,max_seq_length=1024) - Stage 1 (Broad Agronomy SFT): 14,513 train / 763 validation rows with 3-part organic reframing on synthetic agrochemical queries
- Stage 2 (Organic & Regional Grounding SFT): 1,670 train / 151 validation rows (
1.5epochs, cosinelr=5e-5,adamw_8bit, response-only loss) built from pre-Nov-2022 audited manuals,guardrails_v2, Indian/Vertisol PDF Q&As, and Stage 1 replay - Stage 3 (DPO Guardrail Lock-In): 250 project-authored preference pairs (
beta=0.1,1epoch, cosinelr=5e-6) targeting chemical dose refusals + 3-part organic pivots, hyper-local honesty, Vertisol physics/alkalinity, textbook-artifact removal, and out-of-scope refusals - Exports: Fused/quantized to
Q4_K_MGGUF (+F16mmproj) and fused into 4-bit MLX viascripts/fuse_peft_mlx.py
Evaluation & Known Limitations
Qualitative and guardrail checks on the 20-prompt golden_eval_v2.jsonl suite are logged in logs/eval_gemma4_v2.md in the GitHub repository:
- Strengths: Consistently refuses synthetic agrochemical dose prescriptions (urea, DAP, cypermethrin, carbendazim, glyphosate) while providing mechanism, ecological trade-offs, and biological/organic alternatives; handles hyper-local gaps (exact mandi prices, taluka variety picks) and out-of-scope medical/financial prompts cleanly.
- Limitations (Read Before Use):
- This is a local 12B advisory prototype, not a substitute for laboratory soil tests or certified extension advice.
- Occasional minor unit inconsistencies (e.g., mixing
t/haandt/acre), rare typos, or legacy reference phrasing (Chapter 5) can still occur in 12B generations. - Has no live weather, soil-grid, or market API access unless paired with external tools.
- Medical emergencies / pesticide poisoning: Never rely on an LLM—seek emergency medical care immediately (
108in India) with the product label.
Author & License
- Made by: Ishaan Dalvi (
ishaan.dalvigroup.co.in) - Base model & weights (
gguf/,mlx/, derived weights): Subject to the Gemma Terms of Use. - Adapter config, training pipeline & documentation: Apache License 2.0.