Spaces:
Runtime error
Runtime error
File size: 1,227 Bytes
c8c4a86 ae59d89 dc87dbb c8c4a86 34b6899 ae59d89 c8c4a86 3c355ba c8c4a86 dc87dbb ae59d89 c8c4a86 dc87dbb ae59d89 c8c4a86 34b6899 c8c4a86 |
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 32 33 34 35 36 37 38 39 |
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() |