Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
model_name = "google/flan-t5-base"
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 7 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 8 |
+
|
| 9 |
+
def chat(user_input):
|
| 10 |
+
input_ids = tokenizer(user_input, return_tensors="pt").input_ids
|
| 11 |
+
outputs = model.generate(input_ids, max_new_tokens=200)
|
| 12 |
+
reply = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 13 |
+
return reply
|
| 14 |
+
|
| 15 |
+
gr.Interface(fn=chat, inputs="text", outputs="text", title="🧠 Multilingual Chatbot (Hindi + English)").launch()
|