nlouis commited on
Commit
0534ab6
·
verified ·
1 Parent(s): 51a774e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +97 -6
README.md CHANGED
@@ -1,18 +1,109 @@
 
 
 
 
1
  ---
2
- library_name: gguf
3
- license: apache-2.0
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # FunctionGemma Pocket (Q4_K_M)
 
 
 
7
 
8
- 4-bit quantized GGUF model (q4_k_m) for use with llama.cpp / llama-cpp-python.
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  ## Usage
11
 
 
 
12
  ```python
13
  from huggingface_hub import hf_hub_download
14
  from llama_cpp import Llama
15
 
16
- path = hf_hub_download(repo_id="nlouis/functiongemma-pocket-q4_k_m", filename="functiongemma-pocket-q4_k_m.gguf")
17
- llm = Llama(model_path=path, n_ctx=2048, n_gpu_layers=-1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FunctionGemma Pocket (Q4_K_M)
2
+
3
+ A 4-bit quantized GGUF model for **function/tool calling**, based on FunctionGemma and fine-tuned for a small set of tools (weather, security, web search, network scan, stock price). Optimized for edge and resource-constrained devices (e.g. Raspberry Pi) via llama.cpp.
4
+
5
  ---
6
+
7
+ ## Model description
8
+
9
+ - **Format:** GGUF (Q4_K_M quantization)
10
+ - **Base:** FunctionGemma (Gemma-based model for function calling)
11
+ - **Purpose:** Map natural-language user queries to structured tool/function calls
12
+ - **Context length:** 2048 tokens (recommended)
13
+ - **Chat roles:** `developer`, `user`, `assistant`; assistant replies with tool calls in the form `<start_function_call>{"name": "...", "arguments": {...}}<end_function_call>`
14
+
15
+ Fine-tuning was done on ~1000 examples generated from a fixed tool schema so the model learns to select the right function and fill arguments from natural language.
16
+
17
  ---
18
 
19
+ ## Intended use
20
+
21
+ - **In scope:** Choosing one of the supported tools and producing a single, well-formed function call (name + arguments) from a short user message.
22
+ - **Out of scope:** General chat, long-form generation, or tools not present in the training schema. Not intended for high-stakes or safety-critical decisions without human oversight.
23
 
24
+ ---
25
+
26
+ ## Supported tools (training schema)
27
+
28
+ | Tool | Description |
29
+ |------|-------------|
30
+ | `get_weather` | Weather or forecast for a location (`location`: string) |
31
+ | `activate_security_mode` | Toggle Raspberry Pi security, cameras, PIR sensors (no args) |
32
+ | `web_search` | Web search for current info (`query`: string) |
33
+ | `network_scan` | Scan LAN for devices and open ports (no args) |
34
+ | `get_stock_price` | Current stock price and basic market data (`symbol`: string, e.g. AAPL, TSLA) |
35
+
36
+ ---
37
 
38
  ## Usage
39
 
40
+ ### Download and load with llama-cpp-python
41
+
42
  ```python
43
  from huggingface_hub import hf_hub_download
44
  from llama_cpp import Llama
45
 
46
+ # Replace with your repo id, e.g. "your-username/functiongemma-pocket-q4_k_m"
47
+ REPO_ID = "YOUR_USERNAME/functiongemma-pocket-q4_k_m"
48
+ FILENAME = "functiongemma-pocket-q4_k_m.gguf"
49
+
50
+ path = hf_hub_download(repo_id=REPO_ID, filename=FILENAME)
51
+ llm = Llama(
52
+ model_path=path,
53
+ n_ctx=2048,
54
+ n_threads=4,
55
+ n_gpu_layers=-1, # use GPU if available; 0 for CPU-only
56
+ use_mmap=True,
57
+ verbose=False,
58
+ )
59
+ ```
60
+
61
+ ### Function-calling example
62
+
63
+ ```python
64
+ import json
65
+
66
+ tools = [
67
+ {"type": "function", "function": {"name": "get_weather", "description": "Weather for a location.", "parameters": {"type": "object", "properties": {"location": {"type": "string"}}, "required": ["location"]}}},
68
+ # ... add other tools in the same format
69
+ ]
70
+
71
+ messages = [
72
+ {"role": "developer", "content": "You are a model that can do function calling with the provided functions."},
73
+ {"role": "user", "content": "What's the weather in Tokyo?"}
74
+ ]
75
+
76
+ out = llm.create_chat_completion(
77
+ messages=messages,
78
+ tools=tools,
79
+ max_tokens=128,
80
+ temperature=0.1,
81
+ stop=["<end_function_call>", "<eos>"],
82
+ )
83
+
84
+ # Parse assistant message for tool name and arguments
85
+ content = out["choices"][0]["message"].get("content", "")
86
+ # content may contain <start_function_call>{"name": "get_weather", "arguments": {"location": "Tokyo"}}<end_function_call>
87
  ```
88
+
89
+ ---
90
+
91
+ ## Training details
92
+
93
+ - **Data:** ~1000 synthetic examples (user query → single tool call) derived from the tool schema above.
94
+ - **Roles:** System-style instruction in `developer`, user query in `user`, target tool call in `assistant` with `tool_calls`.
95
+ - **Quantization:** Q4_K_M (4-bit) GGUF for smaller size and faster inference on CPU/edge.
96
+
97
+ ---
98
+
99
+ ## Limitations
100
+
101
+ - Trained only on the five tools listed; performance on other tools or schemas is undefined.
102
+ - Small model; may occasionally misselect the tool or omit/alter arguments.
103
+ - Not evaluated for safety or alignment beyond the described use case.
104
+
105
+ ---
106
+
107
+ ## License
108
+
109
+ Apache 2.0 (align with the base model’s license when distributing).