初始化项目,由ModelHub XC社区提供模型
Model: barki273/my-qa-chatbot Source: Original Platform
This commit is contained in:
19
app.py
Normal file
19
app.py
Normal file
@@ -0,0 +1,19 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user