Spaces:
Runtime error
Runtime error
| 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 = '' | |
| all_beams = [] | |
| for i in range(4): | |
| all_beams.append([tok.decode(beam, skip_special_tokens=True, clean_up_tokenization_spaces=False) for beam in output][i]) | |
| for i in len(all_beams) | |
| final_output += all_beams[i] + "\n" | |
| return final_output | |
| iface = gr.Interface(fn=genQuestion, inputs="text", outputs="text") | |
| iface.launch() | |