Spaces:
Sleeping
Sleeping
updated app.py to reflect fields
Browse files
app.py
CHANGED
@@ -3,10 +3,6 @@ import torch
|
|
3 |
import gradio as gr
|
4 |
from transformers import pipeline
|
5 |
|
6 |
-
"""
|
7 |
-
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
8 |
-
"""
|
9 |
-
# client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
10 |
pipe = pipeline(
|
11 |
model="gyulukeyi/llama3-nallm-qa-8B_240708",
|
12 |
token=os.environ.get("hf_token"),
|
@@ -16,16 +12,16 @@ pipe = pipeline(
|
|
16 |
|
17 |
|
18 |
def respond(
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
max_tokens,
|
23 |
temperature,
|
24 |
top_p,
|
25 |
):
|
26 |
-
messages = [{"role": "municipality", "content":
|
27 |
-
messages.append({"role": "title", "content":
|
28 |
-
messages.append({"role": "question", "content":
|
29 |
|
30 |
output = pipe(
|
31 |
messages,
|
@@ -34,22 +30,21 @@ def respond(
|
|
34 |
return_full_text=False,
|
35 |
top_p=top_p,
|
36 |
)
|
|
|
37 |
return output[0]["generated_text"]
|
38 |
|
39 |
|
40 |
-
|
41 |
-
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
42 |
-
"""
|
43 |
-
demo = gr.ChatInterface(
|
44 |
respond,
|
|
|
|
|
45 |
additional_inputs=[
|
46 |
-
gr.Textbox(value="서울특별시", label="municipality"),
|
47 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
48 |
-
gr.Slider(minimum=0.1, maximum=1.0, value=0.
|
49 |
gr.Slider(
|
50 |
minimum=0.1,
|
51 |
maximum=1.0,
|
52 |
-
value=0.
|
53 |
step=0.05,
|
54 |
label="Top-p (nucleus sampling)",
|
55 |
),
|
|
|
3 |
import gradio as gr
|
4 |
from transformers import pipeline
|
5 |
|
|
|
|
|
|
|
|
|
6 |
pipe = pipeline(
|
7 |
model="gyulukeyi/llama3-nallm-qa-8B_240708",
|
8 |
token=os.environ.get("hf_token"),
|
|
|
12 |
|
13 |
|
14 |
def respond(
|
15 |
+
지자체,
|
16 |
+
제목,
|
17 |
+
질문,
|
18 |
max_tokens,
|
19 |
temperature,
|
20 |
top_p,
|
21 |
):
|
22 |
+
messages = [{"role": "municipality", "content": 지자체}]
|
23 |
+
messages.append({"role": "title", "content": 제목})
|
24 |
+
messages.append({"role": "question", "content": 질문})
|
25 |
|
26 |
output = pipe(
|
27 |
messages,
|
|
|
30 |
return_full_text=False,
|
31 |
top_p=top_p,
|
32 |
)
|
33 |
+
|
34 |
return output[0]["generated_text"]
|
35 |
|
36 |
|
37 |
+
demo = gr.Interface(
|
|
|
|
|
|
|
38 |
respond,
|
39 |
+
inputs=["textbox", "textbox", "textbox"],
|
40 |
+
outputs=["textbox"],
|
41 |
additional_inputs=[
|
|
|
42 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
43 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.4, step=0.05, label="Temperature"),
|
44 |
gr.Slider(
|
45 |
minimum=0.1,
|
46 |
maximum=1.0,
|
47 |
+
value=0.90,
|
48 |
step=0.05,
|
49 |
label="Top-p (nucleus sampling)",
|
50 |
),
|