oybek commited on
Commit
983b913
·
1 Parent(s): aa32e79

initial-commit

Browse files
Files changed (10) hide show
  1. .gitattributes +0 -1
  2. .gitattributes +70 -0
  3. README.md +0 -1
  4. README.md +202 -0
  5. config.json +0 -1
  6. config.json +90 -0
  7. params +0 -1
  8. params +10 -0
  9. template +0 -1
  10. template +173 -0
.gitattributes DELETED
@@ -1 +0,0 @@
1
- ../../blobs/81c57bf0049a2882b683d77c52aa853b19888632
 
 
.gitattributes ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz 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
+ gpt-oss-120b-F16.gguf filter=lfs diff=lfs merge=lfs -text
37
+ BF16/gpt-oss-120b-BF16-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
38
+ BF16/gpt-oss-120b-BF16-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
39
+ gpt-oss-120b-Q2_only.gguf filter=lfs diff=lfs merge=lfs -text
40
+ Q2_K/gpt-oss-120b-Q2_K-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
41
+ Q2_K/gpt-oss-120b-Q2_K-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
42
+ Q3_K_M/gpt-oss-120b-Q3_K_M-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
43
+ Q3_K_M/gpt-oss-120b-Q3_K_M-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
44
+ Q6_K/gpt-oss-120b-Q6_K-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
45
+ Q6_K/gpt-oss-120b-Q6_K-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
46
+ Q5_K_M/gpt-oss-120b-Q5_K_M-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
47
+ Q5_K_M/gpt-oss-120b-Q5_K_M-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
48
+ Q4_K_M/gpt-oss-120b-Q4_K_M-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
49
+ Q4_K_M/gpt-oss-120b-Q4_K_M-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
50
+ Q3_K_S/gpt-oss-120b-Q3_K_S-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
51
+ Q3_K_S/gpt-oss-120b-Q3_K_S-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
52
+ Q2_K_L/gpt-oss-120b-Q2_K_L-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
53
+ Q2_K_L/gpt-oss-120b-Q2_K_L-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
54
+ UD-Q6_K_XL/gpt-oss-120b-UD-Q6_K_XL-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
55
+ UD-Q6_K_XL/gpt-oss-120b-UD-Q6_K_XL-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
56
+ Q4_1/gpt-oss-120b-Q4_1-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
57
+ Q4_1/gpt-oss-120b-Q4_1-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
58
+ Q4_0/gpt-oss-120b-Q4_0-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
59
+ Q4_0/gpt-oss-120b-Q4_0-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
60
+ UD-Q8_K_XL/gpt-oss-120b-UD-Q8_K_XL-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
61
+ UD-Q8_K_XL/gpt-oss-120b-UD-Q8_K_XL-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
62
+ Q8_0/gpt-oss-120b-Q8_0-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
63
+ Q8_0/gpt-oss-120b-Q8_0-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
64
+ gpt-oss-120b-BF16.gguf filter=lfs diff=lfs merge=lfs -text
65
+ UD-Q4_K_XL/gpt-oss-120b-UD-Q4_K_XL-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
66
+ UD-Q4_K_XL/gpt-oss-120b-UD-Q4_K_XL-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
67
+ Q5_K_S/gpt-oss-120b-Q5_K_S-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
68
+ Q5_K_S/gpt-oss-120b-Q5_K_S-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
69
+ Q4_K_S/gpt-oss-120b-Q4_K_S-00001-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
70
+ Q4_K_S/gpt-oss-120b-Q4_K_S-00002-of-00002.gguf filter=lfs diff=lfs merge=lfs -text
README.md DELETED
@@ -1 +0,0 @@
1
- ../../blobs/d64de919c8e43aae749de6cdfb366c9f63319a23
 
 
README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - openai/gpt-oss-120b
4
+ license: apache-2.0
5
+ pipeline_tag: text-generation
6
+ library_name: transformers
7
+ tags:
8
+ - openai
9
+ - unsloth
10
+ ---
11
+ > [!NOTE]
12
+ > More GGUF sizes coming soon! This is the MXFP4_MOE quant, now called F16, with our fixes. [Read our guide here.](https://docs.unsloth.ai/basics/gpt-oss)
13
+ >
14
+ <div>
15
+ <p style="margin-bottom: 0; margin-top: 0;">
16
+ <strong>See <a href="https://huggingface.co/collections/unsloth/gpt-oss-6892433695ce0dee42f31681">our collection</a> for all versions of gpt-oss including GGUF, 4-bit & 16-bit formats.</strong>
17
+ </p>
18
+ <p style="margin-bottom: 0;">
19
+ <em>Learn to run gpt-oss correctly - <a href="https://docs.unsloth.ai/basics/gpt-oss">Read our Guide</a>.</em>
20
+ </p>
21
+ <p style="margin-top: 0;margin-bottom: 0;">
22
+ <em>See <a href="https://docs.unsloth.ai/basics/unsloth-dynamic-v2.0-gguf">Unsloth Dynamic 2.0 GGUFs</a> for our quantization benchmarks.</em>
23
+ </p>
24
+ <div style="display: flex; gap: 5px; align-items: center; ">
25
+ <a href="https://github.com/unslothai/unsloth/">
26
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png" width="133">
27
+ </a>
28
+ <a href="https://discord.gg/unsloth">
29
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
30
+ </a>
31
+ <a href="https://docs.unsloth.ai/basics/gpt-oss">
32
+ <img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
33
+ </a>
34
+ </div>
35
+ <h1 style="margin-top: 0rem;">✨ Read our gpt-oss Guide <a href="https://docs.unsloth.ai/basics/gpt-oss">here</a>!</h1>
36
+ </div>
37
+
38
+ - Read our Blog about gpt-oss support: [unsloth.ai/blog/gpt-oss](https://unsloth.ai/blog/gpt-oss)
39
+ - View the rest of our notebooks in our [docs here](https://docs.unsloth.ai/get-started/unsloth-notebooks).
40
+ - Thank you to the [llama.cpp](https://github.com/ggml-org/llama.cpp) team for their work on supporting this model. We wouldn't be able to release quants without them!
41
+
42
+ # gpt-oss-120b Details
43
+ <p align="center">
44
+ <img alt="gpt-oss-120b" src="https://raw.githubusercontent.com/openai/gpt-oss/main/docs/gpt-oss-120b.svg">
45
+ </p>
46
+
47
+ <p align="center">
48
+ <a href="https://gpt-oss.com"><strong>Try gpt-oss</strong></a> ·
49
+ <a href="https://cookbook.openai.com/topic/gpt-oss"><strong>Guides</strong></a> ·
50
+ <a href="https://openai.com/index/gpt-oss-model-card"><strong>System card</strong></a> ·
51
+ <a href="https://openai.com/index/introducing-gpt-oss/"><strong>OpenAI blog</strong></a>
52
+ </p>
53
+
54
+ <br>
55
+
56
+ Welcome to the gpt-oss series, [OpenAI’s open-weight models](https://openai.com/open-models) designed for powerful reasoning, agentic tasks, and versatile developer use cases.
57
+
58
+ We’re releasing two flavors of the open models:
59
+ - `gpt-oss-120b` — for production, general purpose, high reasoning use cases that fits into a single H100 GPU (117B parameters with 5.1B active parameters)
60
+ - `gpt-oss-20b` — for lower latency, and local or specialized use cases (21B parameters with 3.6B active parameters)
61
+
62
+ Both models were trained on our [harmony response format](https://github.com/openai/harmony) and should only be used with the harmony format as it will not work correctly otherwise.
63
+
64
+
65
+ > [!NOTE]
66
+ > This model card is dedicated to the larger `gpt-oss-120b` model. Check out [`gpt-oss-20b`](https://huggingface.co/openai/gpt-oss-20b) for the smaller model.
67
+
68
+ # Highlights
69
+
70
+ * **Permissive Apache 2.0 license:** Build freely without copyleft restrictions or patent risk—ideal for experimentation, customization, and commercial deployment.
71
+ * **Configurable reasoning effort:** Easily adjust the reasoning effort (low, medium, high) based on your specific use case and latency needs.
72
+ * **Full chain-of-thought:** Gain complete access to the model’s reasoning process, facilitating easier debugging and increased trust in outputs. It’s not intended to be shown to end users.
73
+ * **Fine-tunable:** Fully customize models to your specific use case through parameter fine-tuning.
74
+ * **Agentic capabilities:** Use the models’ native capabilities for function calling, [web browsing](https://github.com/openai/gpt-oss/tree/main?tab=readme-ov-file#browser), [Python code execution](https://github.com/openai/gpt-oss/tree/main?tab=readme-ov-file#python), and Structured Outputs.
75
+ * **Native MXFP4 quantization:** The models are trained with native MXFP4 precision for the MoE layer, making `gpt-oss-120b` run on a single H100 GPU and the `gpt-oss-20b` model run within 16GB of memory.
76
+
77
+ ---
78
+
79
+ # Inference examples
80
+
81
+ ## Transformers
82
+
83
+ You can use `gpt-oss-120b` and `gpt-oss-20b` with Transformers. If you use the Transformers chat template, it will automatically apply the [harmony response format](https://github.com/openai/harmony). If you use `model.generate` directly, you need to apply the harmony format manually using the chat template or use our [openai-harmony](https://github.com/openai/harmony) package.
84
+
85
+ To get started, install the necessary dependencies to setup your environment:
86
+
87
+ ```
88
+ pip install -U transformers kernels torch
89
+ ```
90
+
91
+ Once, setup you can proceed to run the model by running the snippet below:
92
+
93
+ ```py
94
+ from transformers import pipeline
95
+ import torch
96
+
97
+ model_id = "openai/gpt-oss-120b"
98
+
99
+ pipe = pipeline(
100
+ "text-generation",
101
+ model=model_id,
102
+ torch_dtype="auto",
103
+ device_map="auto",
104
+ )
105
+
106
+ messages = [
107
+ {"role": "user", "content": "Explain quantum mechanics clearly and concisely."},
108
+ ]
109
+
110
+ outputs = pipe(
111
+ messages,
112
+ max_new_tokens=256,
113
+ )
114
+ print(outputs[0]["generated_text"][-1])
115
+ ```
116
+
117
+ Alternatively, you can run the model via [`Transformers Serve`](https://huggingface.co/docs/transformers/main/serving) to spin up a OpenAI-compatible webserver:
118
+
119
+ ```
120
+ transformers serve
121
+ transformers chat localhost:8000 --model-name-or-path openai/gpt-oss-120b
122
+ ```
123
+
124
+ [Learn more about how to use gpt-oss with Transformers.](https://cookbook.openai.com/articles/gpt-oss/run-transformers)
125
+
126
+ ## vLLM
127
+
128
+ vLLM recommends using [uv](https://docs.astral.sh/uv/) for Python dependency management. You can use vLLM to spin up an OpenAI-compatible webserver. The following command will automatically download the model and start the server.
129
+
130
+ ```bash
131
+ uv pip install --pre vllm==0.10.1+gptoss \
132
+ --extra-index-url https://wheels.vllm.ai/gpt-oss/ \
133
+ --extra-index-url https://download.pytorch.org/whl/nightly/cu128 \
134
+ --index-strategy unsafe-best-match
135
+
136
+ vllm serve openai/gpt-oss-120b
137
+ ```
138
+
139
+ [Learn more about how to use gpt-oss with vLLM.](https://cookbook.openai.com/articles/gpt-oss/run-vllm)
140
+
141
+ ## PyTorch / Triton
142
+
143
+ To learn about how to use this model with PyTorch and Triton, check out our [reference implementations in the gpt-oss repository](https://github.com/openai/gpt-oss?tab=readme-ov-file#reference-pytorch-implementation).
144
+
145
+ ## Ollama
146
+
147
+ If you are trying to run gpt-oss on consumer hardware, you can use Ollama by running the following commands after [installing Ollama](https://ollama.com/download).
148
+
149
+ ```bash
150
+ # gpt-oss-120b
151
+ ollama pull gpt-oss:120b
152
+ ollama run gpt-oss:120b
153
+ ```
154
+
155
+ [Learn more about how to use gpt-oss with Ollama.](https://cookbook.openai.com/articles/gpt-oss/run-locally-ollama)
156
+
157
+ #### LM Studio
158
+
159
+ If you are using [LM Studio](https://lmstudio.ai/) you can use the following commands to download.
160
+
161
+ ```bash
162
+ # gpt-oss-120b
163
+ lms get openai/gpt-oss-120b
164
+ ```
165
+
166
+ Check out our [awesome list](https://github.com/openai/gpt-oss/blob/main/awesome-gpt-oss.md) for a broader collection of gpt-oss resources and inference partners.
167
+
168
+ ---
169
+
170
+ # Download the model
171
+
172
+ You can download the model weights from the [Hugging Face Hub](https://huggingface.co/collections/openai/gpt-oss-68911959590a1634ba11c7a4) directly from Hugging Face CLI:
173
+
174
+ ```shell
175
+ # gpt-oss-120b
176
+ huggingface-cli download openai/gpt-oss-120b --include "original/*" --local-dir gpt-oss-120b/
177
+ pip install gpt-oss
178
+ python -m gpt_oss.chat model/
179
+ ```
180
+
181
+ # Reasoning levels
182
+
183
+ You can adjust the reasoning level that suits your task across three levels:
184
+
185
+ * **Low:** Fast responses for general dialogue.
186
+ * **Medium:** Balanced speed and detail.
187
+ * **High:** Deep and detailed analysis.
188
+
189
+ The reasoning level can be set in the system prompts, e.g., "Reasoning: high".
190
+
191
+ # Tool use
192
+
193
+ The gpt-oss models are excellent for:
194
+ * Web browsing (using built-in browsing tools)
195
+ * Function calling with defined schemas
196
+ * Agentic operations like browser tasks
197
+
198
+ # Fine-tuning
199
+
200
+ Both gpt-oss models can be fine-tuned for a variety of specialized use cases.
201
+
202
+ This larger model `gpt-oss-120b` can be fine-tuned on a single H100 node, whereas the smaller [`gpt-oss-20b`](https://huggingface.co/openai/gpt-oss-20b) can even be fine-tuned on consumer hardware.
config.json DELETED
@@ -1 +0,0 @@
1
- ../../blobs/f73a56c3f0399ee752d405d09d330005207936b9
 
 
config.json ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "GptOssForCausalLM"
4
+ ],
5
+ "attention_bias": true,
6
+ "attention_dropout": 0.0,
7
+ "eos_token_id": 200002,
8
+ "experts_per_token": 4,
9
+ "head_dim": 64,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 2880,
12
+ "initial_context_length": 4096,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 2880,
15
+ "layer_types": [
16
+ "sliding_attention",
17
+ "full_attention",
18
+ "sliding_attention",
19
+ "full_attention",
20
+ "sliding_attention",
21
+ "full_attention",
22
+ "sliding_attention",
23
+ "full_attention",
24
+ "sliding_attention",
25
+ "full_attention",
26
+ "sliding_attention",
27
+ "full_attention",
28
+ "sliding_attention",
29
+ "full_attention",
30
+ "sliding_attention",
31
+ "full_attention",
32
+ "sliding_attention",
33
+ "full_attention",
34
+ "sliding_attention",
35
+ "full_attention",
36
+ "sliding_attention",
37
+ "full_attention",
38
+ "sliding_attention",
39
+ "full_attention",
40
+ "sliding_attention",
41
+ "full_attention",
42
+ "sliding_attention",
43
+ "full_attention",
44
+ "sliding_attention",
45
+ "full_attention",
46
+ "sliding_attention",
47
+ "full_attention",
48
+ "sliding_attention",
49
+ "full_attention",
50
+ "sliding_attention",
51
+ "full_attention"
52
+ ],
53
+ "max_position_embeddings": 131072,
54
+ "model_type": "gpt_oss",
55
+ "num_attention_heads": 64,
56
+ "num_experts_per_tok": 4,
57
+ "num_hidden_layers": 36,
58
+ "num_key_value_heads": 8,
59
+ "num_local_experts": 128,
60
+ "output_router_logits": false,
61
+ "pad_token_id": 200017,
62
+ "quantization_config": {
63
+ "modules_to_not_convert": [
64
+ "model.layers.*.self_attn",
65
+ "model.layers.*.mlp.router",
66
+ "model.embed_tokens",
67
+ "lm_head"
68
+ ],
69
+ "quant_method": "mxfp4"
70
+ },
71
+ "rms_norm_eps": 1e-05,
72
+ "rope_scaling": {
73
+ "beta_fast": 32.0,
74
+ "beta_slow": 1.0,
75
+ "factor": 32.0,
76
+ "original_max_position_embeddings": 4096,
77
+ "rope_type": "yarn",
78
+ "truncate": false
79
+ },
80
+ "rope_theta": 150000,
81
+ "router_aux_loss_coef": 0.9,
82
+ "sliding_window": 128,
83
+ "swiglu_limit": 7.0,
84
+ "tie_word_embeddings": false,
85
+ "transformers_version": "4.56.0.dev0",
86
+ "unsloth_fixed": true,
87
+ "use_cache": true,
88
+ "vocab_size": 201088
89
+ }
90
+
params DELETED
@@ -1 +0,0 @@
1
- ../../blobs/8a0f9a349c7455ea8c27dd662e5b9dedb19e2d71
 
 
params ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "stop": [
3
+ "<|endoftext|>",
4
+ "<|return|>"
5
+ ],
6
+ "temperature": 1.0,
7
+ "min_p" : 0.00,
8
+ "top_k" : 0,
9
+ "top_p" : 1.0
10
+ }
template DELETED
@@ -1 +0,0 @@
1
- ../../blobs/08d0d0f225b3d62db2db3a0d0abe2d0119c79089
 
 
template ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI.
2
+ Knowledge cutoff: 2024-06
3
+ Current date: {{ currentDate }}
4
+ {{- if and .IsThinkSet .Think (ne .ThinkLevel "") }}
5
+
6
+ Reasoning: {{ .ThinkLevel }}
7
+ {{- else if or (not .IsThinkSet) (and .IsThinkSet .Think) }}
8
+
9
+ Reasoning: medium
10
+ {{- end }}
11
+
12
+ {{- $hasNonBuiltinTools := false }}
13
+ {{- if .Tools -}}
14
+ {{- $hasBrowserSearch := false }}
15
+ {{- $hasBrowserOpen := false }}
16
+ {{- $hasBrowserFind := false }}
17
+ {{- $hasPython := false }}
18
+ {{- range .Tools }}
19
+ {{- if eq .Function.Name "browser.search" -}}{{- $hasBrowserSearch = true -}}
20
+ {{- else if eq .Function.Name "browser.open" -}}{{- $hasBrowserOpen = true -}}
21
+ {{- else if eq .Function.Name "browser.find" -}}{{- $hasBrowserFind = true -}}
22
+ {{- else if eq .Function.Name "python" -}}{{- $hasPython = true -}}
23
+ {{- else }}{{ $hasNonBuiltinTools = true -}}
24
+ {{- end }}
25
+ {{- end }}
26
+ {{- if or $hasBrowserSearch $hasBrowserOpen $hasBrowserFind $hasPython }}
27
+
28
+ # Tools
29
+ {{- if or $hasBrowserSearch $hasBrowserOpen $hasBrowserFind }}
30
+
31
+ ## browser
32
+
33
+ // Tool for browsing.
34
+ // The `cursor` appears in brackets before each browsing display: `[{cursor}]`.
35
+ // Cite information from the tool using the following format:
36
+ // `【{cursor}†L{line_start}(-L{line_end})?】`, for example: `【6†L9-L11】` or `【8†L3】`.
37
+ // Do not quote more than 10 words directly from the tool output.
38
+ // sources=web (default: web)
39
+ namespace browser {
40
+ {{- if $hasBrowserSearch }}
41
+
42
+ // Searches for information related to `query` and displays `topn` results.
43
+ type search = (_: {
44
+ query: string,
45
+ topn?: number, // default: 10
46
+ source?: string,
47
+ }) => any;
48
+ {{- end }}
49
+ {{- if $hasBrowserOpen }}
50
+
51
+ // Opens the link `id` from the page indicated by `cursor` starting at line number `loc`, showing `num_lines` lines.
52
+ // Valid link ids are displayed with the formatting: `【{id}†.*】`.
53
+ // If `cursor` is not provided, the most recent page is implied.
54
+ // If `id` is a string, it is treated as a fully qualified URL associated with `source`.
55
+ // If `loc` is not provided, the viewport will be positioned at the beginning of the document or centered on the most relevant passage, if available.
56
+ // Use this function without `id` to scroll to a new location of an opened page.
57
+ type open = (_: {
58
+ id?: number | string, // default: -1
59
+ cursor?: number, // default: -1
60
+ loc?: number, // default: -1
61
+ num_lines?: number, // default: -1
62
+ view_source?: boolean, // default: false
63
+ source?: string,
64
+ }) => any;
65
+ {{- end }}
66
+ {{- if $hasBrowserFind }}
67
+
68
+ // Finds exact matches of `pattern` in the current page, or the page given by `cursor`.
69
+ type find = (_: {
70
+ pattern: string,
71
+ cursor?: number, // default: -1
72
+ }) => any;
73
+ {{- end }}
74
+
75
+ } // namespace browser
76
+ {{- end }}{{/* end if has browser tools */}}
77
+ {{- if $hasPython }}
78
+
79
+ ## python
80
+
81
+ Use this tool to execute Python code in your chain of thought. The code will not be shown to the user. This tool should be used for internal reasoning, but not for code that is intended to be visible to the user (e.g. when creating plots, tables, or files).
82
+
83
+ When you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 120.0 seconds. The drive at '/mnt/data' can be used to save and persist user files. Internet access for this session is UNKNOWN. Depends on the cluster.
84
+ {{- end }}{{/* end if hasPython */}}
85
+ {{- end }}{{/* end if has any built-in tools */}}
86
+ {{- end }}{{/* end if .Tools */}}
87
+
88
+ # Valid channels: analysis, commentary, final. Channel must be included for every message.{{ if $hasNonBuiltinTools }}
89
+ Calls to these tools must go to the commentary channel: 'functions'.
90
+ {{- end -}}<|end|>{{/* end of system */ -}}
91
+ {{- if or $hasNonBuiltinTools .System -}}
92
+ <|start|>developer<|message|>{{- if $hasNonBuiltinTools }}# Tools
93
+
94
+ ## functions
95
+
96
+ namespace functions {
97
+ {{- range .Tools }}
98
+ {{- if not (or (eq .Function.Name "browser.search") (eq .Function.Name "browser.open") (eq .Function.Name "browser.find") (eq .Function.Name "python")) }}
99
+ {{if .Function.Description }}
100
+ // {{ .Function.Description }}
101
+ {{- end }}
102
+ {{- if and .Function.Parameters.Properties (gt (len .Function.Parameters.Properties) 0) }}
103
+ type {{ .Function.Name }} = (_: {
104
+ {{- range $name, $prop := .Function.Parameters.Properties }}
105
+ {{- if $prop.Description }}
106
+ // {{ $prop.Description }}
107
+ {{- end }}
108
+ {{ $name }}: {{ if gt (len $prop.Type) 1 }}{{ range $i, $t := $prop.Type }}{{ if $i }} | {{ end }}{{ $t }}{{ end }}{{ else }}{{ index $prop.Type 0 }}{{ end }},
109
+ {{- end }}
110
+ }) => any;
111
+ {{- else }}
112
+ type {{ .Function.Name }} = () => any;
113
+ {{- end }}
114
+ {{- end }}{{/* end if not browser tool */}}
115
+ {{- end }}{{/* end of range .Tools */}}
116
+
117
+ } // namespace functions
118
+ {{- end }}{{/* end if hasNonBuiltinTools */}}
119
+ {{- if .System}}
120
+
121
+ # Instructions
122
+
123
+ {{ .System }}
124
+ {{- end -}}
125
+ <|end|>
126
+ {{- end -}}
127
+ {{- /* Find the index of the last user message */ -}}
128
+ {{- $lastUserIdx := -1 }}
129
+ {{- $prefillingContent := false }}
130
+ {{- $prefillingThinkingOnly := false }}
131
+ {{- range $i, $msg := .Messages }}
132
+ {{- $last := eq (len (slice $.Messages $i)) 1 -}}
133
+ {{- if eq $msg.Role "user" }}
134
+ {{- $lastUserIdx = $i }}
135
+ {{- end -}}
136
+ {{- if and $last (eq $msg.Role "assistant") (gt (len $msg.Content) 0) }}
137
+ {{- $prefillingContent = true }}
138
+ {{- else if and $last (eq $msg.Role "assistant") (gt (len $msg.Thinking) 0) }}
139
+ {{- $prefillingThinkingOnly = true }}
140
+ {{- end }}
141
+ {{- end -}}
142
+ {{- /* Now render messages */ -}}
143
+ {{- range $i, $msg := .Messages }}
144
+ {{- $last := eq (len (slice $.Messages $i)) 1 -}}
145
+ {{- if (ne $msg.Role "system") -}}
146
+ {{- if eq $msg.Role "tool" -}}
147
+ {{- if or (eq $msg.ToolName "python") (eq $msg.ToolName "browser.search") (eq $msg.ToolName "browser.open") (eq $msg.ToolName "browser.find") -}}
148
+ <|start|>{{ $msg.ToolName }} to=assistant<|message|>{{ $msg.Content }}<|end|>
149
+ {{- else -}}
150
+ <|start|>functions.{{ $msg.ToolName }} to=assistant<|message|>{{ $msg.Content }}<|end|>
151
+ {{- end -}}
152
+ {{- else if eq $msg.Role "assistant" -}}
153
+ {{- if and $msg.Thinking (gt $i $lastUserIdx) -}}{{- /* Show thinking only after last user message */ -}}
154
+ <|start|>assistant<|channel|>analysis<|message|>{{ $msg.Thinking }}{{- if not $prefillingThinkingOnly -}}<|end|>{{- end -}}
155
+ {{- end -}}
156
+ {{- if gt (len $msg.Content) 0 -}}
157
+ <|start|>assistant<|channel|>final<|message|>{{ $msg.Content }}{{- if not $prefillingContent -}}<|end|>{{- end -}}
158
+ {{- end -}}
159
+ {{- if gt (len $msg.ToolCalls) 0 -}}
160
+ {{- range $j, $toolCall := $msg.ToolCalls -}}
161
+ {{- $isBuiltin := or (eq $toolCall.Function.Name "python") (eq $toolCall.Function.Name "browser.search") (eq $toolCall.Function.Name "browser.open") (eq $toolCall.Function.Name "browser.find") -}}
162
+ <|start|>assistant<|channel|>{{ if $isBuiltin }}analysis{{ else }}commentary{{ end }} to={{ if not $isBuiltin}}functions.{{end}}{{ $toolCall.Function.Name }} <|constrain|>json<|message|>{{ $toolCall.Function.Arguments }}<|call|>
163
+ {{- end -}}
164
+ {{- end -}}
165
+ {{- else if eq $msg.Role "user" -}}
166
+ <|start|>{{ $msg.Role }}<|message|>{{ $msg.Content }}<|end|>
167
+ {{- end }}
168
+ {{- else }}
169
+ {{- end }}
170
+ {{- end -}}
171
+ {{- if not (or $prefillingContent $prefillingThinkingOnly) -}}
172
+ <|start|>assistant
173
+ {{- end -}}