Spaces:
Running
Running
ayan4m1
commited on
Commit
·
5bce228
1
Parent(s):
8c6251b
feat: add top-k sampling
Browse files
app.py
CHANGED
@@ -10,9 +10,10 @@ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
|
10 |
def respond(
|
11 |
message,
|
12 |
history: list[tuple[str, str]],
|
13 |
-
max_tokens,
|
14 |
-
temperature,
|
15 |
-
top_p,
|
|
|
16 |
):
|
17 |
messages = []
|
18 |
|
@@ -32,6 +33,7 @@ def respond(
|
|
32 |
stream=True,
|
33 |
temperature=temperature,
|
34 |
top_p=top_p,
|
|
|
35 |
):
|
36 |
token = message.choices[0].delta.content
|
37 |
|
@@ -52,7 +54,14 @@ demo = gr.ChatInterface(
|
|
52 |
maximum=1.0,
|
53 |
value=0.95,
|
54 |
step=0.05,
|
55 |
-
label="Top-p
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
),
|
57 |
],
|
58 |
)
|
|
|
10 |
def respond(
|
11 |
message,
|
12 |
history: list[tuple[str, str]],
|
13 |
+
max_tokens: int,
|
14 |
+
temperature: float,
|
15 |
+
top_p: float,
|
16 |
+
top_k: int
|
17 |
):
|
18 |
messages = []
|
19 |
|
|
|
33 |
stream=True,
|
34 |
temperature=temperature,
|
35 |
top_p=top_p,
|
36 |
+
top_k=top_k
|
37 |
):
|
38 |
token = message.choices[0].delta.content
|
39 |
|
|
|
54 |
maximum=1.0,
|
55 |
value=0.95,
|
56 |
step=0.05,
|
57 |
+
label="Top-p",
|
58 |
+
),
|
59 |
+
gr.Slider(
|
60 |
+
minimum=10,
|
61 |
+
maximum=100,
|
62 |
+
value=30,
|
63 |
+
step=10,
|
64 |
+
label="Top-k"
|
65 |
),
|
66 |
],
|
67 |
)
|