Instructions to use trl-internal-testing/tiny-RemoteForCausalLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-RemoteForCausalLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="trl-internal-testing/tiny-RemoteForCausalLM", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-RemoteForCausalLM", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use trl-internal-testing/tiny-RemoteForCausalLM 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-RemoteForCausalLM" # 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-RemoteForCausalLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/trl-internal-testing/tiny-RemoteForCausalLM
- SGLang
How to use trl-internal-testing/tiny-RemoteForCausalLM 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-RemoteForCausalLM" \ --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-RemoteForCausalLM", "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-RemoteForCausalLM" \ --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-RemoteForCausalLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use trl-internal-testing/tiny-RemoteForCausalLM with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-RemoteForCausalLM
Upload RemoteForCausalLM (regenerated)
Browse files- README.md +9 -0
- chat_template.jinja +83 -83
- config.json +10 -10
- configuration_remote.py +19 -0
- generation_config.json +10 -7
- model.safetensors +2 -2
- modeling_remote.py +21 -0
- tokenizer.json +2 -2
- tokenizer_config.json +8 -9
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 |
-
{
|
| 2 |
-
|
| 3 |
-
{%-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
{%- endif %}
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
{%- else %}
|
| 13 |
-
{%-
|
| 14 |
-
{{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
|
| 15 |
-
{%- endif %}
|
| 16 |
{%- endif %}
|
| 17 |
-
|
| 18 |
-
{
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
{
|
| 25 |
-
{%-
|
| 26 |
-
{
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
{%- else %}
|
| 29 |
-
{
|
| 30 |
-
|
| 31 |
-
{
|
| 32 |
-
|
| 33 |
-
{
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
{
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
{%- endif %}
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
{
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
{
|
| 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 |
-
{
|
| 81 |
-
{{-
|
| 82 |
-
{{- '
|
| 83 |
-
{
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
{%- endif %}
|
|
|
|
| 86 |
{%- endif %}
|
| 87 |
{%- endfor %}
|
| 88 |
{%- if add_generation_prompt %}
|
| 89 |
-
{{- '<|
|
| 90 |
-
|
| 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 |
-
"
|
| 4 |
],
|
| 5 |
"attention_bias": false,
|
| 6 |
"attention_dropout": 0.0,
|
| 7 |
"auto_map": {
|
| 8 |
-
"AutoConfig": "
|
| 9 |
-
"AutoModelForCausalLM": "
|
| 10 |
},
|
| 11 |
"bos_token_id": 1,
|
| 12 |
-
"dtype": "
|
| 13 |
"eos_token_id": 2,
|
| 14 |
-
"head_dim":
|
| 15 |
"hidden_act": "silu",
|
| 16 |
-
"hidden_size":
|
| 17 |
"initializer_range": 0.02,
|
| 18 |
"intermediate_size": 32,
|
| 19 |
-
"max_position_embeddings":
|
| 20 |
"mlp_bias": false,
|
| 21 |
-
"model_type": "
|
| 22 |
-
"num_attention_heads":
|
| 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":
|
| 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 |
-
"
|
| 3 |
-
"
|
| 4 |
-
"eos_token_id":
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 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:
|
| 3 |
-
size
|
|
|
|
| 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:
|
| 3 |
-
size
|
|
|
|
| 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":
|
| 5 |
-
"clean_up_tokenization_spaces":
|
| 6 |
-
"eos_token": "<|
|
| 7 |
-
"errors": "replace",
|
| 8 |
"is_local": false,
|
| 9 |
"local_files_only": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
"model_max_length": 131072,
|
| 11 |
-
"
|
| 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 |
}
|