File size: 795 Bytes
8a554d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import gradio as gr
from transformers import pipeline, set_seed
from transformers import AutoModelForCausalLM, AutoTokenizer
checkpoint = "bigcode/starcoder-3b"
device = "cpu"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
generator = pipeline('text-generation', model='gpt2', return_full_text=False)
set_seed(42)
def Bemenet(bemenet):
inputs = tokenizer.encode(bemenet, return_tensors="pt").to(device)
outputs = model.generate(inputs)
return tokenizer.decode(outputs[0])
interface = gr.Interface(fn=Bemenet,
title="Cím..",
description="Leírás..",
inputs="text",
outputs="text")
interface.launch() |