Feature Extraction
Transformers
Safetensors
Korean
han2han
text-generation
hanja
hangul
historical-korean
encoder-decoder
custom_code
Instructions to use cadazar/han2han-pt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cadazar/han2han-pt with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="cadazar/han2han-pt", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("cadazar/han2han-pt", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download chat_template.jinja from cadazar/han2han-pt: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/cadazar/han2han-pt/resolve/main/chat_template.jinja
- Command line
-
hf download hf://cadazar/han2han-pt/chat_template.jinja
-
curl -L -o chat_template.jinja https://huggingface.co/cadazar/han2han-pt/resolve/main/chat_template.jinja
1.17 kB
| {%- if messages and messages[0]['role'] == 'system' -%} | |
| {%- if messages[0]['content'] is string -%} | |
| {{- '<|system|>' + messages[0]['content'] -}} | |
| {%- else -%} | |
| {{- '<|system|>' + messages[0]['content'] | selectattr('type', 'equalto', 'text') | map(attribute='text') | join('') -}} | |
| {%- endif -%} | |
| {%- set loop_messages = messages[1:] -%} | |
| {%- else -%} | |
| {%- set loop_messages = messages -%} | |
| {%- endif -%} | |
| {%- for message in loop_messages -%} | |
| {%- if message['role'] not in ['user', 'assistant'] -%} | |
| {{- raise_exception('Han2Han chat supports a leading system message, then user and assistant turns; got role ' + message['role']) -}} | |
| {%- endif -%} | |
| {%- if message['content'] is string -%} | |
| {%- set content = message['content'] -%} | |
| {%- else -%} | |
| {%- set content = message['content'] | selectattr('type', 'equalto', 'text') | map(attribute='text') | join('') -%} | |
| {%- endif -%} | |
| {{- '<|' + message['role'] + '|>' + content + '<|end_of_turn|>' -}} | |
| {%- endfor -%} | |
| {%- if add_generation_prompt -%} | |
| {{- '<|think|>' if enable_thinking is defined and enable_thinking else '<|assistant|>' -}} | |
| {%- endif -%} | |