# νμν λΌμ΄λΈλ¬λ¦¬ μ€μΉ λͺ λ Ή (ν°λ―Έλμ΄λ λͺ λ Ή ν둬ννΈμμ μ€ν): | |
# pip install transformers gradio | |
# TensorFlow λλ PyTorch μ€ νλλ₯Ό μ€μΉνμΈμ. μλ₯Ό λ€μ΄, PyTorch μ€μΉ λͺ λ Ή: | |
# pip install torch torchvision torchaudio | |
# λλ TensorFlow μ€μΉ λͺ λ Ή: | |
# pip install tensorflow | |
# λΌμ΄λΈλ¬λ¦¬ μν¬νΈ | |
import gradio as gr | |
from transformers import pipeline | |
# ν μ€νΈ μμ± νμ΄νλΌμΈ μμ± | |
chatbot_pipeline = pipeline('text-generation', model='gpt2') | |
# μ¬μ©μμ μ§λ¬Έμ λν λ΅λ³μ μμ±νλ ν¨μ | |
def answer_question(question): | |
responses = chatbot_pipeline(question, max_length=100) | |
return responses[0]['generated_text'] | |
# Gradio μΈν°νμ΄μ€ μμ± | |
interface = gr.Interface(fn=answer_question, inputs="text", outputs="text", title="κ°λ¨ν μ±λ΄") | |
# μΈν°νμ΄μ€ μ€ν | |
if __name__ == "__main__": | |
interface.launch() |