Spaces:
Runtime error
Runtime error
added prompt debug
Browse files
app.py
CHANGED
@@ -119,11 +119,11 @@ def generate_beam(model, tokenizer, beam_size: int = 5, prompt=None, embed=None,
|
|
119 |
with torch.no_grad():
|
120 |
if embed is not None:
|
121 |
generated = embed
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
for i in range(entry_length):
|
128 |
outputs = model.gpt(inputs_embeds=generated)
|
129 |
logits = outputs.logits
|
|
|
119 |
with torch.no_grad():
|
120 |
if embed is not None:
|
121 |
generated = embed
|
122 |
+
if prompt is not None:
|
123 |
+
tokens = torch.tensor(tokenizer.encode(prompt))
|
124 |
+
tokens = tokens.unsqueeze(0).to(device)
|
125 |
+
prompt_tokens = model.gpt.transformer.wte(tokens)
|
126 |
+
print(">>>>", generated.shape, prompt_tokens.shape)
|
127 |
for i in range(entry_length):
|
128 |
outputs = model.gpt(inputs_embeds=generated)
|
129 |
logits = outputs.logits
|