Commit 4536fa79 authored by zhouxiang's avatar zhouxiang
Browse files

提交完善

parent 3a1bb385
...@@ -23,8 +23,8 @@ fastllm_weight_type_dict = { ...@@ -23,8 +23,8 @@ fastllm_weight_type_dict = {
"embedding": 2 "embedding": 2
} }
v = np.random.randint(-127, 127, [10, 20]); v = np.random.randint(-127, 127, [10, 20])
temp = v; temp = v
c_max = np.expand_dims(np.abs(v).max(axis = -1), -1) c_max = np.expand_dims(np.abs(v).max(axis = -1), -1)
c_scale = c_max / 127.0 c_scale = c_max / 127.0
v = (v / c_scale + 128.5).clip(1, 255).astype(np.uint8) v = (v / c_scale + 128.5).clip(1, 255).astype(np.uint8)
...@@ -36,8 +36,8 @@ def write_int8(fo, v): ...@@ -36,8 +36,8 @@ def write_int8(fo, v):
fo.write(struct.pack('i', 3)) fo.write(struct.pack('i', 3))
fo.write(struct.pack('i', 0)) fo.write(struct.pack('i', 0))
for i in range(c_max.shape[0]): for i in range(c_max.shape[0]):
fo.write(struct.pack('f', -c_max[i][0])); fo.write(struct.pack('f', -c_max[i][0]))
fo.write(struct.pack('f', c_max[i][0])); fo.write(struct.pack('f', c_max[i][0]))
fo.write(v.data) fo.write(v.data)
def write_int4(fo, v): def write_int4(fo, v):
...@@ -51,8 +51,8 @@ def write_int4(fo, v): ...@@ -51,8 +51,8 @@ def write_int4(fo, v):
fo.write(struct.pack('i', 8)) fo.write(struct.pack('i', 8))
fo.write(struct.pack('i', 0)) fo.write(struct.pack('i', 0))
for i in range(c_min.shape[0]): for i in range(c_min.shape[0]):
fo.write(struct.pack('f', c_min[i][0])); fo.write(struct.pack('f', c_min[i][0]))
fo.write(struct.pack('f', c_max[i][0])); fo.write(struct.pack('f', c_max[i][0]))
fo.write(v.data) fo.write(v.data)
def tofile(exportPath, def tofile(exportPath,
......
...@@ -21,9 +21,9 @@ if __name__ == "__main__": ...@@ -21,9 +21,9 @@ if __name__ == "__main__":
history = [] history = []
print("输入内容即可进行对话,clear 清空对话历史,stop 终止程序") print("输入内容即可进行对话,clear 清空对话历史,stop 终止程序")
continue continue
print("AI:", end = ""); print("AI:", end = "")
curResponse = ""; curResponse = ""
for response in model.stream_response(query, history = history): for response in model.stream_response(query, history = history):
curResponse += response; curResponse += response
print(response, flush = True, end = "") print(response, flush = True, end = "")
history.append((query, curResponse)) history.append((query, curResponse))
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment