xu song
commited on
Commit
·
10e2ac5
1
Parent(s):
c38b609
update
Browse files- models/cpp_qwen2.py +3 -9
models/cpp_qwen2.py
CHANGED
@@ -27,7 +27,8 @@ class Qwen2Simulator(Simulator):
|
|
27 |
|
28 |
def __init__(self, from_local=False):
|
29 |
if from_local:
|
30 |
-
self.hf_tokenizer = AutoTokenizer.from_pretrained(
|
|
|
31 |
self.llm = llama_cpp.Llama(
|
32 |
model_path="/workspace/xusong/huggingface/models/Qwen2-0.5B-Instruct-GGUF/qwen2-0_5b-instruct-fp16.gguf",
|
33 |
tokenizer=llama_cpp.llama_tokenizer.LlamaHFTokenizer(self.hf_tokenizer),
|
@@ -41,14 +42,11 @@ class Qwen2Simulator(Simulator):
|
|
41 |
tokenizer=llama_cpp.llama_tokenizer.LlamaHFTokenizer(self.hf_tokenizer),
|
42 |
verbose=False,
|
43 |
)
|
44 |
-
|
45 |
# warmup
|
46 |
|
47 |
-
|
48 |
### local
|
49 |
|
50 |
-
|
51 |
-
|
52 |
def generate_query(self, messages):
|
53 |
"""
|
54 |
:param messages:
|
@@ -79,7 +77,6 @@ class Qwen2Simulator(Simulator):
|
|
79 |
# for new_text in self._stream_generate(input_ids):
|
80 |
# yield new_text
|
81 |
|
82 |
-
|
83 |
def _generate(self, inputs):
|
84 |
"""
|
85 |
qwen2-0.5b-chat 有bug:有时user生成结束没有<|im_end|>,示例:
|
@@ -105,12 +102,9 @@ class Qwen2Simulator(Simulator):
|
|
105 |
return output_text
|
106 |
|
107 |
|
108 |
-
|
109 |
bot = Qwen2Simulator()
|
110 |
|
111 |
-
|
112 |
if __name__ == "__main__":
|
113 |
-
|
114 |
# messages = [
|
115 |
# {"role": "system", "content": "you are a helpful assistant"},
|
116 |
# {"role": "user", "content": "What is the capital of France?"}
|
|
|
27 |
|
28 |
def __init__(self, from_local=False):
|
29 |
if from_local:
|
30 |
+
self.hf_tokenizer = AutoTokenizer.from_pretrained(
|
31 |
+
"/workspace/xusong/huggingface/models/Qwen2-0.5B-Instruct/")
|
32 |
self.llm = llama_cpp.Llama(
|
33 |
model_path="/workspace/xusong/huggingface/models/Qwen2-0.5B-Instruct-GGUF/qwen2-0_5b-instruct-fp16.gguf",
|
34 |
tokenizer=llama_cpp.llama_tokenizer.LlamaHFTokenizer(self.hf_tokenizer),
|
|
|
42 |
tokenizer=llama_cpp.llama_tokenizer.LlamaHFTokenizer(self.hf_tokenizer),
|
43 |
verbose=False,
|
44 |
)
|
45 |
+
logger.info(f"llm has been initialized: {self.llm}")
|
46 |
# warmup
|
47 |
|
|
|
48 |
### local
|
49 |
|
|
|
|
|
50 |
def generate_query(self, messages):
|
51 |
"""
|
52 |
:param messages:
|
|
|
77 |
# for new_text in self._stream_generate(input_ids):
|
78 |
# yield new_text
|
79 |
|
|
|
80 |
def _generate(self, inputs):
|
81 |
"""
|
82 |
qwen2-0.5b-chat 有bug:有时user生成结束没有<|im_end|>,示例:
|
|
|
102 |
return output_text
|
103 |
|
104 |
|
|
|
105 |
bot = Qwen2Simulator()
|
106 |
|
|
|
107 |
if __name__ == "__main__":
|
|
|
108 |
# messages = [
|
109 |
# {"role": "system", "content": "you are a helpful assistant"},
|
110 |
# {"role": "user", "content": "What is the capital of France?"}
|