Update README.md
Browse files
README.md
CHANGED
@@ -39,44 +39,37 @@ llama3.2-3Bκ° λμλλ° νκ΅μ΄κ° ν¬ν¨ μλμλ€κ΅¬?? μ΄λ² Bllosso
|
|
39 |
|
40 |
|
41 |
```python
|
42 |
-
import
|
43 |
-
from transformers import AutoTokenizer
|
44 |
|
45 |
model_id = 'Bllossom/llama-3.2-Korean-Bllossom-3B'
|
46 |
-
|
47 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
48 |
-
model =
|
49 |
-
|
50 |
-
torch_dtype=torch.bfloat16,
|
51 |
-
device_map="auto",
|
52 |
)
|
|
|
53 |
instruction = "μ² μκ° 20κ°μ μ°νμ κ°μ§κ³ μμλλ° μν¬κ° μ λ°μ κ°μ Έκ°κ³ λ―Όμκ° λ¨μ 5κ°λ₯Ό κ°μ Έκ°μΌλ©΄ μ² μμκ² λ¨μ μ°νμ κ°―μλ λͺκ°μΈκ°μ?"
|
54 |
|
55 |
messages = [
|
56 |
{"role": "user", "content": f"{instruction}"}
|
57 |
]
|
58 |
|
59 |
-
|
60 |
-
messages,
|
61 |
-
|
62 |
-
|
63 |
-
).to(model.device)
|
64 |
-
|
65 |
-
terminators = [
|
66 |
-
tokenizer.convert_tokens_to_ids("<|end_of_text|>"),
|
67 |
-
tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
68 |
-
]
|
69 |
-
|
70 |
-
outputs = model.generate(
|
71 |
-
input_ids,
|
72 |
-
max_new_tokens=1024,
|
73 |
-
eos_token_id=terminators,
|
74 |
-
do_sample=True,
|
75 |
-
temperature=0.6,
|
76 |
-
top_p=0.9
|
77 |
)
|
78 |
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
```
|
81 |
```
|
82 |
μ² μκ° 20κ°μ μ°νμ κ°μ§κ³ μμκ³ μν¬κ° μ λ°μ κ°μ Έκ°λ©΄, μν¬κ° κ°μ Έκ° μ°νμ κ°―μλ 20 / 2 = 10κ°μ
λλ€.
|
|
|
39 |
|
40 |
|
41 |
```python
|
42 |
+
from llama_cpp import Llama
|
43 |
+
from transformers import AutoTokenizer
|
44 |
|
45 |
model_id = 'Bllossom/llama-3.2-Korean-Bllossom-3B'
|
|
|
46 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
47 |
+
model = Llama(
|
48 |
+
model_path='llama-3.2-Korean-Bllossom-3B-gguf-Q4_K_M.gguf'
|
|
|
|
|
49 |
)
|
50 |
+
|
51 |
instruction = "μ² μκ° 20κ°μ μ°νμ κ°μ§κ³ μμλλ° μν¬κ° μ λ°μ κ°μ Έκ°κ³ λ―Όμκ° λ¨μ 5κ°λ₯Ό κ°μ Έκ°μΌλ©΄ μ² μμκ² λ¨μ μ°νμ κ°―μλ λͺκ°μΈκ°μ?"
|
52 |
|
53 |
messages = [
|
54 |
{"role": "user", "content": f"{instruction}"}
|
55 |
]
|
56 |
|
57 |
+
prompt = tokenizer.apply_chat_template(
|
58 |
+
messages,
|
59 |
+
tokenize = False,
|
60 |
+
add_generation_prompt=True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
)
|
62 |
|
63 |
+
generation_kwargs = {
|
64 |
+
"max_tokens":512,
|
65 |
+
"stop":["<|eot_id|>"],
|
66 |
+
"echo":True,
|
67 |
+
"top_p":0.9,
|
68 |
+
"temperature":0.6,
|
69 |
+
}
|
70 |
+
|
71 |
+
resonse_msg = model(prompt, **generation_kwargs)
|
72 |
+
print(resonse_msg['choices'][0]['text'][len(prompt):])
|
73 |
```
|
74 |
```
|
75 |
μ² μκ° 20κ°μ μ°νμ κ°μ§κ³ μμκ³ μν¬κ° μ λ°μ κ°μ Έκ°λ©΄, μν¬κ° κ°μ Έκ° μ°νμ κ°―μλ 20 / 2 = 10κ°μ
λλ€.
|