Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import AutoTokenizer
|
| 3 |
+
from petals import AutoDistributedModelForCausalLM
|
| 4 |
+
|
| 5 |
+
# Choose any model available at https://health.petals.dev
|
| 6 |
+
model_name = "daekeun-ml/Llama-2-ko-instruct-13B"
|
| 7 |
+
|
| 8 |
+
#daekeun-ml/Llama-2-ko-instruct-13B
|
| 9 |
+
#quantumaikr/llama-2-70b-fb16-korean
|
| 10 |
+
|
| 11 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 12 |
+
model = AutoDistributedModelForCausalLM.from_pretrained(model_name)
|
| 13 |
+
|
| 14 |
+
# Run the model as if it were on your computer
|
| 15 |
+
def chat(id, npc, text):
|
| 16 |
+
prom = ""
|
| 17 |
+
inputs = tokenizer(prom, return_tensors="pt")["input_ids"]
|
| 18 |
+
outputs = model.generate(inputs, max_new_tokens=100)
|
| 19 |
+
print(tokenizer.decode(outputs[0]))
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
with gr.Blocks() as demo:
|
| 27 |
+
count = 0
|
| 28 |
+
aa = gr.Interface(
|
| 29 |
+
fn=chat,
|
| 30 |
+
inputs=["text","text","text"],
|
| 31 |
+
outputs="text",
|
| 32 |
+
description="chat, ai ์๋ต์ ๋ฐํํฉ๋๋ค. ๋ด๋ถ์ ์ผ๋ก ํธ๋์ญ์
์์ฑ. \n /run/predict",
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
demo.queue(max_size=32).launch(enable_queue=True)
|