Instructions to use trl-internal-testing/tiny-ErgoForCausalLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-ErgoForCausalLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="trl-internal-testing/tiny-ErgoForCausalLM") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("trl-internal-testing/tiny-ErgoForCausalLM") model = AutoModelForCausalLM.from_pretrained("trl-internal-testing/tiny-ErgoForCausalLM", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use trl-internal-testing/tiny-ErgoForCausalLM 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-ErgoForCausalLM" # 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-ErgoForCausalLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/trl-internal-testing/tiny-ErgoForCausalLM
- SGLang
How to use trl-internal-testing/tiny-ErgoForCausalLM 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-ErgoForCausalLM" \ --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-ErgoForCausalLM", "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-ErgoForCausalLM" \ --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-ErgoForCausalLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use trl-internal-testing/tiny-ErgoForCausalLM with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-ErgoForCausalLM
Upload ErgoForCausalLM
Browse files- .gitattributes +1 -0
- README.md +9 -0
- chat_template.jinja +119 -0
- config.json +54 -0
- generation_config.json +12 -0
- model.safetensors +3 -0
- tokenizer.json +3 -0
- tokenizer_config.json +51 -0
.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
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
tags:
|
| 4 |
+
- trl
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# Tiny ErgoForCausalLM
|
| 8 |
+
|
| 9 |
+
This is a minimal model built for unit tests in the [TRL](https://github.com/huggingface/trl) library.
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{#- Ergo chat format. Each turn is `Label<ctrl0>...<ctrl100>` and turns are joined by a newline. -#}
|
| 2 |
+
{%- set labels = {'system': 'System', 'developer': 'System', 'user': 'User', 'assistant': 'Assistant', 'tool': 'CodeExecutor', 'function': 'CodeExecutor'} -%}
|
| 3 |
+
{%- set default_system_prompt = 'You are Ergo, a model built by Amazon. You are a helpful agent that is good at everything. Do not present yourself as a real human being; act as a helpful assistant.' -%}
|
| 4 |
+
|
| 5 |
+
{#- Message content is a string or a list of text parts. -#}
|
| 6 |
+
{%- macro text_of(content) -%}
|
| 7 |
+
{%- if content is string -%}
|
| 8 |
+
{{- content -}}
|
| 9 |
+
{%- elif content is defined and content is not none -%}
|
| 10 |
+
{%- for part in content -%}
|
| 11 |
+
{%- if part is string -%}
|
| 12 |
+
{{- part -}}
|
| 13 |
+
{%- elif part.type == 'text' -%}
|
| 14 |
+
{{- part.text -}}
|
| 15 |
+
{%- else -%}
|
| 16 |
+
{{- raise_exception('Ergo supports text content only, got ' ~ part.type) -}}
|
| 17 |
+
{%- endif -%}
|
| 18 |
+
{%- endfor -%}
|
| 19 |
+
{%- endif -%}
|
| 20 |
+
{%- endmacro -%}
|
| 21 |
+
|
| 22 |
+
{#- Preserve complete tool schemas in client key order, adding missing root defaults. -#}
|
| 23 |
+
{%- macro tool_definitions(tools) -%}
|
| 24 |
+
{%- set out = namespace(definitions=[]) -%}
|
| 25 |
+
{%- for tool in tools -%}
|
| 26 |
+
{%- set function = tool.function -%}
|
| 27 |
+
{%- set parameters = function.get('parameters') -%}
|
| 28 |
+
{%- if parameters is none -%}
|
| 29 |
+
{%- set parameters = {} -%}
|
| 30 |
+
{%- endif -%}
|
| 31 |
+
{%- if parameters is not mapping -%}
|
| 32 |
+
{{- raise_exception('Tool parameters must be a JSON object') -}}
|
| 33 |
+
{%- endif -%}
|
| 34 |
+
{%- set schema = namespace(value={}) -%}
|
| 35 |
+
{%- if 'type' not in parameters -%}
|
| 36 |
+
{%- set schema.value = {'type': 'object'} -%}
|
| 37 |
+
{%- if 'properties' not in parameters -%}
|
| 38 |
+
{%- set schema.value = dict(schema.value, properties={}) -%}
|
| 39 |
+
{%- endif -%}
|
| 40 |
+
{%- endif -%}
|
| 41 |
+
{%- for key, value in parameters.items() -%}
|
| 42 |
+
{%- set schema.value = dict(schema.value, **{key: value}) -%}
|
| 43 |
+
{%- if key == 'type' and 'properties' not in parameters -%}
|
| 44 |
+
{%- set schema.value = dict(schema.value, properties={}) -%}
|
| 45 |
+
{%- endif -%}
|
| 46 |
+
{%- endfor -%}
|
| 47 |
+
{%- set definition = {'type': 'function', 'function': {'name': function.name, 'description': function.get('description') or '', 'parameters': schema.value}} -%}
|
| 48 |
+
{%- set out.definitions = out.definitions + [definition] -%}
|
| 49 |
+
{%- endfor -%}
|
| 50 |
+
{{- '\nThe tool definition is:\n\n```json\n' ~ (out.definitions | tojson(ensure_ascii=false, separators=(',', ':'), sort_keys=false)) ~ '\n```' -}}
|
| 51 |
+
{%- endmacro -%}
|
| 52 |
+
|
| 53 |
+
{%- macro turn(message, state) -%}
|
| 54 |
+
{%- if message.role not in labels -%}
|
| 55 |
+
{{- raise_exception('Unsupported Ergo chat role: ' ~ message.role) -}}
|
| 56 |
+
{%- endif -%}
|
| 57 |
+
{{- ('\n' if state.started else '') ~ labels[message.role] ~ '<ctrl0>' -}}
|
| 58 |
+
{%- set state.started = true -%}
|
| 59 |
+
{%- if message.role == 'assistant' -%}
|
| 60 |
+
{#- Every assistant turn has a reasoning block, empty when there is no reasoning. -#}
|
| 61 |
+
{{- '<ctrl1>' ~ text_of(message.reasoning_content) ~ '<ctrl2>' ~ text_of(message.content) -}}
|
| 62 |
+
{%- for call in message.tool_calls or [] -%}
|
| 63 |
+
{%- set arguments = call.function.arguments or {} -%}
|
| 64 |
+
{%- if arguments is string -%}
|
| 65 |
+
{{- '<ctrl3>{"name":' ~ (call.function.name | tojson) ~ ',"arguments":' ~ arguments ~ '}<ctrl4>' -}}
|
| 66 |
+
{%- else -%}
|
| 67 |
+
{{- '<ctrl3>' ~ ({'name': call.function.name, 'arguments': arguments} | tojson(separators=(',', ':'))) ~ '<ctrl4>' -}}
|
| 68 |
+
{%- endif -%}
|
| 69 |
+
{%- endfor -%}
|
| 70 |
+
{%- else -%}
|
| 71 |
+
{{- text_of(message.content) -}}
|
| 72 |
+
{#- The tool definitions go at the end of the first system turn. -#}
|
| 73 |
+
{%- if labels[message.role] == 'System' and state.tools -%}
|
| 74 |
+
{{- tool_definitions(state.tools) -}}
|
| 75 |
+
{%- set state.tools = none -%}
|
| 76 |
+
{%- endif -%}
|
| 77 |
+
{%- endif -%}
|
| 78 |
+
{{- '<ctrl100>' -}}
|
| 79 |
+
{%- endmacro -%}
|
| 80 |
+
|
| 81 |
+
{%- set state = namespace(started=false, tools=tools, answered=false) -%}
|
| 82 |
+
{%- if messages | selectattr('role', 'in', ['system', 'developer']) | list | length == 0 -%}
|
| 83 |
+
{{- turn({'role': 'system', 'content': default_system_prompt}, state) -}}
|
| 84 |
+
{%- endif -%}
|
| 85 |
+
{%- for message in messages -%}
|
| 86 |
+
{%- if message.role in ['tool', 'function'] and state.answered -%}
|
| 87 |
+
{#- Already written right after the assistant turn it answers. -#}
|
| 88 |
+
{%- continue -%}
|
| 89 |
+
{%- endif -%}
|
| 90 |
+
{%- set state.answered = false -%}
|
| 91 |
+
{{- turn(message, state) -}}
|
| 92 |
+
{%- if message.role == 'assistant' and message.tool_calls -%}
|
| 93 |
+
{#- The format has no call id: the n-th tool result answers the n-th call. Write the results that follow
|
| 94 |
+
in the order of the calls, then the results that match no call. -#}
|
| 95 |
+
{%- set state.answered = true -%}
|
| 96 |
+
{%- set results = namespace(messages=[]) -%}
|
| 97 |
+
{%- for result in messages[loop.index:] -%}
|
| 98 |
+
{%- if result.role not in ['tool', 'function'] -%}
|
| 99 |
+
{%- break -%}
|
| 100 |
+
{%- endif -%}
|
| 101 |
+
{%- set results.messages = results.messages + [result] -%}
|
| 102 |
+
{%- endfor -%}
|
| 103 |
+
{%- set call_ids = message.tool_calls | selectattr('id', 'defined') | map(attribute='id') | unique | list -%}
|
| 104 |
+
{%- for call_id in call_ids -%}
|
| 105 |
+
{%- for result in results.messages if result.tool_call_id == call_id -%}
|
| 106 |
+
{{- turn(result, state) -}}
|
| 107 |
+
{%- endfor -%}
|
| 108 |
+
{%- endfor -%}
|
| 109 |
+
{%- for result in results.messages if result.tool_call_id not in call_ids -%}
|
| 110 |
+
{{- turn(result, state) -}}
|
| 111 |
+
{%- endfor -%}
|
| 112 |
+
{%- endif -%}
|
| 113 |
+
{%- endfor -%}
|
| 114 |
+
{%- if add_generation_prompt -%}
|
| 115 |
+
{{- '\nAssistant<ctrl0><ctrl1>' -}}
|
| 116 |
+
{%- if enable_thinking is defined and not enable_thinking -%}
|
| 117 |
+
{{- '<ctrl2>' -}}
|
| 118 |
+
{%- endif -%}
|
| 119 |
+
{%- endif -%}
|
config.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"ErgoForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"bos_token_id": 2,
|
| 6 |
+
"dtype": "float32",
|
| 7 |
+
"eos_token_id": 1,
|
| 8 |
+
"first_dense_intermediate_size": 32,
|
| 9 |
+
"global_attention_every_n_layers": 2,
|
| 10 |
+
"global_attention_scale": null,
|
| 11 |
+
"head_dim": 8,
|
| 12 |
+
"hidden_size": 32,
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 8,
|
| 15 |
+
"layer_types": [
|
| 16 |
+
"sliding_attention",
|
| 17 |
+
"full_attention"
|
| 18 |
+
],
|
| 19 |
+
"max_position_embeddings": 1048576,
|
| 20 |
+
"mlp_layer_types": [
|
| 21 |
+
"dense",
|
| 22 |
+
"sparse"
|
| 23 |
+
],
|
| 24 |
+
"model_flavor": "55b",
|
| 25 |
+
"model_type": "ergo",
|
| 26 |
+
"moe_expert_output_rms_norm": true,
|
| 27 |
+
"moe_intermediate_size": 8,
|
| 28 |
+
"moe_latent_size": 0,
|
| 29 |
+
"moe_load_balance_strategy": "deepseek",
|
| 30 |
+
"moe_routed_scaling_factor": 2.8284271247461903,
|
| 31 |
+
"moe_routing_method": "sigmoid_topk",
|
| 32 |
+
"num_attention_heads": 4,
|
| 33 |
+
"num_dense_blocks": 1,
|
| 34 |
+
"num_experts": 4,
|
| 35 |
+
"num_experts_per_tok": 2,
|
| 36 |
+
"num_hidden_layers": 2,
|
| 37 |
+
"num_key_value_heads": 2,
|
| 38 |
+
"pad_token_id": 0,
|
| 39 |
+
"rms_norm_eps": 1e-12,
|
| 40 |
+
"rope_parameters": {
|
| 41 |
+
"full_attention": null,
|
| 42 |
+
"sliding_attention": {
|
| 43 |
+
"rope_theta": 1000000.0,
|
| 44 |
+
"rope_type": "default"
|
| 45 |
+
}
|
| 46 |
+
},
|
| 47 |
+
"shared_intermediate_size": 16,
|
| 48 |
+
"sliding_window": 4,
|
| 49 |
+
"source_tp_size": 1,
|
| 50 |
+
"tie_word_embeddings": false,
|
| 51 |
+
"transformers_version": "5.25.0",
|
| 52 |
+
"use_cache": true,
|
| 53 |
+
"vocab_size": 262144
|
| 54 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 2,
|
| 3 |
+
"eos_token_id": [
|
| 4 |
+
1,
|
| 5 |
+
248
|
| 6 |
+
],
|
| 7 |
+
"max_new_tokens": 131072,
|
| 8 |
+
"pad_token_id": 0,
|
| 9 |
+
"temperature": 1.0,
|
| 10 |
+
"top_p": 0.99,
|
| 11 |
+
"transformers_version": "5.25.0"
|
| 12 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8943508d319b152c21451ea335f43c9688bf5487b13c7edd7437f507f6917331
|
| 3 |
+
size 50360032
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fb10d073402428847cac2c23acf8befe0267ecf2a83e8fe5721e2b24ea8c9a62
|
| 3 |
+
size 33605276
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"bos_token": "<bos>",
|
| 4 |
+
"clean_up_tokenization_spaces": false,
|
| 5 |
+
"eos_token": "<ctrl100>",
|
| 6 |
+
"is_local": false,
|
| 7 |
+
"local_files_only": false,
|
| 8 |
+
"model_max_length": 1048576,
|
| 9 |
+
"pad_token": "<pad>",
|
| 10 |
+
"response_template": {
|
| 11 |
+
"defaults": {
|
| 12 |
+
"role": "assistant"
|
| 13 |
+
},
|
| 14 |
+
"fields": {
|
| 15 |
+
"content": {
|
| 16 |
+
"close": [
|
| 17 |
+
"<ctrl100>",
|
| 18 |
+
"<eos>"
|
| 19 |
+
],
|
| 20 |
+
"content": "text",
|
| 21 |
+
"content_args": {
|
| 22 |
+
"strip": false
|
| 23 |
+
},
|
| 24 |
+
"join": "",
|
| 25 |
+
"repeats": true
|
| 26 |
+
},
|
| 27 |
+
"reasoning_content": {
|
| 28 |
+
"close": "<ctrl2>",
|
| 29 |
+
"content": "text",
|
| 30 |
+
"content_args": {
|
| 31 |
+
"strip": false
|
| 32 |
+
},
|
| 33 |
+
"open": "<ctrl1>"
|
| 34 |
+
},
|
| 35 |
+
"tool_calls": {
|
| 36 |
+
"close": "<ctrl4>",
|
| 37 |
+
"content": "json",
|
| 38 |
+
"open": "<ctrl3>",
|
| 39 |
+
"repeats": true,
|
| 40 |
+
"transform": {
|
| 41 |
+
"function": "{content}",
|
| 42 |
+
"type": "function"
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
},
|
| 46 |
+
"start_anchor": "Assistant<ctrl0>"
|
| 47 |
+
},
|
| 48 |
+
"sanitize_control_tokens": true,
|
| 49 |
+
"tokenizer_class": "ErgoTokenizer",
|
| 50 |
+
"unk_token": "<unk>"
|
| 51 |
+
}
|