Text Generation
MLX
Safetensors
afmoe
reasoning
agentic
tool-calling
thinking
conversational
custom_code
4-bit precision
Instructions to use mlx-community/Trinity-Large-Thinking-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/Trinity-Large-Thinking-4bit with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("mlx-community/Trinity-Large-Thinking-4bit") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use mlx-community/Trinity-Large-Thinking-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/Trinity-Large-Thinking-4bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "mlx-community/Trinity-Large-Thinking-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use mlx-community/Trinity-Large-Thinking-4bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "mlx-community/Trinity-Large-Thinking-4bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "mlx-community/Trinity-Large-Thinking-4bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/Trinity-Large-Thinking-4bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use mlx-community/Trinity-Large-Thinking-4bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/Trinity-Large-Thinking-4bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default mlx-community/Trinity-Large-Thinking-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use mlx-community/Trinity-Large-Thinking-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/Trinity-Large-Thinking-4bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "mlx-community/Trinity-Large-Thinking-4bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
| <|begin_of_text|>{%- macro render_extra_keys(json_dict, handled_keys) -%} | |
| {%- if json_dict is mapping %} | |
| {%- for json_key in json_dict if json_key not in handled_keys %} | |
| {%- if json_dict[json_key] is mapping or (json_dict[json_key] is sequence and json_dict[json_key] is not string) %} | |
| {{- '\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson | safe) ~ '</' ~ json_key ~ '>' }} | |
| {%- else %} | |
| {{- '\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '</' ~ json_key ~ '>' }} | |
| {%- endif %} | |
| {%- endfor %} | |
| {%- endif %} | |
| {%- endmacro -%} | |
| {%- macro render_tool_call(raw_tool_call) -%} | |
| {%- if raw_tool_call.function is defined and raw_tool_call.function is mapping %} | |
| {%- set tool_call = raw_tool_call.function %} | |
| {%- else %} | |
| {%- set tool_call = raw_tool_call %} | |
| {%- endif %} | |
| {{- '<tool_call>\n<function=' + (tool_call.name | default('') | string) + '>\n' }} | |
| {%- if tool_call.arguments is defined and tool_call.arguments is mapping %} | |
| {%- for args_name, args_value in tool_call.arguments.items() %} | |
| {{- '<parameter=' + (args_name | string) + '>\n' }} | |
| {%- if args_value is mapping or (args_value is sequence and args_value is not string) %} | |
| {{- args_value | tojson | safe }} | |
| {%- else %} | |
| {{- args_value | string }} | |
| {%- endif %} | |
| {{- '\n</parameter>\n' }} | |
| {%- endfor %} | |
| {%- endif %} | |
| {{- '</function>\n</tool_call>' }} | |
| {%- endmacro -%} | |
| {%- set system_message = none %} | |
| {%- if messages and messages[0]["role"] == "system" %} | |
| {%- set system_message = messages[0]["content"] %} | |
| {%- set loop_messages = messages[1:] %} | |
| {%- else %} | |
| {%- set loop_messages = messages %} | |
| {%- endif %} | |
| {%- if not tools is defined %} | |
| {%- set tools = [] %} | |
| {%- endif %} | |
| {%- set has_tools = tools is iterable and tools is not string and tools | length > 0 %} | |
| {%- if system_message is not none or has_tools %} | |
| {{- '<|im_start|>system\n' }} | |
| {%- if system_message is not none %} | |
| {{- system_message }} | |
| {%- else %} | |
| {{- "You are Trinity Large, a helpful assistant developed by Arcee AI, that can interact with a computer to solve tasks." }} | |
| {%- endif %} | |
| {%- if has_tools %} | |
| {{- "\n\n# Tools\n\nYou have access to the following functions:\n\n<tools>" }} | |
| {%- for tool in tools %} | |
| {%- if tool.function is defined and tool.function is mapping %} | |
| {%- set tool = tool.function %} | |
| {%- endif %} | |
| {{- '\n<function>\n<name>' ~ (tool.name | default('') | string) ~ '</name>' }} | |
| {%- if tool.description is defined and tool.description is not none %} | |
| {{- '\n<description>' ~ (tool.description | string | trim) ~ '</description>' }} | |
| {%- endif %} | |
| {{- '\n<parameters>' }} | |
| {%- if tool.parameters is defined and tool.parameters is mapping and tool.parameters.properties is defined and tool.parameters.properties is mapping %} | |
| {%- for param_name, param_fields in tool.parameters.properties.items() %} | |
| {{- '\n<parameter>\n<name>' ~ (param_name | string) ~ '</name>' }} | |
| {%- if param_fields is mapping and param_fields.type is defined and param_fields.type is not none %} | |
| {{- '\n<type>' ~ (param_fields.type | string) ~ '</type>' }} | |
| {%- endif %} | |
| {%- if param_fields is mapping and param_fields.description is defined and param_fields.description is not none %} | |
| {{- '\n<description>' ~ (param_fields.description | string | trim) ~ '</description>' }} | |
| {%- endif %} | |
| {%- if param_fields is mapping %} | |
| {%- set handled_keys = ['name', 'type', 'description'] %} | |
| {{- render_extra_keys(param_fields, handled_keys) }} | |
| {%- endif %} | |
| {{- '\n</parameter>' }} | |
| {%- endfor %} | |
| {%- endif %} | |
| {%- if tool.parameters is defined %} | |
| {%- set handled_keys = ['type', 'properties'] %} | |
| {{- render_extra_keys(tool.parameters, handled_keys) }} | |
| {%- endif %} | |
| {{- '\n</parameters>' }} | |
| {%- set handled_keys = ['type', 'name', 'description', 'parameters'] %} | |
| {{- render_extra_keys(tool, handled_keys) }} | |
| {{- '\n</function>' }} | |
| {%- endfor %} | |
| {{- "\n</tools>" }} | |
| {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }} | |
| {%- endif %} | |
| {{- '<|im_end|>\n' }} | |
| {%- endif %} | |
| {%- for message in loop_messages %} | |
| {%- set role = message.role | default('') %} | |
| {%- if role == "assistant" %} | |
| {%- set content_str = '' if message.content is none else (message.content | string) %} | |
| {%- set trimmed_content = content_str | trim %} | |
| {%- set has_reasoning_content = message.reasoning_content is defined %} | |
| {%- set has_reasoning = has_reasoning_content or (message.reasoning is defined) %} | |
| {%- if has_reasoning_content %} | |
| {%- set reasoning_value = message.reasoning_content %} | |
| {%- elif message.reasoning is defined %} | |
| {%- set reasoning_value = message.reasoning %} | |
| {%- else %} | |
| {%- set reasoning_value = none %} | |
| {%- endif %} | |
| {%- set has_tool_calls = message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls is not string and message.tool_calls | length > 0 %} | |
| {{- '<|im_start|>assistant\n' }} | |
| {%- if has_reasoning %} | |
| {%- if reasoning_value %} | |
| {{- '<think>' + (reasoning_value | string | trim) + '</think>' }} | |
| {%- else %} | |
| {{- '<think></think>' }} | |
| {%- endif %} | |
| {%- if trimmed_content %} | |
| {{- '\n' + trimmed_content }} | |
| {%- endif %} | |
| {%- elif has_tool_calls %} | |
| {%- if trimmed_content %} | |
| {{- trimmed_content }} | |
| {%- endif %} | |
| {%- else %} | |
| {{- content_str }} | |
| {%- endif %} | |
| {%- if has_tool_calls %} | |
| {%- for tool_call in message.tool_calls %} | |
| {%- set separator = '\n' if ((loop.first and (has_reasoning or trimmed_content)) or (not loop.first)) else '' -%} | |
| {{- separator + render_tool_call(tool_call) }} | |
| {%- endfor %} | |
| {%- endif %} | |
| {{- '<|im_end|>\n' }} | |
| {%- elif role == "tool" or role == "observation" or role == "function" %} | |
| {%- if loop.first or loop.previtem.role not in ["tool", "observation", "function"] %} | |
| {{- '<|im_start|>user\n' }} | |
| {%- endif %} | |
| {{- '<tool_response>\n' }} | |
| {{- '' if message.content is none else (message.content | string) }} | |
| {{- '\n</tool_response>\n' }} | |
| {%- if loop.last or loop.nextitem.role not in ["tool", "observation", "function"] %} | |
| {{- '<|im_end|>\n' }} | |
| {%- endif %} | |
| {%- else %} | |
| {{- '<|im_start|>' + (role | string) }} | |
| {{- '\n' + ('' if message.content is none else (message.content | string)) }} | |
| {{- '<|im_end|>\n' }} | |
| {%- endif %} | |
| {%- endfor %} | |
| {%- if add_generation_prompt %} | |
| {{- '<|im_start|>assistant\n<think>' }} | |
| {%- endif %} |