Thziin commited on
Commit
1c20b88
1 Parent(s): 9463592

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -27
app.py CHANGED
@@ -1,36 +1,24 @@
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()
 
1
  import gradio as gr
2
 
3
+ # Função para processar o texto com os parâmetros ajustáveis
4
+ def generate_response(input_text, temperature, top_p):
5
+ from transformers import pipeline
6
+ # Carregar o modelo da Hugging Face localmente ou via API
7
+ model = pipeline("text-generation", model="meta-llama/Llama-3.3-70B-Instruct")
8
+ result = model(input_text, max_length=512, temperature=temperature, top_p=top_p)
9
+ return result[0]['generated_text']
10
 
11
+ # Interface com entradas ajustáveis
12
  with gr.Blocks() as demo:
13
+ gr.Markdown("# Ajuste de Parâmetros do Modelo")
 
14
  with gr.Row():
15
+ input_text = gr.Textbox(label="Texto de entrada")
 
16
  with gr.Row():
17
+ temperature = gr.Slider(0.1, 1.0, value=0.7, step=0.1, label="Temperatura")
18
+ top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.1, label="Top-p")
 
 
 
 
 
 
19
  with gr.Row():
20
+ output_text = gr.Textbox(label="Texto gerado", interactive=False)
21
+ generate_button = gr.Button("Gerar Resposta")
22
+ generate_button.click(generate_response, [input_text, temperature, top_p], output_text)
 
 
 
 
23
 
24
  demo.launch()