File size: 9,289 Bytes
cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff cba42de 74781ff |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
---
tags:
- functiongemma
- functiongemma-tuning-lab
- outdoor-safety
- hiking
- function-calling
- android
license: gemma
language:
- en
base_model: google/functiongemma-2b-it
---
# FunctionGemma Safety Agent for Outdoor Navigation
A fine-tuned FunctionGemma 270M model that acts as an intelligent safety decision orchestrator for hikers, providing proactive recommendations about when to turn around or stop based on real-time conditions.
## Model Details
### Model Description
Unlike traditional reactive hiking apps (Komoot, AllTrails, Gaia GPS) that only show your position on a route, this model proactively monitors conditions and answers contextual safety questions like "Given my dropping pace, fading daylight, and low battery, should I turn around?"
The model performs pattern matching and tool selection while deterministic Kotlin code handles all safety-critical computations. This hybrid architecture balances AI flexibility with reliability requirements for safety-critical applications.
- **Developed by:** monday8am
- **Model type:** Function-calling language model
- **Language(s):** English
- **License:** Gemma License
- **Finetuned from model:** google/functiongemma-2b-it (270M parameters)
### Model Sources
- **Repository:** https://huggingface.co/monday8am/functiongemma-safety-agent
- **Base Model:** https://huggingface.co/google/functiongemma-2b-it
## Uses
### Direct Use
This model is designed for integration into Android hiking/outdoor navigation apps as an offline-capable safety advisor. The model orchestrates four safety tools:
1. **assess_completion_risk** - Evaluates probability of safe route completion
2. **get_segment_ahead** - Analyzes upcoming terrain difficulty
3. **find_nearest_poi** - Locates resources (water, shelter, trailhead)
4. **get_bailout_options** - Identifies alternative exit routes
Example interaction:
```
Context: Time 14:30, Sunset 17:45, Progress 6.2km/12km, Pace 3.1 km/h (down from 4.2), Battery 67%
User: "Should I continue or turn around?"
Model: → assess_completion_risk(query: "pace")
```
### Downstream Use
The model outputs function calls that trigger Kotlin code execution in the host Android app. It is designed for LiteRT deployment for offline inference on mobile devices (~288MB quantized).
Architecture flow:
```
Sensor Data → Kotlin Orchestrator → FunctionGemma → Tool Selection → Kotlin Execution → Safety Alert
```
### Out-of-Scope Use
- **NOT for direct safety computation** - The model selects tools; it does not execute risk calculations
- **NOT a replacement for judgment** - Users must make final decisions considering factors the model cannot observe
- **NOT for emergency services** - Does not contact help or provide medical advice
- **NOT for other outdoor sports without fine-tuning** - Trained specifically on hiking scenarios
## Bias, Risks, and Limitations
**Safety-Critical Context**: This model informs decisions affecting user safety. The architecture intentionally separates AI decision orchestration from deterministic safety computations.
**Training Distribution**: Fine-tuned on hiking scenarios; performance may degrade for climbing, trail running, or winter sports without additional training.
**Sensor Dependency**: Accuracy depends on correct sensor input (GPS, accelerometer, battery status) from the device.
**No Physical Observation**: Cannot assess trail conditions, weather microclimate, or user physical state directly.
### Recommendations
- Users should treat model outputs as recommendations, not commands
- Always consider personal fitness, group dynamics, and observed conditions
- Maintain traditional safety practices (tell someone your route, carry essentials)
- The model should augment, not replace, outdoor judgment and skills
- Test thoroughly before relying on the system in remote areas
## How to Get Started with the Model
```python
# Convert to LiteRT format for Android deployment
from transformers import AutoTokenizer, AutoModelForCausalLM
import ai_edge_torch
model = AutoModelForCausalLM.from_pretrained("monday8am/functiongemma-safety-agent")
tokenizer = AutoTokenizer.from_pretrained("monday8am/functiongemma-safety-agent")
# Export to LiteRT
edge_model = ai_edge_torch.convert(model, tokenizer)
edge_model.export("safety_agent.tflite")
```
**Android Integration** (Kotlin):
```kotlin
// Load model
val interpreter = Interpreter(loadModelFile("safety_agent.tflite"))
// Prepare context
val context = """
Time: ${getCurrentTime()}, Sunset: ${getSunsetTime()}
Progress: ${getProgressKm()}km of ${getTotalKm()}km
Pace: ${getCurrentPace()} km/h
Battery: ${getBatteryPercent()}%
""".trimIndent()
// Get tool selection from model
val toolCall = interpreter.runInference(context, userQuery)
// Execute selected tool with Kotlin
when (toolCall.name) {
"assess_completion_risk" -> assessRisk(toolCall.args["query"])
"get_segment_ahead" -> getSegmentInfo(toolCall.args["query"])
// ... handle other tools
}
```
## Training Details
### Training Data
**360 training examples** generated from 18 carefully crafted seed scenarios covering:
- Pace decline situations (fatigue, terrain difficulty)
- Daylight management (sunset proximity, headlamp decisions)
- Resource concerns (water, battery, shelter)
- Weather changes (approaching storms, temperature drops)
- Navigation decisions (bailout options, POI location)
- **"No action needed" cases (~20%)** - Teaching the model when NOT to intervene
**Generation Method**: Gemini Flash expansion with controlled variation to ensure diversity while maintaining quality.
**Data Format**: FunctionGemma Tuning Lab compliant format with unified `query: string` parameter across all tools.
### Training Procedure
**Fine-tuning Platform**: FunctionGemma Tuning Lab (no-code UI)
#### Training Hyperparameters
- **Training regime:** Mixed precision (bf16)
- **Epochs:** Tuning Lab default
- **Learning rate:** Tuning Lab default adaptive schedule
- **Dataset:** 360 examples (train/validation split handled by platform)
#### Speeds, Sizes, Times
- **Training time:** ~15-30 minutes on Tuning Lab infrastructure
- **Model size:** 270M parameters (~288MB quantized for mobile)
- **Inference speed:** ~125 tokens/sec on Samsung S25 Ultra (CPU only)
## Evaluation
### Testing Data, Factors & Metrics
#### Testing Data
Held-out validation set from the 360-example dataset, ensuring coverage across all tool types and "no action" scenarios.
#### Factors
Evaluation disaggregated by:
- Tool type (4 safety tools + no-tool cases)
- Scenario urgency (critical vs. marginal situations)
- Context complexity (single vs. multiple risk factors)
#### Metrics
**Primary Metric**: Tool selection accuracy (correct tool chosen for given scenario)
- **Base model**: 58% accuracy
- **Fine-tuned model**: 85% accuracy
**Secondary Metrics**:
- No-tool precision (avoiding false interventions)
- Critical scenario recall (catching dangerous situations)
### Results
| Metric | Base FunctionGemma | Fine-tuned |
|--------|-------------------|------------|
| Overall Accuracy | 58% | 85% |
| Critical Scenario Recall | 62% | 91% |
| No-Tool Precision | 45% | 78% |
The model shows particular improvement in recognizing when NOT to intervene (avoiding alert fatigue) while maintaining high recall on genuinely dangerous situations.
## Environmental Impact
Fine-tuning performed using FunctionGemma Tuning Lab infrastructure.
- **Hardware Type:** Cloud TPU/GPU (managed by Google)
- **Hours used:** ~0.25-0.5 hours
- **Cloud Provider:** Google Cloud
- **Compute Region:** US (exact region varies)
- **Carbon Emitted:** Minimal due to short training time and efficient infrastructure
## Technical Specifications
### Model Architecture and Objective
**Base Architecture**: FunctionGemma 270M (Gemma-2b variant optimized for function calling)
**Fine-tuning Objective**: Function-calling accuracy on outdoor safety scenarios with four tools:
1. `assess_completion_risk(query: string)`
2. `get_segment_ahead(query: string)`
3. `find_nearest_poi(query: string)`
4. `get_bailout_options(query: string)`
**Design Philosophy**: Stateless model calls - the model performs single-turn tool selection while the Kotlin app maintains session state, sensor history, and alert logic.
### Compute Infrastructure
#### Hardware
- **Training:** Google Cloud TPU/GPU via FunctionGemma Tuning Lab
- **Inference:** Android devices (CPU-only deployment via LiteRT)
- **Target Device:** Tested on Samsung S25 Ultra, compatible with most modern Android devices
#### Software
- **Training Framework:** FunctionGemma Tuning Lab
- **Deployment:** TensorFlow Lite Runtime (LiteRT) for Android
- **Development:** Kotlin for Android orchestration layer
## Citation
```bibtex
@misc{functiongemma-safety-agent-2026,
author = {monday8am},
title = {FunctionGemma Safety Agent for Outdoor Navigation},
year = {2026},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/monday8am/functiongemma-safety-agent}},
note = {Fine-tuned from google/functiongemma-2b-it for proactive hiking safety recommendations}
}
```
## Model Card Authors
monday8am
## Model Card Contact
For questions, issues, or collaboration opportunities, please open an issue on the model repository. |