Katorin commited on
Commit
610ad76
·
verified ·
1 Parent(s): f833bd8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +119 -0
README.md CHANGED
@@ -1,3 +1,122 @@
1
  ---
2
  license: gemma
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: gemma
3
+ base_model: unsloth/functiongemma-270m-it
4
+ library_name: ggml
5
+ tags:
6
+ - gguf
7
+ - llama-cpp
8
+ - function-calling
9
+ - tool-use
10
+ - agents
11
+ language:
12
+ - en
13
+ pipeline_tag: text-generation
14
  ---
15
+
16
+ # functiongemma-270m-relay-tools
17
+
18
+ Fine-tuned **FunctionGemma 270M** translator for
19
+ [Relay](https://github.com/baka-onii/relay): single-turn
20
+ `natural-language instruction → exactly one tool call` over the harness's
21
+ 33-tool registry (filesystem, editing, execution, git, web, environment,
22
+ utility, interaction). It does **not** reason or chat — the Relay runtime owns
23
+ validation, confidence gates, and approvals; this model only selects the tool
24
+ by its exact registered name plus small args. Bulk text (file contents, code,
25
+ commands) travels in runtime payload blocks, never through this model.
26
+
27
+ Because selection is by exact tool name, misfires on concrete instructions are
28
+ negligible in practice — failures appear almost only on abstract or ambiguous
29
+ edge-case prompts (e.g. "Show develop for docs/." or "Compare X with
30
+ release/1.2"), never on everyday phrasings like "Read src/auth.py" or
31
+ "Show the last 5 commits".
32
+
33
+ ## Training
34
+
35
+ - **Base:** `unsloth/functiongemma-270m-it`, full fine-tune (no LoRA), Unsloth, WSL + CUDA.
36
+ - **Hyperparameters:** 3 epochs, batch 4 / grad-accum 8 (eff. 32), lr 2e-5,
37
+ `--save-steps 50`, max_seq_length 4096. Main run `outputs/full4`, continued as
38
+ `outputs/full5` from `checkpoint-100`; published weights are the
39
+ **checkpoint-200** export (~200 updates).
40
+ - **Dataset:** one atomic tool call per row (`instruction` + `tool` +
41
+ `arguments`), 30–100 rows per tool across all 33 tools, explicit and implicit
42
+ phrasings; prompts rendered with Relay's own `FunctionGemmaActionModel`
43
+ renderer (zero train/serve skew), 10% held out per tool.
44
+ - **Export:** merged 16-bit → GGUF, both quants in this repo: `Q4_K_M`
45
+ (serving quant, 261 MB) and `BF16` (reference precision).
46
+ No retraining was needed at any point: the one export failure was a
47
+ converter vocab assertion, fixed at export time.
48
+
49
+ ## Evaluation
50
+
51
+ Held-out set, 20 prompts × 33 tools (660 runs) through the real harness adapter
52
+ (`eval_finetune.py`), each quant served via llama-server (avg 0.10 s/call).
53
+ Three tiers — **functional** (right tool + behaviorally equivalent args:
54
+ payload slots exempt, values normalized, missing/extra optional args pass,
55
+ `ask_user` passes on any non-empty question), **selection** (right tool),
56
+ **exact** (byte-identical args):
57
+
58
+ | | Functional | Selection | Exact |
59
+ |---|---|---|---|
60
+ | Base model | 81/660 = 12.3% | 136/660 = 20.6% | 54/660 = 8.2% |
61
+ | Fine-tuned `Q4_K_M` | 583/660 = 88.3% | 603/660 = 91.4% | 446/660 = 67.6% |
62
+ | Fine-tuned `BF16` | **601/660 = 91.1%** | 609/660 = 92.3% | 461/660 = 69.8% |
63
+
64
+ Quantization costs ~2.8pp functional — serve the Q4, keep the BF16 for
65
+ reference. The exact→functional gap is dominated by contract-correct
66
+ placeholder slots (`__PAYLOAD_*__`, filled by the runtime at inference) and
67
+ equivalent phrasings (`(2 ** 5 % 7)` ≡ `2 ** 5 % 7`), not wrong behavior.
68
+ Genuine weak spots: payload-tool *selection* (`run_process`/`run_python`
69
+ confusion), git-range prompts (`git_diff` vs `git_show`/`read_file`), and
70
+ occasional garbled paths — keep these behind runtime approval. Fifteen tools
71
+ score a perfect 20/20 functional on BF16 (`copy_file`, `create_directory`,
72
+ `delete_file`, `delete_text`, `file_info`, `find_executable`, `git_checkout`,
73
+ `git_commit`, `insert_text`, `move_file`, `read_directory`, `read_file`,
74
+ `replace_text`, `run_powershell`, `web_extract`).
75
+
76
+ <details>
77
+ <summary>Per-tool functional scores (Q4_K_M / BF16, 20 prompts each)</summary>
78
+
79
+ apply_patch 17 / 17 · ask_user 17 / 19 · calculator 17 / 17 ·
80
+ copy_file 20 / 20 · create_directory 20 / 20 · delete_file 20 / 20 ·
81
+ delete_text 20 / 20 · file_info 18 / 20 · find_executable 19 / 20 ·
82
+ get_time 17 / 17 · get_working_directory 17 / 18 ·
83
+ git_branch_list 19 / 19 · git_checkout 20 / 20 · git_commit 20 / 20 ·
84
+ git_diff 10 / 10 · git_log 15 / 16 · git_show 14 / 13 · git_stage 18 / 18 ·
85
+ git_status 14 / 16 · insert_text 20 / 20 · move_file 20 / 20 ·
86
+ process_info 19 / 17 · read_directory 20 / 20 · read_file 19 / 20 ·
87
+ replace_text 18 / 20 · run_powershell 20 / 20 · run_process 15 / 15 ·
88
+ run_python 17 / 18 · search_files 13 / 15 · web_extract 20 / 20 ·
89
+ web_open 19 / 19 · web_search 18 / 19 · write_file 13 / 18
90
+ </details>
91
+
92
+ ## Usage
93
+
94
+ Built for [Relay](https://github.com/baka-onii/relay)
95
+ (`FunctionGemmaActionModel`, `--fg-gguf`):
96
+
97
+ ```sh
98
+ # llama-server with the GGUF (CPU is fine — ~0.6 s per translation)
99
+ llama-server -m functiongemma-270m-relay-tools-q4_k_m.gguf -c 32768 --port 8081
100
+
101
+ # inside Relay (auto-detects models/*.gguf, or pass --fg-gguf)
102
+ relay live --workspace /path/to/project --fg-gguf models/fg-tools.gguf
103
+ relay live --workspace /path/to/project --fg-gguf models/fg-tools.gguf --ui
104
+ ```
105
+ Runtime settings: fg_max_tokens = 256 (larger values make it babble into
106
+ input-independent calls), fg_temperature = 0.0. Wire format follows Google's
107
+ FunctionGemma docs (<start_function_declaration> developer turn,
108
+ <start_function_call>call:name{arg:<escape>v<escape>}<end_function_call>);
109
+ the model emits no confidence — Relay parses strictly single-call and treats
110
+ anything else as a retryable error.
111
+
112
+ Limitations
113
+ - Knows only the 33 Relay tools it was trained on; unknown tools fail closed.
114
+ - No multi-tool plans, no chit-chat, no refusals — ambiguity handling lives in
115
+ the runtime gates, not in this model.
116
+ - Keep payload-tool outputs (execution, edits) behind approval; eval shows these
117
+ are its weakest selections.
118
+
119
+ License
120
+ Derivative of FunctionGemma — use is subject to the
121
+ Gemma Terms of Use (https://ai.google.dev/gemma/terms). If you redistribute
122
+ these weights, propagate the same terms.