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
Download chat_template.jinja from trl-internal-testing/tiny-ErgoForCausalLM: direct link, hf CLI and curl.
- Browser
- Download file 5.98 kB
-
https://huggingface.co/trl-internal-testing/tiny-ErgoForCausalLM/resolve/main/chat_template.jinja
- Command line
-
hf download hf://trl-internal-testing/tiny-ErgoForCausalLM/chat_template.jinja
-
curl -L -o chat_template.jinja https://huggingface.co/trl-internal-testing/tiny-ErgoForCausalLM/resolve/main/chat_template.jinja
5.98 kB
| {#- Ergo chat format. Each turn is `Label<ctrl0>...<ctrl100>` and turns are joined by a newline. -#} | |
| {%- set labels = {'system': 'System', 'developer': 'System', 'user': 'User', 'assistant': 'Assistant', 'tool': 'CodeExecutor', 'function': 'CodeExecutor'} -%} | |
| {%- 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.' -%} | |
| {#- Message content is a string or a list of text parts. -#} | |
| {%- macro text_of(content) -%} | |
| {%- if content is string -%} | |
| {{- content -}} | |
| {%- elif content is defined and content is not none -%} | |
| {%- for part in content -%} | |
| {%- if part is string -%} | |
| {{- part -}} | |
| {%- elif part.type == 'text' -%} | |
| {{- part.text -}} | |
| {%- else -%} | |
| {{- raise_exception('Ergo supports text content only, got ' ~ part.type) -}} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- endif -%} | |
| {%- endmacro -%} | |
| {#- Preserve complete tool schemas in client key order, adding missing root defaults. -#} | |
| {%- macro tool_definitions(tools) -%} | |
| {%- set out = namespace(definitions=[]) -%} | |
| {%- for tool in tools -%} | |
| {%- set function = tool.function -%} | |
| {%- set parameters = function.get('parameters') -%} | |
| {%- if parameters is none -%} | |
| {%- set parameters = {} -%} | |
| {%- endif -%} | |
| {%- if parameters is not mapping -%} | |
| {{- raise_exception('Tool parameters must be a JSON object') -}} | |
| {%- endif -%} | |
| {%- set schema = namespace(value={}) -%} | |
| {%- if 'type' not in parameters -%} | |
| {%- set schema.value = {'type': 'object'} -%} | |
| {%- if 'properties' not in parameters -%} | |
| {%- set schema.value = dict(schema.value, properties={}) -%} | |
| {%- endif -%} | |
| {%- endif -%} | |
| {%- for key, value in parameters.items() -%} | |
| {%- set schema.value = dict(schema.value, **{key: value}) -%} | |
| {%- if key == 'type' and 'properties' not in parameters -%} | |
| {%- set schema.value = dict(schema.value, properties={}) -%} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- set definition = {'type': 'function', 'function': {'name': function.name, 'description': function.get('description') or '', 'parameters': schema.value}} -%} | |
| {%- set out.definitions = out.definitions + [definition] -%} | |
| {%- endfor -%} | |
| {{- '\nThe tool definition is:\n\n```json\n' ~ (out.definitions | tojson(ensure_ascii=false, separators=(',', ':'), sort_keys=false)) ~ '\n```' -}} | |
| {%- endmacro -%} | |
| {%- macro turn(message, state) -%} | |
| {%- if message.role not in labels -%} | |
| {{- raise_exception('Unsupported Ergo chat role: ' ~ message.role) -}} | |
| {%- endif -%} | |
| {{- ('\n' if state.started else '') ~ labels[message.role] ~ '<ctrl0>' -}} | |
| {%- set state.started = true -%} | |
| {%- if message.role == 'assistant' -%} | |
| {#- Every assistant turn has a reasoning block, empty when there is no reasoning. -#} | |
| {{- '<ctrl1>' ~ text_of(message.reasoning_content) ~ '<ctrl2>' ~ text_of(message.content) -}} | |
| {%- for call in message.tool_calls or [] -%} | |
| {%- set arguments = call.function.arguments or {} -%} | |
| {%- if arguments is string -%} | |
| {{- '<ctrl3>{"name":' ~ (call.function.name | tojson) ~ ',"arguments":' ~ arguments ~ '}<ctrl4>' -}} | |
| {%- else -%} | |
| {{- '<ctrl3>' ~ ({'name': call.function.name, 'arguments': arguments} | tojson(separators=(',', ':'))) ~ '<ctrl4>' -}} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- else -%} | |
| {{- text_of(message.content) -}} | |
| {#- The tool definitions go at the end of the first system turn. -#} | |
| {%- if labels[message.role] == 'System' and state.tools -%} | |
| {{- tool_definitions(state.tools) -}} | |
| {%- set state.tools = none -%} | |
| {%- endif -%} | |
| {%- endif -%} | |
| {{- '<ctrl100>' -}} | |
| {%- endmacro -%} | |
| {%- set state = namespace(started=false, tools=tools, answered=false) -%} | |
| {%- if messages | selectattr('role', 'in', ['system', 'developer']) | list | length == 0 -%} | |
| {{- turn({'role': 'system', 'content': default_system_prompt}, state) -}} | |
| {%- endif -%} | |
| {%- for message in messages -%} | |
| {%- if message.role in ['tool', 'function'] and state.answered -%} | |
| {#- Already written right after the assistant turn it answers. -#} | |
| {%- continue -%} | |
| {%- endif -%} | |
| {%- set state.answered = false -%} | |
| {{- turn(message, state) -}} | |
| {%- if message.role == 'assistant' and message.tool_calls -%} | |
| {#- The format has no call id: the n-th tool result answers the n-th call. Write the results that follow | |
| in the order of the calls, then the results that match no call. -#} | |
| {%- set state.answered = true -%} | |
| {%- set results = namespace(messages=[]) -%} | |
| {%- for result in messages[loop.index:] -%} | |
| {%- if result.role not in ['tool', 'function'] -%} | |
| {%- break -%} | |
| {%- endif -%} | |
| {%- set results.messages = results.messages + [result] -%} | |
| {%- endfor -%} | |
| {%- set call_ids = message.tool_calls | selectattr('id', 'defined') | map(attribute='id') | unique | list -%} | |
| {%- for call_id in call_ids -%} | |
| {%- for result in results.messages if result.tool_call_id == call_id -%} | |
| {{- turn(result, state) -}} | |
| {%- endfor -%} | |
| {%- endfor -%} | |
| {%- for result in results.messages if result.tool_call_id not in call_ids -%} | |
| {{- turn(result, state) -}} | |
| {%- endfor -%} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- if add_generation_prompt -%} | |
| {{- '\nAssistant<ctrl0><ctrl1>' -}} | |
| {%- if enable_thinking is defined and not enable_thinking -%} | |
| {{- '<ctrl2>' -}} | |
| {%- endif -%} | |
| {%- endif -%} | |