Spaces:
Running
Running
adding frequency penalty, top_k, seed parameters
Browse files
app.py
CHANGED
@@ -20,11 +20,14 @@ def respond(
|
|
20 |
max_tokens,
|
21 |
temperature,
|
22 |
top_p,
|
|
|
|
|
|
|
23 |
):
|
24 |
print(f"Received message: {message}")
|
25 |
print(f"History: {history}")
|
26 |
print(f"System message: {system_message}")
|
27 |
-
print(f"Max tokens: {max_tokens}, Temperature: {temperature}, Top-P: {top_p}")
|
28 |
|
29 |
messages = [{"role": "system", "content": system_message}]
|
30 |
|
@@ -40,13 +43,16 @@ def respond(
|
|
40 |
|
41 |
response = ""
|
42 |
print("Sending request to OpenAI API.")
|
43 |
-
|
44 |
for message in client.chat.completions.create(
|
45 |
model="meta-llama/Llama-3.3-70B-Instruct",
|
46 |
max_tokens=max_tokens,
|
47 |
stream=True,
|
48 |
temperature=temperature,
|
49 |
top_p=top_p,
|
|
|
|
|
|
|
50 |
messages=messages,
|
51 |
):
|
52 |
token = message.choices[0].delta.content
|
@@ -55,7 +61,7 @@ def respond(
|
|
55 |
yield response
|
56 |
|
57 |
print("Completed response generation.")
|
58 |
-
|
59 |
chatbot = gr.Chatbot(height=600)
|
60 |
|
61 |
print("Chatbot interface created.")
|
@@ -73,7 +79,27 @@ demo = gr.ChatInterface(
|
|
73 |
step=0.05,
|
74 |
label="Top-P",
|
75 |
),
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
],
|
78 |
fill_height=True,
|
79 |
chatbot=chatbot,
|
|
|
20 |
max_tokens,
|
21 |
temperature,
|
22 |
top_p,
|
23 |
+
frequency_penalty,
|
24 |
+
top_k,
|
25 |
+
seed,
|
26 |
):
|
27 |
print(f"Received message: {message}")
|
28 |
print(f"History: {history}")
|
29 |
print(f"System message: {system_message}")
|
30 |
+
print(f"Max tokens: {max_tokens}, Temperature: {temperature}, Top-P: {top_p}, Frequency Penalty: {frequency_penalty}, Top-K: {top_k}, Seed: {seed}")
|
31 |
|
32 |
messages = [{"role": "system", "content": system_message}]
|
33 |
|
|
|
43 |
|
44 |
response = ""
|
45 |
print("Sending request to OpenAI API.")
|
46 |
+
|
47 |
for message in client.chat.completions.create(
|
48 |
model="meta-llama/Llama-3.3-70B-Instruct",
|
49 |
max_tokens=max_tokens,
|
50 |
stream=True,
|
51 |
temperature=temperature,
|
52 |
top_p=top_p,
|
53 |
+
frequency_penalty=frequency_penalty,
|
54 |
+
top_k=top_k,
|
55 |
+
seed=seed,
|
56 |
messages=messages,
|
57 |
):
|
58 |
token = message.choices[0].delta.content
|
|
|
61 |
yield response
|
62 |
|
63 |
print("Completed response generation.")
|
64 |
+
|
65 |
chatbot = gr.Chatbot(height=600)
|
66 |
|
67 |
print("Chatbot interface created.")
|
|
|
79 |
step=0.05,
|
80 |
label="Top-P",
|
81 |
),
|
82 |
+
gr.Slider(
|
83 |
+
minimum=0.0,
|
84 |
+
maximum=2.0,
|
85 |
+
value=0.0,
|
86 |
+
step=0.1,
|
87 |
+
label="Frequency Penalty",
|
88 |
+
),
|
89 |
+
gr.Slider(
|
90 |
+
minimum=1,
|
91 |
+
maximum=100,
|
92 |
+
value=50,
|
93 |
+
step=1,
|
94 |
+
label="Top-K",
|
95 |
+
),
|
96 |
+
gr.Slider(
|
97 |
+
minimum=-1,
|
98 |
+
maximum=10000,
|
99 |
+
value=-1,
|
100 |
+
step=1,
|
101 |
+
label="Seed (-1 for random)",
|
102 |
+
),
|
103 |
],
|
104 |
fill_height=True,
|
105 |
chatbot=chatbot,
|