Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
import torch | |
MODEL_NAME = "hacer201145/Failed_Model" | |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME) | |
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, torch_dtype=torch.float16, device_map="auto") | |
def chat(message, history): | |
input_text = message | |
inputs = tokenizer(input_text, return_tensors="pt").to(model.device) | |
with torch.no_grad(): | |
outputs = model.generate(**inputs, max_new_tokens=100, pad_token_id=tokenizer.eos_token_id) | |
response = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
return response | |
iface = gr.ChatInterface(chat) | |
iface.launch() |