19 lines
535 B
Python
19 lines
535 B
Python
import gradio as gr
|
|
from transformers import pipeline
|
|
|
|
generator = pipeline("text-generation", model="your-username/my-qa-chatbot")
|
|
|
|
def chatbot(question):
|
|
prompt = f"Question: {question}\nAnswer:"
|
|
output = generator(prompt, max_new_tokens=15, do_sample=False)
|
|
answer = output[0]["generated_text"].replace(prompt, "").strip()
|
|
return answer
|
|
|
|
demo = gr.Interface(
|
|
fn=chatbot,
|
|
inputs=gr.Textbox(label="Apna sawal poochein"),
|
|
outputs=gr.Textbox(label="Jawab"),
|
|
title="My Fine-Tuned Chatbot"
|
|
)
|
|
|
|
demo.launch() |