Text Generation
Transformers
Safetensors
English
llama
Llama-3.1
instruct
finetune
reasoning
hybrid-mode
chatml
function calling
tool use
json mode
structured outputs
atropos
dataforge
long context
roleplaying
chat
conversational
text-generation-inference
Instructions to use NousResearch/Hermes-4-405B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NousResearch/Hermes-4-405B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NousResearch/Hermes-4-405B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("NousResearch/Hermes-4-405B") model = AutoModelForCausalLM.from_pretrained("NousResearch/Hermes-4-405B", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NousResearch/Hermes-4-405B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NousResearch/Hermes-4-405B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NousResearch/Hermes-4-405B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NousResearch/Hermes-4-405B
- SGLang
How to use NousResearch/Hermes-4-405B 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 "NousResearch/Hermes-4-405B" \ --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": "NousResearch/Hermes-4-405B", "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 "NousResearch/Hermes-4-405B" \ --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": "NousResearch/Hermes-4-405B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NousResearch/Hermes-4-405B with Docker Model Runner:
docker model run hf.co/NousResearch/Hermes-4-405B
Update chat_template.jinja
Browse files- chat_template.jinja +21 -6
chat_template.jinja
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
{%- set thinking_prompt = 'You are a deep thinking AI, you may use extremely long chains of thought to deeply consider the problem and deliberate with yourself via systematic reasoning processes to help come to a correct solution prior to answering. You should enclose your thoughts and internal monologue inside <think> </think> tags, and then provide your solution or response to the problem.' %}
|
| 2 |
{%- set standard_prompt = 'You are Hermes, created by Nous Research.' %}
|
| 3 |
{%- if not thinking is defined %}{% set thinking = false %}{% endif %}
|
|
|
|
| 4 |
{%- if thinking %}{%- set system_prompt = thinking_prompt %}{%- else %}{%- set system_prompt = standard_prompt %}{%- endif %}
|
| 5 |
{%- if tools %}
|
| 6 |
{{- bos_token + '<|start_header_id|>system<|end_header_id|>\n' }}
|
|
@@ -23,12 +24,29 @@
|
|
| 23 |
{%- endif %}
|
| 24 |
{%- endif %}
|
| 25 |
{%- for message in messages %}
|
| 26 |
-
{%- if (message.role == "user") or (message.role == "system" and not loop.first)
|
| 27 |
{{- '<|start_header_id|>' + message.role + '<|end_header_id|>\n\n' + message.content + '<|eot_id|>' }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
{%- elif message.role == "assistant" %}
|
| 29 |
{{- '<|start_header_id|>' + message.role + '<|end_header_id|>\n' }}
|
| 30 |
{%- if message.content %}
|
| 31 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
{%- endif %}
|
| 33 |
{%- for tool_call in message.tool_calls %}
|
| 34 |
{%- if tool_call.function is defined %}
|
|
@@ -55,7 +73,4 @@
|
|
| 55 |
{%- endfor %}
|
| 56 |
{%- if add_generation_prompt %}
|
| 57 |
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }}
|
| 58 |
-
|
| 59 |
-
{{- '<think>' }}
|
| 60 |
-
{%- endif %}
|
| 61 |
-
{%- endif %}
|
|
|
|
| 1 |
{%- set thinking_prompt = 'You are a deep thinking AI, you may use extremely long chains of thought to deeply consider the problem and deliberate with yourself via systematic reasoning processes to help come to a correct solution prior to answering. You should enclose your thoughts and internal monologue inside <think> </think> tags, and then provide your solution or response to the problem.' %}
|
| 2 |
{%- set standard_prompt = 'You are Hermes, created by Nous Research.' %}
|
| 3 |
{%- if not thinking is defined %}{% set thinking = false %}{% endif %}
|
| 4 |
+
{%- if not keep_cots is defined %}{% set keep_cots = false %}{% endif %}
|
| 5 |
{%- if thinking %}{%- set system_prompt = thinking_prompt %}{%- else %}{%- set system_prompt = standard_prompt %}{%- endif %}
|
| 6 |
{%- if tools %}
|
| 7 |
{{- bos_token + '<|start_header_id|>system<|end_header_id|>\n' }}
|
|
|
|
| 24 |
{%- endif %}
|
| 25 |
{%- endif %}
|
| 26 |
{%- for message in messages %}
|
| 27 |
+
{%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
|
| 28 |
{{- '<|start_header_id|>' + message.role + '<|end_header_id|>\n\n' + message.content + '<|eot_id|>' }}
|
| 29 |
+
{%- elif (message.role == "assistant" and not message.tool_calls) %}
|
| 30 |
+
{{- '<|start_header_id|>' + message.role + '<|end_header_id|>\n' }}
|
| 31 |
+
{%- if message.content %}
|
| 32 |
+
{%- set content = message['content'] -%}
|
| 33 |
+
{%- if thinking %}
|
| 34 |
+
{%- if not keep_cots %}
|
| 35 |
+
{%- set content = '<think> </think>' + content.split('</think>', 1)[1] -%}
|
| 36 |
+
{%- endif %}
|
| 37 |
+
{%- endif %}
|
| 38 |
+
{{- '\n' + content + '<|eot_id|>' }}
|
| 39 |
+
{%- endif %}
|
| 40 |
{%- elif message.role == "assistant" %}
|
| 41 |
{{- '<|start_header_id|>' + message.role + '<|end_header_id|>\n' }}
|
| 42 |
{%- if message.content %}
|
| 43 |
+
{%- set content = message['content'] -%}
|
| 44 |
+
{%- if thinking %}
|
| 45 |
+
{%- if not keep_cots %}
|
| 46 |
+
{%- set content = '<think> </think>' + content.split('</think>', 1)[1] -%}
|
| 47 |
+
{%- endif %}
|
| 48 |
+
{%- endif %}
|
| 49 |
+
{{- '\n' + content }}
|
| 50 |
{%- endif %}
|
| 51 |
{%- for tool_call in message.tool_calls %}
|
| 52 |
{%- if tool_call.function is defined %}
|
|
|
|
| 73 |
{%- endfor %}
|
| 74 |
{%- if add_generation_prompt %}
|
| 75 |
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }}
|
| 76 |
+
{%- endif %}
|
|
|
|
|
|
|
|
|