Initial Space setup
Browse files- app.py +28 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load your fine-tuned model from the Hub
|
5 |
+
chatbot = pipeline(
|
6 |
+
"text2text-generation",
|
7 |
+
model="your-username/bayedger-chatbot", # or your fine-tuned model ID
|
8 |
+
tokenizer="your-username/bayedger-chatbot",
|
9 |
+
)
|
10 |
+
|
11 |
+
def respond(query):
|
12 |
+
# generate response
|
13 |
+
out = chatbot(f"question: {query} answer:",
|
14 |
+
max_new_tokens=150,
|
15 |
+
temperature=1.0,
|
16 |
+
top_p=0.9,
|
17 |
+
repetition_penalty=1.1,
|
18 |
+
num_beams=1)[0]["generated_text"]
|
19 |
+
return out
|
20 |
+
|
21 |
+
# Build Gradio interface
|
22 |
+
with gr.Blocks() as demo:
|
23 |
+
gr.Markdown("# 🤖 Bayedger FAQ Chatbot")
|
24 |
+
txt = gr.Textbox(label="Ask me anything", placeholder="Type your question here…")
|
25 |
+
out = gr.Textbox(label="Answer")
|
26 |
+
txt.submit(respond, txt, out)
|
27 |
+
|
28 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch # or accelerate if you prefer
|
3 |
+
gradio
|