limhyeonseok
commited on
Commit
β’
b881e7b
1
Parent(s):
e07d0d3
Update README.md
Browse files
README.md
CHANGED
@@ -84,7 +84,48 @@ Refer to the [original model card](https://huggingface.co/MLP-KTLim/llama-3-Kore
|
|
84 |
|
85 |
|
86 |
## Example code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
|
|
|
|
|
|
88 |
|
89 |
|
90 |
|
|
|
84 |
|
85 |
|
86 |
## Example code
|
87 |
+
'''python
|
88 |
+
!CMAKE_ARGS="-DLLAMA_CUDA=on" pip install llama-cpp-python
|
89 |
+
!huggingface-cli download MLP-KTLim/llama-3-Korean-Bllossom-8B-4bit --local-dir='YOUR-LOCAL-FOLDER-PATH'
|
90 |
+
|
91 |
+
from llama_cpp import Llama
|
92 |
+
from transformers import AutoTokenizer
|
93 |
+
|
94 |
+
model_id = 'MLP-KTLim/llama-3-Korean-Bllossom-8B-4bit'
|
95 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
96 |
+
model = Llama(
|
97 |
+
model_path='YOUR-LOCAL-FOLDER-PATH/llama-3-Korean-Bllossom-8B-Q4_K_M.gguf',
|
98 |
+
n_ctx=512,
|
99 |
+
n_gpu_layers=-1 # Number of model layers to offload to GPU
|
100 |
+
)
|
101 |
+
|
102 |
+
PROMPT = \
|
103 |
+
'''λΉμ μ μ μ©ν AI μ΄μμ€ν΄νΈμ
λλ€. μ¬μ©μμ μ§μμ λν΄ μΉμ νκ³ μ ννκ² λ΅λ³ν΄μΌ ν©λλ€.
|
104 |
+
You are a helpful AI assistant, you'll need to answer users' queries in a friendly and accurate manner.'''
|
105 |
+
|
106 |
+
instruction = 'Your Instruction'
|
107 |
+
|
108 |
+
messages = [
|
109 |
+
{"role": "system", "content": f"{PROMPT}"},
|
110 |
+
{"role": "user", "content": f"{instruction}"}
|
111 |
+
]
|
112 |
+
|
113 |
+
prompt = tokenizer.apply_chat_template(
|
114 |
+
messages,
|
115 |
+
tokenize = False,
|
116 |
+
add_generation_prompt=True
|
117 |
+
)
|
118 |
+
|
119 |
+
generation_kwargs = {
|
120 |
+
"max_tokens":512,
|
121 |
+
"stop":["<|eot_id|>"],
|
122 |
+
"echo":True, # Echo the prompt in the output
|
123 |
+
"top_k":1 # This is essentially greedy decoding, since the model will always return the highest-probability token. Set this value > 1 for sampling decoding
|
124 |
+
}
|
125 |
|
126 |
+
resonse_msg = model(prompt, **generation_kwargs)
|
127 |
+
print(resonse_msg['choices'][0]['text'][len(prompt):])
|
128 |
+
'''
|
129 |
|
130 |
|
131 |
|