monday8am's picture
Update README.md
74781ff verified
---
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.