Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -59,8 +59,11 @@ def generate_and_visualize(prompt, num_tokens=10):
|
|
59 |
max_logits, max_indices = torch.max(output_logits[0, -1, :], dim=-1)
|
60 |
|
61 |
max_logits.backward(max_logits)
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
64 |
|
65 |
next_token = max_indices.unsqueeze(0)
|
66 |
generated_tokens_ids.append(next_token.item())
|
|
|
59 |
max_logits, max_indices = torch.max(output_logits[0, -1, :], dim=-1)
|
60 |
|
61 |
max_logits.backward(max_logits)
|
62 |
+
try:
|
63 |
+
relevance = input_embeds.grad.float().sum(-1).cpu()[0]
|
64 |
+
all_relevances.append(relevance)
|
65 |
+
except:
|
66 |
+
all_relevances.append(0)
|
67 |
|
68 |
next_token = max_indices.unsqueeze(0)
|
69 |
generated_tokens_ids.append(next_token.item())
|