|
--- |
|
license: apache-2.0 |
|
datasets: |
|
- brian-lim/smile_style_orca |
|
language: |
|
- ko |
|
--- |
|
# Korean Style Transfer |
|
|
|
This model is a fine-tuned version of [Synatra-7B-v0.3-dpo](https://huggingface.co/maywell/Synatra-7B-v0.3-dpo) using a Korean style dataset provided by Smilegate AI (https://github.com/smilegate-ai/korean_smile_style_dataset/tree/main). |
|
Since the original dataset is tabular and not fit for training the LLM, I have preprocessed it into an instruction-input-output format, which can be found [here](https://huggingface.co/datasets/brian-lim/smile_style_orca). |
|
The dataset is then fed into the ChatML template. Feel free to use my version of the dataset as needed. |
|
|
|
ν΄λΉ λͺ¨λΈμ [Synatra-7B-v0.3-dpo](https://huggingface.co/maywell/Synatra-7B-v0.3-dpo) λͺ¨λΈμ μ€λ§μΌκ²μ΄νΈ AIμμ μ 곡νλ Smile style λ°μ΄ν°μ
μΌλ‘ νμΈνλ νμ΅λλ€. |
|
κΈ°μ‘΄ λ°μ΄ν°μ
μ ν
μ΄λΈ ννλ‘ λμ΄μμ΄ ν΄λΉ λ°μ΄ν°λ₯Ό instruction-input-output ννλ‘ λ§λ€μκ³ , [μ¬κΈ°](https://huggingface.co/datasets/brian-lim/smile_style_orca)μμ νμΈ κ°λ₯ν©λλ€. |
|
λ°μ΄ν°μ
μ λΆλ¬μ¨ λ€ ChatML νμμ λ§μΆ° νλ ¨ λ°μ΄ν° ꡬμΆμ ν λ€ μ§ννμ΅λλ€. νμνμλ€λ©΄ μμ λ‘κ² μ¬μ©νμκΈ° λ°λλλ€. |
|
|
|
|
|
# How to use |
|
|
|
```python |
|
>>> import torch |
|
>>> from transformers import AutoModelForCausalLM, AutoTokenizer |
|
|
|
device = 'cuda' if torch.cuda.is_available() else 'cpu' |
|
|
|
tokenizer = AutoTokenizer.from_pretrained('brian-lim/smile-style-transfer') |
|
model = AutoModelForCausalLM.from_pretrained('brian-lim/smile-style-transfer', device_map = device) |
|
|
|
prompts = {'informal': 'μ£Όμ΄μ§ κΈμ κ°λ₯ν νμμ μ΄μ§ μκ³ λ±λ±νμ§ μμ λνμ²΄λ‘ λ°κΏμ€.', |
|
'android': 'μ£Όμ΄μ§ κΈμ κ°λ₯ν μλλ‘μ΄λ λ‘λ΄κ³Ό κ°μ λνμ²΄λ‘ λ°κΏμ€.', |
|
'azae': 'μ£Όμ΄μ§ κΈμ κ°λ₯ν μμ μ¨κ°μ λ§ν¬λ‘ λ°κΏμ€.', |
|
'chat': 'μ£Όμ΄μ§ κΈμ κ°λ₯ν μΈν°λ·μμ μ¬μ©νλ λ§ν¬λ‘ λ°κΏμ€.', |
|
'choding': 'μ£Όμ΄μ§ κΈμ κ°λ₯ν μ΄λ±νμμ²λΌ μ§§κ² μ€μΈ λνμ²΄λ‘ λ°κΏμ€.', |
|
'emoticon': 'μ£Όμ΄μ§ κΈμ κ°λ₯ν μ΄λͺ¨ν°μ½μ΄ λ€μ΄κ° λνμ²΄λ‘ λ°κΏμ€.', |
|
'enfp': 'μ£Όμ΄μ§ κΈμ κ°λ₯ν νκΈ°μ°¨λ©΄μ 곡κ°μ λ§μ΄ νλ μΉμ ν λνμ²΄λ‘ λ°κΏμ€.', |
|
'gentle' : 'μ£Όμ΄μ§ κΈμ κ°λ₯ν βμβλ‘ λλμ§ μμΌλ©΄μ κΉλν λνμ²΄λ‘ λ°κΏμ€.', |
|
'halbae' : 'μ£Όμ΄μ§ κΈμ κ°λ₯ν μ°λ₯μ΄ μλ ν μλ²μ§ κ°μ 맑ν¬λ‘ λ°κΏμ€.', |
|
'halmae' : 'μ£Όμ΄μ§ κΈμ κ°λ₯ν λΉμμ΄κ° λ€μ΄κ°λ ν λ¨Έλ κ°μ 맑ν¬λ‘ λ°κΏμ€.', |
|
'joongding': 'μ£Όμ΄μ§ κΈμ κ°λ₯ν μ€νκ΅ 2νλ
μ λ§ν¬λ‘ λ°κΏμ€.', |
|
'king': 'μ£Όμ΄μ§ κΈμ κ°λ₯ν μ‘°μ μλ μμ λ§ν¬λ‘ λ°κΏμ€.', |
|
'seonbi': 'μ£Όμ΄μ§ κΈμ κ°λ₯ν μ‘°μ μλ μ λΉμ λ§ν¬λ‘ λ°κΏμ€.', |
|
'sosim': 'μ£Όμ΄μ§ κΈμ κ°λ₯ν μμ£Ό μμ¬νκ³ μ‘°μ¬μ€λ¬μ΄ λ§ν¬λ‘ λ°κΏμ€.', |
|
'translator': 'μ£Όμ΄μ§ κΈμ κ°λ₯ν μ΄μν νκ΅μ΄ λ²μ λ§ν¬λ‘ λ°κΏμ€.', |
|
} |
|
query = '[INPUT]: μλ
νμΈμ. μμ¦ λ μ¨κ° λ§μ΄ μμνλ€μ \n[OUTPUT]: ' |
|
|
|
input_query = prompts['king'] + query |
|
input_tokenized = tokenizer(input_query,return_tensors="pt").to(device) |
|
|
|
g_config = GenerationConfig(temperature=0.3, |
|
repetition_penalty=1.2, |
|
max_new_tokens=768, |
|
do_sample=True, |
|
) |
|
output = model.generate(**input_tokenized, |
|
generation_config=g_config, |
|
pad_token_id=tokenizer.eos_token_id, |
|
eos_token_id=tokenizer.eos_token_id,) |
|
output_text = tokenizer.decode(output.detach().cpu().numpy()[0]) |
|
output_text = output_text[output_text.find('[OUTPUT]'):] |
|
print(output_text) |
|
``` |
|
|
|
|
|
--- |
|
license: apache-2.0 |
|
--- |