File size: 2,189 Bytes
a9819c3
 
 
 
 
 
 
 
 
 
 
 
 
4961031
a9819c3
 
 
4961031
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a9819c3
 
 
4961031
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
base_model: beomi/Llama-3-Open-Ko-8B
language:
- en
license: apache-2.0
tags:
- text-generation-inference
- transformers
- unsloth
- llama
- trl
---

- **Developed by:** lwef
- **License:** apache-2.0
- **Finetuned from model :** beomi/Llama-3-Open-Ko-8B

# korean dialogue summary fine-tuned model
# how to use
```python
prompt_template = '''
μ•„λž˜ λŒ€ν™”λ₯Ό μš”μ•½ν•΄ μ£Όμ„Έμš”. λŒ€ν™” ν˜•μ‹μ€ '#λŒ€ν™” μ°Έμ—¬μž#: λŒ€ν™” λ‚΄μš©'μž…λ‹ˆλ‹€.
### λŒ€ν™” >>>{dialogue}

### μš”μ•½ >>>'''

if True:
    from unsloth import FastLanguageModel
    model, tokenizer = FastLanguageModel.from_pretrained(
        model_name = "lwef/llama3-8B-ko-dialogue-summary-finetuned", # YOUR MODEL YOU USED FOR TRAINING
        max_seq_length = 2048,
        dtype = None,
        load_in_4bit = True,
    )
    FastLanguageModel.for_inference(model) # Enable native 2x faster inference
dialogue = '''#P01#: μ•„ ν–‰μ‚Ά 과제 λ„ˆλ¬΄ μ–΄λ €μ›Œ... 5μͺ½ μ“Έκ²Œ μ—†λŠ”λ° γ…‘γ…‘ #P02#: λͺ¬λƒλͺ¬λƒλ„ˆκ°€λ”μž˜μ¨ γ…Žγ…Ž #P01#: 5μͺ½ λŒ€μΆ© μ˜μ‹μ˜ νλ¦„λŒ€λ‘œ μ­‰ 써야지..이제 1μͺ½μ”€ ;; 5μͺ½ μ—λŠ” λ„€μ€„λ§Œ 적어야지 #P02#: μ•ˆλŒ€... λ­”κ°€λΆ„λŸ‰μ€‘μš”ν• κ±°κ°™μ•„ κ±°μ˜κ½‰μ±„μ›Œμ„œμ“°μ…ˆ #P01#: λͺ»μ¨ 쓸말업써 #P02#: μ΄κ±°μ€‘κ°„λŒ€μ²΄μ—¬?? #P01#: γ„΄γ„΄ κ·Έλƒ₯ κ³Όμ œμž„ κ·Έλž˜μ„œ 더 μ§œμ¦λ‚¨'''

formatted_prompt = prompt_template.format(dialogue=dialogue)

# ν† ν¬λ‚˜μ΄μ§•
inputs = tokenizer(
    formatted_prompt,
    return_tensors="pt"
).to("cuda")

outputs = model.generate(
    **inputs,
    max_new_tokens = 128,
    eos_token_id=tokenizer.eos_token_id, # EOS 토큰을 μ‚¬μš©ν•˜μ—¬ λͺ…μ‹œμ μœΌλ‘œ 좜λ ₯의 끝을 지정.
    use_cache = True
)
decoded_outputs = tokenizer.batch_decode(outputs, skip_special_tokens=True)
result = decoded_outputs[0]

print(result)
result = result.split('### μš”μ•½ >>>')[-1].strip()
print(result)
```

This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.

[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
I highly recommend checking the Unsloth notebook.