Upload indigo/model.py with huggingface_hub
Browse files- indigo/model.py +6 -1
indigo/model.py
CHANGED
|
@@ -166,7 +166,12 @@ class GPT(nn.Module):
|
|
| 166 |
tokens = torch.cat((tokens, next_id), dim=1)
|
| 167 |
if i == max_new_tokens - 1:
|
| 168 |
break
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
return tokens
|
| 171 |
|
| 172 |
def num_params(self):
|
|
|
|
| 166 |
tokens = torch.cat((tokens, next_id), dim=1)
|
| 167 |
if i == max_new_tokens - 1:
|
| 168 |
break
|
| 169 |
+
if caches is not None and caches[0][0].size(2) >= self.config.block_size:
|
| 170 |
+
caches = None
|
| 171 |
+
idx_in = tokens[:, -self.config.block_size:]
|
| 172 |
+
else:
|
| 173 |
+
idx_in = next_id
|
| 174 |
+
logits, _, caches = self(idx_in, caches=caches, return_caches=True)
|
| 175 |
return tokens
|
| 176 |
|
| 177 |
def num_params(self):
|