Spaces:
Runtime error
Runtime error
| import os | |
| import gradio as gr | |
| import torch | |
| import numpy as np | |
| from transformers import pipeline | |
| name_list = ['microsoft/biogpt', 'google/flan-ul2'] | |
| examples = [['COVID-19 is'],['A 65-year-old female patient with a past medical history of']] | |
| print(f"Is CUDA available: {torch.cuda.is_available()}") | |
| print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}") | |
| pipe_biogpt = pipeline("text-generation", model="microsoft/biogpt", device="cuda:0", model_kwargs={"torch_dtype":torch.bfloat16}) | |
| pipe_flan_ul2 = pipeline("text-generation", model="google/flan-ul2", device="cuda:0", model_kwargs={"torch_dtype":torch.bfloat16}) | |
| title = "LLM vs LLM!" | |
| description = "**Disclaimer:** this demo was made for research purposes only." | |
| def inference(text): | |
| output_biogpt = pipe_biogpt(text, max_length=100)[0]["generated_text"] | |
| output_flan_ul2 = pipe_flan_ul2(text, max_length=100)[0]["generated_text"] | |
| return [ | |
| output_biogpt, | |
| output_flan_ul2 | |
| ] | |
| io = gr.Interface( | |
| inference, | |
| gr.Textbox(lines=3), | |
| outputs=[ | |
| gr.Textbox(lines=3, label="microsoft/biogpt"), | |
| gr.Textbox(lines=3, label="google/flan-ul2"), | |
| ], | |
| title=title, | |
| description=description, | |
| examples=examples | |
| ) | |
| io.launch() |