Shaurya79 commited on
Commit
338e858
·
verified ·
1 Parent(s): 1cda71f

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,33 @@
1
- ---
2
- license: gemma
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: gemma
3
+ tags:
4
+ - coding
5
+ - rag
6
+ - gemma
7
+ - chain-of-thought
8
+ base_model: google/functiongemma-270m-it
9
+ ---
10
+
11
+ # FunctionGemma Coding Assistant
12
+
13
+ Production-ready coding assistant with:
14
+ - Chain of Recursive Thoughts reasoning
15
+ - Web search integration (optional)
16
+ - Local knowledge base (SQLite + FAISS)
17
+ - Fine-tuned on 20k diverse code samples
18
+
19
+ ## Usage
20
+ from transformers import AutoModelForCausalLM, AutoTokenizermodel = AutoModelForCausalLM.from_pretrained("shaurya79/functiongemma-coding-assistant")
21
+ tokenizer = AutoTokenizer.from_pretrained("shaurya79/functiongemma-coding-assistant")prompt = "Write a Python function to reverse a string"
22
+ inputs = tokenizer(prompt, return_tensors="pt")
23
+ outputs = model.generate(**inputs, max_new_tokens=512)
24
+ print(tokenizer.decode(outputs))
25
+
26
+ ## Features
27
+ - Code generation (Python, JavaScript, etc.)
28
+ - Detailed explanations
29
+ - Bug fixing suggestions
30
+ - Multi-language support
31
+
32
+ ## Size
33
+ ~250-300 MB (quantized)
added_tokens.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "<end_of_image>": 262145,
3
+ "<image_soft_token>": 262144
4
+ }
chat_template.jinja ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- macro format_parameters(properties, required) -%}
2
+ {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}
3
+ {%- set ns = namespace(found_first=false) -%}
4
+ {%- for key, value in properties | dictsort -%}
5
+ {%- if key not in standard_keys -%}
6
+ {%- if ns.found_first %},{% endif -%}
7
+ {%- set ns.found_first = true -%}
8
+ {{- key }}:{description:<escape>{{ value['description'] }}<escape>
9
+ {%- if value['type'] | upper == 'STRING' -%}
10
+ {%- if value['enum'] -%}
11
+ ,enum:{{ format_argument(value['enum']) }}
12
+ {%- endif -%}
13
+ {%- elif value['type'] | upper == 'OBJECT' -%}
14
+ ,properties:{
15
+ {%- if value['properties'] is defined and value['properties'] is mapping -%}
16
+ {{- format_parameters(value['properties'], value['required'] | default([])) -}}
17
+ {%- elif value is mapping -%}
18
+ {{- format_parameters(value, value['required'] | default([])) -}}
19
+ {%- endif -%}
20
+ }
21
+ {%- if value['required'] -%}
22
+ ,required:[
23
+ {%- for item in value['required'] | default([]) -%}
24
+ <escape>{{- item -}}<escape>
25
+ {%- if not loop.last %},{% endif -%}
26
+ {%- endfor -%}
27
+ ]
28
+ {%- endif -%}
29
+ {%- elif value['type'] | upper == 'ARRAY' -%}
30
+ {%- if value['items'] is mapping and value['items'] -%}
31
+ ,items:{
32
+ {%- set ns_items = namespace(found_first=false) -%}
33
+ {%- for item_key, item_value in value['items'] | dictsort -%}
34
+ {%- if item_value is not none -%}
35
+ {%- if ns_items.found_first %},{% endif -%}
36
+ {%- set ns_items.found_first = true -%}
37
+ {%- if item_key == 'properties' -%}
38
+ properties:{
39
+ {%- if item_value is mapping -%}
40
+ {{- format_parameters(item_value, value['items']['required'] | default([])) -}}
41
+ {%- endif -%}
42
+ }
43
+ {%- elif item_key == 'required' -%}
44
+ required:[
45
+ {%- for req_item in item_value -%}
46
+ <escape>{{- req_item -}}<escape>
47
+ {%- if not loop.last %},{% endif -%}
48
+ {%- endfor -%}
49
+ ]
50
+ {%- elif item_key == 'type' -%}
51
+ {%- if item_value is string -%}
52
+ type:{{ format_argument(item_value | upper) }}
53
+ {%- else -%}
54
+ type:{{ format_argument(item_value | map('upper') | list) }}
55
+ {%- endif -%}
56
+ {%- else -%}
57
+ {{ item_key }}:{{ format_argument(item_value) }}
58
+ {%- endif -%}
59
+ {%- endif -%}
60
+ {%- endfor -%}
61
+ }
62
+ {%- endif -%}
63
+ {%- endif -%}
64
+ ,type:<escape>{{ value['type'] | upper }}<escape>}
65
+ {%- endif -%}
66
+ {%- endfor -%}
67
+ {%- endmacro -%}
68
+ {% macro format_function_declaration(tool_data) -%}
69
+ declaration:{{- tool_data['function']['name'] -}}
70
+ {description:<escape>{{- tool_data['function']['description'] -}}<escape>
71
+ {%- set params = tool_data['function']['parameters'] -%}
72
+ {%- if params -%}
73
+ ,parameters:{
74
+ {%- if params['properties'] -%}
75
+ properties:{ {{- format_parameters(params['properties'], params['required']) -}} },
76
+ {%- endif -%}
77
+ {%- if params['required'] -%}
78
+ required:[
79
+ {%- for item in params['required'] -%}
80
+ <escape>{{- item -}}<escape>
81
+ {{- ',' if not loop.last -}}
82
+ {%- endfor -%}
83
+ ],
84
+ {%- endif -%}
85
+ {%- if params['type'] -%}
86
+ type:<escape>{{- params['type'] | upper -}}<escape>}
87
+ {%- endif -%}
88
+ {%- endif -%}
89
+ }
90
+ {%- endmacro -%}
91
+ {% macro format_argument(argument, escape_keys=True) -%}
92
+ {%- if argument is string -%}
93
+ {{- '<escape>' + argument + '<escape>' -}}
94
+ {%- elif argument is boolean -%}
95
+ {%- if argument -%}
96
+ {{- 'true' -}}
97
+ {%- else -%}
98
+ {{- 'false' -}}
99
+ {%- endif -%}
100
+ {%- elif argument is mapping -%}
101
+ {{- '{' -}}
102
+ {%- set ns = namespace(found_first=false) -%}
103
+ {%- for key, value in argument | dictsort -%}
104
+ {%- if ns.found_first %},{% endif -%}
105
+ {%- set ns.found_first = true -%}
106
+ {%- if escape_keys -%}
107
+ {{- '<escape>' + key + '<escape>' -}}
108
+ {%- else -%}
109
+ {{- key -}}
110
+ {%- endif -%}
111
+ :{{- format_argument(value, escape_keys=escape_keys) -}}
112
+ {%- endfor -%}
113
+ {{- '}' -}}
114
+ {%- elif argument is sequence -%}
115
+ {{- '[' -}}
116
+ {%- for item in argument -%}
117
+ {{- format_argument(item, escape_keys=escape_keys) -}}
118
+ {%- if not loop.last %},{% endif -%}
119
+ {%- endfor -%}
120
+ {{- ']' -}}
121
+ {%- else -%}
122
+ {{- argument -}}
123
+ {%- endif -%}
124
+ {%- endmacro -%}
125
+ {{ bos_token }}
126
+ {%- set ns = namespace(prev_message_type=None) -%}
127
+ {#- Tool Declarations -#}
128
+ {%- set loop_messages = messages -%}
129
+ {%- if tools or messages[0]['role'] == 'system' or messages[0]['role'] == 'developer' -%}
130
+ {{- '<start_of_turn>developer\n' -}}
131
+ {%- if messages[0]['role'] == 'system' or messages[0]['role'] == 'developer' -%}
132
+ {%- if messages[0]['content'] is string -%}
133
+ {{- messages[0]['content'] | trim -}}
134
+ {%- elif messages[0]['content'] is sequence -%}
135
+ {%- for item in messages[0]['content'] -%}
136
+ {%- if item['type'] == 'text' -%}
137
+ {{- item['text'] | trim -}}
138
+ {%- endif -%}
139
+ {%- endfor -%}
140
+ {%- endif -%}
141
+ {%- set loop_messages = messages[1:] -%}
142
+ {%- else -%}
143
+ {{- 'You are a model that can do function calling with the following functions' -}}
144
+ {%- set loop_messages = messages -%}
145
+ {%- endif -%}
146
+ {%- if tools -%}
147
+ {%- for tool in tools %}
148
+ {{- '<start_function_declaration>' -}}
149
+ {{- format_function_declaration(tool) | trim }}
150
+ {{- '<end_function_declaration>' -}}
151
+ {%- endfor %}
152
+ {%- endif -%}
153
+ {{- '<end_of_turn>\n' }}
154
+ {%- endif %}
155
+ {#- Loop through messages. -#}
156
+ {%- for message in loop_messages -%}
157
+ {%- if (message['role'] == 'assistant') -%}
158
+ {#- Rename "assistant" to "model". -#}
159
+ {%- set role = "model" -%}
160
+ {%- else -%}
161
+ {%- set role = message['role'] -%}
162
+ {%- endif -%}
163
+ {%- if role != 'tool' -%}
164
+ {%- if ns.prev_message_type != 'tool_response' -%}
165
+ {{- '<start_of_turn>' + role + '\n' }}
166
+ {%- endif -%}
167
+ {%- set ns.prev_message_type = None -%}
168
+ {%- if 'content' in message and message['content'] is not none -%}
169
+ {%- if message['content'] is string -%}
170
+ {{ message['content'] | trim }}
171
+ {%- elif message['content'] is sequence -%}
172
+ {%- for item in message['content'] -%}
173
+ {%- if item['type'] == 'image' -%}
174
+ {{ '<start_of_image>' }}
175
+ {%- elif item['type'] == 'text' -%}
176
+ {{ item['text'] | trim }}
177
+ {%- endif -%}
178
+ {%- endfor -%}
179
+ {%- else -%}
180
+ {{ raise_exception("Invalid content type in user/assistant message") }}
181
+ {%- endif -%}
182
+ {%- set ns.prev_message_type = 'content' -%}
183
+ {%- endif -%}
184
+ {%- if 'tool_calls' in message and message['tool_calls'] and message['tool_calls'] is iterable -%}
185
+ {#- Tool Calls -#}
186
+ {%- for tool_call in message['tool_calls'] -%}
187
+ {% set function = tool_call['function'] %}
188
+ {{- '<start_function_call>call:' + function['name'] + '{' -}}
189
+ {%- if 'arguments' in function -%}
190
+ {%- if function['arguments'] is mapping -%}
191
+ {%- set ns = namespace(found_first=false) -%}
192
+ {%- for key, value in function['arguments'] | dictsort -%}
193
+ {%- if ns.found_first %},{% endif -%}
194
+ {%- set ns.found_first = true -%}
195
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
196
+ {%- endfor -%}
197
+ {%- elif function['arguments'] is string -%}
198
+ {# This handles string-JSON, just in case #}
199
+ {{ function['arguments'] }}
200
+ {%- endif %}
201
+ {%- endif -%}
202
+ {{- '}<end_function_call>' -}}
203
+ {%- endfor -%}
204
+ {%- if loop.last -%}
205
+ {{ '<start_function_response>' }}
206
+ {%- endif -%}
207
+ {%- set ns.prev_message_type = 'tool_call' -%}
208
+ {%- endif -%}
209
+ {%- else -%}
210
+ {#- Tool Responses -#}
211
+ {%- if 'content' in message and message['content'] -%}
212
+ {%- if message['content'] is mapping -%}
213
+ {%- if 'name' in message['content'] and 'response' in message['content'] -%}
214
+ {{ '<start_function_response>response:' + message['content']['name'] | trim + '{' }}
215
+ {%- set response_ns = namespace(found_first=false) -%}
216
+ {%- for key, value in message['content']['response'] | dictsort -%}
217
+ {%- if response_ns.found_first %},{% endif -%}
218
+ {%- set response_ns.found_first = true -%}
219
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
220
+ {%- endfor -%}
221
+ {{- '}<end_function_response>' -}}
222
+ {%- elif 'name' in message -%}
223
+ {{ '<start_function_response>response:' + message['name'] | trim + '{' }}
224
+ {%- set response_ns = namespace(found_first=false) -%}
225
+ {%- for key, value in message['content'] | dictsort -%}
226
+ {%- if response_ns.found_first %},{% endif -%}
227
+ {%- set response_ns.found_first = true -%}
228
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
229
+ {%- endfor -%}
230
+ {{- '}<end_function_response>' -}}
231
+ {%- else -%}
232
+ {{ raise_exception("Invalid tool response mapping: must contain 'name' and 'response' keys, or 'name' must be in the message.") }}
233
+ {%- endif -%}
234
+ {%- elif message['content'] is string -%}
235
+ {%- if 'name' in message -%}
236
+ {{ '<start_function_response>response:' + message['name'] | trim + '{value:' + format_argument(message['content'], escape_keys=False) + '}<end_function_response>' }}
237
+ {%- else -%}
238
+ {{ raise_exception("Invalid tool response: 'name' must be provided.") }}
239
+ {%- endif -%}
240
+ {%- elif message['content'] is sequence -%}
241
+ {%- for item in message['content'] -%}
242
+ {%- if item is mapping -%}
243
+ {%- if 'name' in item and 'response' in item -%}
244
+ {{ '<start_function_response>response:' + item['name'] | trim + '{' }}
245
+ {%- set response_ns = namespace(found_first=false) -%}
246
+ {%- for key, value in item['response'] | dictsort -%}
247
+ {%- if response_ns.found_first %},{% endif -%}
248
+ {%- set response_ns.found_first = true -%}
249
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
250
+ {%- endfor -%}
251
+ {{- '}<end_function_response>' -}}
252
+ {%- elif 'name' in message -%}
253
+ {{ '<start_function_response>response:' + message['name'] | trim + '{' }}
254
+ {%- set response_ns = namespace(found_first=false) -%}
255
+ {%- for key, value in item | dictsort -%}
256
+ {%- if response_ns.found_first %},{% endif -%}
257
+ {%- set response_ns.found_first = true -%}
258
+ {{- key -}}:{{- format_argument(value, escape_keys=False) -}}
259
+ {%- endfor -%}
260
+ {{- '}<end_function_response>' -}}
261
+ {%- else -%}
262
+ {{ raise_exception("Invalid tool response mapping: must contain 'name' and 'response' keys, or 'name' must be in the message.") }}
263
+ {%- endif -%}
264
+ {%- else -%}
265
+ {{ raise_exception("Invalid tool response message: multiple responses must all be mappings") }}
266
+ {%- endif -%}
267
+ {%- endfor -%}
268
+ {%- else -%}
269
+ {{ raise_exception("Invalid content type in tool message: must be mapping, sequence of mappings, or string.") }}
270
+ {%- endif -%}
271
+ {%- endif -%}
272
+ {%- set ns.prev_message_type = 'tool_response' -%}
273
+ {%- endif -%}
274
+ {%- if ns.prev_message_type not in ['tool_call', 'tool_response'] -%}
275
+ {{ '<end_of_turn>\n' }}
276
+ {%- endif -%}
277
+ {%- endfor -%}
278
+ {%- if add_generation_prompt -%}
279
+ {%- if ns.prev_message_type != 'tool_response' -%}
280
+ {{- '<start_of_turn>model\n' -}}
281
+ {%- endif -%}
282
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_name": "FunctionGemma Coding Assistant",
3
+ "version": "1.0.0",
4
+ "base_model": "google/functiongemma-270m-it",
5
+ "training_steps": 1000,
6
+ "dataset_size": 9997
7
+ }
knowledge_base.db ADDED
Binary file (20.5 kB). View file
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44c66c66c80dfc0661e17b54df7904c96c3b073d915cae9d82ae3e344bb711bb
3
+ size 536223056
special_tokens_map.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "boi_token": "<start_of_image>",
3
+ "bos_token": {
4
+ "content": "<bos>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false
9
+ },
10
+ "eoi_token": "<end_of_image>",
11
+ "eos_token": {
12
+ "content": "<end_of_turn>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false
17
+ },
18
+ "image_token": "<image_soft_token>",
19
+ "pad_token": {
20
+ "content": "<pad>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false
25
+ },
26
+ "sfr_token": "<start_function_response>",
27
+ "unk_token": {
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false
33
+ }
34
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b6b09a0b4a803ad453063ca4bb49a784540e8120004e2450e025df2b27d41fb2
3
+ size 33384899
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa009fcbc3589a9904d30d04834094fea4653c2ac6d2de2cd1262d4f7a50ceb3
3
+ size 4689144
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff