Instructions to use trl-internal-testing/tiny-GptOssForCausalLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-GptOssForCausalLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="trl-internal-testing/tiny-GptOssForCausalLM") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-GptOssForCausalLM") model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-GptOssForCausalLM") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use trl-internal-testing/tiny-GptOssForCausalLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "trl-internal-testing/tiny-GptOssForCausalLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trl-internal-testing/tiny-GptOssForCausalLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/trl-internal-testing/tiny-GptOssForCausalLM
- SGLang
How to use trl-internal-testing/tiny-GptOssForCausalLM with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "trl-internal-testing/tiny-GptOssForCausalLM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trl-internal-testing/tiny-GptOssForCausalLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "trl-internal-testing/tiny-GptOssForCausalLM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trl-internal-testing/tiny-GptOssForCausalLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use trl-internal-testing/tiny-GptOssForCausalLM with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-GptOssForCausalLM
Upload tokenizer
Browse files- chat_template.jinja +56 -131
chat_template.jinja
CHANGED
|
@@ -84,8 +84,7 @@
|
|
| 84 |
|
| 85 |
{%- elif param_spec.type == "object" -%}
|
| 86 |
{%- if param_spec.properties -%}
|
| 87 |
-
{{- "{
|
| 88 |
-
" }}
|
| 89 |
{%- for prop_name, prop_spec in param_spec.properties.items() -%}
|
| 90 |
{{- prop_name -}}
|
| 91 |
{%- if prop_name not in (param_spec.required or []) -%}
|
|
@@ -107,24 +106,17 @@
|
|
| 107 |
{%- endmacro -%}
|
| 108 |
|
| 109 |
{%- macro render_tool_namespace(namespace_name, tools) -%}
|
| 110 |
-
{{- "## " + namespace_name + "
|
| 111 |
-
|
| 112 |
-
" }}
|
| 113 |
-
{{- "namespace " + namespace_name + " {
|
| 114 |
-
|
| 115 |
-
" }}
|
| 116 |
{%- for tool in tools %}
|
| 117 |
{%- set tool = tool.function %}
|
| 118 |
-
{{- "// " + tool.description + "
|
| 119 |
-
" }}
|
| 120 |
{{- "type "+ tool.name + " = " }}
|
| 121 |
{%- if tool.parameters and tool.parameters.properties %}
|
| 122 |
-
{{- "(_: {
|
| 123 |
-
" }}
|
| 124 |
{%- for param_name, param_spec in tool.parameters.properties.items() %}
|
| 125 |
{%- if param_spec.description %}
|
| 126 |
-
{{- "// " + param_spec.description + "
|
| 127 |
-
" }}
|
| 128 |
{%- endif %}
|
| 129 |
{{- param_name }}
|
| 130 |
{%- if param_name not in (tool.parameters.required or []) -%}
|
|
@@ -142,20 +134,14 @@
|
|
| 142 |
{%- endif -%}
|
| 143 |
{%- endif -%}
|
| 144 |
{%- if not loop.last %}
|
| 145 |
-
{{- ",
|
| 146 |
-
" }}
|
| 147 |
{%- else %}
|
| 148 |
-
{{- ",
|
| 149 |
-
" }}
|
| 150 |
{%- endif -%}
|
| 151 |
{%- endfor %}
|
| 152 |
-
{{- "}) => any;
|
| 153 |
-
|
| 154 |
-
" }}
|
| 155 |
{%- else -%}
|
| 156 |
-
{{- "() => any;
|
| 157 |
-
|
| 158 |
-
" }}
|
| 159 |
{%- endif -%}
|
| 160 |
{%- endfor %}
|
| 161 |
{{- "} // namespace " + namespace_name }}
|
|
@@ -163,92 +149,46 @@
|
|
| 163 |
|
| 164 |
{%- macro render_builtin_tools(browser_tool, python_tool) -%}
|
| 165 |
{%- if browser_tool %}
|
| 166 |
-
{{- "## browser
|
| 167 |
-
|
| 168 |
-
" }}
|
| 169 |
-
{{- "//
|
| 170 |
-
" }}
|
| 171 |
-
{{- "//
|
| 172 |
-
" }}
|
| 173 |
-
{{- "
|
| 174 |
-
" }}
|
| 175 |
-
{{- "
|
| 176 |
-
" }}
|
| 177 |
-
{{- "//
|
| 178 |
-
" }}
|
| 179 |
-
{{- "
|
| 180 |
-
" }}
|
| 181 |
-
{{- "
|
| 182 |
-
|
| 183 |
-
" }}
|
| 184 |
-
{{- "//
|
| 185 |
-
" }}
|
| 186 |
-
{{- "type
|
| 187 |
-
" }}
|
| 188 |
-
{{- "
|
| 189 |
-
" }}
|
| 190 |
-
{{- "
|
| 191 |
-
" }}
|
| 192 |
-
{{- "source?: string,
|
| 193 |
-
" }}
|
| 194 |
-
{{- "
|
| 195 |
-
|
| 196 |
-
" }}
|
| 197 |
-
{{- "
|
| 198 |
-
" }}
|
| 199 |
-
{{- "//
|
| 200 |
-
" }}
|
| 201 |
-
{{- "// If `cursor` is not provided, the most recent page is implied.
|
| 202 |
-
" }}
|
| 203 |
-
{{- "// If `id` is a string, it is treated as a fully qualified URL associated with `source`.
|
| 204 |
-
" }}
|
| 205 |
-
{{- "// 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.
|
| 206 |
-
" }}
|
| 207 |
-
{{- "// Use this function without `id` to scroll to a new location of an opened page.
|
| 208 |
-
" }}
|
| 209 |
-
{{- "type open = (_: {
|
| 210 |
-
" }}
|
| 211 |
-
{{- "id?: number | string, // default: -1
|
| 212 |
-
" }}
|
| 213 |
-
{{- "cursor?: number, // default: -1
|
| 214 |
-
" }}
|
| 215 |
-
{{- "loc?: number, // default: -1
|
| 216 |
-
" }}
|
| 217 |
-
{{- "num_lines?: number, // default: -1
|
| 218 |
-
" }}
|
| 219 |
-
{{- "view_source?: boolean, // default: false
|
| 220 |
-
" }}
|
| 221 |
-
{{- "source?: string,
|
| 222 |
-
" }}
|
| 223 |
-
{{- "}) => any;
|
| 224 |
-
|
| 225 |
-
" }}
|
| 226 |
-
{{- "// Finds exact matches of `pattern` in the current page, or the page given by `cursor`.
|
| 227 |
-
" }}
|
| 228 |
-
{{- "type find = (_: {
|
| 229 |
-
" }}
|
| 230 |
-
{{- "pattern: string,
|
| 231 |
-
" }}
|
| 232 |
-
{{- "cursor?: number, // default: -1
|
| 233 |
-
" }}
|
| 234 |
-
{{- "}) => any;
|
| 235 |
-
|
| 236 |
-
" }}
|
| 237 |
-
{{- "} // namespace browser
|
| 238 |
-
|
| 239 |
-
" }}
|
| 240 |
{%- endif -%}
|
| 241 |
|
| 242 |
{%- if python_tool %}
|
| 243 |
-
{{- "## python
|
| 244 |
-
|
| 245 |
-
" }}
|
| 246 |
-
{{- "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).
|
| 247 |
-
|
| 248 |
-
" }}
|
| 249 |
-
{{- "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.
|
| 250 |
-
|
| 251 |
-
" }}
|
| 252 |
{%- endif -%}
|
| 253 |
{%- endmacro -%}
|
| 254 |
|
|
@@ -257,23 +197,15 @@
|
|
| 257 |
{%- if model_identity is not defined %}
|
| 258 |
{%- set model_identity = "You are ChatGPT, a large language model trained by OpenAI." %}
|
| 259 |
{%- endif %}
|
| 260 |
-
{{- model_identity + "
|
| 261 |
-
" }}
|
| 262 |
-
{{- "
|
| 263 |
-
" }}
|
| 264 |
-
{{- "Current date: " + strftime_now("%Y-%m-%d") + "
|
| 265 |
-
|
| 266 |
-
" }}
|
| 267 |
{%- if reasoning_effort is not defined %}
|
| 268 |
{%- set reasoning_effort = "medium" %}
|
| 269 |
{%- endif %}
|
| 270 |
-
{{- "Reasoning: " + reasoning_effort + "
|
| 271 |
-
|
| 272 |
-
" }}
|
| 273 |
{%- if builtin_tools %}
|
| 274 |
-
{{- "# Tools
|
| 275 |
-
|
| 276 |
-
" }}
|
| 277 |
{%- set available_builtin_tools = namespace(browser=false, python=false) %}
|
| 278 |
{%- for tool in builtin_tools %}
|
| 279 |
{%- if tool == "browser" %}
|
|
@@ -286,8 +218,7 @@
|
|
| 286 |
{%- endif -%}
|
| 287 |
{{- "# Valid channels: analysis, commentary, final. Channel must be included for every message." }}
|
| 288 |
{%- if tools -%}
|
| 289 |
-
{{- "
|
| 290 |
-
Calls to these tools must go to the commentary channel: 'functions'." }}
|
| 291 |
{%- endif -%}
|
| 292 |
{%- endmacro -%}
|
| 293 |
|
|
@@ -312,18 +243,12 @@ Calls to these tools must go to the commentary channel: 'functions'." }}
|
|
| 312 |
{%- if developer_message or tools %}
|
| 313 |
{{- "<|start|>developer<|message|>" }}
|
| 314 |
{%- if developer_message %}
|
| 315 |
-
{{- "# Instructions
|
| 316 |
-
|
| 317 |
-
" }}
|
| 318 |
{{- developer_message }}
|
|
|
|
| 319 |
{%- endif %}
|
| 320 |
{%- if tools -%}
|
| 321 |
-
{{- "
|
| 322 |
-
|
| 323 |
-
" }}
|
| 324 |
-
{{- "# Tools
|
| 325 |
-
|
| 326 |
-
" }}
|
| 327 |
{{- render_tool_namespace("functions", tools) }}
|
| 328 |
{%- endif -%}
|
| 329 |
{{- "<|end|>" }}
|
|
|
|
| 84 |
|
| 85 |
{%- elif param_spec.type == "object" -%}
|
| 86 |
{%- if param_spec.properties -%}
|
| 87 |
+
{{- "{\n" }}
|
|
|
|
| 88 |
{%- for prop_name, prop_spec in param_spec.properties.items() -%}
|
| 89 |
{{- prop_name -}}
|
| 90 |
{%- if prop_name not in (param_spec.required or []) -%}
|
|
|
|
| 106 |
{%- endmacro -%}
|
| 107 |
|
| 108 |
{%- macro render_tool_namespace(namespace_name, tools) -%}
|
| 109 |
+
{{- "## " + namespace_name + "\n\n" }}
|
| 110 |
+
{{- "namespace " + namespace_name + " {\n\n" }}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
{%- for tool in tools %}
|
| 112 |
{%- set tool = tool.function %}
|
| 113 |
+
{{- "// " + tool.description + "\n" }}
|
|
|
|
| 114 |
{{- "type "+ tool.name + " = " }}
|
| 115 |
{%- if tool.parameters and tool.parameters.properties %}
|
| 116 |
+
{{- "(_: {\n" }}
|
|
|
|
| 117 |
{%- for param_name, param_spec in tool.parameters.properties.items() %}
|
| 118 |
{%- if param_spec.description %}
|
| 119 |
+
{{- "// " + param_spec.description + "\n" }}
|
|
|
|
| 120 |
{%- endif %}
|
| 121 |
{{- param_name }}
|
| 122 |
{%- if param_name not in (tool.parameters.required or []) -%}
|
|
|
|
| 134 |
{%- endif -%}
|
| 135 |
{%- endif -%}
|
| 136 |
{%- if not loop.last %}
|
| 137 |
+
{{- ",\n" }}
|
|
|
|
| 138 |
{%- else %}
|
| 139 |
+
{{- ",\n" }}
|
|
|
|
| 140 |
{%- endif -%}
|
| 141 |
{%- endfor %}
|
| 142 |
+
{{- "}) => any;\n\n" }}
|
|
|
|
|
|
|
| 143 |
{%- else -%}
|
| 144 |
+
{{- "() => any;\n\n" }}
|
|
|
|
|
|
|
| 145 |
{%- endif -%}
|
| 146 |
{%- endfor %}
|
| 147 |
{{- "} // namespace " + namespace_name }}
|
|
|
|
| 149 |
|
| 150 |
{%- macro render_builtin_tools(browser_tool, python_tool) -%}
|
| 151 |
{%- if browser_tool %}
|
| 152 |
+
{{- "## browser\n\n" }}
|
| 153 |
+
{{- "// Tool for browsing.\n" }}
|
| 154 |
+
{{- "// The `cursor` appears in brackets before each browsing display: `[{cursor}]`.\n" }}
|
| 155 |
+
{{- "// Cite information from the tool using the following format:\n" }}
|
| 156 |
+
{{- "// `【{cursor}†L{line_start}(-L{line_end})?】`, for example: `【6†L9-L11】` or `【8†L3】`.\n" }}
|
| 157 |
+
{{- "// Do not quote more than 10 words directly from the tool output.\n" }}
|
| 158 |
+
{{- "// sources=web (default: web)\n" }}
|
| 159 |
+
{{- "namespace browser {\n\n" }}
|
| 160 |
+
{{- "// Searches for information related to `query` and displays `topn` results.\n" }}
|
| 161 |
+
{{- "type search = (_: {\n" }}
|
| 162 |
+
{{- "query: string,\n" }}
|
| 163 |
+
{{- "topn?: number, // default: 10\n" }}
|
| 164 |
+
{{- "source?: string,\n" }}
|
| 165 |
+
{{- "}) => any;\n\n" }}
|
| 166 |
+
{{- "// Opens the link `id` from the page indicated by `cursor` starting at line number `loc`, showing `num_lines` lines.\n" }}
|
| 167 |
+
{{- "// Valid link ids are displayed with the formatting: `【{id}†.*】`.\n" }}
|
| 168 |
+
{{- "// If `cursor` is not provided, the most recent page is implied.\n" }}
|
| 169 |
+
{{- "// If `id` is a string, it is treated as a fully qualified URL associated with `source`.\n" }}
|
| 170 |
+
{{- "// 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.\n" }}
|
| 171 |
+
{{- "// Use this function without `id` to scroll to a new location of an opened page.\n" }}
|
| 172 |
+
{{- "type open = (_: {\n" }}
|
| 173 |
+
{{- "id?: number | string, // default: -1\n" }}
|
| 174 |
+
{{- "cursor?: number, // default: -1\n" }}
|
| 175 |
+
{{- "loc?: number, // default: -1\n" }}
|
| 176 |
+
{{- "num_lines?: number, // default: -1\n" }}
|
| 177 |
+
{{- "view_source?: boolean, // default: false\n" }}
|
| 178 |
+
{{- "source?: string,\n" }}
|
| 179 |
+
{{- "}) => any;\n\n" }}
|
| 180 |
+
{{- "// Finds exact matches of `pattern` in the current page, or the page given by `cursor`.\n" }}
|
| 181 |
+
{{- "type find = (_: {\n" }}
|
| 182 |
+
{{- "pattern: string,\n" }}
|
| 183 |
+
{{- "cursor?: number, // default: -1\n" }}
|
| 184 |
+
{{- "}) => any;\n\n" }}
|
| 185 |
+
{{- "} // namespace browser\n\n" }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
{%- endif -%}
|
| 187 |
|
| 188 |
{%- if python_tool %}
|
| 189 |
+
{{- "## python\n\n" }}
|
| 190 |
+
{{- "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).\n\n" }}
|
| 191 |
+
{{- "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.\n\n" }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
{%- endif -%}
|
| 193 |
{%- endmacro -%}
|
| 194 |
|
|
|
|
| 197 |
{%- if model_identity is not defined %}
|
| 198 |
{%- set model_identity = "You are ChatGPT, a large language model trained by OpenAI." %}
|
| 199 |
{%- endif %}
|
| 200 |
+
{{- model_identity + "\n" }}
|
| 201 |
+
{{- "Knowledge cutoff: 2024-06\n" }}
|
| 202 |
+
{{- "Current date: " + strftime_now("%Y-%m-%d") + "\n\n" }}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
{%- if reasoning_effort is not defined %}
|
| 204 |
{%- set reasoning_effort = "medium" %}
|
| 205 |
{%- endif %}
|
| 206 |
+
{{- "Reasoning: " + reasoning_effort + "\n\n" }}
|
|
|
|
|
|
|
| 207 |
{%- if builtin_tools %}
|
| 208 |
+
{{- "# Tools\n\n" }}
|
|
|
|
|
|
|
| 209 |
{%- set available_builtin_tools = namespace(browser=false, python=false) %}
|
| 210 |
{%- for tool in builtin_tools %}
|
| 211 |
{%- if tool == "browser" %}
|
|
|
|
| 218 |
{%- endif -%}
|
| 219 |
{{- "# Valid channels: analysis, commentary, final. Channel must be included for every message." }}
|
| 220 |
{%- if tools -%}
|
| 221 |
+
{{- "\nCalls to these tools must go to the commentary channel: 'functions'." }}
|
|
|
|
| 222 |
{%- endif -%}
|
| 223 |
{%- endmacro -%}
|
| 224 |
|
|
|
|
| 243 |
{%- if developer_message or tools %}
|
| 244 |
{{- "<|start|>developer<|message|>" }}
|
| 245 |
{%- if developer_message %}
|
| 246 |
+
{{- "# Instructions\n\n" }}
|
|
|
|
|
|
|
| 247 |
{{- developer_message }}
|
| 248 |
+
{{- "\n\n" }}
|
| 249 |
{%- endif %}
|
| 250 |
{%- if tools -%}
|
| 251 |
+
{{- "# Tools\n\n" }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
{{- render_tool_namespace("functions", tools) }}
|
| 253 |
{%- endif -%}
|
| 254 |
{{- "<|end|>" }}
|