Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,12 +8,12 @@ name_list = ['microsoft/biogpt', 'stanford-crfm/BioMedLM']
|
|
8 |
|
9 |
examples = [['COVID-19 is'],['A 65-year-old female patient with a past medical history of']]
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
pipe_biogpt = pipeline("text-generation", model="microsoft/biogpt")
|
16 |
-
pipe_biomedlm = pipeline("text-generation", model="stanford-crfm/BioMedLM")
|
17 |
|
18 |
title = "Compare generative biomedical LLMs!"
|
19 |
description = "This demo compares [BioGPT](https://huggingface.co/microsoft/biogpt) and [BioMedLM](https://huggingface.co/stanford-crfm/BioMedLM)."
|
@@ -38,31 +38,3 @@ io = gr.Interface(
|
|
38 |
examples=examples
|
39 |
)
|
40 |
io.launch()
|
41 |
-
|
42 |
-
"""
|
43 |
-
def generate_biomedical(text):
|
44 |
-
interfaces = [gr.Interface.load(name) for name in name_list]
|
45 |
-
return [interface(text) for interface in interfaces]
|
46 |
-
|
47 |
-
def set_example(example: list) -> dict:
|
48 |
-
return gr.Textbox.update(value=example[0])
|
49 |
-
|
50 |
-
with gr.Blocks() as demo:
|
51 |
-
gr.Markdown("# Compare generative biomedical LLMs")
|
52 |
-
with gr.Box():
|
53 |
-
with gr.Row():
|
54 |
-
with gr.Column():
|
55 |
-
input_text = gr.Textbox(label = "Write your text here", lines=4)
|
56 |
-
with gr.Row():
|
57 |
-
btn = gr.Button("Generate ✨")
|
58 |
-
|
59 |
-
example_text = gr.Dataset(components=[input_text], samples=examples)
|
60 |
-
example_text.click(fn=set_example,
|
61 |
-
inputs = example_text,
|
62 |
-
outputs= example_text.components)
|
63 |
-
with gr.Column():
|
64 |
-
gr.Markdown("Let’s compare!")
|
65 |
-
btn.click(generate_biomedical, inputs = input_text, outputs = [gr.Textbox(label=name_list[_], lines=4) for _ in range(len(name_list))])
|
66 |
-
|
67 |
-
demo.launch(enable_queue=True, debug=True)
|
68 |
-
"""
|
|
|
8 |
|
9 |
examples = [['COVID-19 is'],['A 65-year-old female patient with a past medical history of']]
|
10 |
|
11 |
+
import torch
|
12 |
+
print(f"Is CUDA available: {torch.cuda.is_available()}")
|
13 |
+
print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
|
14 |
|
15 |
pipe_biogpt = pipeline("text-generation", model="microsoft/biogpt")
|
16 |
+
pipe_biomedlm = pipeline("text-generation", model="stanford-crfm/BioMedLM", device="cuda:0")
|
17 |
|
18 |
title = "Compare generative biomedical LLMs!"
|
19 |
description = "This demo compares [BioGPT](https://huggingface.co/microsoft/biogpt) and [BioMedLM](https://huggingface.co/stanford-crfm/BioMedLM)."
|
|
|
38 |
examples=examples
|
39 |
)
|
40 |
io.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|