ChihChiu29 commited on
Commit
316f95c
·
1 Parent(s): d557d40

change token size limit to 512

Browse files
Files changed (1) hide show
  1. main.py +6 -2
main.py CHANGED
@@ -9,24 +9,28 @@ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
9
  from transformers import T5Tokenizer, T5ForConditionalGeneration
10
 
11
 
 
 
12
  # FROM: https://huggingface.co/facebook/blenderbot-400M-distill?text=Hey+my+name+is+Thomas%21+How+are+you%3F
13
  # tokenizer = AutoTokenizer.from_pretrained("facebook/blenderbot-400M-distill")
14
  # model = AutoModelForSeq2SeqLM.from_pretrained("facebook/blenderbot-400M-distill")
15
  # tokenizer = AutoTokenizer.from_pretrained("facebook/blenderbot-1B-distill")
16
  # model = AutoModelForSeq2SeqLM.from_pretrained("facebook/blenderbot-1B-distill")
 
 
 
17
  # tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-small")
18
  # model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-small")
19
  # tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-base")
20
  # model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-base")
21
  tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
22
  model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large")
 
23
 
24
  # Too large for 16GB
25
  # tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xl")
26
  # model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xl")
27
 
28
- token_size_limit = 128
29
-
30
 
31
  app = FastAPI()
32
 
 
9
  from transformers import T5Tokenizer, T5ForConditionalGeneration
10
 
11
 
12
+ token_size_limit = None
13
+
14
  # FROM: https://huggingface.co/facebook/blenderbot-400M-distill?text=Hey+my+name+is+Thomas%21+How+are+you%3F
15
  # tokenizer = AutoTokenizer.from_pretrained("facebook/blenderbot-400M-distill")
16
  # model = AutoModelForSeq2SeqLM.from_pretrained("facebook/blenderbot-400M-distill")
17
  # tokenizer = AutoTokenizer.from_pretrained("facebook/blenderbot-1B-distill")
18
  # model = AutoModelForSeq2SeqLM.from_pretrained("facebook/blenderbot-1B-distill")
19
+ # token_size_limit = 128
20
+
21
+ # T5 model can use "any" sequence lenghth, but memory usage is O(L^2).
22
  # tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-small")
23
  # model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-small")
24
  # tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-base")
25
  # model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-base")
26
  tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
27
  model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large")
28
+ token_size_limit = 512
29
 
30
  # Too large for 16GB
31
  # tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xl")
32
  # model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xl")
33
 
 
 
34
 
35
  app = FastAPI()
36