macmacmacmac commited on
Commit
e16caa5
·
verified ·
1 Parent(s): 9fc5ee7

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +142 -0
README.md ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FunctionGemma Infrastructure LiteRT-LM
2
+
3
+ A fine-tuned [FunctionGemma-270M](https://huggingface.co/google/functiongemma-270m-it) model converted to LiteRT-LM format for on-device inference. Designed for self-healing infrastructure and automatic error remediation.
4
+
5
+ ## Model Details
6
+
7
+ | Property | Value |
8
+ |----------|-------|
9
+ | Base Model | google/functiongemma-270m-it |
10
+ | Format | LiteRT-LM (.litertlm) |
11
+ | Quantization | Dynamic INT8 |
12
+ | File Size | 272 MB |
13
+ | Parameters | 270M |
14
+
15
+ ## Intended Use
16
+
17
+ This model is designed for [dad-express](https://github.com/anthropics/dad-express), a self-healing gateway that monitors HTTP traffic and automatically fixes infrastructure configuration issues by calling the appropriate tools.
18
+
19
+ ## Supported Tools
20
+
21
+ The model was fine-tuned on 9 infrastructure tools:
22
+
23
+ | Tool | Description | Parameters |
24
+ |------|-------------|------------|
25
+ | `addProxyRoute` | Add reverse proxy route | path, upstream, port |
26
+ | `addCorsHeaders` | Configure CORS headers | origin, credentials |
27
+ | `configureSsl` | Configure SSL certificate | hostname, selfSigned |
28
+ | `setEnvVariable` | Set environment variable | name, value |
29
+ | `exposePort` | Expose port in Docker/firewall | service, port |
30
+ | `addHostEntry` | Add hostname to /etc/hosts | hostname, ip |
31
+ | `restartService` | Restart a service | service |
32
+ | `clearCache` | Clear cache | cacheType |
33
+ | `modifyConfig` | Modify config file | file, key, value |
34
+
35
+ ## Training Details
36
+
37
+ ### Dataset
38
+ - **Total Examples**: 10,216
39
+ - **Train/Eval Split**: 90/10 (9,194 train, 1,022 eval)
40
+ - **Format**: Prompt-completion pairs using FunctionGemma chat template
41
+ - **Distribution**: ~1,000-1,200 examples per tool (balanced)
42
+
43
+ ### Training Configuration
44
+
45
+ Trained following [Google's official FunctionGemma fine-tuning notebook](https://colab.research.google.com/github/google-gemini/gemma-cookbook/blob/main/FunctionGemma/%5BFunctionGemma%5DFinetune_FunctionGemma_270M_for_Mobile_Actions_with_Hugging_Face.ipynb):
46
+
47
+ ```python
48
+ SFTConfig(
49
+ num_train_epochs=2,
50
+ per_device_train_batch_size=4,
51
+ gradient_accumulation_steps=8,
52
+ learning_rate=1e-5,
53
+ lr_scheduler_type="cosine",
54
+ gradient_checkpointing=True,
55
+ packing=False,
56
+ optim="adamw_torch_fused",
57
+ bf16=True,
58
+ completion_only_loss=True, # Critical: only train on completion tokens
59
+ )
60
+ ```
61
+
62
+ ### Hardware
63
+ - **GPU**: NVIDIA L4 (24GB)
64
+ - **Training Time**: ~23 minutes
65
+ - **Conversion Time**: ~10 minutes
66
+
67
+ ### Performance Metrics
68
+
69
+ | Metric | Value |
70
+ |--------|-------|
71
+ | Final Eval Loss | 0.034 |
72
+ | Token Accuracy | 98.6% |
73
+ | Training Steps | 576 |
74
+
75
+ ## LiteRT-LM Conversion
76
+
77
+ Converted using [ai-edge-torch](https://github.com/google-ai-edge/ai-edge-torch):
78
+
79
+ ```python
80
+ converter.convert_to_litert(
81
+ pytorch_model,
82
+ prefill_seq_len=256,
83
+ kv_cache_max_len=1024,
84
+ quantize="dynamic_int8",
85
+ output_format="litertlm",
86
+ )
87
+ ```
88
+
89
+ ### LLM Metadata
90
+ ```protobuf
91
+ start_token: { token_ids: { ids: [ 2 ] } }
92
+ stop_tokens: { token_str: "<end_of_turn>" }
93
+ stop_tokens: { token_str: "<start_function_response>" }
94
+ llm_model_type: { function_gemma: {} }
95
+ ```
96
+
97
+ ## Usage
98
+
99
+ ### With LiteRT-LM Runtime
100
+ ```typescript
101
+ import { LiteRTLM } from 'litert-lm';
102
+
103
+ const model = await LiteRTLM.load('functiongemma-infrastructure_q8_ekv1024.litertlm');
104
+ const response = await model.generate(prompt);
105
+ ```
106
+
107
+ ### Example Input/Output
108
+
109
+ **Input:**
110
+ ```
111
+ Error: CORS - No 'Access-Control-Allow-Origin' header from http://localhost:3000
112
+ ```
113
+
114
+ **Output:**
115
+ ```
116
+ <start_function_call>call:addCorsHeaders{origin:<escape>http://localhost:3000<escape>,credentials:<escape>true<escape>}<end_function_call><start_function_response>
117
+ ```
118
+
119
+ ## Dependencies
120
+
121
+ - Python 3.11+
122
+ - transformers==4.57.1
123
+ - trl==0.25.1
124
+ - datasets==4.4.1
125
+ - ai-edge-torch-nightly
126
+ - ai-edge-litert-nightly
127
+
128
+ ## License
129
+
130
+ This model inherits the [Gemma Terms of Use](https://ai.google.dev/gemma/terms).
131
+
132
+ ## Citation
133
+
134
+ ```bibtex
135
+ @misc{functiongemma-infrastructure-litertlm,
136
+ title={FunctionGemma Infrastructure LiteRT-LM},
137
+ author={dad-express contributors},
138
+ year={2024},
139
+ publisher={Hugging Face},
140
+ url={https://huggingface.co/macmacmacmac/functiongemma-infrastructure-litertlm}
141
+ }
142
+ ```