Update app.py
Browse files
app.py
CHANGED
@@ -37,17 +37,20 @@ def generate(title, context, max_len):
|
|
37 |
|
38 |
# input_ids.extend( tokenizer.encode(input_text + "-", add_special_tokens=False) )
|
39 |
|
40 |
-
title_ids = tokenizer.encode(title, add_special_tokens=False)
|
41 |
-
context_ids = tokenizer.encode(context, add_special_tokens=False)
|
42 |
-
|
43 |
-
input_ids
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
print(input_ids)
|
46 |
-
|
47 |
-
cur_len = len(input_ids)
|
48 |
-
input_len = cur_len
|
49 |
-
last_token_id = input_ids[-1]
|
50 |
-
input_ids = torch.tensor([input_ids], dtype=torch.long)
|
51 |
|
52 |
while True:
|
53 |
outputs = model( input_ids=input_ids[:, -200:] )
|
|
|
37 |
|
38 |
# input_ids.extend( tokenizer.encode(input_text + "-", add_special_tokens=False) )
|
39 |
|
40 |
+
# title_ids = tokenizer.encode(title, add_special_tokens=False)
|
41 |
+
# context_ids = tokenizer.encode(context, add_special_tokens=False)
|
42 |
+
# input_ids = title_ids + [sep_id] + context_ids
|
43 |
+
# print(input_ids)
|
44 |
+
# cur_len = len(input_ids)
|
45 |
+
# input_len = cur_len
|
46 |
+
# last_token_id = input_ids[-1]
|
47 |
+
# input_ids = torch.tensor([input_ids], dtype=torch.long)
|
48 |
+
|
49 |
+
input_ids = [tokenizer.cls_token_id]
|
50 |
+
input_ids.extend( tokenizer.encode(title + "-" +context, add_special_tokens=False) )
|
51 |
+
input_ids = torch.tensor( [input_ids] )
|
52 |
|
53 |
print(input_ids)
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
while True:
|
56 |
outputs = model( input_ids=input_ids[:, -200:] )
|