Text Generation
Transformers
Safetensors
Korean
English
exaone_moe
Mixture of Experts
awq
quantized
w4a16
compressed-tensors
vllm
llm-compressor
conversational
Instructions to use Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128") model = AutoModelForCausalLM.from_pretrained("Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128") 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 Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128
- SGLang
How to use Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128 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 "Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128" \ --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": "Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128", "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 "Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128" \ --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": "Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128 with Docker Model Runner:
docker model run hf.co/Hyun9junn/K-EXAONE-236B-A23B-W4A16-G128
Add chat_template.jinja
Browse files- chat_template.jinja +159 -0
chat_template.jinja
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% set image_count = namespace(value=0) %}
|
| 2 |
+
{% set video_count = namespace(value=0) %}
|
| 3 |
+
|
| 4 |
+
{%- set role_indicators = {
|
| 5 |
+
'user': '<|user|>\n',
|
| 6 |
+
'assistant': '<|assistant|>\n',
|
| 7 |
+
'system': '<|system|>\n',
|
| 8 |
+
'tool': '<|tool|>\n',
|
| 9 |
+
'tool_declare': '<|tool_declare|>\n'
|
| 10 |
+
} %}
|
| 11 |
+
{%- set end_of_turn = '<|endofturn|>\n' %}
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
{%- macro declare_available_tools(tools) %}
|
| 15 |
+
{{- "# Tools" }}
|
| 16 |
+
{{- "\n" }}
|
| 17 |
+
{%- for tool in tools %}
|
| 18 |
+
{{- "<tool>" }}
|
| 19 |
+
{{- tool | tojson(ensure_ascii=False) | safe }}
|
| 20 |
+
{{- "</tool>\n" }}
|
| 21 |
+
{%- endfor %}
|
| 22 |
+
{%- endmacro %}
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
{%- set ns = namespace(last_query_index = messages|length - 1, last_query_index_not_yet_determined = true) %}
|
| 26 |
+
{%- for message in messages[::-1] %}
|
| 27 |
+
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 28 |
+
{%- if ns.last_query_index_not_yet_determined and message.role == "user" and message.content is string %}
|
| 29 |
+
{%- set ns.last_query_index = index -%}
|
| 30 |
+
{%- set ns.last_query_index_not_yet_determined = false -%}
|
| 31 |
+
{%- endif %}
|
| 32 |
+
{%- endfor %}
|
| 33 |
+
|
| 34 |
+
{%- if tools is defined and tools %}
|
| 35 |
+
{{- role_indicators['tool_declare'] }}
|
| 36 |
+
{{- declare_available_tools(tools) }}
|
| 37 |
+
{{- end_of_turn -}}
|
| 38 |
+
{%- endif %}
|
| 39 |
+
|
| 40 |
+
{%- for i in range(messages | length) %}
|
| 41 |
+
{%- set msg = messages[i] %}
|
| 42 |
+
{%- set role = msg.role %}
|
| 43 |
+
{%- if role not in role_indicators %}
|
| 44 |
+
{{- raise_exception('Unknown role: ' ~ role) }}
|
| 45 |
+
{%- endif %}
|
| 46 |
+
|
| 47 |
+
{%- if i == 0 %}
|
| 48 |
+
{%- if role == 'system' %}
|
| 49 |
+
{{- role_indicators['system'] }}
|
| 50 |
+
{{- msg.content }}
|
| 51 |
+
{{- end_of_turn -}}
|
| 52 |
+
{%- continue %}
|
| 53 |
+
{%- endif %}
|
| 54 |
+
{%- endif %}
|
| 55 |
+
|
| 56 |
+
{%- if role == 'assistant' %}
|
| 57 |
+
{{- role_indicators['assistant'] }}
|
| 58 |
+
|
| 59 |
+
{%- set content = (msg.content if (msg.content is defined and msg.content) else "") -%}
|
| 60 |
+
{%- set reasoning = none -%}
|
| 61 |
+
|
| 62 |
+
{%- if msg.reasoning_content is defined and msg.reasoning_content%}
|
| 63 |
+
{%- set reasoning = msg.reasoning_content.strip() -%}
|
| 64 |
+
{%- elif content and "</think>" in content %}
|
| 65 |
+
{%- set _parts = content.split('</think>') -%}
|
| 66 |
+
{%- set reasoning = _parts[0].lstrip('<think>').strip() -%}
|
| 67 |
+
{%- set content = _parts[-1].strip() -%}
|
| 68 |
+
{%- endif %}
|
| 69 |
+
|
| 70 |
+
{%- if not (reasoning and i > ns.last_query_index) or (skip_think is defined and skip_think) %}
|
| 71 |
+
{%- set reasoning = none %}
|
| 72 |
+
{%- endif %}
|
| 73 |
+
|
| 74 |
+
{%- set content = content.strip() -%}
|
| 75 |
+
|
| 76 |
+
{{- "<think>\n" }}
|
| 77 |
+
{{- (reasoning if reasoning is not none else "") }}
|
| 78 |
+
{{- "\n</think>\n\n" }}
|
| 79 |
+
|
| 80 |
+
{{- content }}
|
| 81 |
+
|
| 82 |
+
{%- if msg.tool_calls %}
|
| 83 |
+
{%- if content is defined and content %}
|
| 84 |
+
{{- "\n" }}
|
| 85 |
+
{%- endif %}
|
| 86 |
+
{%- for tool_call in msg.tool_calls %}
|
| 87 |
+
{%- if tool_call.function is defined %}
|
| 88 |
+
{%- set tool_call = tool_call.function %}
|
| 89 |
+
{%- endif %}
|
| 90 |
+
|
| 91 |
+
{%- if tool_call.arguments is defined %}
|
| 92 |
+
{%- set arguments = tool_call.arguments %}
|
| 93 |
+
{%- elif tool_call.parameters is defined %}
|
| 94 |
+
{%- set arguments = tool_call.parameters %}
|
| 95 |
+
{%- else %}
|
| 96 |
+
{{- raise_exception('arguments or parameters are mandatory: ' ~ tool_call) }}
|
| 97 |
+
{%- endif %}
|
| 98 |
+
{%- if arguments is string %}
|
| 99 |
+
{{- "<tool_call>" }}{"name": "{{- tool_call.name }}", "arguments": {{ arguments }}}{{- "</tool_call>" }}
|
| 100 |
+
{%- else %}
|
| 101 |
+
{{- "<tool_call>" }}{"name": "{{- tool_call.name }}", "arguments": {{ arguments | tojson(ensure_ascii=False) | safe }}}{{- "</tool_call>" }}
|
| 102 |
+
{%- endif %}
|
| 103 |
+
{%- if not loop.last %}
|
| 104 |
+
{{- "\n" }}
|
| 105 |
+
{%- endif %}
|
| 106 |
+
|
| 107 |
+
{%- endfor %}
|
| 108 |
+
{%- endif %}
|
| 109 |
+
{{- end_of_turn -}}
|
| 110 |
+
|
| 111 |
+
{%- elif role == "tool" %}
|
| 112 |
+
{%- if i == 0 or messages[i - 1].role != "tool" %}
|
| 113 |
+
{{- role_indicators['tool'] }}
|
| 114 |
+
{%- endif %}
|
| 115 |
+
{%- if msg.content is defined %}
|
| 116 |
+
{%- if msg.content is string %}
|
| 117 |
+
{{- "<tool_result>" }}{{ msg.content }}{{- "</tool_result>" }}
|
| 118 |
+
{%- else %}
|
| 119 |
+
{{- "<tool_result>" }}{{ msg.content | tojson(ensure_ascii=False) | safe }}{{- "</tool_result>" }}
|
| 120 |
+
{%- endif %}
|
| 121 |
+
{%- endif %}
|
| 122 |
+
{%- if loop.last or messages[i + 1].role != "tool" %}
|
| 123 |
+
{{- end_of_turn -}}
|
| 124 |
+
{%- else %}
|
| 125 |
+
{{- "\n" }}
|
| 126 |
+
{%- endif %}
|
| 127 |
+
|
| 128 |
+
{%- else %}
|
| 129 |
+
{{- role_indicators[role] }}
|
| 130 |
+
{%- if msg.content is string %}
|
| 131 |
+
{{- msg.content }}
|
| 132 |
+
{%- else %}
|
| 133 |
+
{%- for content in msg.content %}
|
| 134 |
+
{%- if content.type == 'image' %}
|
| 135 |
+
{%- set image_count.value = image_count.value + 1 %}
|
| 136 |
+
{%- if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<vision><image_pad></vision>
|
| 137 |
+
{%- elif content.type == 'video' %}
|
| 138 |
+
{%- set video_count.value = video_count.value + 1 %}
|
| 139 |
+
{%- if add_vision_id %}Video {{ video_count.value }}: {% endif %}<vision><video_pad></vision>
|
| 140 |
+
{%- elif content.type == 'text' %}
|
| 141 |
+
{{- content.text }}
|
| 142 |
+
{%- else %}
|
| 143 |
+
{{- content.text }}
|
| 144 |
+
{%- endif %}
|
| 145 |
+
{%- endfor %}
|
| 146 |
+
{%- endif %}
|
| 147 |
+
{{- end_of_turn -}}
|
| 148 |
+
{%- endif %}
|
| 149 |
+
{% endfor %}
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
{%- if add_generation_prompt %}
|
| 153 |
+
{{- role_indicators['assistant'] }}
|
| 154 |
+
{%- if enable_thinking is not defined or enable_thinking is true %}
|
| 155 |
+
{{- "<think>\n" }}
|
| 156 |
+
{%- else %}
|
| 157 |
+
{{- "<think>\n\n</think>\n\n" }}
|
| 158 |
+
{%- endif %}
|
| 159 |
+
{%- endif %}
|