Downloads · 30 days
7
13% of all-time downloads
avijeetsingh1608/TerraGround-Gemma-4-E2B-LoRA
TerraGround-Gemma-4-E2B-LoRA is a text generation model from avijeetsingh1608. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as gemma.
Downloads · 30 days
7
13% of all-time downloads
All-time downloads
56
Public
Repo size
50.6 MB
Likes
1
Public
Click a slice to open those files.
.safetensors48.4 MB · 97%
From the Hugging Face model README
TerraGround is a LoRA adapter for google/gemma-4-e2b-it that turns Gemma into a grounded Earth-observation analyst. It answers questions about any place on Earth — dominant land cover, vegetation greenness (NDVI) and moisture (NDMI), surface water — from the free, co-located TESSERA satellite embedding decoded into analysis products, with calibrated confidence and a refusal gate for out-of-scope questions. It lifts grounded geo-QA accuracy from 0.694 (frozen base) to 0.794 on held-out cells.
Built for the edge / orbit→ground setting (the LatentBridge thesis): a tiny TESSERA embedding is available for free on both the satellite and the ground, so a frozen Gemma on the ground can reason about a location without downlinking imagery. Honesty is a feature — see Limitations.

How Gemma is modified (frozen backbone + LoRA on the text-layer projections + external geo-grounding + safety wrappers — no structural change, drop-in from_pretrained):

🚀 Live demo (verifiable grounding): TerraGround-Verifiable-EO Space
📄 Paper: PAPER.md (LaTeX source: paper.tex) · 🔁 Reproduce: REPRODUCE.md · 🧩 Offline grounding kit: decode_offline.py + reference.npz
google/gemma-4-e2b-it (gated; Gemma terms). Adapter type: PEFT LoRA (r=8).transformers==5.10.0.dev0 (ships the gemma4_unified arch), peft==0.19.1, bitsandbytes; see requirements.txt.Anything not derivable from satellite bands — ownership, prices, people/counts, specific dated events, sub-pixel or indoor facts, far-future prediction. The gate refuses these deterministically.
<p align="center">◆ ◇ ◆</p># 1) Accept the base model gate at https://huggingface.co/google/gemma-4-e2b-it then: huggingface-cli login
# 2) pip install -r requirements.txt (transformers 5.10.0.dev0, peft 0.19.1, bitsandbytes, numpy)
import torch, numpy as np
from transformers import AutoModelForCausalLM, AutoProcessor, BitsAndBytesConfig
from peft import PeftModel
from decode_offline import DecodeHeads, grounding_block # shipped with this adapter
BASE = "google/gemma-4-e2b-it"; ADAPTER = "<org>/TerraGround-Gemma-4-E2B-LoRA"
cfg = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16, bnb_4bit_use_double_quant=True)
model = AutoModelForCausalLM.from_pretrained(BASE, quantization_config=cfg, device_map={"": 0})
model = PeftModel.from_pretrained(model, ADAPTER) # the TerraGround geo-adapter
proc = AutoProcessor.from_pretrained(BASE); tok = proc.tokenizer
# Ground a question in the FREE co-located TESSERA embedding (offline; bundled reference.npz)
heads = DecodeHeads("reference.npz")
emb = np.load("example_embedding.npy") # a 128-D TESSERA embedding for some place
block = grounding_block(heads, emb) # decoded land cover + indices, as text
sys = "You are a careful Earth-observation analyst. Use the grounded context; respect its caveats. Be concise."
msgs = [{"role": "system", "content": [{"type": "text", "text": sys}]},
{"role": "user", "content": [{"type": "text",
"text": f"GROUNDED EARTH-OBSERVATION CONTEXT:\n{block}\n\nQUESTION: What is the dominant land cover here?"}]}]
ids = proc.apply_chat_template(msgs, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt").to(model.device)
print(tok.decode(model.generate(**ids, max_new_tokens=64)[0][ids["input_ids"].shape[1]:], skip_special_tokens=True))

All numbers below are produced by the scripts in latent_bridge/terraground/ and read from out/terraground/*.json (see Reproducibility). Evaluation is on a geographically held-out subset of the reference corpus, not an external benchmark — see Limitations. CIs are Wilson 95%.
Frozen base vs the adapter, both reading the same decoded TESSERA grounding (n=60 cells):
| task | base | this adapter |
|---|---|---|
| land cover (8-class) | 0.92 [0.82, 0.96] | 0.92 [0.82, 0.96] |
| vegetation greenness level | 0.70 [0.57, 0.80] | 0.80 [0.68, 0.88] |
| vegetation moisture level | 0.47 [0.35, 0.59] | 0.67 [0.54, 0.77] |
| overall | 0.69 [0.57, 0.80] | 0.79 [0.68, 0.88] |
A deterministic capability-match gate refuses questions outside the satellite-derived bands, evaluated on fresh probes disjoint from training:
k-NN agreement is a calibrated confidence: held-out land-cover accuracy is 0.00 below the 0.71 threshold vs 0.92 above it. Abstaining below threshold is selective prediction:
| threshold | coverage | accuracy on answered |
|---|---|---|
| 0.0 | 1.0 | 0.911 |
| 0.71 | 0.989 | 0.921 |
| 0.85 | 0.989 | 0.921 |
| 1.0 | 0.955 | 0.918 |
Backfilling the reference with geographically diverse sites (571→1286 cells) raised mean decode confidence on held-out exotic locations (never added to the reference) from 0.671 to 0.914, with corrected classes (e.g. boreal grassland→tree cover, Punjab→cropland, tundra→moss & lichen).
The land-cover decode head was upgraded from k-NN to a class-balanced MLP. k-NN memorises reference geometry (great in-distribution, poor on new regions); the MLP generalizes:
| head | in-distribution test | out-of-distribution (fresh regions) |
|---|---|---|
| k-NN (old) | 0.916 | 0.64 |
| MLP (deployed) | 0.911 | 0.84 |
Clay/Prithvi scene embeddings were tested and do not help here (they are scene-scale; fusing them lowered OOD land cover) — TESSERA-only MLP is best.
An earlier single run reported a 0.0 LoRA hallucination rate, but that evaluated the same question templates seen in training. Under the rigorous protocol (training on one set of unanswerable question types, testing on disjoint held-out types), the fine-tuned adapter's hallucination rate is 1.0 — i.e. LoRA-taught abstention does not generalize to unseen question types. This is why out-of-scope refusal is handled by the deterministic gate on the frozen base (above), not by the adapter. We report this null deliberately.
On the ReAct prompt, the adapter emits a tool call (rather than short-circuiting to a final answer) 100% of the time vs 100% for the base (n=12).



transformers==5.10.0.dev0.If you use this adapter, please cite the base model and data sources (see CITATION.cff):
License: the adapter is governed by the Gemma terms of the base model; the TerraGround training/inference code is Apache-2.0. ESA WorldCover labels are CC BY 4.0.