qgallouedec HF Staff commited on
Commit
ea04124
·
verified ·
1 Parent(s): c30f17e

Upload RemoteForCausalLM (regenerated)

Browse files
README.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags:
4
+ - trl
5
+ ---
6
+
7
+ # Tiny RemoteForCausalLM
8
+
9
+ This is a minimal model built for unit tests in the [TRL](https://github.com/huggingface/trl) library.
chat_template.jinja CHANGED
@@ -1,93 +1,93 @@
1
- {%- if tools %}
2
- {{- '<|im_start|>system\n' }}
3
- {%- if messages[0].role == 'system' %}
4
- {{- messages[0].content + '\n\n' }}
 
 
 
 
 
 
 
 
5
  {%- endif %}
6
- {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
7
- {%- for tool in tools %}
8
- {{- "\n" }}
9
- {{- tool | tojson }}
10
- {%- endfor %}
11
- {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
 
 
 
12
  {%- else %}
13
- {%- if messages[0].role == 'system' %}
14
- {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
- {%- endif %}
16
  {%- endif %}
17
- {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
- {%- for message in messages[::-1] %}
19
- {%- set index = (messages|length - 1) - loop.index0 %}
20
- {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
- {%- set ns.multi_step_tool = false %}
22
- {%- set ns.last_query_index = index %}
23
- {%- endif %}
24
- {%- endfor %}
25
- {%- for message in messages %}
26
- {%- if message.content is string %}
27
- {%- set content = message.content %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  {%- else %}
29
- {%- set content = '' %}
30
- {%- endif %}
31
- {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
- {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
- {%- elif message.role == "assistant" %}
34
- {%- set reasoning_content = '' %}
35
- {%- if message.reasoning_content is string %}
36
- {%- set reasoning_content = message.reasoning_content %}
37
- {%- else %}
38
- {%- if '</think>' in content %}
39
- {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40
- {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
- {%- endif %}
42
- {%- endif %}
43
 
44
- {{- '<|im_start|>' + message.role }}
45
- {% generation %}
46
- {%- if loop.index0 > ns.last_query_index %}
47
- {%- if loop.last or (not loop.last and reasoning_content) %}
48
- {{- '<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
49
- {%- else %}
50
- {{- content }}
51
- {%- endif %}
52
- {%- else %}
53
- {{- content }}
54
- {%- endif %}
55
- {%- if message.tool_calls %}
56
- {%- for tool_call in message.tool_calls %}
57
- {%- if (loop.first and content) or (not loop.first) %}
58
- {{- '\n' }}
59
- {%- endif %}
60
- {%- if tool_call.function %}
61
- {%- set tool_call = tool_call.function %}
62
- {%- endif %}
63
- {{- '<tool_call>\n{"name": "' }}
64
- {{- tool_call.name }}
65
- {{- '", "arguments": ' }}
66
- {%- if tool_call.arguments is string %}
67
- {{- tool_call.arguments }}
68
- {%- else %}
69
- {{- tool_call.arguments | tojson }}
70
- {%- endif %}
71
- {{- '}\n</tool_call>' }}
72
- {%- endfor %}
73
- {%- endif %}
74
- {{- '<|im_end|>' }}
75
- {% endgeneration %}
76
- {%- elif message.role == "tool" %}
77
- {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
78
- {{- '<|im_start|>user' }}
79
  {%- endif %}
80
- {{- '\n<tool_response>\n' }}
81
- {{- content }}
82
- {{- '\n</tool_response>' }}
83
- {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
84
- {{- '<|im_end|>\n' }}
 
 
 
 
 
 
 
 
85
  {%- endif %}
 
86
  {%- endif %}
87
  {%- endfor %}
88
  {%- if add_generation_prompt %}
89
- {{- '<|im_start|>assistant\n' }}
90
- {%- if enable_thinking is defined and enable_thinking is false %}
91
- {{- '<think>\n\n</think>\n\n' }}
92
- {%- endif %}
93
- {%- endif %}
 
1
+ {{- bos_token }}
2
+ {%- if custom_tools is defined %}
3
+ {%- set tools = custom_tools %}
4
+ {%- endif %}
5
+ {%- if not tools_in_user_message is defined %}
6
+ {%- set tools_in_user_message = true %}
7
+ {%- endif %}
8
+ {%- if not date_string is defined %}
9
+ {%- if strftime_now is defined %}
10
+ {%- set date_string = strftime_now("%d %b %Y") %}
11
+ {%- else %}
12
+ {%- set date_string = "26 Jul 2024" %}
13
  {%- endif %}
14
+ {%- endif %}
15
+ {%- if not tools is defined %}
16
+ {%- set tools = none %}
17
+ {%- endif %}
18
+
19
+ {#- This block extracts the system message, so we can slot it into the right place. #}
20
+ {%- if messages[0]['role'] == 'system' %}
21
+ {%- set system_message = messages[0]['content']|trim %}
22
+ {%- set messages = messages[1:] %}
23
  {%- else %}
24
+ {%- set system_message = "" %}
 
 
25
  {%- endif %}
26
+
27
+ {#- System message #}
28
+ {{- "<|start_header_id|>system<|end_header_id|>\n\n" }}
29
+ {%- if tools is not none %}
30
+ {{- "Environment: ipython\n" }}
31
+ {%- endif %}
32
+ {{- "Cutting Knowledge Date: December 2023\n" }}
33
+ {{- "Today Date: " + date_string + "\n\n" }}
34
+ {%- if tools is not none and not tools_in_user_message %}
35
+ {{- "You have access to the following functions. To call a function, please respond with JSON for a function call." }}
36
+ {{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }}
37
+ {{- "Do not use variables.\n\n" }}
38
+ {%- for t in tools %}
39
+ {{- t | tojson(indent=4) }}
40
+ {{- "\n\n" }}
41
+ {%- endfor %}
42
+ {%- endif %}
43
+ {{- system_message }}
44
+ {{- "<|eot_id|>" }}
45
+
46
+ {#- Custom tools are passed in a user message with some extra guidance #}
47
+ {%- if tools_in_user_message and not tools is none %}
48
+ {#- Extract the first user message so we can plug it in here #}
49
+ {%- if messages | length != 0 %}
50
+ {%- set first_user_message = messages[0]['content']|trim %}
51
+ {%- set messages = messages[1:] %}
52
  {%- else %}
53
+ {{- raise_exception("Cannot put tools in the first user message when there's no first user message!") }}
54
+ {%- endif %}
55
+ {{- '<|start_header_id|>user<|end_header_id|>\n\n' -}}
56
+ {{- "Given the following functions, please respond with a JSON for a function call " }}
57
+ {{- "with its proper arguments that best answers the given prompt.\n\n" }}
58
+ {{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }}
59
+ {{- "Do not use variables.\n\n" }}
60
+ {%- for t in tools %}
61
+ {{- t | tojson(indent=4) }}
62
+ {{- "\n\n" }}
63
+ {%- endfor %}
64
+ {{- first_user_message + "<|eot_id|>"}}
65
+ {%- endif %}
 
66
 
67
+ {%- for message in messages %}
68
+ {%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}
69
+ {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' }}
70
+ {%- elif 'tool_calls' in message %}
71
+ {%- if not message.tool_calls|length == 1 %}
72
+ {{- raise_exception("This model only supports single tool-calls at once!") }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  {%- endif %}
74
+ {%- set tool_call = message.tool_calls[0].function %}
75
+ {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}
76
+ {{- '{"name": "' + tool_call.name + '", ' }}
77
+ {{- '"parameters": ' }}
78
+ {{- tool_call.arguments | tojson }}
79
+ {{- "}" }}
80
+ {{- "<|eot_id|>" }}
81
+ {%- elif message.role == "tool" or message.role == "ipython" %}
82
+ {{- "<|start_header_id|>ipython<|end_header_id|>\n\n" }}
83
+ {%- if message.content is mapping or message.content is iterable %}
84
+ {{- message.content | tojson }}
85
+ {%- else %}
86
+ {{- message.content }}
87
  {%- endif %}
88
+ {{- "<|eot_id|>" }}
89
  {%- endif %}
90
  {%- endfor %}
91
  {%- if add_generation_prompt %}
92
+ {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }}
93
+ {%- endif %}
 
 
 
config.json CHANGED
@@ -1,25 +1,25 @@
1
  {
2
  "architectures": [
3
- "MinimalForCausalLM"
4
  ],
5
  "attention_bias": false,
6
  "attention_dropout": 0.0,
7
  "auto_map": {
8
- "AutoConfig": "configuration_minimal.MinimalConfig",
9
- "AutoModelForCausalLM": "modeling_minimal.MinimalForCausalLM"
10
  },
11
  "bos_token_id": 1,
12
- "dtype": "float32",
13
  "eos_token_id": 2,
14
- "head_dim": 8,
15
  "hidden_act": "silu",
16
- "hidden_size": 16,
17
  "initializer_range": 0.02,
18
  "intermediate_size": 32,
19
- "max_position_embeddings": 128,
20
  "mlp_bias": false,
21
- "model_type": "minimal",
22
- "num_attention_heads": 2,
23
  "num_hidden_layers": 2,
24
  "num_key_value_heads": 2,
25
  "pad_token_id": null,
@@ -32,5 +32,5 @@
32
  "tie_word_embeddings": false,
33
  "transformers_version": "5.8.0.dev0",
34
  "use_cache": true,
35
- "vocab_size": 32000
36
  }
 
1
  {
2
  "architectures": [
3
+ "RemoteForCausalLM"
4
  ],
5
  "attention_bias": false,
6
  "attention_dropout": 0.0,
7
  "auto_map": {
8
+ "AutoConfig": "configuration_remote.RemoteConfig",
9
+ "AutoModelForCausalLM": "modeling_remote.RemoteForCausalLM"
10
  },
11
  "bos_token_id": 1,
12
+ "dtype": "bfloat16",
13
  "eos_token_id": 2,
14
+ "head_dim": 2,
15
  "hidden_act": "silu",
16
+ "hidden_size": 8,
17
  "initializer_range": 0.02,
18
  "intermediate_size": 32,
19
+ "max_position_embeddings": 2048,
20
  "mlp_bias": false,
21
+ "model_type": "remote",
22
+ "num_attention_heads": 4,
23
  "num_hidden_layers": 2,
24
  "num_key_value_heads": 2,
25
  "pad_token_id": null,
 
32
  "tie_word_embeddings": false,
33
  "transformers_version": "5.8.0.dev0",
34
  "use_cache": true,
35
+ "vocab_size": 128256
36
  }
configuration_remote.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020-2026 The HuggingFace Team. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from transformers import LlamaConfig
16
+
17
+
18
+ class RemoteConfig(LlamaConfig):
19
+ model_type = "remote"
generation_config.json CHANGED
@@ -1,9 +1,12 @@
1
  {
2
- "_from_model_config": true,
3
- "bos_token_id": 1,
4
- "eos_token_id": 2,
5
- "output_attentions": false,
6
- "output_hidden_states": false,
7
- "transformers_version": "5.8.0.dev0",
8
- "use_cache": true
 
 
 
9
  }
 
1
  {
2
+ "bos_token_id": 128000,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 128001,
6
+ 128008,
7
+ 128009
8
+ ],
9
+ "temperature": 0.6,
10
+ "top_p": 0.9,
11
+ "transformers_version": "5.8.0.dev0"
12
  }
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:529b12eb5e318c4e4c4fed1fce88f633253581d828788b9a5e65f1032f70b554
3
- size 4118992
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:38c6b5ca5d1a5a97ef63203d2396cdebb2e401182c7c49053797ee525061e128
3
+ size 4110296
modeling_remote.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020-2026 The HuggingFace Team. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from transformers import LlamaForCausalLM
16
+
17
+ from .configuration_remote import RemoteConfig
18
+
19
+
20
+ class RemoteForCausalLM(LlamaForCausalLM):
21
+ config_class = RemoteConfig
tokenizer.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:be75606093db2094d7cd20f3c2f385c212750648bd6ea4fb2bf507a6a4c55506
3
- size 11422650
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b
3
+ size 17209920
tokenizer_config.json CHANGED
@@ -1,15 +1,14 @@
1
  {
2
- "add_prefix_space": false,
3
  "backend": "tokenizers",
4
- "bos_token": null,
5
- "clean_up_tokenization_spaces": false,
6
- "eos_token": "<|im_end|>",
7
- "errors": "replace",
8
  "is_local": false,
9
  "local_files_only": false,
 
 
 
 
10
  "model_max_length": 131072,
11
- "pad_token": "<|endoftext|>",
12
- "split_special_tokens": false,
13
- "tokenizer_class": "Qwen2Tokenizer",
14
- "unk_token": null
15
  }
 
1
  {
 
2
  "backend": "tokenizers",
3
+ "bos_token": "<|begin_of_text|>",
4
+ "clean_up_tokenization_spaces": true,
5
+ "eos_token": "<|eot_id|>",
 
6
  "is_local": false,
7
  "local_files_only": false,
8
+ "model_input_names": [
9
+ "input_ids",
10
+ "attention_mask"
11
+ ],
12
  "model_max_length": 131072,
13
+ "tokenizer_class": "TokenizersBackend"
 
 
 
14
  }