import gradio as gr import torch from transformers import BartForConditionalGeneration, BartTokenizer model = BartForConditionalGeneration.from_pretrained("hyechanjun/interview-question-remake") tok = BartTokenizer.from_pretrained("hyechanjun/interview-question-remake") def genQuestion(context): inputs = tok(context, return_tensors="pt") output = model.generate(inputs["input_ids"], num_beams=4, max_length=64, min_length=9) final_output = '' for i in range(4): final_output += [tok.decode(beam, skip_special_tokens=True, clean_up_tokenization_spaces=False) for beam in output][i] + " " return final_output iface = gr.Interface(fn=genQuestion, inputs="text", outputs="text") iface.launch()