File size: 748 Bytes
1ef591c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
from transformers import pipeline
# Либо используй свою локальную fine-tuned модель,
# либо загружай из HF Hub:
MODEL_PATH = "./ft_model" # или "username/my-ft-distilgpt2"
pipe = pipeline("text-generation", model=MODEL_PATH)
def chat(prompt):
result = pipe(prompt, max_new_tokens=100)[0]["generated_text"]
return result.strip()
with gr.Blocks() as demo:
gr.Markdown("### 💬 Fine-tuned Mini-LLM Playground")
inp = gr.Textbox(label="Введите вопрос или инструкцию")
out = gr.Textbox(label="Ответ модели")
btn = gr.Button("Сгенерировать")
btn.click(fn=chat, inputs=inp, outputs=out)
demo.launch()
|