File size: 719 Bytes
ff8ef9c fddc759 ff8ef9c fddc759 ff8ef9c fddc759 ff8ef9c 8d22315 fddc759 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load your model
model_name = "khaled123/hf"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
def chat(input_text):
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(inputs["input_ids"], max_length=150, num_return_sequences=1)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
return response
iface = gr.Interface(fn=chat,
inputs="text",
outputs="text",
title="Chatbot",
description="A chatbot using a model")
iface.launch()
|