davila7 commited on
Commit
dc87dbb
1 Parent(s): c92fa56
Files changed (1) hide show
  1. app.py +14 -20
app.py CHANGED
@@ -4,31 +4,27 @@ import torch
4
  import numpy as np
5
  from transformers import pipeline
6
 
7
- examples = [['Q: Can Geoffrey Hinton have a conversation with George Washington? Give the rationale before answering.'],['Translate to German: My name is Arthur'], ['Please answer the following question. What is the boiling point of Nitrogen?']]
 
 
8
 
9
  print(f"Is CUDA available: {torch.cuda.is_available()}")
10
  print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
11
 
12
- #pipe_biogpt = pipeline("text-generation", model="microsoft/BioGPT-Large", device="cuda:0", model_kwargs={"torch_dtype":torch.bfloat16})
13
- pipe_flan_t5 = pipeline("text-generation", model="google/flan-t5-xxl", device="cuda:0", model_kwargs={"torch_dtype":torch.bfloat16})
14
- #pipe_gpt2 = pipeline("text-generation", model="gpt2", device="cuda:0", model_kwargs={"torch_dtype":torch.bfloat16})
15
- #pipe_flan_ul2 = pipeline("text-generation", model="google/flan-ul2", device="cuda:0", model_kwargs={"torch_dtype":torch.bfloat16})
16
  pipe_galactica = pipeline("text-generation", model="facebook/galactica-1.3b", device="cuda:0", model_kwargs={"torch_dtype":torch.bfloat16})
17
 
18
- title = "LLM vs LLM"
19
- description = "**Disclaimer:** this demo was made for research purposes."
20
 
21
  def inference(text):
22
- #output_biogpt = pipe_biogpt(text, max_length=100)[0]["generated_text"]
23
- output_flan_t5 = pipe_flan_t5(text, max_length=100)[0]["generated_text"]
24
- #output_gpt2 = pipe_gpt2(text, max_length=100)[0]["generated_text"]
25
- #pipe_flan_ul2 = pipe_flan_t5(text, max_length=100)[0]["generated_text"]
26
  output_galactica = pipe_galactica(text, max_length=100)[0]["generated_text"]
27
  return [
28
- #output_biogpt,
29
- output_flan_t5,
30
- #output_gpt2,
31
- #pipe_flan_ul2,
32
  output_galactica
33
  ]
34
 
@@ -36,11 +32,9 @@ io = gr.Interface(
36
  inference,
37
  gr.Textbox(lines=3),
38
  outputs=[
39
- #gr.Textbox(lines=3, label="Microsoft: BioGPT-Large"),
40
- gr.Textbox(lines=3, label="Google: FLAN-T5-XXL"),
41
- #gr.Textbox(lines=3, label="GPT-2"),
42
- #gr.Textbox(lines=3, label="Google: FLAN-UL2"),
43
- gr.Textbox(lines=3, label="Facebook: Galactica 1.3B"),
44
  ],
45
  title=title,
46
  description=description,
 
4
  import numpy as np
5
  from transformers import pipeline
6
 
7
+ name_list = ['microsoft/biogpt', 'stanford-crfm/BioMedLM', 'facebook/galactica-1.3b']
8
+
9
+ examples = [['COVID-19 is'],['A 65-year-old female patient with a past medical history of']]
10
 
11
  print(f"Is CUDA available: {torch.cuda.is_available()}")
12
  print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
13
 
14
+ pipe_biogpt = pipeline("text-generation", model="microsoft/BioGPT-Large", device="cuda:0", model_kwargs={"torch_dtype":torch.bfloat16})
15
+ pipe_biomedlm = pipeline("text-generation", model="stanford-crfm/BioMedLM", device="cuda:0", model_kwargs={"torch_dtype":torch.bfloat16})
 
 
16
  pipe_galactica = pipeline("text-generation", model="facebook/galactica-1.3b", device="cuda:0", model_kwargs={"torch_dtype":torch.bfloat16})
17
 
18
+ title = "Compare generative biomedical LLMs!"
19
+ description = "**Disclaimer:** this demo was made for research purposes only and should not be used for medical purposes."
20
 
21
  def inference(text):
22
+ output_biogpt = pipe_biogpt(text, max_length=100)[0]["generated_text"]
23
+ output_biomedlm = pipe_biomedlm(text, max_length=100)[0]["generated_text"]
 
 
24
  output_galactica = pipe_galactica(text, max_length=100)[0]["generated_text"]
25
  return [
26
+ output_biogpt,
27
+ output_biomedlm,
 
 
28
  output_galactica
29
  ]
30
 
 
32
  inference,
33
  gr.Textbox(lines=3),
34
  outputs=[
35
+ gr.Textbox(lines=3, label="BioGPT-Large"),
36
+ gr.Textbox(lines=3, label="BioMedLM (fka PubmedGPT)"),
37
+ gr.Textbox(lines=3, label="Galactica 1.3B"),
 
 
38
  ],
39
  title=title,
40
  description=description,