|
import gradio as gr |
|
|
|
|
|
def generate_response(input_text, temperature, top_p): |
|
from transformers import pipeline |
|
|
|
model = pipeline("text-generation", model="meta-llama/Llama-3.3-70B-Instruct") |
|
result = model(input_text, max_length=512, temperature=temperature, top_p=top_p) |
|
return result[0]['generated_text'] |
|
|
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown("# Ajuste de Parâmetros do Modelo") |
|
with gr.Row(): |
|
input_text = gr.Textbox(label="Texto de entrada") |
|
with gr.Row(): |
|
temperature = gr.Slider(0.1, 1.0, value=0.7, step=0.1, label="Temperatura") |
|
top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.1, label="Top-p") |
|
with gr.Row(): |
|
output_text = gr.Textbox(label="Texto gerado", interactive=False) |
|
generate_button = gr.Button("Gerar Resposta") |
|
generate_button.click(generate_response, [input_text, temperature, top_p], output_text) |
|
|
|
demo.launch() |