Pierce Maloney
commited on
Commit
•
eebf1ef
1
Parent(s):
0425154
adding back truncation
Browse files- handler.py +3 -3
handler.py
CHANGED
@@ -31,11 +31,11 @@ class EndpointHandler():
|
|
31 |
|
32 |
input_ids = self.tokenizer.encode(inputs, return_tensors="pt")
|
33 |
max_generation_length = 75 # Desired number of tokens to generate
|
34 |
-
|
35 |
|
36 |
# # Truncate input_ids to the most recent tokens that fit within the max_input_length
|
37 |
-
|
38 |
-
|
39 |
|
40 |
max_length = input_ids.shape[1] + max_generation_length
|
41 |
|
|
|
31 |
|
32 |
input_ids = self.tokenizer.encode(inputs, return_tensors="pt")
|
33 |
max_generation_length = 75 # Desired number of tokens to generate
|
34 |
+
max_input_length = 4092 - max_generation_length # Maximum input length to allow space for generation
|
35 |
|
36 |
# # Truncate input_ids to the most recent tokens that fit within the max_input_length
|
37 |
+
if input_ids.shape[1] > max_input_length:
|
38 |
+
input_ids = input_ids[:, -max_input_length:]
|
39 |
|
40 |
max_length = input_ids.shape[1] + max_generation_length
|
41 |
|