limhyeonseok commited on
Commit
b881e7b
β€’
1 Parent(s): e07d0d3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +41 -0
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