NPG commited on
Commit
24fb9f1
1 Parent(s): a1e9152

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -2,13 +2,14 @@
2
 
3
  #!pip install transformers gradio accelerate bitsandbytes sentencepiece
4
 
5
- import multiprocessing
6
  import torch
7
  from transformers import T5Tokenizer, T5ForConditionalGeneration
8
  import gradio as gr
9
 
10
  """#Code"""
11
 
 
12
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
13
 
14
  """##FP 16"""
@@ -19,7 +20,7 @@ model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xl", device_m
19
  """###Interface"""
20
 
21
  def generate(input_text, minimum_length, maximum_length, temperature, repetition_penalty):
22
- input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(dtype=torch.float16).to(device)
23
  outputs = model.generate(input_ids,
24
  min_length=minimum_length,
25
  max_new_tokens=maximum_length,
 
2
 
3
  #!pip install transformers gradio accelerate bitsandbytes sentencepiece
4
 
5
+ #import multiprocessing
6
  import torch
7
  from transformers import T5Tokenizer, T5ForConditionalGeneration
8
  import gradio as gr
9
 
10
  """#Code"""
11
 
12
+ torch.set_default_dtype(torch.float16)
13
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
14
 
15
  """##FP 16"""
 
20
  """###Interface"""
21
 
22
  def generate(input_text, minimum_length, maximum_length, temperature, repetition_penalty):
23
+ input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(dtype=torch.long).to(device)
24
  outputs = model.generate(input_ids,
25
  min_length=minimum_length,
26
  max_new_tokens=maximum_length,