lab / app.py
hey1800's picture
Update app.py
4e931e5 verified
raw
history blame contribute delete
715 Bytes
import gradio as gr
from transformers import AutoTokenizer, GPTJForCausalLM
model_name = "rycont/kakaobrain__kogpt-6b-8bit"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = GPTJForCausalLM.from_pretrained(model_name)
def generate_response(prompt):
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(inputs['input_ids'], max_new_tokens=50)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
return response
iface = gr.Interface(
fn=generate_response,
inputs="text",
outputs="text",
title="KoGPT-6B Chatbot",
description="Enter a prompt and the model will generate a response."
)
if __name__ == "__main__":
iface.launch()