haramkoo's picture
webapp update 03-07-2022 6:09 pm
d3c3cdf
raw
history blame
602 Bytes
import gradio as gr
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.tokenize(context, return_tensors="pt")
output = model.generate(inputs["input_ids"], num_beams=4, max_length=64)
return tok.batch_decode(output, skip_special_tokens=True, clean_up_tokenization_spaces=False)
iface = gr.Interface(fn=genQuestion, inputs="text", outputs="text")
iface.launch()