jackJessada
commited on
Commit
•
f818e52
1
Parent(s):
971e636
add GGUF
Browse files
README.md
CHANGED
@@ -78,6 +78,53 @@ generated_ids = model.generate(
|
|
78 |
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
79 |
print(response)
|
80 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
## **Evaluation Performance**
|
83 |
| Model | m3exam | thaiexam | xcopa | belebele | xnli | thaisentiment | XL sum | flores200 eng > th | flores200 th > eng | iapp | AVG(NLU) | AVG(MC) | AVG(NLG) |
|
|
|
78 |
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
79 |
print(response)
|
80 |
```
|
81 |
+
## **Implementation for GGUF**
|
82 |
+
|
83 |
+
```python
|
84 |
+
%pip install --quiet https://github.com/abetlen/llama-cpp-python/releases/download/v0.2.90-cu124/llama_cpp_python-0.2.90-cp310-cp310-linux_x86_64.whl
|
85 |
+
import transformers
|
86 |
+
import torch
|
87 |
+
from llama_cpp import Llama
|
88 |
+
import os
|
89 |
+
import requests
|
90 |
+
|
91 |
+
local_dir = "your local dir"
|
92 |
+
directory_path = r'{local_dir}/Pathumma-llm-text-1.0.0'
|
93 |
+
if not os.path.exists(directory_path):
|
94 |
+
os.mkdir(directory_path)
|
95 |
+
|
96 |
+
if not os.path.exists(f'{local_dir}/Pathumma-llm-text-1.0.0/Pathumma-llm-it-7b-Q4_K_M.gguf'):
|
97 |
+
!wget -O f'{local_dir}/Pathumma-llm-text-1.0.0/Pathumma-llm-it-7b-Q4_K_M.gguf' "https://huggingface.co/nectec/Pathumma-llm-text-1.0.0/resolve/main/Pathumma-llm-it-7b-Q4_K_M.gguf?download=true"
|
98 |
+
|
99 |
+
# Initialize the Llama model
|
100 |
+
llm = Llama(model_path=f'{local_dir}/Pathumma-llm-text-1.0.0/Pathumma-llm-it-7b-Q4_K_M.gguf', n_gpu_layers=-1, n_ctx=8192,verbose=False)
|
101 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained("nectec/Pathumma-llm-text-1.0.0")
|
102 |
+
|
103 |
+
memory = [{'content': 'You are Pathumma LLM, created by NECTEC (National Electronics and Computer Technology Center). Your are a helpful assistant.', 'role': 'system'},]
|
104 |
+
|
105 |
+
def generate(instuction,memory=memory):
|
106 |
+
memory.append({'content': instuction, 'role': 'user'})
|
107 |
+
p = tokenizer.apply_chat_template(
|
108 |
+
memory,
|
109 |
+
tokenize=False,
|
110 |
+
add_generation_prompt=True
|
111 |
+
)
|
112 |
+
response = llm(
|
113 |
+
p,
|
114 |
+
max_tokens=2048,
|
115 |
+
temperature=0.2,
|
116 |
+
top_p=0.95,
|
117 |
+
repeat_penalty=1.1,
|
118 |
+
top_k=40,
|
119 |
+
min_p=0.05,
|
120 |
+
stop=["<|im_end|>"]
|
121 |
+
)
|
122 |
+
output = response['choices'][0]['text']
|
123 |
+
memory.append({'content': output, 'role': 'assistant'})
|
124 |
+
return output
|
125 |
+
|
126 |
+
print(generate("คุณคือใคร"))
|
127 |
+
```
|
128 |
|
129 |
## **Evaluation Performance**
|
130 |
| Model | m3exam | thaiexam | xcopa | belebele | xnli | thaisentiment | XL sum | flores200 eng > th | flores200 th > eng | iapp | AVG(NLU) | AVG(MC) | AVG(NLG) |
|