test23 / app.py
khaled123's picture
Update app.py
8d22315 verified
raw
history blame
778 Bytes
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load your quantized model
model_name = "khaled123/hf"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16)
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 quantized model")
iface.launch()