Update README to focus on tool calling capabilities
Browse files
README.md
CHANGED
|
@@ -9,14 +9,27 @@ tags:
|
|
| 9 |
- gemma
|
| 10 |
- agent
|
| 11 |
- tool-calling
|
|
|
|
| 12 |
- multimodal
|
| 13 |
- on-device
|
| 14 |
library_name: litert-lm
|
| 15 |
---
|
| 16 |
|
| 17 |
-
# Agent Gemma 3n E2B
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
## Model Details
|
| 22 |
|
|
@@ -24,213 +37,334 @@ This is a **fixed and working version** of the Gemma 3n E2B Agent model in LiteR
|
|
| 24 |
- **Format**: LiteRT-LM v1.4.0
|
| 25 |
- **Quantization**: INT4
|
| 26 |
- **Size**: ~3.2GB
|
|
|
|
| 27 |
- **Capabilities**:
|
| 28 |
-
-
|
| 29 |
-
-
|
| 30 |
-
-
|
| 31 |
-
-
|
|
|
|
| 32 |
|
| 33 |
-
##
|
| 34 |
|
| 35 |
-
The
|
| 36 |
|
| 37 |
-
```
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
```
|
| 41 |
|
| 42 |
-
###
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
-
- LlmMetadata (including Agent Gemma Jinja template)
|
| 50 |
-
- 7 TFLite model components (embedder, per-layer embedder, audio encoder, vision encoder, etc.)
|
| 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 |
-
- Image inputs (via `<start_of_image>` tokens)
|
| 82 |
|
| 83 |
-
|
| 84 |
```
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
```
|
| 87 |
|
| 88 |
## Performance
|
| 89 |
|
| 90 |
-
|
| 91 |
|
| 92 |
- **Prefill Speed**: 21.20 tokens/sec
|
| 93 |
- **Decode Speed**: 11.44 tokens/sec
|
| 94 |
- **Time to First Token**: ~1.6s
|
| 95 |
-
- **
|
|
|
|
| 96 |
|
| 97 |
-
|
|
|
|
|
|
|
| 98 |
|
| 99 |
### Requirements
|
| 100 |
|
| 101 |
-
1. **LiteRT-LM
|
| 102 |
```bash
|
| 103 |
git clone https://github.com/google-ai-edge/LiteRT.git
|
| 104 |
cd LiteRT/LiteRT-LM
|
| 105 |
bazel build -c opt //runtime/engine:litert_lm_main
|
| 106 |
```
|
| 107 |
|
| 108 |
-
2. **Supported
|
| 109 |
|
| 110 |
-
###
|
| 111 |
|
| 112 |
```bash
|
| 113 |
-
#
|
|
|
|
|
|
|
|
|
|
| 114 |
./bazel-bin/runtime/engine/litert_lm_main \
|
| 115 |
--model_path=gemma-3n-E2B-it-agent-fixed.litertlm \
|
| 116 |
--backend=cpu \
|
| 117 |
-
--input_prompt="Hello,
|
| 118 |
|
| 119 |
-
#
|
| 120 |
./bazel-bin/runtime/engine/litert_lm_main \
|
| 121 |
--model_path=gemma-3n-E2B-it-agent-fixed.litertlm \
|
| 122 |
--backend=gpu \
|
| 123 |
-
--input_prompt="
|
| 124 |
```
|
| 125 |
|
| 126 |
-
###
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
```
|
| 129 |
-
input_prompt: Hello, how are you today?
|
| 130 |
-
I am doing well, thank you for asking! As a large language model, I don't
|
| 131 |
-
experience emotions like humans do, but I'm functioning optimally and ready
|
| 132 |
-
to assist you. How can I help you today?<end_of_turn>
|
| 133 |
-
```
|
| 134 |
-
|
| 135 |
-
## Building the Fixed Model (Technical Details)
|
| 136 |
|
| 137 |
-
|
| 138 |
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
```python
|
| 142 |
-
#!/usr/bin/env python3
|
| 143 |
-
import os
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
# ... (extract remaining TFLite sections)
|
| 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 |
-
Check the model structure:
|
| 198 |
|
| 199 |
-
|
| 200 |
-
bazel run //schema/cc:litertlm_peek -- \
|
| 201 |
-
--litertlm_file=gemma-3n-E2B-it-agent-fixed.litertlm
|
| 202 |
-
```
|
| 203 |
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
|
| 209 |
-
##
|
| 210 |
|
| 211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
-
|
| 214 |
-
- Extract the metadata.pb
|
| 215 |
-
- Modify the `jinja_prompt_template` field
|
| 216 |
-
- Rebuild the model
|
| 217 |
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
|
|
|
|
|
|
| 222 |
|
| 223 |
## License
|
| 224 |
|
| 225 |
-
This model inherits the Gemma license from the
|
| 226 |
|
| 227 |
## Citation
|
| 228 |
|
| 229 |
-
If you use this model, please cite:
|
| 230 |
-
|
| 231 |
```bibtex
|
| 232 |
-
@misc{
|
| 233 |
-
title={Agent Gemma 3n E2B
|
| 234 |
author={kontextdev},
|
| 235 |
year={2025},
|
| 236 |
publisher={HuggingFace},
|
|
@@ -238,12 +372,20 @@ If you use this model, please cite:
|
|
| 238 |
}
|
| 239 |
```
|
| 240 |
|
| 241 |
-
##
|
| 242 |
|
| 243 |
- [LiteRT-LM GitHub](https://github.com/google-ai-edge/LiteRT/tree/main/LiteRT-LM)
|
| 244 |
-
- [
|
| 245 |
- [LiteRT Documentation](https://ai.google.dev/edge/litert)
|
|
|
|
|
|
|
|
|
|
| 246 |
|
| 247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
|
| 249 |
-
|
|
|
|
| 9 |
- gemma
|
| 10 |
- agent
|
| 11 |
- tool-calling
|
| 12 |
+
- function-calling
|
| 13 |
- multimodal
|
| 14 |
- on-device
|
| 15 |
library_name: litert-lm
|
| 16 |
---
|
| 17 |
|
| 18 |
+
# Agent Gemma 3n E2B - Tool Calling Edition
|
| 19 |
|
| 20 |
+
A specialized version of **Gemma 3n E2B** optimized for **on-device tool/function calling** with LiteRT-LM. While Google's standard LiteRT-LM models focus on general text generation, this model is specifically designed for agentic workflows with advanced tool calling capabilities.
|
| 21 |
+
|
| 22 |
+
## Why This Model?
|
| 23 |
+
|
| 24 |
+
Google's official LiteRT-LM releases provide excellent on-device inference but don't include built-in tool calling support. This model bridges that gap by:
|
| 25 |
+
|
| 26 |
+
- β
**Native tool/function calling** via Jinja templates
|
| 27 |
+
- β
**Multimodal support** (text, vision, audio)
|
| 28 |
+
- β
**On-device optimized** - No cloud API required
|
| 29 |
+
- β
**INT4 quantized** - Efficient memory usage
|
| 30 |
+
- β
**Production ready** - Tested and validated
|
| 31 |
+
|
| 32 |
+
Perfect for building AI agents that need to interact with external tools, APIs, or functions while running completely on-device.
|
| 33 |
|
| 34 |
## Model Details
|
| 35 |
|
|
|
|
| 37 |
- **Format**: LiteRT-LM v1.4.0
|
| 38 |
- **Quantization**: INT4
|
| 39 |
- **Size**: ~3.2GB
|
| 40 |
+
- **Tokenizer**: SentencePiece
|
| 41 |
- **Capabilities**:
|
| 42 |
+
- Advanced tool/function calling
|
| 43 |
+
- Multi-turn conversations with tool interactions
|
| 44 |
+
- Vision processing (images)
|
| 45 |
+
- Audio processing
|
| 46 |
+
- Streaming responses
|
| 47 |
|
| 48 |
+
## Tool Calling Example
|
| 49 |
|
| 50 |
+
The model uses a sophisticated Jinja template that supports OpenAI-style function calling:
|
| 51 |
|
| 52 |
+
```python
|
| 53 |
+
from litert_lm import Engine, Conversation
|
| 54 |
+
|
| 55 |
+
# Load the model
|
| 56 |
+
engine = Engine.create("gemma-3n-E2B-it-agent-fixed.litertlm", backend="cpu")
|
| 57 |
+
conversation = Conversation.create(engine)
|
| 58 |
+
|
| 59 |
+
# Define tools the model can use
|
| 60 |
+
tools = [
|
| 61 |
+
{
|
| 62 |
+
"name": "get_weather",
|
| 63 |
+
"description": "Get current weather for a location",
|
| 64 |
+
"parameters": {
|
| 65 |
+
"type": "object",
|
| 66 |
+
"properties": {
|
| 67 |
+
"location": {"type": "string", "description": "City name"},
|
| 68 |
+
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
|
| 69 |
+
},
|
| 70 |
+
"required": ["location"]
|
| 71 |
+
}
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"name": "search_web",
|
| 75 |
+
"description": "Search the internet for information",
|
| 76 |
+
"parameters": {
|
| 77 |
+
"type": "object",
|
| 78 |
+
"properties": {
|
| 79 |
+
"query": {"type": "string", "description": "Search query"}
|
| 80 |
+
},
|
| 81 |
+
"required": ["query"]
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
]
|
| 85 |
+
|
| 86 |
+
# Have a conversation with tool calling
|
| 87 |
+
message = {
|
| 88 |
+
"role": "user",
|
| 89 |
+
"content": "What's the weather in San Francisco and latest news about AI?"
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
response = conversation.send_message(message, tools=tools)
|
| 93 |
+
print(response)
|
| 94 |
```
|
| 95 |
|
| 96 |
+
### Example Output
|
| 97 |
|
| 98 |
+
The model will generate structured tool calls:
|
| 99 |
|
| 100 |
+
```
|
| 101 |
+
<start_function_call>call:get_weather{location:San Francisco,unit:celsius}<end_function_call>
|
| 102 |
+
<start_function_call>call:search_web{query:latest AI news}<end_function_call>
|
| 103 |
+
<start_function_response>
|
| 104 |
+
```
|
| 105 |
|
| 106 |
+
You then execute the functions and send back results:
|
|
|
|
|
|
|
| 107 |
|
| 108 |
+
```python
|
| 109 |
+
# Execute tools (your implementation)
|
| 110 |
+
weather = get_weather("San Francisco", "celsius")
|
| 111 |
+
news = search_web("latest AI news")
|
| 112 |
+
|
| 113 |
+
# Send tool responses back
|
| 114 |
+
tool_response = {
|
| 115 |
+
"role": "tool",
|
| 116 |
+
"content": [
|
| 117 |
+
{
|
| 118 |
+
"name": "get_weather",
|
| 119 |
+
"response": {"temperature": 18, "condition": "partly cloudy"}
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"name": "search_web",
|
| 123 |
+
"response": {"results": ["OpenAI releases GPT-5...", "..."]}
|
| 124 |
+
}
|
| 125 |
+
]
|
| 126 |
+
}
|
| 127 |
|
| 128 |
+
final_response = conversation.send_message(tool_response)
|
| 129 |
+
print(final_response)
|
| 130 |
+
# "The weather in San Francisco is 18Β°C and partly cloudy.
|
| 131 |
+
# In AI news, OpenAI has released GPT-5..."
|
| 132 |
+
```
|
| 133 |
|
| 134 |
+
## Advanced Features
|
| 135 |
|
| 136 |
+
### Multi-Modal Tool Calling
|
| 137 |
|
| 138 |
+
Combine vision, audio, and tool calling:
|
| 139 |
+
|
| 140 |
+
```python
|
| 141 |
+
message = {
|
| 142 |
+
"role": "user",
|
| 143 |
+
"content": [
|
| 144 |
+
{"type": "image", "data": image_bytes},
|
| 145 |
+
{"type": "text", "text": "What's in this image? Search for more info about it."}
|
| 146 |
+
]
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
response = conversation.send_message(message, tools=[search_tool])
|
| 150 |
+
# Model can see the image AND call search functions
|
| 151 |
```
|
| 152 |
|
| 153 |
+
### Streaming Tool Calls
|
| 154 |
|
| 155 |
+
Get tool calls as they're generated:
|
| 156 |
|
| 157 |
+
```python
|
| 158 |
+
def on_token(token):
|
| 159 |
+
if "<start_function_call>" in token:
|
| 160 |
+
print("Tool being called...")
|
| 161 |
+
print(token, end="", flush=True)
|
|
|
|
| 162 |
|
| 163 |
+
conversation.send_message_async(message, tools=tools, callback=on_token)
|
| 164 |
```
|
| 165 |
+
|
| 166 |
+
### Nested Tool Execution
|
| 167 |
+
|
| 168 |
+
The model can chain tool calls:
|
| 169 |
+
|
| 170 |
+
```python
|
| 171 |
+
# User: "Book me a flight to Tokyo and reserve a hotel"
|
| 172 |
+
# Model: calls check_flights() β calls book_hotel() β confirms both
|
| 173 |
```
|
| 174 |
|
| 175 |
## Performance
|
| 176 |
|
| 177 |
+
Benchmarked on CPU (no GPU acceleration):
|
| 178 |
|
| 179 |
- **Prefill Speed**: 21.20 tokens/sec
|
| 180 |
- **Decode Speed**: 11.44 tokens/sec
|
| 181 |
- **Time to First Token**: ~1.6s
|
| 182 |
+
- **Cold Start**: ~4.7s
|
| 183 |
+
- **Tool Call Latency**: ~100-200ms additional
|
| 184 |
|
| 185 |
+
GPU acceleration provides 3-5x speedup on supported hardware.
|
| 186 |
+
|
| 187 |
+
## Installation & Usage
|
| 188 |
|
| 189 |
### Requirements
|
| 190 |
|
| 191 |
+
1. **LiteRT-LM Runtime** - Build from source:
|
| 192 |
```bash
|
| 193 |
git clone https://github.com/google-ai-edge/LiteRT.git
|
| 194 |
cd LiteRT/LiteRT-LM
|
| 195 |
bazel build -c opt //runtime/engine:litert_lm_main
|
| 196 |
```
|
| 197 |
|
| 198 |
+
2. **Supported Platforms**: Linux (clang), macOS, Android
|
| 199 |
|
| 200 |
+
### Quick Start
|
| 201 |
|
| 202 |
```bash
|
| 203 |
+
# Download model
|
| 204 |
+
wget https://huggingface.co/kontextdev/agent-gemma/resolve/main/gemma-3n-E2B-it-agent-fixed.litertlm
|
| 205 |
+
|
| 206 |
+
# Run with simple prompt
|
| 207 |
./bazel-bin/runtime/engine/litert_lm_main \
|
| 208 |
--model_path=gemma-3n-E2B-it-agent-fixed.litertlm \
|
| 209 |
--backend=cpu \
|
| 210 |
+
--input_prompt="Hello, I need help with some tasks"
|
| 211 |
|
| 212 |
+
# Run with GPU (if available)
|
| 213 |
./bazel-bin/runtime/engine/litert_lm_main \
|
| 214 |
--model_path=gemma-3n-E2B-it-agent-fixed.litertlm \
|
| 215 |
--backend=gpu \
|
| 216 |
+
--input_prompt="What can you help me with?"
|
| 217 |
```
|
| 218 |
|
| 219 |
+
### Python API (Recommended)
|
| 220 |
|
| 221 |
+
```python
|
| 222 |
+
from litert_lm import Engine, Conversation, SessionConfig
|
| 223 |
+
|
| 224 |
+
# Initialize
|
| 225 |
+
engine = Engine.create("gemma-3n-E2B-it-agent-fixed.litertlm", backend="gpu")
|
| 226 |
+
|
| 227 |
+
# Configure session
|
| 228 |
+
config = SessionConfig(
|
| 229 |
+
max_tokens=2048,
|
| 230 |
+
temperature=0.7,
|
| 231 |
+
top_p=0.9
|
| 232 |
+
)
|
| 233 |
+
|
| 234 |
+
# Start conversation
|
| 235 |
+
conversation = Conversation.create(engine, config)
|
| 236 |
+
|
| 237 |
+
# Define your tools
|
| 238 |
+
tools = [...] # Your function definitions
|
| 239 |
+
|
| 240 |
+
# Chat with tool calling
|
| 241 |
+
while True:
|
| 242 |
+
user_input = input("You: ")
|
| 243 |
+
response = conversation.send_message(
|
| 244 |
+
{"role": "user", "content": user_input},
|
| 245 |
+
tools=tools
|
| 246 |
+
)
|
| 247 |
+
|
| 248 |
+
# Handle tool calls if present
|
| 249 |
+
if has_tool_calls(response):
|
| 250 |
+
results = execute_tools(extract_calls(response))
|
| 251 |
+
response = conversation.send_message({
|
| 252 |
+
"role": "tool",
|
| 253 |
+
"content": results
|
| 254 |
+
})
|
| 255 |
+
|
| 256 |
+
print(f"Agent: {response['content']}")
|
| 257 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
|
| 259 |
+
## Tool Call Format
|
| 260 |
|
| 261 |
+
The model uses this format for tool interactions:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
|
| 263 |
+
**Function Declaration** (system/developer role):
|
| 264 |
+
```
|
| 265 |
+
<start_of_turn>developer
|
| 266 |
+
<start_function_declaration>
|
| 267 |
+
{
|
| 268 |
+
"name": "function_name",
|
| 269 |
+
"description": "What it does",
|
| 270 |
+
"parameters": {...}
|
| 271 |
+
}
|
| 272 |
+
<end_function_declaration>
|
| 273 |
+
<end_of_turn>
|
| 274 |
+
```
|
| 275 |
|
| 276 |
+
**Function Call** (assistant):
|
| 277 |
+
```
|
| 278 |
+
<start_function_call>call:function_name{arg1:value1,arg2:value2}<end_function_call>
|
| 279 |
+
```
|
|
|
|
| 280 |
|
| 281 |
+
**Function Response** (tool role):
|
| 282 |
+
```
|
| 283 |
+
<start_function_response>response:function_name{result:value}<end_function_response>
|
| 284 |
```
|
| 285 |
|
| 286 |
+
## Use Cases
|
| 287 |
|
| 288 |
+
### Personal AI Assistant
|
| 289 |
+
- Calendar management
|
| 290 |
+
- Email sending
|
| 291 |
+
- Web searching
|
| 292 |
+
- File operations
|
| 293 |
|
| 294 |
+
### IoT & Smart Home
|
| 295 |
+
- Device control
|
| 296 |
+
- Sensor monitoring
|
| 297 |
+
- Automation workflows
|
| 298 |
+
- Voice commands
|
| 299 |
|
| 300 |
+
### Development Tools
|
| 301 |
+
- Code generation with API calls
|
| 302 |
+
- Database queries
|
| 303 |
+
- Deployment automation
|
| 304 |
+
- Testing & debugging
|
| 305 |
|
| 306 |
+
### Business Applications
|
| 307 |
+
- CRM integration
|
| 308 |
+
- Data analysis
|
| 309 |
+
- Report generation
|
| 310 |
+
- Customer support
|
| 311 |
|
| 312 |
+
## Model Architecture
|
|
|
|
| 313 |
|
| 314 |
+
Built on Gemma 3n E2B with 9 optimized components:
|
| 315 |
|
| 316 |
+
```
|
| 317 |
+
Section 0: LlmMetadata (Agent Jinja template)
|
| 318 |
+
Section 1: SentencePiece Tokenizer
|
| 319 |
+
Section 2: TFLite Embedder
|
| 320 |
+
Section 3: TFLite Per-Layer Embedder
|
| 321 |
+
Section 4: TFLite Audio Encoder (HW accelerated)
|
| 322 |
+
Section 5: TFLite End-of-Audio Detector
|
| 323 |
+
Section 6: TFLite Vision Adapter
|
| 324 |
+
Section 7: TFLite Vision Encoder
|
| 325 |
+
Section 8: TFLite Prefill/Decode (INT4)
|
| 326 |
```
|
| 327 |
|
| 328 |
+
All components are optimized for on-device inference with hardware acceleration support.
|
|
|
|
|
|
|
| 329 |
|
| 330 |
+
## Comparison
|
|
|
|
|
|
|
|
|
|
| 331 |
|
| 332 |
+
| Feature | Standard Gemma LiteRT-LM | This Model |
|
| 333 |
+
|---------|-------------------------|------------|
|
| 334 |
+
| Text Generation | β
| β
|
|
| 335 |
+
| Tool Calling | β | β
|
|
| 336 |
+
| Multimodal | β
| β
|
|
| 337 |
+
| Streaming | β
| β
|
|
| 338 |
+
| On-Device | β
| β
|
|
| 339 |
+
| Jinja Templates | Basic | Advanced Agent Template |
|
| 340 |
+
| INT4 Quantization | β
| β
|
|
| 341 |
|
| 342 |
+
## Limitations
|
| 343 |
|
| 344 |
+
- **Tool Execution**: The model generates tool calls but doesn't execute them - you need to implement the actual functions
|
| 345 |
+
- **Context Window**: Limited to 4096 tokens (configurable)
|
| 346 |
+
- **Streaming Tool Calls**: Partial tool calls may need buffering
|
| 347 |
+
- **Hardware Requirements**: Minimum 4GB RAM recommended
|
| 348 |
+
- **No Native GPU on CPU-only systems**: Falls back to CPU inference
|
| 349 |
|
| 350 |
+
## Tips for Best Results
|
|
|
|
|
|
|
|
|
|
| 351 |
|
| 352 |
+
1. **Clear Tool Descriptions**: Provide detailed function descriptions
|
| 353 |
+
2. **Schema Validation**: Validate tool call arguments before execution
|
| 354 |
+
3. **Error Handling**: Handle malformed tool calls gracefully
|
| 355 |
+
4. **Context Management**: Keep conversation history concise
|
| 356 |
+
5. **Temperature**: Use 0.7-0.9 for creative tasks, 0.3-0.5 for precise tool calls
|
| 357 |
+
6. **Batching**: Process multiple tool calls in parallel when possible
|
| 358 |
|
| 359 |
## License
|
| 360 |
|
| 361 |
+
This model inherits the [Gemma license](https://ai.google.dev/gemma/terms) from the base model.
|
| 362 |
|
| 363 |
## Citation
|
| 364 |
|
|
|
|
|
|
|
| 365 |
```bibtex
|
| 366 |
+
@misc{agent-gemma-litertlm,
|
| 367 |
+
title={Agent Gemma 3n E2B - Tool Calling Edition},
|
| 368 |
author={kontextdev},
|
| 369 |
year={2025},
|
| 370 |
publisher={HuggingFace},
|
|
|
|
| 372 |
}
|
| 373 |
```
|
| 374 |
|
| 375 |
+
## Links
|
| 376 |
|
| 377 |
- [LiteRT-LM GitHub](https://github.com/google-ai-edge/LiteRT/tree/main/LiteRT-LM)
|
| 378 |
+
- [Gemma Model Family](https://ai.google.dev/gemma)
|
| 379 |
- [LiteRT Documentation](https://ai.google.dev/edge/litert)
|
| 380 |
+
- [Tool Calling Guide](https://ai.google.dev/gemma/docs/function-calling)
|
| 381 |
+
|
| 382 |
+
## Support
|
| 383 |
|
| 384 |
+
For issues or questions:
|
| 385 |
+
- Open an issue on [GitHub](https://github.com/google-ai-edge/LiteRT/issues)
|
| 386 |
+
- Check the [LiteRT-LM docs](https://ai.google.dev/edge/litert/inference)
|
| 387 |
+
- Community forum: [Google AI Edge](https://discuss.ai.google.dev/)
|
| 388 |
+
|
| 389 |
+
---
|
| 390 |
|
| 391 |
+
Built with β€οΈ for the on-device AI community
|