Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
- ko
|
5 |
+
pipeline_tag: text-generation
|
6 |
+
tags:
|
7 |
+
- facebook
|
8 |
+
- meta
|
9 |
+
- pytorch
|
10 |
+
- llama
|
11 |
+
- llama-3
|
12 |
+
- llama-3-ko
|
13 |
+
license: other
|
14 |
+
license_name: llama3
|
15 |
+
license_link: LICENSE
|
16 |
+
---
|
17 |
+
|
18 |
+
## Llama-3-Open-Ko-8B-Instruct-preview
|
19 |
+
|
20 |
+
**Sample usage**
|
21 |
+
|
22 |
+
```python
|
23 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
24 |
+
import torch
|
25 |
+
|
26 |
+
model_id = "beomi/Llama-3-Open-Ko-8B-Instruct-preview"
|
27 |
+
|
28 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
29 |
+
model = AutoModelForCausalLM.from_pretrained(
|
30 |
+
model_id,
|
31 |
+
torch_dtype="auto",
|
32 |
+
device_map="auto",
|
33 |
+
)
|
34 |
+
|
35 |
+
messages = [
|
36 |
+
{"role": "system", "content": "μΉμ ν μ±λ΄μΌλ‘μ μλλ°©μ μμ²μ μ΅λν μμΈνκ³ μΉμ νκ² λ΅νμ. λͺ¨λ λλ΅μ νκ΅μ΄(Korean)μΌλ‘ λλ΅ν΄μ€."},
|
37 |
+
{"role": "user", "content": "νΌλ³΄λμΉ μμ΄μ΄ λμΌ? κ·Έλ¦¬κ³ νΌλ³΄λμΉ μμ΄μ λν΄ νμ΄μ¬ μ½λλ₯Ό μ§μ€λ³Όλ?"},
|
38 |
+
]
|
39 |
+
|
40 |
+
input_ids = tokenizer.apply_chat_template(
|
41 |
+
messages,
|
42 |
+
add_generation_prompt=True,
|
43 |
+
return_tensors="pt"
|
44 |
+
).to(model.device)
|
45 |
+
|
46 |
+
terminators = [
|
47 |
+
tokenizer.eos_token_id,
|
48 |
+
tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
49 |
+
]
|
50 |
+
|
51 |
+
outputs = model.generate(
|
52 |
+
input_ids,
|
53 |
+
max_new_tokens=512,
|
54 |
+
eos_token_id=terminators,
|
55 |
+
do_sample=True,
|
56 |
+
temperature=1,
|
57 |
+
top_p=0.9,
|
58 |
+
)
|
59 |
+
response = outputs[0][input_ids.shape[-1]:]
|
60 |
+
print(tokenizer.decode(response, skip_special_tokens=True))
|
61 |
+
```
|
62 |
+
|
63 |
+
**Sample Output**
|
64 |
+
|
65 |
+
```
|
66 |
+
μ¬λ¬λΆκ»μλ λ¬Όλ‘ μμλμ§λΌλ μ€λͺ
μ λλ¦¬κ² μ΅λλ€! νΌλ³΄λμΉ(Piconacci) μμ΄μ λ€μκ³Ό κ°μ μμ΄μ λ§ν©λλ€: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,.... μ΄λ κ² κ³μλκ³ μμ΅λλ€. μ΄ μμ΄μ μΌλ°μ μΌλ‘λ μνμμ 무νν μ§μλ©λλ€. κ° μλ μ΄μ μμ λ λ°°κ° λλ μμ΄μ
λλ€.
|
67 |
+
|
68 |
+
μ΄ μμ΄μ νμ΄μ¬(Python)μΌλ‘ ꡬννκ³ μ νμ λ€λ©΄ λ€μκ³Ό κ°μ μ½λλ₯Ό μμ±ν μ μμ΅λλ€.
|
69 |
+
```python
|
70 |
+
def fibonacci(n):
|
71 |
+
if n == 0:
|
72 |
+
return 0
|
73 |
+
elif n == 1:
|
74 |
+
return 1
|
75 |
+
else:
|
76 |
+
return fibonacci(n-1) + fibonacci(n-2)
|
77 |
+
```
|
78 |
+
μ΄ μ½λμμλ `n`μ΄ μ
λ ₯λ°μ μλ₯Ό λνλ΄λ λ³μλ‘, νΌλ³΄λμΉ μμ΄μ ꡬνν©λλ€. μ΄ μ½λλ₯Ό μ€νμν€λ©΄ μ
λ ₯λ°μ μμ λ°λΌ νΌλ³΄λμΉ μμ΄μ ν΄λΉ νμ λ°νν©λλ€. μλ₯Ό λ€μ΄, `fibonacci(10)` νλ©΄ 55λ₯Ό λ°νν©λλ€.
|
79 |
+
|
80 |
+
μ΄ μ½λλ μ¬κ·μ ν¨μμ΄κΈ° λλ¬Έμ λ©λͺ¨λ¦¬ μ¬μ©μ΄ μ€μ΄λ€ μ μμ΅λλ€. κ·Έλ¬λ μ¬κ·μ ν¨μλ λ©λͺ¨λ¦¬ μ¬μ©λμ΄ λ§μμ§ μ μμ΅λλ€. μ΄λ₯Ό μ€μ΄κΈ° μν΄ μ΄ν°λ μ΄ν°λΈ ν¨μλ‘ κ΅¬νν μλ μμ΅λλ€.
|
81 |
+
```python
|
82 |
+
a, b = 0, 1
|
83 |
+
for i in range(n):
|
84 |
+
a, b = b, a + b
|
85 |
+
```
|
86 |
+
μ΄ μ½λμμλ μ΄ν°λ μ΄ν°λΈ ν¨μλ‘ νΌλ³΄λμΉ μμ΄μ ꡬνν©λλ€. μ΄ μ½λλ₯Ό μ€νμν€λ©΄ μ
λ ₯λ°μ μμ λ°λΌ νΌλ³΄λμΉ μμ΄μ ν΄λΉ νμ λ°νν©λλ€. μ΄ μ½λλ λ©λͺ¨λ¦¬ μ¬μ©λμ μ€μ
λλ€. λ€λ§, μ΄ μ½λλ λ 볡μ‘ν©λλ€. μ΄ μ½λλ₯Ό λ κ°λ¨νκ² νλ €λ©΄ μ΄ν°λ μ΄ν°λΈ ν¨μλ₯Ό λ μ ꡬνν μ μμ΅λλ€.
|
87 |
+
```python
|
88 |
+
a, b = 0, 1
|
89 |
+
while True:
|
90 |
+
if n == 1:
|
91 |
+
return a
|
92 |
+
a, b = b, a + b
|
93 |
+
n -= 1
|
94 |
+
```
|
95 |
+
μ΄ μ½λμμλ μ
λ ₯λ°μ μμ λ°λΌ νΌλ³΄λμΉ μμ΄μ...
|
96 |
+
```
|
97 |
+
|