use int8 model
Browse files
app.py
CHANGED
@@ -1,3 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Credit:
|
2 |
# https://huggingface.co/spaces/ljsabc/Fujisaki/blob/main/app.py
|
3 |
|
@@ -8,7 +24,7 @@ from peft import PeftModel
|
|
8 |
from transformers import AutoTokenizer, GenerationConfig, AutoModel
|
9 |
|
10 |
|
11 |
-
model = AutoModel.from_pretrained("
|
12 |
tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True, revision="4de8efe")
|
13 |
peft_path = 'KumaTea/twitter'
|
14 |
model = PeftModel.from_pretrained(
|
@@ -90,7 +106,7 @@ def evaluate_stream(msg, history, temperature, top_p):
|
|
90 |
|
91 |
|
92 |
title = """<h1 align="center">KumaGLM</h1>
|
93 |
-
<h3 align='center'>这是一个 AI Kuma
|
94 |
<p align='center'>采样范围 2020/06/13 - 2023/04/15</p>"""
|
95 |
footer = """<p align='center'>
|
96 |
本项目基于
|
|
|
1 |
+
with open('/usr/local/lib/python3.8/dist-packages/torch/nn/parameter.py', 'r') as f:
|
2 |
+
text = f.read()
|
3 |
+
|
4 |
+
if 'if data.dtype == torch.int8' not in text:
|
5 |
+
text = text.replace(
|
6 |
+
' return torch.Tensor._make_subclass(cls, data, requires_grad)',
|
7 |
+
' if data.dtype == torch.int8:\n' \
|
8 |
+
' requires_grad = False\n' \
|
9 |
+
' return torch.Tensor._make_subclass(cls, data, requires_grad)'
|
10 |
+
)
|
11 |
+
|
12 |
+
with open('/usr/local/lib/python3.8/dist-packages/torch/nn/parameter.py', 'w') as f:
|
13 |
+
f.write(text)
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
# Credit:
|
18 |
# https://huggingface.co/spaces/ljsabc/Fujisaki/blob/main/app.py
|
19 |
|
|
|
24 |
from transformers import AutoTokenizer, GenerationConfig, AutoModel
|
25 |
|
26 |
|
27 |
+
model = AutoModel.from_pretrained("KumaTea/twitter-int8", trust_remote_code=True).float()
|
28 |
tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True, revision="4de8efe")
|
29 |
peft_path = 'KumaTea/twitter'
|
30 |
model = PeftModel.from_pretrained(
|
|
|
106 |
|
107 |
|
108 |
title = """<h1 align="center">KumaGLM</h1>
|
109 |
+
<h3 align='center'>这是一个 AI Kuma,你可以与他聊天,或者直接在文本框按下Enter</h3>
|
110 |
<p align='center'>采样范围 2020/06/13 - 2023/04/15</p>"""
|
111 |
footer = """<p align='center'>
|
112 |
本项目基于
|