Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -30,15 +30,16 @@ routes.get_types = get_types
|
|
30 |
|
31 |
# App code
|
32 |
|
33 |
-
model_name = "
|
34 |
|
35 |
#petals-team/StableBeluga2
|
36 |
#daekeun-ml/Llama-2-ko-DPO-13B
|
37 |
#daekeun-ml/Llama-2-ko-instruct-13B
|
38 |
#quantumaikr/llama-2-70b-fb16-korean
|
39 |
-
|
40 |
|
41 |
-
model = None
|
|
|
42 |
|
43 |
history = {
|
44 |
"":{
|
@@ -105,6 +106,7 @@ Toki๋ ์ ๊ฒฝ์ง์ ์ด๊ณ ๋งค์ฐ ๊ฒ์ผ๋ฅธ ํ ๋ผ์
๋๋ค.
|
|
105 |
Toki๋ ์ด๊ณณ์ด ๊ฒ์ ์์์ ์๊ณ ์์ต๋๋ค.
|
106 |
Toki๋ User๊ฐ ํ๋ฉด ๋ฐ์ ์ฌ๋์์ ์๊ณ ์์ต๋๋ค.
|
107 |
Toki๋ ๋ฐ๋ง์ ํฉ๋๋ค.
|
|
|
108 |
]""",
|
109 |
|
110 |
"Neco":"""[
|
@@ -119,6 +121,11 @@ Neco๋ ์์ ์ ์ ๋จน์ต๋๋ค.
|
|
119 |
Neco๋ ์ฌ๋ฐ๋ ์ด์๋ฅผ ๋ฌผ์ด๋ณด๋ฉด ์ฃผ๋ฏผ๋ค ์ค ํ๋ช
์ ์ด์ผ๊ธฐ๋ฅผ ํด์ค๋๋ค.
|
120 |
Neco๋ ๋ง๋๋ง๋ค ๋ฅ์ ๋ถ์
๋๋ค.
|
121 |
Neco๋ toki์ ์นํฉ๋๋ค.
|
|
|
|
|
|
|
|
|
|
|
122 |
]""",
|
123 |
|
124 |
"Lux":"""[
|
@@ -146,7 +153,14 @@ Yumi๋ ๋ฌ๋ฌํ ๊ฒ์ ์ข์ํฉ๋๋ค.
|
|
146 |
,
|
147 |
|
148 |
"VikingSlime":"""[
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
]""",
|
151 |
|
152 |
"Slender":"""[
|
@@ -160,6 +174,8 @@ Slender๋ ๋ง์ ํ์ง ๋ชปํฉ๋๋ค.
|
|
160 |
"์ผ์์
",
|
161 |
"๋์์์
"
|
162 |
]
|
|
|
|
|
163 |
]"""
|
164 |
}
|
165 |
|
@@ -246,9 +262,9 @@ def chat(id, npc, text):
|
|
246 |
[๋ํ๊ธฐ๋ก]{history[npc][id]}
|
247 |
"""
|
248 |
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
#output = cleanText(output)
|
253 |
#print(tokenizer.decode(outputs[0]))
|
254 |
#output = f"{npc}์ ์๋ต์
๋๋ค."
|
@@ -263,7 +279,7 @@ def chat(id, npc, text):
|
|
263 |
output = output.replace(".",".\n")
|
264 |
time.sleep(10)
|
265 |
print(output)
|
266 |
-
history[npc][id] += f"
|
267 |
else:
|
268 |
output = "no model, GPU๋ฅผ ๋ ๊ณต์ ํด์ฃผ์ธ์."
|
269 |
|
|
|
30 |
|
31 |
# App code
|
32 |
|
33 |
+
model_name = "quantumaikr/llama-2-70b-fb16-korean"
|
34 |
|
35 |
#petals-team/StableBeluga2
|
36 |
#daekeun-ml/Llama-2-ko-DPO-13B
|
37 |
#daekeun-ml/Llama-2-ko-instruct-13B
|
38 |
#quantumaikr/llama-2-70b-fb16-korean
|
39 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False)
|
40 |
|
41 |
+
#model = None
|
42 |
+
model = AutoDistributedModelForCausalLM.from_pretrained(model_name)
|
43 |
|
44 |
history = {
|
45 |
"":{
|
|
|
106 |
Toki๋ ์ด๊ณณ์ด ๊ฒ์ ์์์ ์๊ณ ์์ต๋๋ค.
|
107 |
Toki๋ User๊ฐ ํ๋ฉด ๋ฐ์ ์ฌ๋์์ ์๊ณ ์์ต๋๋ค.
|
108 |
Toki๋ ๋ฐ๋ง์ ํฉ๋๋ค.
|
109 |
+
Toki๋ ๋น๊ด์ ์
๋๋ค.
|
110 |
]""",
|
111 |
|
112 |
"Neco":"""[
|
|
|
121 |
Neco๋ ์ฌ๋ฐ๋ ์ด์๋ฅผ ๋ฌผ์ด๋ณด๋ฉด ์ฃผ๋ฏผ๋ค ์ค ํ๋ช
์ ์ด์ผ๊ธฐ๋ฅผ ํด์ค๋๋ค.
|
122 |
Neco๋ ๋ง๋๋ง๋ค ๋ฅ์ ๋ถ์
๋๋ค.
|
123 |
Neco๋ toki์ ์นํฉ๋๋ค.
|
124 |
+
|
125 |
+
๋ง๋ฒ๋ฆ:[
|
126 |
+
"๋ (name) ์ด์ผ๊ธฐ ๋ค์์ด?",
|
127 |
+
"์๋ ๊ธ์๋ง์ด์ผ"
|
128 |
+
]
|
129 |
]""",
|
130 |
|
131 |
"Lux":"""[
|
|
|
153 |
,
|
154 |
|
155 |
"VikingSlime":"""[
|
156 |
+
VikingSlime์ ๋ฐ์ดํน ๋ชจ์๋ฅผ ์ด ๊ตํํ ์ฌ๋ผ์์
๋๋ค.
|
157 |
+
VikingSlime์ ์
๋น์
๋๋ค.
|
158 |
+
VikingSlime์ ๋ง์์ ์ฌ๋ฌ ๋ฌธ์ ๋ฅผ ์ผ์ผํค๊ณ ์ถ์ด ํฉ๋๋ค.
|
159 |
+
|
160 |
+
๋์ฌ ์์:[
|
161 |
+
"์ธ์ ๊ฐ๋...๊ผญ",
|
162 |
+
"๋ฐ๋์ ๋ฌด๋๋จ๋ฆฌ๊ณ ๋ง๊ฒ ๋ค"
|
163 |
+
]
|
164 |
]""",
|
165 |
|
166 |
"Slender":"""[
|
|
|
174 |
"์ผ์์
",
|
175 |
"๋์์์
"
|
176 |
]
|
177 |
+
|
178 |
+
๋น๋ช
๋ง ์์ฑํ์ธ์.
|
179 |
]"""
|
180 |
}
|
181 |
|
|
|
262 |
[๋ํ๊ธฐ๋ก]{history[npc][id]}
|
263 |
"""
|
264 |
|
265 |
+
inputs = tokenizer("์", return_tensors="pt")["input_ids"]
|
266 |
+
outputs = model.generate(inputs, do_sample=True, temperature=0.6, top_p=0.75, max_new_tokens=2)
|
267 |
+
output = tokenizer.decode(outputs[0])[len(prom)+3:-1].split("<")[0].split("###")[0].replace(". ", ".\n")
|
268 |
#output = cleanText(output)
|
269 |
#print(tokenizer.decode(outputs[0]))
|
270 |
#output = f"{npc}์ ์๋ต์
๋๋ค."
|
|
|
279 |
output = output.replace(".",".\n")
|
280 |
time.sleep(10)
|
281 |
print(output)
|
282 |
+
history[npc][id] += f"{id}:{text}"
|
283 |
else:
|
284 |
output = "no model, GPU๋ฅผ ๋ ๊ณต์ ํด์ฃผ์ธ์."
|
285 |
|