Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,36 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# Função para carregar o modelo e executar inferência com parâmetros personalizados
|
4 |
+
def predict(input_text, temperature, max_length, top_p, top_k):
|
5 |
+
# Carregue o modelo
|
6 |
+
model = gr.load("models/meta-llama/Llama-3.3-70B-Instruct")
|
7 |
+
|
8 |
+
# Use os parâmetros passados para configurar o modelo
|
9 |
+
return model(input_text, temperature=temperature, max_length=max_length, top_p=top_p, top_k=top_k)
|
10 |
+
|
11 |
+
# Interface Gradio
|
12 |
+
with gr.Blocks() as demo:
|
13 |
+
gr.Markdown("# Modelo Llama 3.3 - Ajuste de Parâmetros")
|
14 |
+
|
15 |
+
with gr.Row():
|
16 |
+
input_text = gr.Textbox(label="Texto de entrada", placeholder="Digite seu texto aqui")
|
17 |
+
|
18 |
+
with gr.Row():
|
19 |
+
temperature = gr.Slider(0, 1, value=0.7, label="Temperature")
|
20 |
+
max_length = gr.Slider(1, 2048, value=512, step=1, label="Comprimento Máximo")
|
21 |
+
top_p = gr.Slider(0, 1, value=0.9, label="Top-p (nucleus sampling)")
|
22 |
+
top_k = gr.Slider(1, 100, value=50, step=1, label="Top-k")
|
23 |
+
|
24 |
+
with gr.Row():
|
25 |
+
output = gr.Textbox(label="Saída do Modelo")
|
26 |
+
|
27 |
+
with gr.Row():
|
28 |
+
submit_btn = gr.Button("Executar")
|
29 |
+
|
30 |
+
submit_btn.click(
|
31 |
+
predict,
|
32 |
+
inputs=[input_text, temperature, max_length, top_p, top_k],
|
33 |
+
outputs=output,
|
34 |
+
)
|
35 |
+
|
36 |
+
demo.launch()
|