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
File size: 1,173 Bytes
bfd235a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | {%- 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 -%}
|