Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,24 +16,35 @@ def generate_response(input_text, temperature, top_k, top_p):
|
|
16 |
outputs = model.generate(
|
17 |
**inputs,
|
18 |
max_length=512, # Adjust this if needed
|
19 |
-
do_sample=True,
|
20 |
-
top_k=int(top_k),
|
21 |
-
top_p=float(top_p),
|
22 |
-
temperature=float(temperature)
|
23 |
)
|
|
|
|
|
|
|
|
|
24 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
# Create a Gradio interface with sliders
|
28 |
interface = gr.Interface(
|
29 |
fn=generate_response,
|
30 |
inputs=[
|
31 |
-
gr.Textbox(lines=5, placeholder="Enter
|
32 |
-
gr.Slider(0.1, 2.0, value=0.
|
33 |
-
gr.Slider(1, 100, value=
|
34 |
gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="Top-p")
|
35 |
],
|
36 |
-
outputs=
|
|
|
|
|
|
|
|
|
37 |
title="Falcon decompiler Interactive Demo",
|
38 |
description="Adjust the sliders for temperature, top-k, and top-p to customize the model's response."
|
39 |
)
|
|
|
16 |
outputs = model.generate(
|
17 |
**inputs,
|
18 |
max_length=512, # Adjust this if needed
|
|
|
|
|
|
|
|
|
19 |
)
|
20 |
+
# do_sample=True,
|
21 |
+
# top_k=int(top_k),
|
22 |
+
# top_p=float(top_p),
|
23 |
+
# temperature=float(temperature)
|
24 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
25 |
+
# Split the response into assembly and source code (if applicable)
|
26 |
+
if "# This is the assembly code:" in response:
|
27 |
+
parts = response.split("# What is the source code?")
|
28 |
+
assembly_code = parts[0].replace("# This is the assembly code:", "").strip()
|
29 |
+
source_code = parts[1].strip() if len(parts) > 1 else ""
|
30 |
+
return f"```c\n{assembly_code}\n```", f"```c\n{source_code}\n```"
|
31 |
+
else:
|
32 |
+
return "No assembly code found.", "No source code found."
|
33 |
|
34 |
# Create a Gradio interface with sliders
|
35 |
interface = gr.Interface(
|
36 |
fn=generate_response,
|
37 |
inputs=[
|
38 |
+
gr.Textbox(lines=5, placeholder="Enter assembly code here...", label="Input Assembly Code"),
|
39 |
+
gr.Slider(0.1, 2.0, value=0.7, step=0.1, label="Temperature"),
|
40 |
+
gr.Slider(1, 100, value=50, step=1, label="Top-k"),
|
41 |
gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="Top-p")
|
42 |
],
|
43 |
+
outputs=[
|
44 |
+
gr.Markdown(label="Assembly Code"),
|
45 |
+
gr.Markdown(label="Source Code")
|
46 |
+
],
|
47 |
+
|
48 |
title="Falcon decompiler Interactive Demo",
|
49 |
description="Adjust the sliders for temperature, top-k, and top-p to customize the model's response."
|
50 |
)
|