Text Generation
Transformers
Safetensors
MLX
gemma3_text
conversational
text-generation-inference
4-bit precision
Instructions to use alexcovo/rnj-1-instruct-mlx-4Bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use alexcovo/rnj-1-instruct-mlx-4Bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="alexcovo/rnj-1-instruct-mlx-4Bit") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("alexcovo/rnj-1-instruct-mlx-4Bit") model = AutoModelForCausalLM.from_pretrained("alexcovo/rnj-1-instruct-mlx-4Bit", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - MLX
How to use alexcovo/rnj-1-instruct-mlx-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("alexcovo/rnj-1-instruct-mlx-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
- vLLM
How to use alexcovo/rnj-1-instruct-mlx-4Bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "alexcovo/rnj-1-instruct-mlx-4Bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "alexcovo/rnj-1-instruct-mlx-4Bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/alexcovo/rnj-1-instruct-mlx-4Bit
- SGLang
How to use alexcovo/rnj-1-instruct-mlx-4Bit 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 "alexcovo/rnj-1-instruct-mlx-4Bit" \ --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": "alexcovo/rnj-1-instruct-mlx-4Bit", "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 "alexcovo/rnj-1-instruct-mlx-4Bit" \ --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": "alexcovo/rnj-1-instruct-mlx-4Bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Pi
How to use alexcovo/rnj-1-instruct-mlx-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 "alexcovo/rnj-1-instruct-mlx-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": "alexcovo/rnj-1-instruct-mlx-4Bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use alexcovo/rnj-1-instruct-mlx-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 "alexcovo/rnj-1-instruct-mlx-4Bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "alexcovo/rnj-1-instruct-mlx-4Bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "alexcovo/rnj-1-instruct-mlx-4Bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Docker Model Runner
How to use alexcovo/rnj-1-instruct-mlx-4Bit with Docker Model Runner:
docker model run hf.co/alexcovo/rnj-1-instruct-mlx-4Bit
- Hermes Agent
How to use alexcovo/rnj-1-instruct-mlx-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 "alexcovo/rnj-1-instruct-mlx-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 alexcovo/rnj-1-instruct-mlx-4Bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use alexcovo/rnj-1-instruct-mlx-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 "alexcovo/rnj-1-instruct-mlx-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 "alexcovo/rnj-1-instruct-mlx-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"
Upload chat_template.jinja with huggingface_hub
Browse files- chat_template.jinja +122 -0
chat_template.jinja
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) -%}
|
| 2 |
+
{%- set emit = namespace(started=false) -%}
|
| 3 |
+
|
| 4 |
+
{# ---------- Build base system message (always emitted) ---------- #}
|
| 5 |
+
{%- set base_system = 'You are rnj-1, a foundation model trained by Essential AI.\n' -%}
|
| 6 |
+
|
| 7 |
+
{# ---------- Optional tools preface as a synthetic system message ---------- #}
|
| 8 |
+
{%- if tools %}
|
| 9 |
+
{%- set sys_preamble -%}
|
| 10 |
+
# Tools
|
| 11 |
+
|
| 12 |
+
You may call one or more functions to assist with the user query.
|
| 13 |
+
|
| 14 |
+
You are provided with function signatures within <tools></tools> XML tags:
|
| 15 |
+
<tools>
|
| 16 |
+
{%- for tool in tools %}
|
| 17 |
+
{{ "\n" ~ (tool | tojson) }}
|
| 18 |
+
{% endfor %}
|
| 19 |
+
</tools>
|
| 20 |
+
|
| 21 |
+
For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
|
| 22 |
+
<tool_call>
|
| 23 |
+
{"name": <function-name>, "arguments": <args-json-object>}
|
| 24 |
+
</tool_call>
|
| 25 |
+
{%- endset -%}
|
| 26 |
+
|
| 27 |
+
{# If the first user-provided message is system, include it above the tools preface #}
|
| 28 |
+
{%- set combined_system = (messages and messages[0].role == 'system')
|
| 29 |
+
and (messages[0].content is string) -%}
|
| 30 |
+
{%- set sys_content = (combined_system and (messages[0].content ~ "\n\n" ~ sys_preamble)) or sys_preamble -%}
|
| 31 |
+
|
| 32 |
+
{%- set content = '<|start_header_id|>system<|end_header_id|>\n' ~ base_system ~ '\n' ~ sys_content ~ '<|eot_id|>' -%}
|
| 33 |
+
{%- if not emit.started -%}{%- set content = bos_token ~ content -%}{%- set emit.started = true -%}{%- endif -%}
|
| 34 |
+
{{- content -}}
|
| 35 |
+
{%- else %}
|
| 36 |
+
{# No tools: always emit base_system, and include user's system message if present #}
|
| 37 |
+
{%- set user_system_content = '' -%}
|
| 38 |
+
{%- if messages and messages[0].role == 'system' and (messages[0].content is string) -%}
|
| 39 |
+
{%- set user_system_content = '\n' ~ messages[0].content -%}
|
| 40 |
+
{%- endif -%}
|
| 41 |
+
{%- set content = '<|start_header_id|>system<|end_header_id|>\n' ~ base_system ~ user_system_content ~ '<|eot_id|>' -%}
|
| 42 |
+
{%- if not emit.started -%}{%- set content = bos_token ~ content -%}{%- set emit.started = true -%}{%- endif -%}
|
| 43 |
+
{{- content -}}
|
| 44 |
+
{%- endif -%}
|
| 45 |
+
|
| 46 |
+
{# ---------- Locate last user query for multi-step tool behavior ---------- #}
|
| 47 |
+
{%- for message in messages[::-1] %}
|
| 48 |
+
{%- set index = (messages|length - 1) - loop.index0 -%}
|
| 49 |
+
{%- if ns.multi_step_tool
|
| 50 |
+
and message.role == "user"
|
| 51 |
+
and message.content is string
|
| 52 |
+
and not (message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) -%}
|
| 53 |
+
{%- set ns.multi_step_tool = false -%}
|
| 54 |
+
{%- set ns.last_query_index = index -%}
|
| 55 |
+
{%- endif -%}
|
| 56 |
+
{%- endfor -%}
|
| 57 |
+
|
| 58 |
+
{# ---------- Walk all messages and emit in Llama-3 format ---------- #}
|
| 59 |
+
{%- for message in messages %}
|
| 60 |
+
{# normalize content #}
|
| 61 |
+
{%- if message.content is string -%}
|
| 62 |
+
{%- set content = message.content -%}
|
| 63 |
+
{%- else -%}
|
| 64 |
+
{%- set content = '' -%}
|
| 65 |
+
{%- endif -%}
|
| 66 |
+
|
| 67 |
+
{# --- user/system (non-initial system already handled above) --- #}
|
| 68 |
+
{%- if (message.role == "user") or (message.role == "system" and not loop.first) -%}
|
| 69 |
+
{%- set block = '<|start_header_id|>' ~ message.role ~ '<|end_header_id|>\n' ~ content ~ '<|eot_id|>' -%}
|
| 70 |
+
{%- if not emit.started -%}{%- set block = bos_token ~ block -%}{%- set emit.started = true -%}{%- endif -%}
|
| 71 |
+
{{- block -}}
|
| 72 |
+
|
| 73 |
+
{# --- assistant --- #}
|
| 74 |
+
{%- elif message.role == "assistant" -%}
|
| 75 |
+
|
| 76 |
+
{%- set body = content -%}
|
| 77 |
+
{%- set header = '<|start_header_id|>assistant<|end_header_id|>\n' -%}
|
| 78 |
+
{%- if not emit.started -%}{{ bos_token }}{%- set emit.started = true -%}{%- endif -%}
|
| 79 |
+
{{- header -}}
|
| 80 |
+
{% generation %}
|
| 81 |
+
{{- body -}}
|
| 82 |
+
{%- if message.tool_calls -%}
|
| 83 |
+
{%- for tool_call in message.tool_calls -%}
|
| 84 |
+
{%- if tool_call.function -%}{%- set tc = tool_call.function -%}{%- else -%}{%- set tc = tool_call -%}{%- endif -%}
|
| 85 |
+
{%- set args_json = (tc.arguments if (tc.arguments is string) else (tc.arguments | tojson)) -%}
|
| 86 |
+
{%- if loop.first -%}
|
| 87 |
+
{{- '<tool_call>\n{"name": "' ~ tc.name ~ '", "arguments": ' ~ args_json ~ '}\n</tool_call>' -}}
|
| 88 |
+
{%- else -%}
|
| 89 |
+
{{- '\n<tool_call>\n{"name": "' ~ tc.name ~ '", "arguments": ' ~ args_json ~ '}\n</tool_call>' -}}
|
| 90 |
+
{%- endif -%}
|
| 91 |
+
{%- endfor -%}
|
| 92 |
+
{%- endif -%}
|
| 93 |
+
{{- '<|eot_id|>' -}}{%- endgeneration -%}
|
| 94 |
+
{# --- tool messages are wrapped as synthetic user messages with <tool_response> --- #}
|
| 95 |
+
{%- elif message.role == "tool" -%}
|
| 96 |
+
{%- set open_user = (loop.first or (loop.index0 > 0 and messages[loop.index0 - 1].role != "tool")) -%}
|
| 97 |
+
{%- set close_user = (loop.last or (loop.index0 < messages|length - 1 and messages[loop.index0 + 1].role != "tool")) -%}
|
| 98 |
+
|
| 99 |
+
{%- if open_user -%}
|
| 100 |
+
{%- set header = '<|start_header_id|>user<|end_header_id|>\n' -%}
|
| 101 |
+
{%- if not emit.started -%}{%- set header = bos_token ~ header -%}{%- set emit.started = true -%}{%- endif -%}
|
| 102 |
+
{{- header -}}
|
| 103 |
+
{%- endif -%}
|
| 104 |
+
{%- if open_user -%}
|
| 105 |
+
{{- '<tool_response>\n' -}}
|
| 106 |
+
{%- else -%}
|
| 107 |
+
{{- '\n<tool_response>\n' -}}
|
| 108 |
+
{%- endif -%}
|
| 109 |
+
{{- content -}}
|
| 110 |
+
{{- '\n</tool_response>' -}}
|
| 111 |
+
|
| 112 |
+
{%- if close_user -%}
|
| 113 |
+
{{- '<|eot_id|>' -}}
|
| 114 |
+
{%- endif -%}
|
| 115 |
+
{%- endif -%}
|
| 116 |
+
{%- endfor -%}
|
| 117 |
+
|
| 118 |
+
{# ---------- Add generation prompt header for the model to continue ---------- #}
|
| 119 |
+
{%- if add_generation_prompt -%}
|
| 120 |
+
{%- set tail = '<|start_header_id|>assistant<|end_header_id|>\n' -%}
|
| 121 |
+
{{- tail -}}
|
| 122 |
+
{%- endif -%}
|