Downloads · 30 days
0
tasfuuu19/gemma-4-e2b-spatial-lora
gemma-4-e2b-spatial-lora is a text generation model from tasfuuu19. Use it when you need the model to write or continue text. The card lists the license as apache-2.0.
Gemma 4 E2B fine-tuned for humanitarian spatial tool calling Part of GemmaTerrain — Multimodal GeoAI for the Unconnected
Downloads · 30 days
0
Access
Public
Updated May 18, 2026
Repo size
69.4 MB
Likes
0
Public
Click a slice to open those files.
.safetensors37.2 MB · 54%
From the Hugging Face model README
Gemma 4 E2B fine-tuned for humanitarian spatial tool calling
Part of GemmaTerrain — Multimodal GeoAI for the Unconnected
This is a LoRA adapter for google/gemma-4-e2b-it, fine-tuned to output structured JSON tool calls for humanitarian spatial queries. It runs offline on ARM edge hardware (Raspberry Pi 5, Steam Deck) as part of the GemmaTerrain system — no internet, no cloud, no GPU required.
Given a natural language query in English, Bangla, Spanish, or Indonesian, the model selects exactly one spatial tool and outputs its arguments as JSON.
Example:
| Input | Output |
|---|---|
"Find the nearest hospital to Camp 6" | {"name": "find_nearest_poi_with_route", "arguments": {"poi_type": "hospital", "lat": 21.2, "lon": 92.16}} |
"15 minute walking radius from Condado" | {"name": "generate_isochrone", "arguments": {"lat": 18.46, "lon": -66.07, "max_minutes": 15}} |
"Camp 6 er kache hospital kothay?" | {"name": "find_nearest_poi_with_route", "arguments": {"poi_type": "hospital", "lat": 21.2, "lon": 92.16}} |
"Farmacias dentro de 1km de Ocean Park" | {"name": "list_pois", "arguments": {"poi_type": "pharmacy", "lat": 18.46, "lon": -66.05, "radius_m": 1000}} |
The model is trained to call exactly one of these 6 tools:
| Tool | Use case |
|---|---|
find_nearest_poi_with_route | "Nearest hospital to X" — returns closest POI + walking route |
list_pois | "Clinics within 2km of X" — returns all POIs in radius |
calculate_route | "Walk from A to B" — returns distance + time |
generate_isochrone | "15 min walking area from X" — returns reachable boundary |
find_along_route | "Pharmacies along the way from A to B" |
geocode_place | "Where is X?" — resolves place name to coordinates |
Supported POI types: hospital, clinic, doctors, pharmacy, police, fire_station, shelter, school, university, bank, atm, supermarket, marketplace, drinking_water, water_point, fuel, bus_station, place_of_worship
| Parameter | Value |
|---|---|
| Base model | google/gemma-4-e2b-it |
| Method | QLoRA (4-bit quantization) |
| LoRA rank | 16 |
| LoRA alpha | 32 |
| Target modules | q_proj, k_proj, v_proj, o_proj |
| Max sequence length | 512 tokens |
| Training examples | 28 unique × augmented to 5,000 |
| Epochs | 3 |
| Batch size | 2 (effective: 8 with grad accumulation) |
| Learning rate | 2e-4 |
| Precision | fp16 |
| Framework | Unsloth + TRL SFTTrainer |
| Hardware | Kaggle T4 (15GB) |
| Training time | ~45 minutes |
28 hand-crafted humanitarian spatial query → tool call pairs across 3 real-world locations and 4 languages:
| Location | Context |
|---|---|
| Cox's Bazar, Bangladesh | Rohingya refugee camps (Camp 3, 6, 8W, 9, 12, 15) |
| San Juan, Puerto Rico | Post-hurricane disaster response (Condado, Santurce, Miramar) |
| Jakarta, Indonesia | Urban humanitarian operations (Menteng, Gelora, Gambir, Kemang) |
Languages: English · Bangla (transliterated) · Spanish · Indonesian
Query types: nearest POI, radius search, route calculation, isochrone, along-route search
You are GemmaTerrain, a humanitarian spatial assistant running offline on edge hardware.
Select exactly ONE tool. Output only the tool call JSON — no explanation.
Valid poi_type values: hospital, clinic, doctors, pharmacy, police, fire_station,
shelter, school, university, bank, atm, supermarket, marketplace, drinking_water,
water_point, fuel, bus_station, place_of_worship
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="tasfuuu19/gemma-4-e2b-spatial-lora",
max_seq_length=512,
load_in_4bit=True,
)
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = AutoModelForCausalLM.from_pretrained("google/gemma-4-e2b-it", load_in_4bit=True)
model = PeftModel.from_pretrained(base, "tasfuuu19/gemma-4-e2b-spatial-lora")
tokenizer = AutoTokenizer.from_pretrained("tasfuuu19/gemma-4-e2b-spatial-lora")
messages = [
{"role": "system", "content": "You are Meridian, a humanitarian spatial assistant..."},
{"role": "user", "content": "Find the nearest hospital to Camp 6"},
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=128, temperature=0.1)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
# {"name": "find_nearest_poi_with_route", "arguments": {"poi_type": "hospital", "lat": 21.2, "lon": 92.16}}
This adapter is the E2B component of the GemmaTerrain dual-model routing system:
Query → Geocode Layer → Cactus Router → Gemma 4 E2B (this model) → Spatial Tool → Result
↘ Gemma 4 E4B (complex/multimodal queries)
The router sends queries to E2B for simple spatial lookups (nearest, list, route, isochrone) and to E4B for multimodal or complex multi-hop reasoning. Battery level is also a routing signal — below 20%, all queries go to E2B.
The spatial backend uses NetworKit (Dijkstra routing) + DuckDB (spatial queries) on OpenStreetMap data, running fully offline.
Apache 2.0 — same as the base Gemma 4 model.