Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,24 +28,12 @@ def predict(message, history):
|
|
| 28 |
history_transformer_format = history + [[message, ""]]
|
| 29 |
stop = StopOnTokens()
|
| 30 |
|
| 31 |
-
'''
|
| 32 |
-
inputs = tokenizer(
|
| 33 |
-
[
|
| 34 |
-
alpaca_prompt.format(
|
| 35 |
-
message, # instruction
|
| 36 |
-
"", # input
|
| 37 |
-
"", # output - leave this blank for generation!
|
| 38 |
-
)
|
| 39 |
-
], return_tensors = "pt").to("cuda")
|
| 40 |
-
|
| 41 |
-
text_streamer = TextStreamer(tokenizer)
|
| 42 |
-
_ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 2048)
|
| 43 |
-
'''
|
| 44 |
|
| 45 |
messages = "".join(["".join(["\n<human>:"+item[0], "\n<bot>:"+item[1]])
|
| 46 |
for item in history_transformer_format])
|
| 47 |
|
| 48 |
-
model_inputs = tokenizer([messages], return_tensors="pt")
|
|
|
|
| 49 |
streamer = TextIteratorStreamer(tokenizer, timeout=10., skip_prompt=True, skip_special_tokens=True)
|
| 50 |
generate_kwargs = dict(
|
| 51 |
model_inputs,
|
|
@@ -67,6 +55,4 @@ def predict(message, history):
|
|
| 67 |
partial_message += new_token
|
| 68 |
yield partial_message
|
| 69 |
|
| 70 |
-
gr.ChatInterface(predict).launch(debug=True)
|
| 71 |
-
|
| 72 |
-
gr.close_all()
|
|
|
|
| 28 |
history_transformer_format = history + [[message, ""]]
|
| 29 |
stop = StopOnTokens()
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
messages = "".join(["".join(["\n<human>:"+item[0], "\n<bot>:"+item[1]])
|
| 33 |
for item in history_transformer_format])
|
| 34 |
|
| 35 |
+
model_inputs = tokenizer([messages], return_tensors="pt")
|
| 36 |
+
#.to("cuda")
|
| 37 |
streamer = TextIteratorStreamer(tokenizer, timeout=10., skip_prompt=True, skip_special_tokens=True)
|
| 38 |
generate_kwargs = dict(
|
| 39 |
model_inputs,
|
|
|
|
| 55 |
partial_message += new_token
|
| 56 |
yield partial_message
|
| 57 |
|
| 58 |
+
gr.ChatInterface(predict).launch(debug=True)
|
|
|
|
|
|